@import url("../brand/colours.css");

/* =========================================================================
   Miamesa Rapor Merkezi — tasarım token'ları
   Grafik paleti scripts/validate_palette.js ile doğrulandı:
   açık (#fffdf8) ve koyu (#152130) yüzeyde L bandı, kroma, renk körlüğü (CVD)
   ve normal görüş ayrımı PASS. Sıra sabittir; renk sıraya göre değil varlığa göre atanır.
   ========================================================================= */
:root {
  color-scheme: light;
  --mia-azul: #104379;
  --mesa-marfil: #F8F1E2;
  --mesa-tierra: #BBA99B;
  --azul-deep: #0b2f56;

  --bg: #f6efe0;
  --surface: #fffdf8;
  --surface-2: #fbf6ea;
  --surface-sunk: #f1e9d8;
  --ink: #18212c;
  --ink-2: #4b5260;
  --ink-3: #7a7480;
  --line: rgba(16, 67, 121, 0.10);
  --line-strong: rgba(16, 67, 121, 0.18);
  --grid: rgba(16, 67, 121, 0.08);
  --brand: #104379;
  --brand-ink: #F8F1E2;
  --brand-soft: rgba(16, 67, 121, 0.07);
  --focus: #2a64ad;

  /* Kategorik palet (açık) */
  --c1: #2a64ad;
  --c2: #3f8f5a;
  --c3: #7b56a6;
  --c4: #c89a2a;
  --c5: #b8395f;
  --c6: #d26a22;
  --c-other: #a9a3a0;
  --track: rgba(42, 100, 173, 0.10);

  /* Durum renkleri — kategorik paletten ayrı, yalnızca anlam taşır */
  --good: #2f7d4a;
  --good-bg: rgba(47, 125, 74, 0.10);
  --warn: #a8610b;
  --warn-bg: rgba(200, 120, 20, 0.12);
  --crit: #a52a43;
  --crit-bg: rgba(165, 42, 67, 0.10);
  --info: #2a64ad;
  --info-bg: rgba(42, 100, 173, 0.10);

  --shadow-sm: 0 1px 2px rgba(16, 33, 52, 0.05);
  --shadow: 0 1px 2px rgba(16, 33, 52, 0.04), 0 8px 24px -12px rgba(16, 33, 52, 0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --font-display: Georgia, "Times New Roman", serif;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --sidebar-w: 248px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1823;
    --surface: #152130;
    --surface-2: #1a2738;
    --surface-sunk: #111c29;
    --ink: #eef0f3;
    --ink-2: #b9c0cb;
    --ink-3: #8a93a1;
    --line: rgba(220, 230, 245, 0.09);
    --line-strong: rgba(220, 230, 245, 0.16);
    --grid: rgba(220, 230, 245, 0.07);
    --brand: #8fb4e6;
    --brand-ink: #0f1823;
    --brand-soft: rgba(143, 180, 230, 0.10);
    --focus: #8fb4e6;
    --c1: #4f86cf;
    --c2: #4c9a68;
    --c3: #9070c0;
    --c4: #b98d22;
    --c5: #c94a86;
    --c6: #d27324;
    --c-other: #6b7380;
    --track: rgba(79, 134, 207, 0.16);
    --good: #6cc08a;
    --good-bg: rgba(108, 192, 138, 0.12);
    --warn: #e2a24f;
    --warn-bg: rgba(226, 162, 79, 0.13);
    --crit: #ef7d93;
    --crit-bg: rgba(239, 125, 147, 0.12);
    --info: #8fb4e6;
    --info-bg: rgba(143, 180, 230, 0.12);
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px -14px rgba(0, 0, 0, 0.6);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1823;
  --surface: #152130;
  --surface-2: #1a2738;
  --surface-sunk: #111c29;
  --ink: #eef0f3;
  --ink-2: #b9c0cb;
  --ink-3: #8a93a1;
  --line: rgba(220, 230, 245, 0.09);
  --line-strong: rgba(220, 230, 245, 0.16);
  --grid: rgba(220, 230, 245, 0.07);
  --brand: #8fb4e6;
  --brand-ink: #0f1823;
  --brand-soft: rgba(143, 180, 230, 0.10);
  --focus: #8fb4e6;
  --c1: #4f86cf;
  --c2: #4c9a68;
  --c3: #9070c0;
  --c4: #b98d22;
  --c5: #c94a86;
  --c6: #d27324;
  --c-other: #6b7380;
  --track: rgba(79, 134, 207, 0.16);
  --good: #6cc08a;
  --good-bg: rgba(108, 192, 138, 0.12);
  --warn: #e2a24f;
  --warn-bg: rgba(226, 162, 79, 0.13);
  --crit: #ef7d93;
  --crit-bg: rgba(239, 125, 147, 0.12);
  --info: #8fb4e6;
  --info-bg: rgba(143, 180, 230, 0.12);
  --shadow-sm: none;
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 10px 30px -14px rgba(0, 0, 0, 0.6);
}

/* ------------------------------------------------------------------ Temel */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
button { font: inherit; }
a { color: var(--brand); }

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* ------------------------------------------------------------------ Kenar çubuğu */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(255, 255, 255, 0.07), transparent 60%),
    linear-gradient(180deg, var(--azul-deep), var(--mia-azul));
  color: var(--mesa-marfil);
  padding: 1.5rem 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
  overflow-y: auto;
}

