/* ---------- renk ve tipografi değişkenleri ---------- */
:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #7d7b75;
  --line: #e1e0d9;
  --line-strong: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --accent-wash: #e8f1fd;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-prev: #a9a79f;
  --bar-track: #ebeae5;
  --good: #006300;
  --bad: #b3261e;
  --warn-bg: #fdf3d7;
  --warn-ink: #6b4a00;
  --danger: #d03b3b;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.05), 0 8px 24px rgba(11, 11, 11, 0.06);
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --line: #2c2c2a;
    --line-strong: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --accent-wash: #16263b;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-prev: #6b6963;
    --bar-track: #2a2a28;
    --good: #0ca30c;
    --bad: #e66767;
    --warn-bg: #3a2e0c;
    --warn-ink: #f3d27a;
    --danger: #e66767;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 14px/1.45 var(--font); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 22px; }
h2 { font-size: 15px; }
h3 { font-size: 13px; }
p { margin: 0 0 8px; }
a { color: var(--accent-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.grow { flex: 1; }
.hidden { display: none !important; }

/* ---------- iskelet ---------- */
.app { display: grid; grid-template-columns: 216px 1fr; min-height: 100vh; }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: 16px 12px; display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, var(--accent), #1baf7a); flex: none; }
.brand-name { font-weight: 700; }
.brand-sub { font-size: 12px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.active { background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; }
.nav .nav-sep { height: 1px; background: var(--line); margin: 8px 4px; }
.nav .badge { margin-left: auto; }
.side-foot { margin-top: auto; font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; padding: 0 6px; }
.main { min-width: 0; display: flex; flex-direction: column; }
.filters { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 24px; background: color-mix(in srgb, var(--page) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.filters label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.view { padding: 20px 24px 60px; max-width: 1480px; width: 100%; outline: none; }
.page-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- form öğeleri ---------- */
.btn { border: 1px solid var(--line-strong); background: var(--surface); padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.sm { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.icon-btn { border: 0; background: transparent; cursor: pointer; padding: 4px 6px; border-radius: 6px; color: var(--ink-2); line-height: 1; }
.icon-btn:hover { background: var(--surface-2); color: var(--ink); }
input[type="text"], input[type="number"], input[type="password"], input[type="search"], select, textarea {
  border: 1px solid var(--line-strong); background: var(--surface); border-radius: 8px; padding: 6px 9px; min-width: 0;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, .icon-btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
textarea { width: 100%; resize: vertical; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .field { flex: 1; min-width: 140px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 6px 12px; cursor: pointer; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--accent-wash); color: var(--accent-ink); font-weight: 600; }

/* ---------- açılır firma seçici ---------- */
.dd { position: relative; }
.dd-panel { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; width: 340px; max-height: 420px; overflow: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; }
.dd-panel label { display: flex; gap: 8px; align-items: center; padding: 5px 6px; border-radius: 6px; color: var(--ink); font-size: 13px; cursor: pointer; }
.dd-panel label:hover { background: var(--surface-2); }
.dd-panel .dd-actions { display: flex; gap: 6px; padding: 2px 4px 8px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }

/* ---------- kartlar ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card > h2 { margin-bottom: 2px; }
.card > .card-sub { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.grid { display: grid; gap: 14px; }
.grid > * { min-width: 0; }
.grid.kpis { grid-template-columns: 1.4fr 1fr 1fr 1fr; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.side-main { grid-template-columns: 232px 1fr; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 1100px) {
  .grid.kpis { grid-template-columns: 1fr 1fr; }
  .grid.two, .grid.side-main { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .side-foot { display: none; }
  .view, .filters { padding-left: 14px; padding-right: 14px; }
}

/* ---------- gösterge kutuları ---------- */
.tile .label { font-size: 12px; color: var(--ink-2); }
.tile .value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; margin: 4px 0 2px; }
.tile.hero .value { font-size: 44px; line-height: 1.05; }
.tile .foot { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.delta { font-weight: 600; white-space: nowrap; }
.delta.up { color: var(--bad); }
.delta.down { color: var(--good); }
.delta.flat { color: var(--muted); }

/* ---------- çubuk listesi (grup / firma dağılımı) ---------- */
.bars { display: flex; flex-direction: column; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 31%) 1fr 76px 48px 74px; gap: 10px; align-items: center; padding: 5px 6px; border-radius: 6px; border: 0; background: none; text-align: left; width: 100%; color: inherit; font: inherit; }
button.bar-row { cursor: pointer; }
button.bar-row:hover { background: var(--surface-2); }
.bar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 14px; background: var(--bar-track); border-radius: 0 4px 4px 0; position: relative; }
.bar-fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; min-width: 2px; }
.bar-prev { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink-2); border-radius: 1px; }
.bar-val { font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; gap: 8px; align-items: baseline; justify-content: flex-end; min-width: 168px; }
.bar-val .share { color: var(--muted); font-size: 12px; min-width: 44px; text-align: right; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--ink-2); margin-bottom: 8px; }
.legend .key { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 14px; height: 3px; border-radius: 2px; background: var(--series-1); }
.legend .swatch.prev { background: var(--series-prev); }
.legend .swatch.s2 { background: var(--series-2); }
.legend .swatch.s3 { background: var(--series-3); }
.section-title { font-size: 12px; font-weight: 650; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.06em; margin: 6px 0 -4px; display: flex; gap: 10px; align-items: baseline; }
.section-title a { text-transform: none; letter-spacing: 0; font-weight: 400; }
.grid.kpis4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid.kpis4 { grid-template-columns: 1fr 1fr; } }
tr.pl-total > td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-strong); }
tr.pl-margin > td { color: var(--muted); font-size: 12px; padding-top: 2px; padding-bottom: 8px; }
td.neg { color: var(--bad); }
.est { font-style: italic; }
.legend .swatch.tick { width: 2px; height: 12px; background: var(--ink-2); }
.chart-box { position: relative; height: 260px; }

