/* ── RESET & BASE ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:      #f5f4f0;
  --white:   #ffffff;
  --border:  #e5e1d8;
  --ink:     #1a1814;
  --ink2:    #9c9690;
  --blue:    #2563eb;
  --green:   #16a34a;
  --amber:   #d97706;
  --red:     #dc2626;
  --panel-r: 12px;
  --ff-mono: 'DM Mono', monospace;
  --ff-head: 'Syne', sans-serif;
  --ff-body: 'Geist', sans-serif;
}

html { font-size: 14px; }
body { background: var(--bg); color: var(--ink); font-family: var(--ff-body); min-height: 100vh; }

::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: #d4d0c8; border-radius: 99px; }

/* ── TOPBAR ───────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 999;
  background: var(--white); border-bottom: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  height: 60px; padding: 0 28px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 32px; height: 32px; background: var(--ink); border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: #fff;
}
.brand-name { font-family: var(--ff-head); font-weight: 800; font-size: 17px; letter-spacing: .08em; }
.topbar-sub { font-size: 12px; color: var(--ink2); font-family: var(--ff-mono); }

/* ── TAB NAV ──────────────────────────────────── */
.tab-nav {
  display: flex; gap: 4px;
  padding: 14px 28px 0;
  background: var(--bg);
  margin-bottom: 10px;
}
.tab-btn {
  font-family: var(--ff-body); font-size: 13px; font-weight: 500;
  padding: 7px 22px; border-radius: 8px; border: 1.5px solid var(--border);
  background: var(--white); color: var(--ink2); cursor: pointer;
  transition: all .15s;
}
.tab-btn.active, .tab-btn:hover {
  background: var(--ink); color: #fff; border-color: var(--ink);
}

/* ── TAB CONTENT ──────────────────────────────── */
.tab-content { display: none; padding: 0 0 40px; }
.tab-content.active { display: block; }

/* ── TOOLBAR ──────────────────────────────────── */
.toolbar {
  display: flex; align-items: flex-end; gap: 12px;
  padding: 18px 28px 16px; flex-wrap: wrap;
  border-bottom: 1.5px solid var(--border);
  background: var(--white);
}
.toolbar-group { display: flex; flex-direction: column; gap: 4px; }
.toolbar-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink2); }
.date-input, .month-input {
  font-family: var(--ff-mono); font-size: 13px;
  border: 1.5px solid var(--border); border-radius: 7px;
  background: var(--bg); padding: 0 12px; height: 36px;
  color: var(--ink); outline: none; transition: border .15s;
}
.date-input:focus, .month-input:focus { border-color: var(--ink); }

.btn-primary {
  height: 36px; padding: 0 20px; border-radius: 7px; border: none;
  background: var(--ink); color: #fff; font-family: var(--ff-body);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s;
  white-space: nowrap;
}
.btn-primary:hover { background: #2d2d2d; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  height: 36px; padding: 0 18px; border-radius: 7px;
  border: 1.5px solid var(--border); background: transparent;
  color: var(--ink); font-family: var(--ff-body); font-size: 13px;
  font-weight: 500; cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-secondary:hover { background: var(--bg); border-color: var(--ink); }

.loading-wrap { display: flex; align-items: center; gap: 8px; color: var(--ink2); font-size: 13px; }
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--ink); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── COMPARE TOOLBAR ──────────────────────────── */
.compare-toolbar { align-items: center; gap: 16px; }
.compare-toolbar .btn-primary { margin-top: 20px }

.compare-period { display: flex; flex-direction: column; gap: 5px; }
.compare-period-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.compare-vs {
  font-family: var(--ff-head); font-size: 20px; color: var(--ink2);
  padding: 0 4px; padding-top: 16px; font-weight: 700;
}

