/* ══════════ TOKENS (dataviz reference palette) ══════════ */
:root {
  --surface-1: #fcfcfb;
  --plane: #f9f9f7;
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;
  --series-2: #1baf7a;
  --seq-250: #86b6ef;
  --seq-450: #2a78d6;
  --cat-1: #2a78d6;
  --cat-2: #1baf7a;
  --cat-3: #eda100;
  --cat-4: #008300;
  --cat-5: #4a3aa7;
  --cat-6: #e34948;
  --cat-7: #e87ba4;
  --cat-8: #eb6834;
  --cat-other: #898781;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --accent: #2a78d6;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(11, 11, 11, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #1a1a19;
    --plane: #0d0d0d;
    --ink-1: #ffffff;
    --ink-2: #c3c2b7;
    --ink-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-2: #199e70;
    --seq-250: #1c5cab;
    --seq-450: #3987e5;
    --cat-1: #3987e5;
    --cat-2: #199e70;
    --cat-3: #c98500;
    --cat-4: #008300;
    --cat-5: #9085e9;
    --cat-6: #e66767;
    --cat-7: #d55181;
    --cat-8: #d95926;
    --good-text: #0ca30c;
    --accent: #3987e5;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--plane);
  color: var(--ink-1);
  font-size: 15px;
  line-height: 1.45;
}
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
button { font: inherit; cursor: pointer; }

/* ══════════ TOPBAR ══════════ */
.topbar {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between;
  padding: 14px 22px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--grid);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 1.25rem; }
.topbar .sub { margin: 2px 0 0; color: var(--ink-2); font-size: .85rem; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 1px solid var(--border); background: var(--surface-1); color: var(--ink-1);
  border-radius: 8px; padding: 8px 14px; font-weight: 600; font-size: .875rem;
}
.btn:hover { border-color: var(--baseline); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; }

/* ══════════ UPLOAD ══════════ */
.upload-panel { max-width: 1100px; margin: 40px auto; padding: 0 22px; display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; }
@media (max-width: 800px) { .upload-panel { grid-template-columns: 1fr; } }
.dropzone {
  background: var(--surface-1); border: 2px dashed var(--baseline); border-radius: var(--radius);
  padding: 42px 28px; text-align: center; transition: border-color .15s, background .15s;
}
.dropzone.dragover { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, var(--surface-1)); }
.dz-icon { font-size: 2.6rem; margin-bottom: 8px; }
.dropzone h2 { font-size: 1.1rem; }
.dropzone p { color: var(--ink-2); }
.linklike { color: var(--accent); text-decoration: underline; cursor: pointer; font-weight: 600; }
.file-list { list-style: none; margin: 14px 0 0; padding: 0; text-align: left; }
.file-list li { padding: 7px 10px; border: 1px solid var(--grid); border-radius: 8px; margin-top: 6px; font-size: .85rem; background: var(--plane); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.file-list .ok { color: var(--good-text); font-weight: 600; }
.parse-status { font-weight: 600; margin-top: 12px; }
.upload-hints { background: var(--surface-1); border: 1px solid var(--grid); border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow); }
.upload-hints h3 { font-size: 1rem; }
.upload-hints ol { padding-left: 20px; margin: 8px 0; color: var(--ink-2); font-size: .9rem; }
.upload-hints li { margin-bottom: 8px; }
.privacy { font-size: .82rem; color: var(--ink-muted); border-top: 1px solid var(--grid); padding-top: 10px; }