.sidebar-brand { text-align: center; padding: 0.2rem 0.5rem 0.4rem; }
.sidebar-logo { width: min(150px, 100%); height: auto; display: block; margin: 0 auto; }
.sidebar-tag {
  margin: 0.6rem 0 0;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  opacity: 0.7;
}

.side-nav { display: grid; gap: 0.2rem; align-content: start; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  border: 0;
  background: transparent;
  color: rgba(248, 241, 226, 0.72);
  text-align: left;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.62rem 0.8rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-item svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav-item:hover { background: rgba(248, 241, 226, 0.08); color: var(--mesa-marfil); }
.nav-item.is-active {
  background: var(--mesa-marfil);
  color: var(--mia-azul);
  box-shadow: 0 6px 16px -8px rgba(0, 0, 0, 0.45);
}
.nav-item.is-active svg { opacity: 1; }

.sidebar-foot { display: grid; gap: 0.5rem; }

/* ------------------------------------------------------------------ Ana sütun */
.main-column {
  min-width: 0;
  padding: 1.5rem clamp(1rem, 2.2vw, 2rem) 2rem;
  max-width: 1480px;
  width: 100%;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 1rem 1.5rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 0.3rem;
  color: var(--ink-3);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
}

.topbar h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 2.4vw, 2.1rem);
  line-height: 1.15;
  color: var(--brand);
  letter-spacing: -0.01em;
}

.lede { margin: 0.3rem 0 0; color: var(--ink-2); }

