/* ---------------------------------------------------------------
   Token Defteri — "sade finansal panel"
   İlke: kartsız, gölgesiz; ince çizgiler ve boşluk hiyerarşi kurar.
   Başlıklar serif (bir muhasebe defteri hissi), veriler tablo-hizalı sans.
   Tek anlamsal renk çifti: teal (kâr/olumlu) + gold (tahmin/uyarı).
--------------------------------------------------------------- */

:root {
  --ink: #16213a;
  --ink-soft: #4b5264;
  --muted: #767c6e;
  --paper: #f3f4ef;
  --paper-raised: #ffffff;
  --line: #dcded4;
  --line-strong: #c3c6b9;
  --teal: #1f6f64;
  --teal-dim: #e4efec;
  --gold: #8f6a1f;
  --gold-dim: #f2ead6;
  --red: #8c3f34;
  --red-dim: #f3e4e1;

  --serif: Iowan Old Style, Palatino Linotype, Palatino, Georgia, "Noto Serif", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --radius: 3px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; color: var(--ink); }
h2 { font-size: 19px; letter-spacing: 0.01em; }
button, input, select { font-family: inherit; font-size: inherit; color: inherit; }
a { color: var(--teal); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
code { font-family: var(--mono); background: var(--paper-raised); border: 1px solid var(--line); padding: 0 4px; border-radius: 2px; }

[hidden] { display: none !important; }
.screen { min-height: 100%; }

/* ---------- Giriş ekranı ---------- */
#login {
  display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background: var(--paper);
}
.login-card {
  width: min(360px, 90vw);
  background: var(--paper-raised);
  border: 1px solid var(--line);
  padding: 36px 32px;
}
.login-card h1 { font-size: 26px; margin-bottom: 6px; }
.login-sub { color: var(--muted); font-size: 13px; margin: 0 0 24px; }
.login-card label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 18px; }
.login-card input {
  display: block; width: 100%; margin-top: 6px; padding: 10px 11px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper);
}
.login-card button[type="submit"] {
  width: 100%; padding: 11px; background: var(--ink); color: var(--paper-raised);
  border: none; border-radius: var(--radius); cursor: pointer; font-weight: 600;
}
.login-card button[type="submit"]:hover { background: var(--teal); }
.error { color: var(--red); font-size: 13px; margin-top: 14px; }