/* ══════════ FILTERS ══════════ */
.filters {
  display: flex; flex-wrap: wrap; gap: 12px; align-items: end;
  padding: 14px 22px; background: var(--surface-1); border-bottom: 1px solid var(--grid);
  position: sticky; top: 63px; z-index: 15;
}
.f-group { display: flex; flex-direction: column; gap: 3px; }
.f-group label { font-size: .72rem; font-weight: 600; color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
.f-group select, .f-group input {
  font: inherit; font-size: .875rem; padding: 7px 9px; border: 1px solid var(--baseline); border-radius: 8px;
  background: var(--surface-1); color: var(--ink-1); min-width: 130px;
}
.f-search { flex: 1; min-width: 220px; }
.f-search input { width: 100%; }

/* ══════════ TABS ══════════ */
.tabs { display: flex; gap: 4px; padding: 12px 22px 0; flex-wrap: wrap; }
.tab {
  border: 1px solid var(--grid); border-bottom: none; background: transparent; color: var(--ink-2);
  padding: 9px 16px; border-radius: 10px 10px 0 0; font-weight: 600; font-size: .9rem;
}
.tab.active { background: var(--surface-1); color: var(--ink-1); border-color: var(--baseline); }
.tabpane { display: none; padding: 20px 22px 60px; max-width: 1500px; margin: 0 auto; }
.tabpane.active { display: block; }

/* ══════════ CARDS / KPI ══════════ */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi {
  background: var(--surface-1); border: 1px solid var(--grid); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.kpi .k-label { font-size: .78rem; font-weight: 600; color: var(--ink-2); }
.kpi .k-value { font-size: 1.7rem; font-weight: 700; margin-top: 2px; }
.kpi .k-note { font-size: .76rem; color: var(--ink-muted); margin-top: 2px; }

.card {
  background: var(--surface-1); border: 1px solid var(--grid); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.card h2 { font-size: 1.05rem; }
.card .card-sub { color: var(--ink-2); font-size: .85rem; margin: -2px 0 12px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 20px; }
@media (max-width: 900px) { .card-grid { grid-template-columns: 1fr; } }

/* verdict banner */
.verdict { display: flex; gap: 12px; align-items: center; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; border: 1px solid var(--grid); background: var(--surface-1); }
.verdict .v-icon { font-size: 1.6rem; }
.verdict .v-title { font-weight: 700; }
.verdict .v-desc { color: var(--ink-2); font-size: .88rem; }
.verdict.hot { border-left: 5px solid var(--critical); }
.verdict.warm { border-left: 5px solid var(--warning); }
.verdict.cool { border-left: 5px solid var(--good); }

/* ══════════ TABLES ══════════ */
.tablewrap { overflow-x: auto; }
table.rpt { border-collapse: collapse; width: 100%; font-size: .855rem; }
.rpt th, .rpt td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--grid); vertical-align: top; }
.rpt th { font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-2); border-bottom: 2px solid var(--baseline); white-space: nowrap; }
.rpt td.num, .rpt th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rpt tr.total td { font-weight: 700; border-top: 2px solid var(--baseline); }
.rpt tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.rpt .muted { color: var(--ink-muted); }
.rpt td.wrap { white-space: normal; min-width: 240px; }

/* bar meter (tek renk — büyüklük) */
.meter { display: inline-block; width: 120px; height: 8px; background: var(--grid); border-radius: 4px; vertical-align: middle; margin-right: 8px; }
.meter i { display: block; height: 100%; background: var(--series-1); border-radius: 4px; min-width: 2px; }

/* repeat detail */
.expander { background: none; border: 1px solid var(--baseline); border-radius: 6px; padding: 2px 9px; font-size: .8rem; font-weight: 700; color: var(--accent); }
tr.detail-row > td { background: var(--plane); padding: 12px 16px; }
.detail-inner table.rpt { font-size: .82rem; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--baseline); font-size: .76rem; margin: 1px 3px 1px 0; white-space: nowrap; }

/* sekme içi kontroller (pencere, hariç tutma, eşikler) */
.ctrls {
  display: flex; flex-wrap: wrap; gap: 10px 22px; align-items: center;
  padding: 10px 14px; margin-bottom: 14px;
  background: var(--plane); border: 1px solid var(--grid); border-radius: 8px;
  font-size: .85rem;
}
.ctrls > label { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; color: var(--ink-2); }
.ctrls select {
  font: inherit; padding: 5px 8px; border: 1px solid var(--baseline); border-radius: 7px;
  background: var(--surface-1); color: var(--ink-1);
}
.chk-set { display: inline-flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-weight: 600; color: var(--ink-2); }
.chk { display: inline-flex; align-items: center; gap: 5px; font-weight: 400; color: var(--ink-1); cursor: pointer; }
.chk input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }

.load-more { margin-top: 12px; }
.pager { display: flex; gap: 8px; align-items: center; margin-top: 12px; font-size: .85rem; color: var(--ink-2); }

.foot { text-align: center; color: var(--ink-muted); font-size: .78rem; padding: 26px 0 34px; }

.print-header { display: none; }

