:root {
    --accent: #4f46e5;
    --accent-soft: #eef2ff;
    --gelir: #16a34a;
    --gider: #dc2626;
    --surface: #ffffff;
    --surface-2: #f6f7fb;
    --border: #e5e7ef;
    --sidebar-w: 248px;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 16px rgba(16, 24, 40, .06);
}
[data-bs-theme="dark"] {
    --accent: #818cf8;
    --accent-soft: #232650;
    --gelir: #4ade80;
    --gider: #f87171;
    --surface: #1a1d2b;
    --surface-2: #12141f;
    --border: #2a2e42;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
}

body { background: var(--surface-2); font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; font-size: .94rem; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; font-weight: 650; }
.text-gelir { color: var(--gelir) !important; }
.text-gider { color: var(--gider) !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* ---- Shell ---- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 18px 14px; z-index: 1040;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; padding: 4px 8px 18px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #fff; display: grid; place-items: center; font-size: 1.1rem; }
.brand-text { font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em; }
.brand-text span { color: var(--accent); }
.nav-list { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--bs-secondary-color); text-decoration: none; font-weight: 500; }
.nav-item i { font-size: 1.1rem; }
.nav-item:hover { background: var(--surface-2); color: var(--bs-body-color); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-section { text-transform: uppercase; font-size: .68rem; letter-spacing: .08em; color: var(--bs-secondary-color); padding: 16px 12px 4px; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; }
.sidebar-backdrop { display: none; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; display: flex; align-items: center; gap: 12px; padding: 0 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 1030; }
.topbar-title { font-weight: 600; flex: 1; }
.topbar-actions { display: flex; gap: 4px; align-items: center; }
.btn-icon { border: 0; background: transparent; font-size: 1.25rem; color: var(--bs-secondary-color); border-radius: 10px; padding: 6px 10px; }
.btn-icon:hover { background: var(--surface-2); color: var(--bs-body-color); }
.content { padding: 24px; max-width: 1400px; width: 100%; margin: 0 auto; }

@media (max-width: 991.98px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s ease; }
    .sidebar.open { transform: none; }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .4); z-index: 1035; }
    .content { padding: 16px; }
    .topbar { padding: 0 12px; }
}