/* ---------- Üst şerit ---------- */
.masthead {
  display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  padding: 22px clamp(16px, 4vw, 40px) 16px;
  border-bottom: 1px solid var(--line-strong);
}
.masthead-title { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.masthead h1 { font-size: 24px; }
.masthead-sub { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.masthead-actions { display: flex; gap: 8px; flex-wrap: wrap; }

button.ghost, a.ghost {
  background: transparent; border: 1px solid var(--line-strong); color: var(--ink-soft);
  padding: 7px 13px; border-radius: var(--radius); cursor: pointer; text-decoration: none; font-size: 13px;
}
button.ghost:hover, a.ghost:hover { border-color: var(--teal); color: var(--teal); }
button.primary {
  background: var(--teal); color: #fff; border: none; padding: 9px 18px;
  border-radius: var(--radius); cursor: pointer; font-weight: 600; font-size: 14px;
}
button.primary:hover { background: #185a51; }

/* ---------- Bantlar ---------- */
.banner { margin: 14px clamp(16px, 4vw, 40px) 0; padding: 10px 14px; border-radius: var(--radius); font-size: 13px; }
.banner:not(.warn):not(.err) { background: var(--gold-dim); color: var(--gold); border: 1px solid #e2d3a4; }
.banner.warn { background: var(--gold-dim); color: var(--gold); border: 1px solid #e2d3a4; }
.banner.err { background: var(--red-dim); color: var(--red); border: 1px solid #dcb7ae; }

/* ---------- Filtreler ---------- */
.filters {
  display: flex; gap: 22px; flex-wrap: wrap;
  padding: 16px clamp(16px, 4vw, 40px); border-bottom: 1px solid var(--line);
}
.filters label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 5px; }
.filters select, .filters input {
  padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper-raised); min-width: 140px;
}

/* ---------- Özet şeridi ---------- */
.summary {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  padding: 26px clamp(16px, 4vw, 40px); gap: 0;
  border-bottom: 1px solid var(--line-strong);
}
.stat { padding: 0 22px; border-left: 1px solid var(--line); }
.stat:first-child { padding-left: 0; border-left: none; }
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-family: var(--serif); font-size: 30px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat-value.est { color: var(--gold); }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }

/* ---------- Bloklar ---------- */
.block { padding: 26px clamp(16px, 4vw, 40px); border-bottom: 1px solid var(--line); }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.block > h2 { margin-bottom: 16px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.two-col h2 { margin-bottom: 16px; }
@media (max-width: 820px) { .two-col { grid-template-columns: 1fr; } }

.chart-toggle { display: flex; gap: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; }
.chart-toggle button { background: var(--paper-raised); border: none; padding: 6px 12px; font-size: 12px; cursor: pointer; color: var(--ink-soft); }
.chart-toggle button.active { background: var(--ink); color: #fff; }

.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; padding: 6px 9px; border-radius: 3px; transform: translate(-50%, -110%); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- Tablolar ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 11.5px; text-transform: none; padding: 0 10px 8px 0; border-bottom: 1px solid var(--line-strong); }
td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-cell { position: relative; }
.bar-cell .bar-bg { position: absolute; inset: 3px 0; background: var(--teal-dim); border-radius: 2px; z-index: 0; }
.bar-cell .bar-label { position: relative; z-index: 1; }
.empty { color: var(--muted); font-size: 13px; padding: 6px 0; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; }
.pill.ok { background: var(--teal-dim); color: var(--teal); }
.pill.low { background: var(--gold-dim); color: var(--gold); }
.est-mark { color: var(--gold); border-bottom: 1px dashed var(--gold); }

/* ---------- Konuşma dağılım ---------- */
.dist-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; }
.dist-item { border-left: 1px solid var(--line); padding-left: 14px; }
.dist-item .k { font-size: 11.5px; color: var(--muted); }
.dist-item .v { font-size: 18px; font-variant-numeric: tabular-nums; margin-top: 4px; }

/* ---------- Ücretlendirme / tahmin ---------- */
.pricing, .forecast {}
.formula {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  font-size: 15px; font-variant-numeric: tabular-nums; padding: 16px 0; border-top: 1px solid var(--line); margin-top: 6px;
}
.formula .op { color: var(--muted); }
.formula .term { padding: 4px 10px; background: var(--paper-raised); border: 1px solid var(--line); border-radius: var(--radius); }
.formula .result { font-weight: 700; color: var(--teal); font-size: 18px; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px 24px; margin-bottom: 4px; }
.kv-grid .k { font-size: 12px; color: var(--muted); }
.kv-grid .v { font-size: 17px; font-variant-numeric: tabular-nums; margin-top: 3px; }

.foot { padding: 20px clamp(16px, 4vw, 40px) 40px; color: var(--muted); font-size: 12px; display: flex; gap: 8px; }

/* ---------- Ayarlar ekranı ---------- */
#settings { background: var(--paper); }
.settings-panel { max-width: 760px; margin: 0 auto; padding: 30px clamp(16px, 4vw, 40px) 60px; }
.settings-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.settings-panel section { padding: 22px 0; border-top: 1px solid var(--line); }
.settings-panel section:first-of-type { border-top: none; }
.settings-panel h2 { font-size: 16px; margin-bottom: 10px; }
.hint { color: var(--muted); font-size: 12.5px; margin: 8px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px 20px; margin-bottom: 14px; }
.form-grid label { font-size: 12px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 5px; }
.form-grid input { padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper-raised); }

.customer-row { display: grid; grid-template-columns: 1.2fr 1.4fr 0.8fr 0.8fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.customer-row input, .customer-row select { padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper-raised); width: 100%; }
.customer-row button { background: none; border: none; color: var(--red); cursor: pointer; font-size: 12px; }
.add-customer { display: flex; gap: 8px; margin-top: 12px; }
.add-customer input { flex: 1; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius); }

.cust-card { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; background: var(--paper-raised); }
.cust-summary { display: flex; align-items: center; gap: 10px; padding: 10px 14px; flex-wrap: wrap; }
.cust-summary-name { display: flex; flex-direction: column; margin-right: auto; }
.cust-summary-name span:first-child { font-weight: 600; font-size: 14px; }
.cust-code { font-size: 11.5px; color: var(--muted); font-family: var(--mono); }
.cust-form { padding: 4px 14px 16px; border-top: 1px solid var(--line); }
.cust-form .form-grid { margin-top: 14px; }
.cust-form label { font-size: 12px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 5px; }
.cust-form input, .cust-form select { padding: 8px 9px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--paper); width: 100%; }
.cust-form-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; }

