:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #e3e6eb;
    --text: #141821;
    --text-2: #5c6575;
    --income: #12a37f;
    --income-soft: rgba(18, 163, 127, .12);
    --expense: #e04f5f;
    --expense-soft: rgba(224, 79, 95, .12);
    --accent: #3d5afe;
    --accent-soft: rgba(61, 90, 254, .12);
    --warn: #f0a020;
    --grid: rgba(20, 24, 33, .07);
    --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 2px 8px rgba(16, 24, 40, .04);
    --radius: 14px;
    color-scheme: light;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0e1116;
        --surface: #161a22;
        --surface-2: #1d222c;
        --border: #262c38;
        --text: #e8ebf1;
        --text-2: #8b94a5;
        --income: #2fc79c;
        --income-soft: rgba(47, 199, 156, .14);
        --expense: #ff6b7a;
        --expense-soft: rgba(255, 107, 122, .14);
        --accent: #6f86ff;
        --accent-soft: rgba(111, 134, 255, .16);
        --grid: rgba(232, 235, 241, .07);
        --shadow: none;
        color-scheme: dark;
    }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-feature-settings: "tnum" 1, "cv11" 1;
}
a { color: var(--accent); text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 600; }
.muted { color: var(--text-2); }
.pos { color: var(--income); }
.neg { color: var(--expense); }
.r { text-align: right; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 20px; }