/* ---- Components ---- */
.page-head { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; }
.card-x { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-x > .card-head { padding: 16px 20px 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-x > .card-body-x { padding: 16px 20px 20px; }
.stat { padding: 18px 20px; display: flex; gap: 14px; align-items: flex-start; height: 100%; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; flex: 0 0 42px; }
.stat-icon.gelir { background: color-mix(in srgb, var(--gelir) 14%, transparent); color: var(--gelir); }
.stat-icon.gider { background: color-mix(in srgb, var(--gider) 14%, transparent); color: var(--gider); }
.stat-icon.net { background: var(--accent-soft); color: var(--accent); }
.stat-icon.kdv { background: color-mix(in srgb, #f59e0b 16%, transparent); color: #d97706; }
.stat-label { color: var(--bs-secondary-color); font-size: .82rem; font-weight: 500; }
.stat-value { font-size: 1.45rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat-sub { color: var(--bs-secondary-color); font-size: .78rem; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 6px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--bs-secondary-color); text-decoration: none; font-size: .85rem; font-weight: 500; }
.chip:hover { color: var(--bs-body-color); border-color: var(--accent); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.table-x { margin: 0; }
.table-x thead th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--bs-secondary-color); font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; background: transparent; }
.table-x td { vertical-align: middle; border-color: var(--border); }
.table-x tbody tr:hover { background: var(--surface-2); }
.table-x .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-x tfoot td { font-weight: 700; border-top: 2px solid var(--border); }
.firma-cell { max-width: 320px; }
.firma-cell .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.firma-cell .s { font-size: .78rem; color: var(--bs-secondary-color); }

.dir-badge { font-size: .72rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.dir-badge.gelir { background: color-mix(in srgb, var(--gelir) 14%, transparent); color: var(--gelir); }
.dir-badge.gider { background: color-mix(in srgb, var(--gider) 14%, transparent); color: var(--gider); }

.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: #4338ca; --bs-btn-hover-border-color: #4338ca; --bs-btn-active-bg: #3730a3; --bs-btn-active-border-color: #3730a3; --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent); }
.btn { border-radius: 10px; font-weight: 500; }
.form-control, .form-select { border-radius: 10px; border-color: var(--border); background-color: var(--surface); }
.form-control:focus, .form-select:focus { border-color: var(--accent); box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--accent) 22%, transparent); }
.form-label { font-weight: 500; font-size: .85rem; }

.chart-box { position: relative; height: 300px; }
.chart-box.sm { height: 260px; }

.progress-row { display: flex; align-items: center; gap: 12px; padding: 7px 0; }
.progress-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress-row .val { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; width: 100%; }
.bar > progress { display: block; width: 100%; height: 6px; border: 0; appearance: none; -webkit-appearance: none; background: transparent; color: var(--accent); }
.bar > progress::-webkit-progress-bar { background: transparent; }
.bar > progress::-webkit-progress-value { background: var(--accent); border-radius: 999px; }
.bar > progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }
.bar.gelir > progress { color: var(--gelir); }
.bar.gelir > progress::-webkit-progress-value { background: var(--gelir); }
.bar.gelir > progress::-moz-progress-bar { background: var(--gelir); }
.bar.gider > progress { color: var(--gider); }
.bar.gider > progress::-webkit-progress-value { background: var(--gider); }
.bar.gider > progress::-moz-progress-bar { background: var(--gider); }

.empty { text-align: center; padding: 36px 16px; color: var(--bs-secondary-color); }
.empty i { font-size: 2.2rem; display: block; margin-bottom: 8px; opacity: .6; }

/* ---- Upload ---- */
.dir-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dir-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.dir-toggle label { border: 2px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; display: flex; gap: 12px; align-items: center; background: var(--surface); }
.dir-toggle label .ic { font-size: 1.6rem; }
.dir-toggle input:checked + label { border-color: var(--accent); background: var(--accent-soft); }
.dir-toggle input:focus-visible + label { box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--accent) 30%, transparent); }
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 44px 16px; text-align: center; background: var(--surface); cursor: pointer; transition: border-color .15s, background .15s; }
.dropzone:hover, .dropzone.drag { border-color: var(--accent); background: var(--accent-soft); }
.dropzone i { font-size: 2.6rem; color: var(--accent); }
.upload-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); margin-top: 8px; }
.upload-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item progress { width: 120px; height: 8px; }
.upload-item .status { min-width: 150px; }

/* ---- Review ---- */
.review-grid { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.preview-frame { width: 100%; height: calc(100vh - 170px); min-height: 480px; border: 0; border-radius: var(--radius); background: var(--surface); }
.preview-img { max-width: 100%; border-radius: var(--radius); }
@media (max-width: 1100px) { .review-grid { grid-template-columns: 1fr; } .preview-frame { height: 70vh; } }
.conf-pill { font-size: .75rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); }
pre.ocr { max-height: 260px; overflow: auto; font-size: .75rem; background: var(--surface-2); border-radius: 10px; padding: 12px; white-space: pre-wrap; }

/* ---- Auth ---- */
.auth-body { background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent), var(--surface-2); min-height: 100vh; }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); }
.auth-brand { display: flex; gap: 10px; align-items: center; margin-bottom: 22px; }
.auth-foot { color: var(--bs-secondary-color); font-size: .8rem; margin-top: 16px; }
.code-input { letter-spacing: .35em; font-size: 1.4rem; text-align: center; font-variant-numeric: tabular-nums; }
.recovery-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-family: ui-monospace, Consolas, monospace; }
.recovery-grid span { background: var(--surface-2); border: 1px solid var(--border); padding: 6px 10px; border-radius: 8px; text-align: center; }
.qr { width: 190px; height: 190px; background: #fff; padding: 8px; border-radius: 12px; border: 1px solid var(--border); }

.subnav { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; }

@media print {
    .sidebar, .topbar, .no-print, .btn { display: none !important; }
    .content { padding: 0; max-width: none; }
    body { background: #fff; }
    .card-x { box-shadow: none; }
}