.code-block { background: var(--ink); color: #e8e9e2; padding: 14px 16px; border-radius: var(--radius); font-size: 12.5px; overflow-x: auto; line-height: 1.6; }
.code-block { font-family: var(--mono); }

@media (max-width: 640px) {
  .masthead, .filters, .summary, .block, .foot { padding-left: 16px; padding-right: 16px; }
  .customer-row { grid-template-columns: 1fr 1fr; }
}

/* ---------- Kompakt yerleşim (v2) ---------- */
body { font-size: 14px; }
.screen:not(#login) { max-width: 1040px; margin: 0 auto; }
[hidden] { display: none !important; }
h2 { font-size: 16px; }
.masthead { padding: 14px clamp(14px, 3vw, 24px) 12px; }
.masthead h1 { font-size: 20px; }
.filters { padding: 10px clamp(14px, 3vw, 24px); gap: 14px; }
.filters select, .filters input { padding: 5px 8px; min-width: 120px; }
.summary { padding: 14px clamp(14px, 3vw, 24px); }
.stat { padding: 0 16px; }
.stat-label { margin-bottom: 4px; }
.stat-value { font-size: 22px; }
.stat-sub { margin-top: 3px; }
.block { padding: 14px clamp(14px, 3vw, 24px); }
.block-head { margin-bottom: 10px; }
.block > h2 { margin-bottom: 10px; }
button.sm { padding: 5px 11px; font-size: 12.5px; }
button.primary.sm { padding: 6px 13px; }
.banner { margin: 10px clamp(14px, 3vw, 24px) 0; padding: 8px 12px; }
table th, table td { padding-top: 6px; padding-bottom: 6px; }

/* Grafik: sabit kısa yükseklik */
.bars { display: flex; gap: 3px; height: 120px; align-items: stretch; }
.bcol { flex: 1; min-width: 0; max-width: 56px; display: flex; flex-direction: column; }
.btrack { flex: 1; display: flex; align-items: flex-end; border-bottom: 1px solid var(--line-strong); }
.bar { width: 100%; background: var(--teal); border-radius: 2px 2px 0 0; }
.bar.zero { background: #e2e4da; height: 2px; }
.bval { font-size: 10px; color: var(--ink-soft); text-align: center; height: 13px; white-space: nowrap; overflow: hidden; font-variant-numeric: tabular-nums; }
.blab { font-size: 10px; color: var(--muted); text-align: center; height: 14px; white-space: nowrap; overflow: hidden; }

/* Ayrıntılar katlanır */
details.more { border-bottom: 1px solid var(--line); }
details.more > summary { cursor: pointer; padding: 12px clamp(14px, 3vw, 24px); font-size: 13px; color: var(--ink-soft); list-style: none; }
details.more > summary::before { content: "▸ "; }
details.more[open] > summary::before { content: "▾ "; }
details.more > summary:hover { color: var(--teal); }

/* Ayarlar ekranı iki görünüm: Müşteriler / Ayarlar */
#settings[data-view="customers"] .v-settings { display: none; }
#settings[data-view="settings"] .v-customers { display: none; }
#settings[data-view="customers"] .v-customers:first-of-type > h2 { display: none; }