/* ---------- Topbar ---------- */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 60px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 16px; }
.brand strong { font-weight: 700; }
.brand-mark {
    width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
    background: linear-gradient(135deg, var(--accent), #7b4dff); color: #fff; font-weight: 700;
}
.ticker { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tick {
    display: flex; flex-direction: column; padding: 4px 12px; border-radius: 10px; background: var(--surface-2);
    line-height: 1.25;
}
.tick-label { font-size: 10.5px; color: var(--text-2); font-weight: 600; letter-spacing: .04em; }
.tick-val { font-weight: 600; font-size: 14px; }
.tick-src { display: flex; align-items: center; gap: 4px; font-size: 11.5px; color: var(--text-2); margin-left: 6px; }
.tick-src form { margin: 0; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 10px;
    border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
    transition: filter .15s, background .15s;
}
.btn:hover { filter: brightness(1.06); }
.btn.income { background: var(--income); color: #fff; }
.btn.expense { background: var(--expense); color: #fff; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.icon-btn {
    width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 9px;
    border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
    font-size: 16px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.sm { width: 28px; height: 28px; font-size: 13px; }
.icon-btn.danger:hover { background: var(--expense-soft); border-color: var(--expense); }
.link-btn { font-weight: 600; font-size: 13px; margin-left: 4px; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.seg a, .seg button {
    border: 0; background: transparent; font: inherit; font-weight: 600; font-size: 13px; color: var(--text-2);
    padding: 5px 12px; border-radius: 7px; cursor: pointer;
}
.seg .active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg.small a, .seg.small button { padding: 3px 10px; font-size: 12.5px; }

/* ---------- Toolbar ---------- */
main.wrap { padding-top: 22px; padding-bottom: 40px; }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar-right { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.month-nav { display: flex; align-items: center; gap: 8px; }
.month-pick { position: relative; margin: 0; }
.month-pick h1 { font-size: 22px; font-weight: 700; padding: 0 6px; min-width: 150px; text-align: center; pointer-events: none; }
.month-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.month-pick input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }

.flash { padding: 10px 14px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; border: 1px solid; }
.flash.success { background: var(--income-soft); border-color: var(--income); color: var(--income); }
.flash.error { background: var(--expense-soft); border-color: var(--expense); color: var(--expense); }

/* ---------- Cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 18px; min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; }
.wrap-head { flex-wrap: wrap; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 14px; }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi-head { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-weight: 500; font-size: 13px; }
.kpi-val { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.delta { font-size: 12.5px; font-weight: 600; }
.meter { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 4px 0 2px; }
.meter span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.income { background: var(--income); }
.dot.expense { background: var(--expense); }
.dot.net { background: var(--accent); }
.dot.rate { background: var(--warn); }

.grid-2 { display: grid; grid-template-columns: 1.65fr 1fr; gap: 14px; margin-bottom: 14px; }

.legend { display: flex; gap: 12px; font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.income { background: var(--income); }
.sw.expense { background: var(--expense); }
.sw.net { background: var(--accent); }
.sw.line { height: 3px; border-radius: 2px; width: 14px; }

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

.donut-wrap { display: flex; flex-direction: column; gap: 14px; }
.chart-box.donut { height: 190px; }
.donut-center {
    position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none;
    font-size: 12px; color: var(--text-2);
}
.donut-center strong { display: block; font-size: 17px; color: var(--text); }
.cat-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; max-height: 190px; overflow: auto; }
.cat-list li { display: grid; grid-template-columns: 10px 1fr auto; gap: 4px 10px; align-items: center; font-size: 13px; }
.cat-list .sw { width: 10px; height: 10px; }
.cat-list .bar { grid-column: 2 / 4; height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.cat-list .bar span { display: block; height: 100%; border-radius: 99px; }
.cat-list .val { font-weight: 600; }
.cat-list .pct { color: var(--text-2); font-weight: 500; margin-left: 6px; font-size: 12px; }
.empty-mini { color: var(--text-2); text-align: center; padding: 30px 0; margin: 0; }

/* Para birimi bazında */
.cur-table { display: flex; flex-direction: column; gap: 10px; }
.cur-row {
    display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center;
    padding: 12px; border-radius: 12px; background: var(--surface-2);
}
.cur-badge {
    width: 40px; height: 40px; border-radius: 10px; background: var(--accent-soft); color: var(--accent);
    display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.cur-name { font-weight: 600; }
.cur-vals { display: flex; gap: 12px; font-size: 13px; font-weight: 500; flex-wrap: wrap; }
.cur-net { text-align: right; display: flex; flex-direction: column; font-size: 13px; }
.cur-net strong { font-size: 15px; }

/* ---------- Tablo ---------- */
.filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
input, select {
    font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; height: 38px; padding: 0 12px; outline: none; min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#search { width: 230px; height: 34px; }

.table-wrap { overflow-x: auto; margin: 0 -18px -18px; }
.tx-table { width: 100%; border-collapse: collapse; }
.tx-table th {
    font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); font-weight: 600;
    text-align: left; padding: 10px 18px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.tx-table th.r { text-align: right; }
.tx-table td { padding: 12px 18px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tx-table tbody tr:hover { background: var(--surface-2); }
.tx-table tfoot td { border-bottom: 0; background: var(--surface-2); font-size: 13px; }
.tx-table .date { white-space: nowrap; }
.tx-table .date strong { font-size: 15px; }
.tx-table .cat { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.tx-table .desc { font-size: 12.5px; margin-left: 16px; }
.tx-table .amount { font-weight: 700; white-space: nowrap; }
.tx-table td.r { white-space: nowrap; }
.tx-table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.tx-table .actions form { margin: 0; }

.empty { text-align: center; padding: 40px 20px; }
.empty-ico { font-size: 40px; }
.empty h3 { margin: 8px 0 4px; }
.empty p { max-width: 420px; margin: 0 auto 16px; }
.empty-actions { display: flex; gap: 8px; justify-content: center; }

.foot { font-size: 12px; text-align: center; margin-top: 22px; line-height: 1.7; }

/* ---------- Modal ---------- */
.modal {
    border: 1px solid var(--border); border-radius: 18px; padding: 0; width: min(480px, calc(100vw - 32px));
    background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
.modal::backdrop { background: rgba(10, 12, 18, .55); backdrop-filter: blur(3px); }
.modal form { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

.type-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-switch input { position: absolute; opacity: 0; pointer-events: none; }
.type-switch span {
    display: block; text-align: center; padding: 10px; border-radius: 10px; border: 1px solid var(--border);
    font-weight: 600; cursor: pointer; color: var(--text-2);
}
.type-switch label:first-child input:checked + span { background: var(--income-soft); border-color: var(--income); color: var(--income); }
.type-switch label:last-child input:checked + span { background: var(--expense-soft); border-color: var(--expense); color: var(--expense); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field summary { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field summary { cursor: pointer; }
details.field[open] input { margin-top: 8px; width: 100%; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.amount-group { display: grid; grid-template-columns: 1fr 110px; gap: 8px; }
.amount-group input { font-size: 20px; font-weight: 700; height: 48px; }
.amount-group select { height: 48px; font-weight: 600; }
.hint { font-size: 12.5px; color: var(--text-2); min-height: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .wrap { padding: 0 14px; }
    .ticker .tick-src span { display: none; }
    .tick { padding: 3px 8px; }
    .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
    .kpi-val { font-size: 20px; }
    .toolbar, .toolbar-right { width: 100%; }
    .toolbar-right .btn.income, .toolbar-right .btn.expense { flex: 1; justify-content: center; }
    .month-pick h1 { font-size: 18px; min-width: 120px; }
    #search { width: 100%; }
    .filters { width: 100%; }
    .hide-sm { display: none; }
    .tx-table td, .tx-table th { padding: 10px 12px; }
    .table-wrap { margin: 0 -18px -18px; }
    .field-row { grid-template-columns: 1fr; }
}

/* =====================================================================
   v2: simgeler, logolar, sabit ödemeler, platform seçici, giriş
   ===================================================================== */
[hidden] { display: none !important; }
.lucide { width: 16px; height: 16px; flex: none; }
.icon-btn .lucide { width: 16px; height: 16px; }
.icon-btn.sm .lucide { width: 14px; height: 14px; }
.btn .lucide { width: 16px; height: 16px; margin-left: -2px; }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.block { width: 100%; justify-content: center; height: 42px; }
.danger-text { color: var(--expense) !important; }
.mb { margin-bottom: 14px; }

.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.user-actions { display: flex; gap: 6px; padding-left: 12px; border-left: 1px solid var(--border); }
.user-actions form { margin: 0; }

.kpi-ico {
    width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center;
}
.kpi-ico .lucide { width: 15px; height: 15px; }
.kpi-ico.income { background: var(--income-soft); color: var(--income); }
.kpi-ico.expense { background: var(--expense-soft); color: var(--expense); }
.kpi-ico.net { background: var(--accent-soft); color: var(--accent); }
.kpi-ico.rate { background: rgba(240, 160, 32, .14); color: var(--warn); }

/* Logo / kategori kutucukları */
.tile {
    width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; flex: none; overflow: hidden;
}
.tile.xs { width: 24px; height: 24px; border-radius: 7px; }
.tile.logo { background: #fff; border: 1px solid var(--border); padding: 6px; }
.tile.logo.xs { padding: 3px; }
.tile.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.tile.cat { background: var(--surface-2); color: var(--text-2); }
.tile.cat.income { background: var(--income-soft); color: var(--income); }
.tile.cat.expense { background: var(--expense-soft); color: var(--expense); }
.tile.cat .lucide { width: 18px; height: 18px; }
.tile.cat.xs .lucide { width: 14px; height: 14px; }

/* Dağılım listesi */
.cat-list li { grid-template-columns: 20px 1fr auto; }
.cat-list .mini-logo { width: 20px; height: 20px; border-radius: 5px; background: #fff; padding: 2px; object-fit: contain; border: 1px solid var(--border); }
.cat-list .mini-ico { display: grid; place-items: center; }
.cat-list .mini-ico .lucide { width: 16px; height: 16px; }
.cat-list .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sabit ödemeler */
.rec-progress { margin-bottom: 12px; }
.rec-progress-head { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; gap: 8px; flex-wrap: wrap; }
.rec-progress .meter span { background: var(--expense); }
.rec-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; max-height: 360px; overflow: auto; }
.rec-item {
    display: grid; grid-template-columns: 36px 1fr auto auto; gap: 12px; align-items: center;
    padding: 10px 4px; border-top: 1px solid var(--border);
}
.rec-item:first-child { border-top: 0; }
.rec-item.paused { opacity: .55; }
.rec-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-body { min-width: 0; }
.rec-meta { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-amount { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; white-space: nowrap; }
.rec-actions { display: flex; gap: 4px; opacity: .35; transition: opacity .15s; }
.rec-item:hover .rec-actions, .rec-actions:focus-within { opacity: 1; }
.rec-actions form { margin: 0; }
.status {
    display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 600;
    padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2);
}
.status .lucide { width: 12px; height: 12px; }
.status.paid { background: var(--income-soft); color: var(--income); }
.status.upcoming { background: var(--accent-soft); color: var(--accent); }
.status.upcoming.urgent, .status.pending { background: rgba(240, 160, 32, .16); color: var(--warn); }

.empty.compact { padding: 20px 10px; }
.empty-logos { display: flex; justify-content: center; gap: 8px; margin-bottom: 12px; }
.empty-logos .tile { width: 40px; height: 40px; }
.empty-ico .lucide { width: 40px; height: 40px; color: var(--text-2); }

/* İşlem tablosu */
.tx-main { display: flex; align-items: center; gap: 12px; }
.tx-title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tx-table .desc { margin-left: 0; }
.badge {
    display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 1px 7px;
    border-radius: 99px; background: var(--accent-soft); color: var(--accent);
}
.badge .lucide { width: 11px; height: 11px; }

/* Platform seçici */
.pp { position: relative; }
.pp-current {
    width: 100%; display: flex; align-items: center; gap: 10px; height: 42px; padding: 0 10px; text-align: left;
    background: var(--surface); border: 1px solid var(--border); border-radius: 10px; font: inherit; color: var(--text); cursor: pointer;
}
.pp-current:hover { border-color: var(--accent); }
.pp-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-current .muted.pp-name { font-weight: 400; }
.pp-domain { font-size: 12px; }
.pp-clear, .pp-chev { margin-left: auto; color: var(--text-2); display: grid; place-items: center; }
.pp-clear { width: 24px; height: 24px; border-radius: 6px; }
.pp-clear:hover { background: var(--expense-soft); color: var(--expense); }
.pp-panel {
    margin-top: 6px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); padding: 10px;
}
.pp-panel input { width: 100%; height: 36px; margin-bottom: 8px; }
.pp-grid { max-height: 260px; overflow: auto; }
.pp-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); margin: 8px 2px 6px; }
.pp-group:first-child { margin-top: 0; }
.pp-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.pp-item {
    display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 4px 8px; border-radius: 10px;
    border: 1px solid transparent; background: var(--surface); cursor: pointer; font: inherit; font-size: 11.5px; color: var(--text);
}
.pp-item:hover, .pp-item:focus-visible { border-color: var(--accent); outline: none; }
.pp-item img { width: 32px; height: 32px; object-fit: contain; background: #fff; border-radius: 8px; padding: 4px; border: 1px solid var(--border); }
.pp-item span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-item.custom { grid-column: 1 / -1; flex-direction: row; justify-content: flex-start; padding: 8px 10px; font-size: 13px; font-weight: 600; }
.pp-empty { font-size: 13px; padding: 8px 2px; margin: 0; }

/* Checkbox */
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 13.5px; }
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--accent); flex: none; padding: 0; }
.repeat-box { padding: 12px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface-2); }

/* Modal içi */
.modal-inner { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal { max-height: calc(100vh - 32px); }
.modal .stack { padding: 0; display: flex; flex-direction: column; gap: 12px; }
.modal h4 { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 14px; }
.modal hr { border: 0; border-top: 1px solid var(--border); margin: 4px 0; width: 100%; }
.type-switch span { display: flex; align-items: center; justify-content: center; gap: 6px; }

/* Giriş ekranı */
.auth-body { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(400px, 100%); padding: 32px 28px; display: flex; flex-direction: column; gap: 10px; }
.auth-brand { margin-bottom: 14px; }
.auth-card h1 { font-size: 22px; }
.auth-card > p { margin: 0 0 8px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; margin-top: 6px; }
.auth-form input[type=password], .auth-form input[type=text] { width: 100%; height: 42px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 42px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; width: 34px; height: 34px; border: 0; background: none; cursor: pointer; opacity: .6; font-size: 15px; }
.pw-toggle:hover { opacity: 1; }

@media (max-width: 640px) {
    .user-actions { padding-left: 0; border-left: 0; }
    .topbar-right { width: 100%; justify-content: space-between; }
    .rec-item { grid-template-columns: 36px 1fr auto; }
    .rec-actions { grid-column: 2 / 4; opacity: 1; justify-content: flex-end; }
    .hide-sm { display: none; }
    .pp-items { grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); }
}