/* ---------- tablolar ---------- */
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: 12px; color: var(--ink-2); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; z-index: 1; white-space: nowrap; }
tr:last-child > td { border-bottom: 0; }
tbody tr:hover > td { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
td.num, th.num { text-align: right; }
table.plain th { background: none; position: static; }
table.plain { font-size: 13px; }
tr.group-row > td { font-weight: 650; background: var(--surface-2); cursor: pointer; }
tr.total-row > td { font-weight: 700; border-top: 2px solid var(--line-strong); background: var(--surface); position: sticky; bottom: 0; }
tr.item-row > td:first-child { padding-left: 30px; }
tr.sub-row > td { background: var(--surface-2); font-size: 13px; }
tr.clickable { cursor: pointer; }
.caret { display: inline-block; width: 14px; color: var(--muted); }
.sticky-col { position: sticky; left: 0; background: inherit; z-index: 1; }
td.sticky-col { background: var(--surface); }
tr.group-row td.sticky-col { background: var(--surface-2); }
th.sticky-col { z-index: 2; }
.cell-link { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; font-variant-numeric: tabular-nums; text-align: left; }
td.num .cell-link { text-align: right; }
.cell-link:hover { color: var(--accent-ink); text-decoration: underline; }

/* ---------- rozetler ---------- */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); white-space: nowrap; }
.badge.new { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.badge.ok { background: var(--accent-wash); color: var(--accent-ink); border-color: transparent; }
.badge.live { background: color-mix(in srgb, var(--good) 14%, transparent); color: var(--good); border-color: transparent; }
.note { background: var(--warn-bg); color: var(--warn-ink); padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.info { background: var(--accent-wash); color: var(--accent-ink); padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- kalem yönetimi ---------- */
.group-list { display: flex; flex-direction: column; gap: 2px; }
.group-item { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; padding: 7px 8px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.group-item:hover { background: var(--surface-2); }
.group-item.on { background: var(--accent-wash); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.group-item .g-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-item .g-meta { font-size: 12px; color: var(--muted); }
.group-item .g-tools { display: none; gap: 0; }
.group-item:hover .g-tools, .group-item.on .g-tools { display: flex; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.bulkbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 8px 12px; background: var(--accent-wash); border-radius: 8px; margin-bottom: 10px; }
td .inline-select { border-color: transparent; background: transparent; padding: 3px 4px; max-width: 165px; text-overflow: ellipsis; }
table.dense th, table.dense td { padding: 6px 7px; }
table.dense .icon-btn { padding: 4px 4px; }
td .inline-select:hover, td .inline-select:focus { border-color: var(--line-strong); background: var(--surface); }
.item-name { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dim { opacity: 0.55; }

/* ---------- pencere (modal) ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.42); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow: auto; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow); border: 1px solid var(--line); width: min(560px, 100%); padding: 18px; }
.modal.wide { width: min(1080px, 100%); }
.modal-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.modal-head h2 { font-size: 17px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
#toast-root { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; }
.toast { background: var(--ink); color: var(--page); padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow); max-width: 420px; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- yapay zeka ---------- */
.md h2, .md h3 { margin: 14px 0 6px; font-size: 14px; }
.md h2:first-child, .md h3:first-child { margin-top: 0; }
.md ul, .md ol { margin: 4px 0 10px; padding-left: 20px; }
.md li { margin-bottom: 4px; }
.md table { font-size: 13px; margin: 8px 0; }
.md p:last-child { margin-bottom: 0; }
.commentary { border-left: 3px solid var(--accent); padding-left: 14px; }
.chat { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 860px; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.msg.user { align-self: flex-end; background: var(--accent-wash); border-color: transparent; white-space: pre-wrap; }
.chat-input { display: flex; gap: 8px; margin-top: 14px; position: sticky; bottom: 12px; background: var(--page); padding-top: 6px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-strong); background: var(--surface); border-radius: 999px; padding: 5px 12px; cursor: pointer; font-size: 13px; }
.chip:hover { background: var(--surface-2); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- sunum (patron görünümü) ---------- */
.present-head { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 4px; }
.present-meta { color: var(--muted); font-size: 12px; margin-bottom: 16px; }

/* ---------- yazdırma ---------- */
@media print {
  :root { --page: #fff; --surface: #fff; --surface-2: #f4f4f2; --ink: #000; --ink-2: #333; --muted: #555; --line: #d5d5d0; --bar-track: #eee; }
  .side, .filters, .no-print, #toast-root, #modal-root { display: none !important; }
  .app { display: block; }
  .view { padding: 0; max-width: none; }
  .card, .table-wrap { break-inside: avoid; box-shadow: none; }
  body { font-size: 11.5px; }
  .tile.hero .value { font-size: 34px; }
  .grid.kpis { grid-template-columns: 1.4fr 1fr 1fr 1fr; }
  .grid.two { grid-template-columns: 1fr 1fr; }
  tr.total-row > td, th { position: static; }
  @page { size: A4 portrait; margin: 12mm; }
}