/* ══════════ GRAFİKLER ══════════ */
.viz-tip {
  position: fixed; z-index: 100; pointer-events: none;
  background: var(--ink-1); color: var(--plane);
  border-radius: 8px; padding: 8px 11px; font-size: .8rem; line-height: 1.4;
  max-width: 300px; box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
}

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 4px 0 14px; }
.lg-item { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; color: var(--ink-2); }
.lg-sw { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.lg-note { color: var(--ink-muted); }

/* dikey çubuklar */
.vbar { display: flex; align-items: flex-end; margin-top: 6px; }
.vb-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.vb-area {
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  border-bottom: 2px solid var(--baseline); padding: 0 7px;
}
.gb-area { flex-direction: row; align-items: flex-end; justify-content: center; gap: 2px; }
.gb-slot { display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; flex: 0 1 34px; }
.vb-bar {
  display: block; width: 100%; max-width: 54px; min-height: 2px;
  border-radius: 4px 4px 0 0;
  transform-origin: bottom; animation: growY .65s cubic-bezier(.2, .7, .3, 1) both;
}
.vb-val { font-size: .78rem; font-weight: 600; color: var(--ink-2); margin-bottom: 4px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.vb-val.sm { font-size: .7rem; }
.vb-val.strong { color: var(--ink-1); font-weight: 700; }
.vb-lab { text-align: center; font-size: .76rem; color: var(--ink-2); padding-top: 6px; overflow-wrap: break-word; }
.vb-lab.strong { color: var(--ink-1); font-weight: 700; }
.vb-col[data-tip]:hover .vb-bar, .gb-slot[data-tip]:hover .vb-bar { filter: brightness(1.12); }

/* yatay yığılmış çubuklar */
.hstack { display: flex; flex-direction: column; gap: 9px; margin-top: 4px; }
.hs-row { display: grid; grid-template-columns: minmax(110px, 170px) 1fr 74px; gap: 10px; align-items: center; }
.hs-lab { font-size: .82rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs-trackwrap { min-width: 0; }
.hs-track {
  display: flex; gap: 2px; height: 20px;
  transform-origin: left; animation: growX .6s cubic-bezier(.2, .7, .3, 1) both;
}
.hs-seg { display: block; min-width: 3px; border-radius: 4px; transition: filter .12s; }
.hs-seg[data-tip]:hover { filter: brightness(1.15); }
.hs-tot { font-size: .82rem; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* donut */
.donut-flex { display: flex; gap: 26px; align-items: center; flex-wrap: wrap; }
.donut-flex .legend { flex-direction: column; gap: 8px; margin: 0; }
.donut-wrap { position: relative; width: 190px; flex: none; }
.donut-svg { width: 100%; display: block; }
.dn-seg { animation: dnIn .55s ease both; transition: filter .12s; }
.dn-seg:hover { filter: brightness(1.12); }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; text-align: center; }
.dc-val { font-size: 1.45rem; font-weight: 700; }
.dc-lab { font-size: .72rem; color: var(--ink-2); }

/* giriş animasyonları */
.kpi, .card, .verdict { animation: fadeUp .45s ease both; }
.kpi:nth-child(2) { animation-delay: .05s; }
.kpi:nth-child(3) { animation-delay: .1s; }
.kpi:nth-child(4) { animation-delay: .15s; }
.kpi:nth-child(5) { animation-delay: .2s; }
.card { animation-delay: .08s; }
.kpi { transition: transform .15s ease, box-shadow .15s ease; }
.kpi:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(11, 11, 11, .10); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes growY { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes growX { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes dnIn { from { opacity: 0; stroke-width: 0.5; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ══════════ PRINT ══════════ */
@media print {
  @page { size: A4 landscape; margin: 12mm; }
  body { background: #fff; color: #000; font-size: 11px; }
  .topbar, .filters, .tabs, .upload-panel, .foot, .load-more, .pager, .expander, .ctrls { display: none !important; }
  .print-header { display: block; margin-bottom: 14px; border-bottom: 2px solid #000; padding-bottom: 8px; }
  .print-header h1 { font-size: 18px; }
  .print-header p { font-size: 10px; color: #333; margin: 2px 0 0; }
  .tabpane { display: none; padding: 0; max-width: none; }
  .tabpane.active { display: block; }
  .card, .kpi, .verdict { box-shadow: none; border-color: #999; break-inside: avoid; }
  .kpi .k-value { font-size: 1.3rem; }
  .tablewrap { overflow: visible; }
  table.rpt { font-size: 9.5px; }
  .rpt th, .rpt td { padding: 3px 6px; }
  tr.detail-row { display: table-row !important; }
  .meter { border: 1px solid #999; }
  .meter i { background: #666 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .kpi, .card, .verdict, .vb-bar, .hs-track, .dn-seg { animation: none !important; }
  .vb-bar, .hs-seg, .lg-sw, .dn-seg { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .viz-tip { display: none; }
  .donut-wrap { width: 150px; }
}
