:root {
    --bg: #0f172a;
    --sidebar-bg: #111827;
    --surface: #ffffff;
    --surface-alt: #f8fafc;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-soft: #eef2ff;
    --success: #16a34a;
    --success-soft: #dcfce7;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.15);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--surface-alt);
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.6rem; font-weight: 700; margin: 0 0 .25rem; }
h1:focus { outline: none; }
h2 { font-size: 1.15rem; font-weight: 600; margin: 0 0 1rem; }

/* ---------- Layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: .5px;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand span { color: #818cf8; }

.nav-scroll { padding: .75rem; flex: 1; overflow-y: auto; display: flex; flex-direction: column; }

.nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .6rem .85rem;
    border-radius: 8px;
    color: #cbd5e1;
    font-weight: 500;
    margin-bottom: 2px;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.nav-link .icon { font-size: 1.05rem; width: 1.2rem; text-align: center; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 1.75rem;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 10;
}
.content { padding: 1.75rem; max-width: 1400px; width: 100%; }

.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.page-header p { color: var(--text-muted); margin: 0; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem 1.5rem;
    margin-bottom: 1.25rem;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.stat-card .label { color: var(--text-muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.stat-card .value { font-size: 2rem; font-weight: 700; margin-top: .35rem; }
.stat-card .value.primary { color: var(--primary); }
.stat-card .value.warning { color: var(--warning); }
.stat-card .value.danger { color: var(--danger); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: .75rem 1rem; text-align: left; white-space: nowrap; }
table.data thead th { background: var(--surface-alt); color: var(--text-muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--border); }
table.data tbody tr { border-bottom: 1px solid var(--border); }
table.data tbody tr:last-child { border-bottom: none; }
table.data tbody tr:hover { background: var(--surface-alt); }
.mono { font-family: 'Cascadia Code', 'Consolas', monospace; font-size: .82rem; color: var(--text-muted); }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.red { background: var(--danger-soft); color: var(--danger); }
.badge.amber { background: var(--warning-soft); color: var(--warning); }
.badge.gray { background: #f1f5f9; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .9rem; border-radius: 8px; border: 1px solid transparent; font-weight: 600; font-size: .85rem; cursor: pointer; transition: background .15s, border .15s; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-outline:hover { background: var(--surface-alt); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: .3rem .6rem; font-size: .78rem; }

/* ---------- Forms ---------- */
.form-row { margin-bottom: 1rem; }
.form-row label { display: block; font-weight: 600; margin-bottom: .35rem; font-size: .85rem; }
.form-control, select.form-control, textarea.form-control {
    width: 100%;
    padding: .55rem .75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: .9rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.form-control input[type="date"],
.form-control input[type="month"] { border: none; padding: 0; width: 100%; font: inherit; background: transparent; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.checkbox-row { display: flex; align-items: center; gap: .5rem; }
.checkbox-row input { width: 18px; height: 18px; }
.validation-message { color: var(--danger); font-size: .8rem; }
.invalid { border-color: var(--danger) !important; }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: flex-start; justify-content: center; padding: 3rem 1rem; z-index: 100; overflow-y: auto; }
.modal-box { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; }
.modal-box.modal-sm { max-width: 420px; }
.modal-header { padding: 1.1rem 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: .6rem; }
.modal-close { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text-muted); line-height: 1; }

/* ---------- Bar chart (token usage) ---------- */
.bar-track { background: var(--surface-alt); border-radius: 999px; height: 10px; overflow: hidden; min-width: 120px; }
.bar-fill { height: 100%; border-radius: 999px; background: var(--primary); transition: width .3s; }
.bar-fill.amber { background: var(--warning); }
.bar-fill.red { background: var(--danger); }

.toolbar { display: flex; gap: .75rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1.25rem; }
.toolbar .form-row { margin-bottom: 0; }
.search-input { max-width: 420px; flex: 1; min-width: 220px; }
.actions-cell { white-space: nowrap; display: flex; gap: .4rem; justify-content: flex-end; }
.text-muted { color: var(--text-muted); font-size: .88rem; margin: .5rem 0 0; }

.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }

.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; font-weight: 500; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.info { background: var(--primary-soft); color: var(--primary); }

/* ---------- Error UI ---------- */
#blazor-error-ui {
    background: #fef3c7;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.blazor-error-boundary { background: #b32121; padding: 1rem; color: white; border-radius: 8px; }
.blazor-error-boundary::after { content: "Bir hata oluştu."; }

@media (max-width: 768px) {
    .sidebar { width: 64px; }
    .sidebar-brand { font-size: 0; padding: 1rem; }
    .nav-link span:not(.icon) { display: none; }
}

/* ---------- Login ---------- */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    padding: 1rem;
}
.login-box {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
}
.login-brand { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: .25rem; }
.login-brand span { color: var(--primary); }
.login-sub { text-align: center; color: var(--text-muted); margin: 0 0 1.5rem; font-size: .9rem; }
.login-btn { width: 100%; justify-content: center; margin-top: .5rem; padding: .65rem; }