/* ── KPI GRID ─────────────────────────────────── */
.kpi-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; padding: 22px 28px 0;
}
.kpi-card {
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: var(--panel-r); padding: 20px 22px 16px;
  position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.kpi-card.kpi-verilen { border-color: #bfdbfe; background: #eff6ff; }
.kpi-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.07); }
.kpi-label { font-size: 11px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink2); margin-bottom: 9px; }
.kpi-value { font-family: var(--ff-mono); font-size: 26px; font-weight: 500; color: var(--ink); line-height: 1; margin-bottom: 6px; }
.kpi-sub { font-size: 12px; color: var(--ink2); }
.kpi-bar { position: absolute; bottom: 0; left: 0; height: 3px; border-radius: 0 0 var(--panel-r) var(--panel-r); opacity: .3; }

/* KPI bölücü etiket */
.kpi-section-title {
  padding: 18px 28px 4px;
  font-family: var(--ff-head); font-size: 11px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  display: flex; align-items: center; gap: 10px; color: var(--ink2);
}
.kpi-section-title::after { content:''; flex:1; height:1px; background:var(--border); }
.kpi-section-title.blue { color: var(--blue); }
.kpi-section-title.blue::after { background: #bfdbfe; }

/* ── SECTION LABEL ────────────────────────────── */
.section-label {
  font-family: var(--ff-head); font-weight: 700; font-size: 12px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink2);
  padding: 22px 28px 12px;
  display: flex; align-items: center; gap: 12px;
}
.section-label::after { content: ''; flex: 1; height: 1.5px; background: var(--border); }

/* ── PANEL ────────────────────────────────────── */
.panel-row { display: flex; gap: 14px; padding: 0 28px; }
.panel {
  background: var(--white); border: 1.5px solid var(--border);
  border-radius: var(--panel-r); overflow: hidden;
  margin: 0 28px 14px;
}
.panel-row .panel { margin: 0; }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1.5px solid var(--border);
}
.panel-title { font-family: var(--ff-head); font-size: 14px; font-weight: 700; }
.panel-tag {
  font-family: var(--ff-mono); font-size: 11px; color: var(--ink2);
  background: #f0ede8; padding: 3px 9px; border-radius: 5px;
}

/* ── CHART WRAP ───────────────────────────────── */
.chart-wrap { width: 100%; height: 420px; }

/* ── COMPARE BANNER ───────────────────────────── */
.compare-banner {
  background: var(--ink); color: #fff;
  padding: 14px 28px;
  font-size: 14px; font-family: var(--ff-head); font-weight: 700;
  letter-spacing: .04em;
  display: flex; align-items: center; gap: 16px;
}
.compare-pill {
  border-radius: 99px; padding: 4px 16px;
  font-family: var(--ff-mono); font-size: 12px; font-weight: 500; letter-spacing: .04em;
}

/* ── COMPARE KPI ──────────────────────────────── */
.compare-kpi-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 16px; padding: 20px 28px 6px;
}
.compare-kpi-card {
  background: var(--white); border-radius: var(--panel-r);
  padding: 22px 26px 20px; transition: box-shadow .15s;
}
.compare-kpi-card:hover { box-shadow: 0 4px 18px rgba(0,0,0,.07); }
.compare-kpi-card-label {
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; margin-bottom: 16px;
}
.compare-kpi-inner {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 0; margin-top: 16px;
}
.compare-kpi-item { padding: 0 20px 0 0; border-right: 1.5px solid var(--border); }
.compare-kpi-item:last-child { border-right: none; padding-right: 0; padding-left: 20px; }
.compare-kpi-item:not(:first-child):not(:last-child) { padding-left: 20px; }
.compare-kpi-item-label {
  font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink2); margin-bottom: 6px; font-weight: 600;
}
.compare-kpi-item-value {
  font-family: var(--ff-mono); font-size: 20px; color: var(--ink);
  font-weight: 500; line-height: 1.2;
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px;
}
.delta-up {
  font-size: 11px; color: var(--green); font-family: var(--ff-mono); font-weight: 600;
  background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 4px;
  padding: 1px 6px; white-space: nowrap;
}
.delta-down {
  font-size: 11px; color: var(--red); font-family: var(--ff-mono); font-weight: 600;
  background: #fff1f2; border: 1px solid #fecdd3; border-radius: 4px;
  padding: 1px 6px; white-space: nowrap;
}

