/* Villa Getiri — arayüz stilleri. Renkler token olarak tanımlı; koyu tema sistem ayarını izler. */
:root {
  color-scheme: light;
  --page: #f6f6f3;
  --surface: #fcfcfb;
  --surface-2: #f1f0ec;
  --ink: #141413;
  --ink-2: #52514e;
  --muted: #898781;
  --line: #e4e3dc;
  --line-strong: #c3c2b7;
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --accent-soft: #e3eefb;
  --good: #006300;
  --bad: #b42626;
  --warn-bg: #fff6df;
  --warn-line: #f0c770;
  --shadow: 0 1px 2px rgba(20, 20, 19, .05), 0 2px 8px rgba(20, 20, 19, .04);
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0f0f0e; --surface: #1a1a19; --surface-2: #232321; --ink: #f5f5f2; --ink-2: #c3c2b7;
    --muted: #898781; --line: #2c2c2a; --line-strong: #44443f; --accent: #3987e5; --accent-ink: #ffffff;
    --accent-soft: #1b2a3d; --good: #0ca30c; --bad: #e66767; --warn-bg: #2e2510; --warn-line: #7a5a12;
    --shadow: none;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0f0f0e; --surface: #1a1a19; --surface-2: #232321; --ink: #f5f5f2; --ink-2: #c3c2b7;
  --muted: #898781; --line: #2c2c2a; --line-strong: #44443f; --accent: #3987e5; --accent-ink: #ffffff;
  --accent-soft: #1b2a3d; --good: #0ca30c; --bad: #e66767; --warn-bg: #2e2510; --warn-line: #7a5a12;
  --shadow: none;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--page); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