/* Tarih filtresi — tek satır kontrol çubuğu */
.date-panel {
  display: grid;
  gap: 0.55rem;
  justify-items: end;
}
.preset-row {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.chip {
  border: 0;
  background: transparent;
  color: var(--ink-2);
  border-radius: 9px;
  padding: 0.38rem 0.72rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.chip:hover { color: var(--ink); background: var(--brand-soft); }
.chip.is-active {
  background: var(--surface);
  color: var(--brand);
  box-shadow: var(--shadow-sm), 0 0 0 1px var(--line);
}

.custom-range {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  justify-content: flex-end;
}
.custom-range label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  color: var(--ink-3);
  font-weight: 600;
}
.custom-range input[type="date"],
.search-input,
.chat-form input,
.auth-form input {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  font: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.custom-range input[type="date"] { padding: 0.42rem 0.55rem; font-size: 0.88rem; }
.custom-range input:focus, .search-input:focus, .chat-form input:focus, .auth-form input:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
.range-label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink-3);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.range-label .freshness { font-weight: 500; }
.range-label.is-updating .freshness { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.loading-veil p { max-width: 34ch; text-align: center; margin: 0; }

/* ------------------------------------------------------------------ Görünümler */
.content { display: grid; gap: 1rem; }
.view { display: none; gap: 1rem; }
.view.is-active { display: grid; animation: rise 0.35s ease both; }
@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* ------------------------------------------------------------------ KPI kutuları */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.75rem;
}
.kpi-grid.compact { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.kpi, .stat-card, .panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.kpi, .stat-card {
  padding: 0.95rem 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 0;
  position: relative;
}
.kpi > span, .stat-card > span {
  color: var(--ink-3);
  font-size: 0.8rem;
  font-weight: 600;
}
.kpi strong, .stat-card strong {
  font-family: var(--font-body);
  font-size: clamp(1.35rem, 1.9vw, 1.7rem);
  line-height: 1.1;
  color: var(--ink);
  font-weight: 650;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi .kpi-sub { font-size: 0.78rem; color: var(--ink-3); font-weight: 500; }

/* Kahraman rakam: görünümde tek */
.kpi.hero { grid-column: span 2; }
.kpi.hero strong { font-size: clamp(2.2rem, 3.4vw, 3rem); font-weight: 650; }

.kpi.accent {
  background: linear-gradient(150deg, var(--mia-azul), var(--azul-deep));
  border-color: transparent;
}
.kpi.accent > span, .kpi.accent .kpi-sub { color: rgba(248, 241, 226, 0.72); }
.kpi.accent strong { color: var(--mesa-marfil); }

.spark { display: block; width: 100%; height: 34px; margin-top: auto; padding-top: 0.35rem; }
.spark path.l { fill: none; stroke: var(--c1); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.spark path.a { fill: var(--c1); opacity: 0.1; stroke: none; }
.spark circle { fill: var(--c1); stroke: var(--surface); stroke-width: 2; }

/* ------------------------------------------------------------------ Paneller */
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 1rem; }
.grid-2.even { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }

.panel { padding: 1.05rem 1.15rem 1.15rem; min-width: 0; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
}
.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.08rem;
  color: var(--ink);
  font-weight: 700;
}
.panel-head .sub { display: block; margin-top: 0.15rem; font-family: var(--font-body); font-size: 0.8rem; color: var(--ink-3); font-weight: 500; }
.panel-head.spaced { margin-top: 1.4rem; }

.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box.tall { height: 300px; }
.chart-box.short { height: 220px; }
.chart-empty {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 160px;
  color: var(--ink-3);
  font-size: 0.9rem;
  text-align: center;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 1rem;
}
.chart-empty strong { display: block; font-size: 1.8rem; color: var(--ink); font-weight: 650; margin-bottom: 0.2rem; }

/* Sıralı yatay çubuk listesi (tek seri → tek renk) */
.bar-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.7rem; }
.bar-list li { display: grid; gap: 0.3rem; }
.bar-list .bl-row { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.88rem; }
.bar-list .bl-name { color: var(--ink); font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-list .bl-val { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-list .bl-val em { font-style: normal; color: var(--ink-3); margin-left: 0.35rem; }
.bar-list .bl-track { height: 8px; border-radius: 4px; background: var(--track); overflow: hidden; }
.bar-list .bl-fill {
  height: 100%;
  border-radius: 0 4px 4px 0;
  background: var(--c1);
  transform-origin: left;
  animation: grow 0.6s cubic-bezier(.2,.7,.2,1) both;
}
.bar-list li:hover .bl-fill { filter: brightness(1.08); }
.bar-list .is-other .bl-fill { background: var(--c-other); }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Parçalı çubuk (bütün → parçalar, ≤6) */
.seg-bar { display: flex; gap: 2px; height: 28px; border-radius: 4px; overflow: hidden; }
.seg-bar > span {
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  min-width: 2px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 650;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}
.seg-bar > span.dark-text { color: #18212c; }
.legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1rem; margin: 0.8rem 0 0; padding: 0; list-style: none; font-size: 0.85rem; color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.seg-table { width: 100%; margin-top: 0.9rem; }

/* Panel içi küçük istatistikler */
.mini-stats { display: flex; flex-wrap: wrap; gap: 0.5rem 1.4rem; margin: -0.2rem 0 0.9rem; }
.mini-stats div { display: grid; gap: 0.1rem; }
.mini-stats span { font-size: 0.75rem; color: var(--ink-3); font-weight: 600; }
.mini-stats strong { font-size: 1.05rem; color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }
.tag { display: inline-block; margin-left: 0.4rem; padding: 0.05rem 0.4rem; border-radius: 999px; font-size: 0.7rem; font-weight: 650; background: var(--good-bg); color: var(--good); vertical-align: middle; }
.code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-weight: 650; font-size: 0.85rem; }

/* Saat yoğunluğu: tek renk tonu, açıktan koyuya (sıralı ölçek) */
.hour-strip { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 2px; }
.hour-strip i { display: block; height: 30px; border-radius: 4px; background: var(--c1); }
.hour-strip i.zero { background: var(--track); }
.hour-strip b { grid-row: 2; font-size: 0.66rem; color: var(--ink-3); font-weight: 600; text-align: left; white-space: nowrap; }

/* ------------------------------------------------------------------ Tablolar */
.table-wrap { overflow-x: auto; margin: 0 -0.25rem; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td {
  text-align: left;
  padding: 0.62rem 0.5rem;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th {
  color: var(--ink-3);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  background: var(--surface);
  position: sticky;
  top: 0;
}
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.rank { color: var(--ink-3); width: 2rem; font-variant-numeric: tabular-nums; }
td.name { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
td.mono { color: var(--ink-3); font-size: 0.82rem; white-space: nowrap; }
.share { display: flex; align-items: center; gap: 0.5rem; justify-content: flex-end; }
.share b { font-weight: 600; min-width: 3.2em; text-align: right; }
.share i { display: inline-block; width: 56px; height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.share i::after { content: ""; display: block; height: 100%; width: var(--w, 0%); background: var(--c1); border-radius: 0 3px 3px 0; }
.table-empty { color: var(--ink-3); text-align: center; padding: 1.6rem 0.5rem; }

/* Durum rozetleri: renk + metin (renk tek başına anlam taşımaz) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 650;
  white-space: nowrap;
  background: var(--brand-soft);
  color: var(--ink-2);
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.crit { background: var(--crit-bg); color: var(--crit); }
.badge.info { background: var(--info-bg); color: var(--info); }

/* ------------------------------------------------------------------ Listeler */
.rank-list, .simple-list, .insight-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
}
.rank-list li, .simple-list li, .insight-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.62rem 0.15rem;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.rank-list li:last-child, .simple-list li:last-child, .insight-list li:last-child { border-bottom: 0; }
.rank-list li > span:first-child, .simple-list li > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.insight-list li span { color: var(--ink-2); }
.insight-list li strong { color: var(--ink); text-align: right; }
.meta, .muted { color: var(--ink-3); font-size: 0.85rem; }
.meta { white-space: nowrap; font-variant-numeric: tabular-nums; }
.rank-idx {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  margin-right: 0.55rem;
  border-radius: 7px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.rank-list li:first-child .rank-idx { background: var(--brand); color: var(--brand-ink); }
.avatar {
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin-right: 0.6rem;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand);
  font-weight: 700;
  font-size: 0.8rem;
  flex: none;
  vertical-align: middle;
}
.person { display: inline-flex; align-items: center; min-width: 0; }
.person small { display: block; color: var(--ink-3); font-size: 0.8rem; overflow: hidden; text-overflow: ellipsis; }

/* ------------------------------------------------------------------ Araç çubuğu, butonlar */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  padding: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.search-input { flex: 1; min-width: 200px; padding: 0.65rem 0.9rem; }

.btn, .linkish { font: inherit; font-weight: 650; cursor: pointer; transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.15s ease; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.9rem;
  background: var(--surface);
  color: var(--brand);
  font-size: 0.9rem;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--mia-azul); color: var(--mesa-marfil); border-color: var(--mia-azul); }
.btn-primary:hover { background: var(--azul-deep); }
:root[data-theme="dark"] .btn-primary { background: #2a64ad; border-color: #2a64ad; color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { background: #2a64ad; border-color: #2a64ad; color: #fff; } }
.btn-cream { background: var(--mesa-marfil); color: var(--mia-azul); border-color: transparent; }
.btn-cream:hover { background: #fff; }
.btn-ghost { background: transparent; }
.btn-ghost-light { background: transparent; color: var(--mesa-marfil); border-color: rgba(248, 241, 226, 0.22); }
.btn-ghost-light:hover { background: rgba(248, 241, 226, 0.08); }
.btn-block { width: 100%; }
.btn svg, .linkish svg { width: 15px; height: 15px; }

.linkish {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  font-size: 0.8rem;
  padding: 0.25rem 0.45rem;
  border-radius: 7px;
  white-space: nowrap;
}
.linkish:hover { color: var(--brand); background: var(--brand-soft); }

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 650;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  border: 1px solid rgba(248, 241, 226, 0.18);
}
.status-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.is-live { background: rgba(108, 192, 138, 0.16); color: #b9e7c8; }
.status-pill.is-live::before { box-shadow: 0 0 0 3px rgba(108, 192, 138, 0.25); }
.status-pill.is-demo { background: rgba(226, 162, 79, 0.16); color: #ffd9a8; }

.theme-toggle { justify-content: center; }

/* ------------------------------------------------------------------ Uyarılar */
.alert {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  margin-bottom: 1rem;
  padding: 0.75rem 0.95rem;
  border-radius: 12px;
  background: var(--crit-bg);
  border: 1px solid color-mix(in srgb, var(--crit) 25%, transparent);
  color: var(--crit);
  font-size: 0.9rem;
}
.alert.success, .alert.info {
  background: var(--info-bg);
  border-color: color-mix(in srgb, var(--info) 22%, transparent);
  color: var(--ink-2);
}
.alert.demo {
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 25%, transparent);
  color: var(--ink-2);
}
.alert strong { color: var(--ink); }
.alert[hidden] { display: none !important; }

/* ------------------------------------------------------------------ AI sohbet */
.chat-panel { display: flex; flex-direction: column; min-height: 560px; }
.chat-stream {
  flex: 1;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.9rem;
  max-height: 520px;
  padding: 0.25rem;
}
.chat-bubble {
  max-width: min(720px, 90%);
  padding: 0.75rem 0.95rem;
  border-radius: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-bubble.bot { background: var(--surface-2); border: 1px solid var(--line); border-top-left-radius: 4px; }
.chat-bubble.user { margin-left: auto; background: var(--mia-azul); color: var(--mesa-marfil); border-top-right-radius: 4px; }
.chat-bubble strong { color: inherit; font-weight: 700; }
.chat-bubble em { color: var(--ink-3); font-style: normal; font-size: 0.88em; }
.chat-bubble.user em { color: rgba(248, 241, 226, 0.8); }
.chat-suggest { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.75rem; max-height: 6.6rem; overflow-y: auto; }
.chat-suggest button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  font-size: 0.82rem;
  cursor: pointer;
}
.chat-suggest button:hover { color: var(--brand); border-color: var(--brand); }
.chat-form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chat-form input { flex: 1; min-width: 200px; padding: 0.7rem 0.95rem; }

/* ------------------------------------------------------------------ Alt bilgi, yükleme */
.foot { margin-top: 1.5rem; color: var(--ink-3); font-size: 0.82rem; }
.foot a { font-weight: 650; }
.perf { margin-top: 0.6rem; font-variant-numeric: tabular-nums; }
.perf summary { cursor: pointer; color: var(--ink-2); font-weight: 600; }
.perf table { margin-top: 0.4rem; font-size: 0.8rem; max-width: 640px; }
.perf td, .perf th { padding: 0.3rem 0.5rem; }
.perf .slow { color: var(--crit); font-weight: 650; }

.loading-veil {
  position: fixed;
  inset: 0;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  backdrop-filter: blur(4px);
  display: none;
  place-items: center;
  align-content: center;
  gap: 0.75rem;
  z-index: 60;
  color: var(--ink-2);
  font-weight: 600;
}
.loading-veil.is-on, .loading-veil:not([hidden]) { display: grid; }
.loading-veil[hidden] { display: none !important; }
.loader {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid var(--track);
  border-top-color: var(--c1);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ Giriş */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(160deg, rgba(16, 67, 121, 0.9), rgba(11, 47, 86, 0.96)),
    url("../brand/pattern-earth.svg") center / cover;
}
.auth-shell { width: min(420px, 100%); }
.auth-panel {
  background: var(--mesa-marfil);
  color: #18212c;
  border-radius: 22px;
  padding: 2.2rem 1.8rem;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
}
.auth-panel .eyebrow { color: #7a7480; }
.auth-panel .lede { color: #4b5260; }
.auth-logo { width: 170px; margin: 0 auto 0.8rem; display: block; }
.auth-panel h1 { margin: 0.2rem 0 0.4rem; font-family: var(--font-display); color: #104379; font-size: 1.9rem; }
.auth-form { display: grid; gap: 0.5rem; text-align: left; margin-top: 1.3rem; }
.auth-form label { color: #4b5260; font-size: 0.85rem; font-weight: 650; }
.auth-form input { padding: 0.75rem 0.95rem; background: #fffdf8; color: #18212c; border-color: rgba(16, 67, 121, 0.2); }
.auth-form .btn { padding: 0.75rem; margin-top: 0.3rem; }
.auth-panel .alert { color: #a52a43; background: rgba(165, 42, 67, 0.1); border-color: rgba(165, 42, 67, 0.2); }

/* ------------------------------------------------------------------ Duyarlı */
@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kpi.hero { grid-column: span 2; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 1080px) {
  .grid-2, .grid-2.even { grid-template-columns: minmax(0, 1fr); }
  .date-panel { justify-items: start; width: 100%; }
  .custom-range { justify-content: flex-start; }
}
@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1rem;
    overflow: visible;
  }
  .sidebar-brand { padding: 0; flex: none; }
  .sidebar-logo { width: 84px; }
  .sidebar-tag { display: none; }
  .side-nav {
    display: flex;
    overflow-x: auto;
    gap: 0.2rem;
    scrollbar-width: none;
    flex: 1;
    min-width: 0;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .nav-item { padding: 0.5rem 0.7rem; white-space: nowrap; font-size: 0.88rem; }
  .nav-item svg { display: none; }
  .sidebar-foot { display: flex; gap: 0.4rem; flex: none; }
  .sidebar-foot .status-pill { display: none; }
  .sidebar-foot .btn { width: auto; padding: 0.4rem 0.6rem; font-size: 0.8rem; }
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .main-column { padding: 1rem; }
  .kpi-grid, .kpi-grid.compact { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .kpi.hero { grid-column: 1 / -1; }
  .preset-row { display: flex; overflow-x: auto; flex-wrap: nowrap; max-width: 100%; scrollbar-width: none; }
  .custom-range { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .custom-range label { display: grid; gap: 0.25rem; }
  .custom-range input[type="date"] { width: 100%; min-width: 0; }
  .sidebar-logo { width: 64px; }
  .chart-box { height: 220px; }
  .chart-box.tall { height: 240px; }
  .sidebar-foot .theme-toggle { display: none; }
  .panel { padding: 0.95rem; }
  td.name { max-width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  .view.is-active, .loader, .bar-list .bl-fill { animation: none !important; }
}

@media print {
  .sidebar, .date-panel .preset-row, .custom-range, .linkish, .toolbar, .foot { display: none !important; }
  .app-shell { grid-template-columns: 1fr; }
  .panel, .kpi { box-shadow: none; break-inside: avoid; }
}