/* ── MINI TABS ────────────────────────────────── */
.mini-tabs { display: flex; gap: 4px; }
.mini-tab {
  font-family: var(--ff-body); font-size: 12px; padding: 5px 16px;
  border-radius: 6px; border: 1.5px solid var(--border);
  background: var(--bg); color: var(--ink2); cursor: pointer; transition: all .15s;
}
.mini-tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ── TABLES ───────────────────────────────────── */
.table-scroll { overflow-x: auto; }

.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  table-layout: fixed;
}
.data-table th {
  background: #e2e8f0; font-family: var(--ff-body); font-weight: 700;
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  padding: 11px 16px; text-align: left; white-space: nowrap;
  border-bottom: 2px solid var(--border);
  border-right: 1px solid #cbd5e1;
  color: var(--ink);
}
.data-table th:last-child { border-right: none; }

.data-table td {
  padding: 9px 16px; border-bottom: 1px solid #f0ede8;
  border-right: 1px solid #f0ede8;
  font-family: var(--ff-body); white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.data-table td:last-child { border-right: none; }
.data-table td.num { font-family: var(--ff-mono); text-align: right; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(0,0,0,.025); }

.row-green  { background: #f0fdf4; }
.row-yellow { background: #fefce8; }
.row-orange { background: #fff7ed; }
.row-red    { background: #fff1f2; }

/* ── STOK PIVOT tablosu (Pivot Analiz sekmesi) ── */
#stok-pivot-table { table-layout: auto; }
#stok-pivot-table th:first-child,
#stok-pivot-table td:first-child { min-width: 220px; white-space: normal; }
#stok-pivot-table th:not(:first-child),
#stok-pivot-table td:not(:first-child) { width: 160px; }

/* ── TRANSPOSED PIVOT tabloları (Normal + Karşılaştırma) ── */
#pivot-table,
#cmp-pivot-table {
  table-layout: auto;
}

#pivot-table td:first-child,
#cmp-pivot-table td:first-child {
  white-space: normal;
  line-height: 1.4;
  min-width: 150px;
  max-width: 250px;
}

#pivot-table thead th:not(:first-child),
#cmp-pivot-table thead th:not(:first-child) {
  white-space: nowrap;
  vertical-align: bottom;
  padding: 8px 10px 14px;
  min-width: 60px;
  max-width: 90px;
  text-align: left;
}

#pivot-table thead th:first-child,
#cmp-pivot-table thead th:first-child {
  writing-mode: horizontal-tb;
  transform: none;
  height: auto;
  vertical-align: middle;
  min-width: 200px;
}

#pivot-table td.num,
#cmp-pivot-table td.num {
  text-align: center;
  font-size: 12px;
  padding: 8px 6px;
}

#pivot-table tbody tr:last-child td,
#cmp-pivot-table tbody tr:last-child td {
  font-weight: 700;
}

/* ── EMPTY STATE ──────────────────────────────── */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 62vh; gap: 12px;
  text-align: center; padding: 40px;
}
.empty-icon  { font-size: 42px; opacity: .18; }
.empty-title { font-family: var(--ff-head); font-size: 22px; font-weight: 700; }
.empty-sub   { color: var(--ink2); font-size: 14px; max-width: 300px; line-height: 1.6; }