h1, h2 { margin: 0; font-weight: 600; }
h2 { font-size: 15px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.strong { font-weight: 600; }

/* ---- Form öğeleri ---- */
input[type=text], input[type=password], select, textarea {
  font: inherit; color: var(--ink); background: var(--surface); width: 100%;
  border: 1px solid var(--line-strong); border-radius: 7px; padding: 6px 8px; min-height: 32px;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
.btn {
  font: inherit; font-weight: 500; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  border-radius: 7px; padding: 6px 12px; cursor: pointer; white-space: nowrap; min-height: 32px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; min-height: 28px; font-size: 13px; }
.icon-btn {
  border: 0; background: transparent; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
  width: 32px; height: 32px; border-radius: 6px; align-self: end;
}
.icon-btn:hover { background: var(--surface-2); color: var(--bad); }
.link { border: 0; background: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px; padding: 2px 4px; }
.link:hover { text-decoration: underline; }

/* ---- Üst bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 16px; letter-spacing: -.01em; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent) url(favicon.svg) center/cover; }
.villa-picker { display: flex; gap: 6px; align-items: center; flex: 1; min-width: 280px; }
.villa-picker select { max-width: 340px; font-weight: 500; }
.topbar-right { display: flex; gap: 4px; align-items: center; }
.save-state { font-size: 12px; color: var(--muted); margin-right: 8px; white-space: nowrap; }
.save-state.dirty, .save-state.busy { color: var(--ink-2); }
.save-state.ok::before { content: "✓ "; color: var(--good); }
.save-state.err { color: var(--bad); }

/* ---- KPI şeridi ---- */
.kpi-strip { position: sticky; top: 53px; z-index: 15; background: var(--page); border-bottom: 1px solid var(--line); }
.kpi-inner { display: grid; grid-template-columns: 1.4fr repeat(5, 1fr); gap: 1px; background: var(--line); }
.kpi { background: var(--surface); padding: 10px 16px; min-width: 0; }
.kpi-label { font-size: 12px; color: var(--ink-2); }
.kpi-value { font-size: 20px; font-weight: 650; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi.hero .kpi-value { font-size: 28px; color: var(--good); }
.kpi-value.neg, .kpi.hero .kpi-value.neg { color: var(--bad); }
.kpi-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- Yerleşim ---- */
/* Tek sütun: önce veri girişi, altında rapor */
.layout { display: flex; flex-direction: column; gap: 14px; padding: 20px; max-width: 1400px; margin: 0 auto; }
.inputs, .report { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.report-title { font-size: 18px; margin: 18px 0 0; padding-top: 18px; border-top: 1px solid var(--line-strong); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; min-width: 0; }
details.card > summary { list-style: none; cursor: pointer; display: flex; align-items: baseline; gap: 10px; }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary::before { content: "▸"; color: var(--muted); font-size: 12px; transition: transform .15s; display: inline-block; }
details.card[open] > summary::before { transform: rotate(90deg); }
.sec-title { font-weight: 600; font-size: 15px; }
.sec-sum { margin-left: auto; color: var(--ink-2); font-size: 13px; font-variant-numeric: tabular-nums; }
.sec-body { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.hint.tight { margin: 6px 0 2px; }
.empty { color: var(--muted); margin: 0; }

.grid { display: grid; gap: 10px 12px; }
.g-2 { grid-template-columns: 1fr 1fr; }
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field > span { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.field > span em { font-style: normal; color: var(--muted); }
.field small { color: var(--muted); font-size: 11.5px; }
output.out, .out { font-variant-numeric: tabular-nums; color: var(--ink-2); }
output.out { min-height: 32px; display: flex; align-items: center; justify-content: flex-end; }
output.out.strong { color: var(--ink); font-weight: 600; }

.row { display: grid; gap: 8px; align-items: end; }
.season-row { grid-template-columns: minmax(110px, 1.3fr) auto auto minmax(90px, .8fr) 32px; }
.channel-row { grid-template-columns: minmax(140px, 2fr) 90px 90px minmax(90px, 1fr) 32px; }
.expense-row { grid-template-columns: minmax(140px, 2fr) minmax(110px, 1.2fr) minmax(120px, 1.3fr) minmax(90px, .9fr) minmax(80px, .8fr) 32px; }
.income-row { grid-template-columns: minmax(140px, 2fr) minmax(120px, 1.3fr) minmax(90px, .9fr) minmax(80px, .8fr) 32px; }
.tax-row { grid-template-columns: minmax(140px, 2fr) minmax(150px, 1.5fr) 80px minmax(80px, .8fr) 32px; }
.row-card { border: 1px solid var(--line); border-radius: 8px; padding: 10px; background: var(--surface); }
.row-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; }
.row-foot .warn { color: var(--bad); font-weight: 500; }
.md { display: flex; gap: 4px; }
.md select { width: auto; }

.chips { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 8px; align-items: center; }
.chip {
  font: inherit; font-size: 11.5px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 2px 7px; cursor: pointer; min-width: 36px;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip-tools { margin-left: 6px; }
.chip-note { font-size: 11.5px; color: var(--muted); }

/* ---- Tablolar ---- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 6px 8px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child { text-align: left; }
thead th { font-size: 12px; font-weight: 500; color: var(--ink-2); border-bottom-color: var(--line-strong); }
tbody th { font-weight: 500; }
tfoot th, tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); border-bottom: 0; }
.occ-table td { padding: 3px 6px; }
.occ-table input.num { width: 84px; min-height: 28px; padding: 3px 6px; }
.data td.neg, td.neg, b.neg { color: var(--bad); }
.data td.pos { color: var(--good); }
.items th { display: flex; align-items: center; gap: 8px; border-bottom: 0; }
.items tr { border-bottom: 1px solid var(--line); }
.items td { border-bottom: 0; }
.bar-col { width: 34%; }
.bar-cell { padding-right: 12px; }
.hbar { display: block; height: 10px; border-radius: 0 4px 4px 0; min-width: 2px; }
.calendar td, .calendar th { padding: 5px 6px; font-size: 12.5px; }
.calendar tbody th { max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

/* ---- Rapor ---- */
.report-card h2 { font-size: 15px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
details.report-card > summary h2 { display: inline; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; }
.s1 { background: var(--series-1); } .s2 { background: var(--series-2); } .s3 { background: var(--series-3); } .s4 { background: var(--series-4); }
.s5 { background: var(--series-5); } .s6 { background: var(--series-6); } .s7 { background: var(--series-7); } .s8 { background: var(--series-8); }
.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid.base { stroke: var(--line-strong); }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .s1-fill { fill: var(--series-1); }
.chart .s2-fill { fill: var(--series-2); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit.active { fill: var(--ink); fill-opacity: .04; }
.stack { display: flex; gap: 2px; height: 18px; border-radius: 5px; overflow: hidden; margin: 4px 0 12px; }
.stack .seg { min-width: 3px; cursor: default; }
.cat-list { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 20px; }
.cat-list li { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.cl-name { flex: 1; color: var(--ink-2); }
.cl-val { font-variant-numeric: tabular-nums; font-weight: 600; }
.cl-pct { font-variant-numeric: tabular-nums; color: var(--muted); width: 52px; text-align: right; }
.notice { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: var(--radius); padding: 10px 14px; font-size: 13px; }
.notice ul { margin: 4px 0 0; padding-left: 18px; }
.notes p { margin: 8px 0 0; color: var(--ink-2); }
.print-head { display: none; }

.tooltip {
  position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: 8px; padding: 8px 10px; font-size: 12.5px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .12); min-width: 180px;
}
.tt-title { font-weight: 600; margin-bottom: 4px; }
.tt-row { display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.tt-row b { margin-left: auto; font-weight: 600; }
.tt-row.total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px; }
.tt-sub { color: var(--muted); font-size: 11.5px; }

/* ---- Giriş sayfası ---- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { font-size: 20px; }
.login-card p { margin: -8px 0 4px; }
.login-card .btn { min-height: 38px; }
.error { color: var(--bad); min-height: 1em; margin: 0 !important; font-size: 13px; }

/* ---- Duyarlı ---- */
.mini-bar { display: none; }
/* Dar ya da alçak ekranda KPI şeridi sabit durmaz; yerine altta küçük özet çubuğu çıkar */
@media (max-width: 1250px), (max-height: 760px) {
  .kpi-strip { position: static; }
  .layout { padding-bottom: 64px; }
  .mini-bar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; gap: 18px; justify-content: center; flex-wrap: wrap;
    padding: 8px 16px; background: var(--surface); border-top: 1px solid var(--line); font-size: 13px; font-variant-numeric: tabular-nums;
    box-shadow: 0 -2px 10px rgba(0,0,0,.06);
  }
  .mini-bar span { color: var(--ink-2); }
  .mini-bar b { color: var(--ink); margin-left: 4px; }
  .mini-bar b.pos { color: var(--good); }
  .mini-bar b.neg { color: var(--bad); }
}
@media (max-width: 1250px) {
  .topbar { position: static; }
  .kpi-inner { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 760px) {
  .topbar { padding: 8px 16px; gap: 8px; position: static; }
  .villa-picker { min-width: 0; width: 100%; order: 3; flex-wrap: wrap; }
  .villa-picker select { flex: 1 1 100%; max-width: none; min-width: 0; }
  .topbar-right { margin-left: auto; flex-wrap: wrap; }
  .topbar-right .btn { padding: 6px 8px; }
  .save-state { margin-right: 0; }
  .kpi:last-child:nth-child(even) { grid-column: span 2; }
  .mini-bar { gap: 12px; }
  .mini-bar span:nth-child(4) { display: none; }
  .kpi-strip { top: 0; }
  .kpi-inner { grid-template-columns: repeat(2, 1fr); }
  .kpi.hero { grid-column: span 2; }
  .kpi { padding: 8px 12px; }
  .layout { padding: 12px 16px; gap: 12px; }
  .g-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .season-row, .channel-row, .expense-row, .income-row, .tax-row { grid-template-columns: 1fr 1fr; }
  .row > .field:first-child { grid-column: span 2; }
  .row .icon-btn { grid-column: 2; justify-self: end; }
  .card { padding: 12px; }
}

/* ---- Yazdırma ---- */
@media print {
  body { background: #fff; font-size: 11px; }
  .topbar, .inputs, .tooltip, .mini-bar { display: none !important; }
  .kpi-strip { position: static; border: 0; }
  .kpi-inner { grid-template-columns: repeat(3, 1fr); }
  .layout { display: block; padding: 0; }
  .report { position: static; max-height: none; overflow: visible; }
  .card { box-shadow: none; break-inside: avoid; margin-bottom: 10px; }
  .print-head { display: block; margin-bottom: 8px; }
  .report-title { display: none; }
  .print-head h1 { font-size: 18px; }
  .print-head p { margin: 2px 0 0; color: #555; }
  .kpi-strip { order: 0; }
}