/* ── TOAST ────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  background: var(--red); color: #fff; padding: 12px 20px;
  border-radius: 9px; font-size: 13px; font-family: var(--ff-body);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: slideUp .25s ease; max-width: 360px;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── RESPONSIVE ───────────────────────────────── */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-row  { flex-direction: column; }
  .compare-kpi-grid { grid-template-columns: 1fr; }
  .compare-kpi-inner { grid-template-columns: 1fr 1fr; }
  .compare-kpi-item:nth-child(2) { border-right: none; }
  .compare-kpi-item:last-child { padding-left: 0; border-left: none; }
}
@media (max-width: 600px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .toolbar { padding: 14px 16px; }
  .compare-toolbar { gap: 10px; }
  .panel, .panel-row { margin-left: 16px; margin-right: 16px; }
  .kpi-grid { padding: 16px 16px 0; }
  .compare-kpi-grid { padding: 16px 16px 0; }
  .compare-kpi-inner { grid-template-columns: 1fr; gap: 12px; }
  .compare-kpi-item { border-right: none; padding: 0; }
  .compare-kpi-item:last-child { padding-left: 0; }
}

/* ── CARİ UNVAN BAR CHART ─────────────────────── */
.unvan-bar-wrapper {
  height: 520px;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  background: #fff;
}

/*.unvan-bar-wrapper::-webkit-scrollbar { width: 5px; height: 0; }*/
/*.unvan-bar-wrapper::-webkit-scrollbar-track { background: #f0ede8; border-radius: 10px; }*/
/*.unvan-bar-wrapper::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }*/
/*.unvan-bar-wrapper::-webkit-scrollbar-thumb:hover { background: #94a3b8; }*/
.unvan-bar-wrapper::-webkit-scrollbar { width: 6px; height: 0; }
.unvan-bar-wrapper::-webkit-scrollbar-track { background: #f0ede8; border-radius: 10px; }
.unvan-bar-wrapper::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
.unvan-bar-wrapper::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
/* Fullscreen modunda wrapper - scroll aktif */
.unvan-bar-wrapper:fullscreen,
.unvan-bar-wrapper:-webkit-full-screen {
  height: 100vh !important;
  max-height: 100vh !important;
  min-height: 100vh !important;
  overflow-y: auto !important;
  background: #fff;
}

/* Fullscreen'de Plotly div'i - yüksekliği otomatik yap */
:fullscreen #chart-unvan-bar,
:-webkit-full-screen #chart-unvan-bar {
  height: auto !important;
  min-height: 100% !important;
}

/* Plotly div */
#chart-unvan-bar {
  width: 100%;
  background: #fff;
}

/* Fullscreen toolbar düzeltmesi */
/*:fullscreen .modebar,*/
/*:-webkit-full-screen .modebar {*/
/*  position: fixed !important;*/
/*  top: 10px !important;*/
/*  right: 10px !important;*/
/*  z-index: 9999 !important;*/
/*  background: rgba(0,0,0,0.7) !important;*/
/*  border-radius: 8px !important;*/
/*}*/
:fullscreen .modebar,
:-webkit-full-screen .modebar {
  position: fixed !important;
  top: 10px !important;
  right: 10px !important;
  z-index: 9999 !important;
  background: rgba(0,0,0,0.7) !important;
  border-radius: 8px !important;
}
/* Fullscreen modunda wrapper - scroll aktif */
/*.unvan-bar-wrapper:fullscreen,*/
/*.unvan-bar-wrapper:-webkit-full-screen {*/
/*  height: 100vh !important;*/
/*  max-height: 100vh !important;*/
/*  min-height: 100vh !important;*/
/*  overflow-y: auto !important;*/
/*  overflow-x: hidden !important;*/
/*  background: #fff;*/
/*}*/
/* Fullscreen modunda wrapper */
.unvan-bar-wrapper:fullscreen,
.unvan-bar-wrapper:-webkit-full-screen {
  height: 100vh !important;
  max-height: 100vh !important;
  min-height: 100vh !important;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  background: #fff;
}
/* Fullscreen'de Plotly div'i */
:fullscreen #chart-unvan-bar,
:-webkit-full-screen #chart-unvan-bar {
  width: 100% !important;
  background: #fff;
}
