/* MilyonPark Tedarikçi Portalı — tasarım sistemi
   Apple tarzı: sistem fontu, yumuşak kartlar, saf beyaz yüzeyler, canlı mavi vurgu.
   Koyu tema otomatik (prefers-color-scheme). */

:root {
  color-scheme: light;
  /* Yüzeyler */
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --surface-2: #FAFAFC;
  --hairline: rgba(0, 0, 0, 0.08);
  --hairline-strong: rgba(0, 0, 0, 0.14);
  /* Metin */
  --ink: #1D1D1F;
  --ink-2: #55555A;
  --ink-3: #8E8E93;
  /* Vurgu */
  --accent: #007AFF;
  --accent-press: #0066D6;
  --accent-soft: rgba(0, 122, 255, 0.10);
  --danger: #FF3B30;
  --danger-soft: rgba(255, 59, 48, 0.10);
  --success: #34C759;
  --success-soft: rgba(52, 199, 89, 0.12);
  --warning: #FF9500;
  /* Grafik (dataviz paleti — doğrulanmış) */
  --chart-surface: #fcfcfb;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --chart-grid: #e1e0d9;
  --chart-axis: #c3c2b7;
  --chart-muted: #898781;
  /* Ölçüler */
  --radius: 20px;
  --radius-sm: 13px;
  --shadow: 0 2px 16px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lift: 0 8px 32px rgba(0, 0, 0, 0.10);
  --tabbar-h: 78px;
  --sidebar-w: 250px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #000000;
    --surface: #1C1C1E;
    --surface-2: #2C2C2E;
    --hairline: rgba(255, 255, 255, 0.12);
    --hairline-strong: rgba(255, 255, 255, 0.2);
    --ink: #F5F5F7;
    --ink-2: #B8B8BE;
    --ink-3: #8E8E93;
    --accent: #0A84FF;
    --accent-press: #3395FF;
    --accent-soft: rgba(10, 132, 255, 0.16);
    --danger: #FF453A;
    --danger-soft: rgba(255, 69, 58, 0.16);
    --success: #30D158;
    --success-soft: rgba(48, 209, 88, 0.16);
    --warning: #FF9F0A;
    --chart-surface: #1a1a19;
    --series-1: #3987e5;
    --series-2: #d95926;
    --chart-grid: #2c2c2a;
    --chart-axis: #383835;
    --chart-muted: #898781;
    --shadow: 0 2px 16px rgba(0, 0, 0, 0.4);
    --shadow-lift: 0 8px 32px rgba(0, 0, 0, 0.55);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
}

body.no-nav { padding-bottom: 0; }

/* ── Yerleşim ── */
.shell { max-width: 680px; margin: 0 auto; padding: 0 16px; }
.page-head {
  padding: calc(14px + env(safe-area-inset-top)) 0 6px;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
}
.page-head h1 { font-size: 30px; font-weight: 800; letter-spacing: -0.6px; }
.page-head .sub { color: var(--ink-3); font-size: 13px; font-weight: 600; margin-top: 2px; }
main { animation: pageIn .35s cubic-bezier(.2,.7,.3,1) both; }
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Masaüstü: kenar çubuğu */
@media (min-width: 1024px) {
  body { padding-bottom: 0; padding-left: var(--sidebar-w); }
  body.no-nav { padding-left: 0; }
  .shell { max-width: 860px; padding: 0 32px; }
  .shell.wide { max-width: 1180px; }
}

/* ── Kartlar ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--hairline);
  padding: 18px;
  margin-bottom: 14px;
}
.card.flush { padding: 0; overflow: hidden; }
.card h2 { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; margin-bottom: 12px; }
.card .card-note { color: var(--ink-3); font-size: 12.5px; }

/* ── KPI kutuları ── */
.kpi-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
@media (min-width: 720px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
.kpi {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--hairline);
  box-shadow: var(--shadow); padding: 14px 16px; position: relative; overflow: hidden;
}
.kpi .k-label { font-size: 12px; font-weight: 600; color: var(--ink-3); letter-spacing: .1px; }
.kpi .k-value { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; margin-top: 3px; white-space: nowrap; }
.kpi .k-delta { font-size: 12px; font-weight: 700; margin-top: 3px; display: inline-flex; align-items: center; gap: 3px; }
.kpi .k-delta.up { color: var(--success); }
.kpi .k-delta.down { color: var(--danger); }
.kpi .k-delta.flat { color: var(--ink-3); }
.kpi .k-spark { position: absolute; right: 10px; bottom: 8px; opacity: .9; }

/* ── Hero sayı ── */
.hero-value { font-size: 44px; font-weight: 800; letter-spacing: -1.5px; line-height: 1.1; }
.hero-label { color: var(--ink-3); font-size: 13px; font-weight: 600; }

/* ── Butonlar ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-size: 14.5px; font-weight: 650; letter-spacing: -0.1px;
  border: none; cursor: pointer; user-select: none; -webkit-tap-highlight-color: transparent;
  border-radius: 14px; padding: 11px 18px;
  background: var(--accent); color: #fff;
  transition: transform .12s ease, background .15s ease, opacity .15s ease;
}
.btn:active { transform: scale(.96); }
.btn:hover { background: var(--accent-press); }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.secondary:hover { background: rgba(0, 122, 255, 0.16); }
.btn.ghost { background: transparent; color: var(--accent); padding: 8px 12px; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.small { padding: 7px 13px; font-size: 13px; border-radius: 11px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn .spin { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
.btn.secondary .spin, .btn.ghost .spin { border-color: rgba(0,122,255,.3); border-top-color: var(--accent); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Form ── */
.field label { display: block; font-size: 12px; font-weight: 650; color: var(--ink-3); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; font: inherit; font-size: 15px; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--hairline); border-radius: 13px;
  padding: 11px 14px; outline: none; transition: border .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none; appearance: none;
}
.input:focus { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.input::placeholder { color: var(--ink-3); }

/* ── Segment kontrol ── */
.segment {
  display: flex; background: var(--surface-2); border: 1px solid var(--hairline);
  border-radius: 13px; padding: 3px; gap: 2px; overflow-x: auto; scrollbar-width: none;
}
.segment::-webkit-scrollbar { display: none; }
.segment button {
  flex: 1; font: inherit; font-size: 13.5px; font-weight: 650; color: var(--ink-2);
  background: transparent; border: none; border-radius: 10px; padding: 8px 12px;
  cursor: pointer; white-space: nowrap; transition: all .18s ease; -webkit-tap-highlight-color: transparent;
}
.segment button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,.08); }

/* ── Chip / rozet ── */
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 4px 10px; }
.chip.blue { background: var(--accent-soft); color: var(--accent); }
.chip.green { background: var(--success-soft); color: var(--success); }
.chip.red { background: var(--danger-soft); color: var(--danger); }
.chip.gray { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--hairline); }

/* ── Tablolar ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  color: var(--ink-3); padding: 9px 12px; border-bottom: 1px solid var(--hairline-strong);
  position: sticky; top: 0; background: var(--surface); white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--hairline); vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.total td { font-weight: 800; background: var(--accent-soft); position: sticky; bottom: 0; }
table.data tbody tr { transition: background .12s; }
table.data tbody tr:hover { background: var(--surface-2); }

/* ── Liste satırları (iOS ayar listesi hissi) ── */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  border-bottom: 1px solid var(--hairline); cursor: pointer; transition: background .12s;
  -webkit-tap-highlight-color: transparent; text-decoration: none; color: inherit;
}
.list-row:last-child { border-bottom: none; }
.list-row:active { background: var(--surface-2); }
.list-row .lr-icon {
  width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); flex-shrink: 0;
}
.list-row .lr-body { flex: 1; min-width: 0; }
.list-row .lr-title { font-weight: 650; font-size: 14.5px; }
.list-row .lr-sub { color: var(--ink-3); font-size: 12.5px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .lr-right { text-align: right; flex-shrink: 0; }
.chevron { color: var(--ink-3); flex-shrink: 0; }

/* ── Alt sekme çubuğu (mobil) ── */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(22px); backdrop-filter: saturate(180%) blur(22px);
  border-top: 1px solid var(--hairline);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; font-weight: 650; color: var(--ink-3); text-decoration: none;
  padding: 4px 10px; border-radius: 12px; min-width: 58px; position: relative;
  transition: color .15s; -webkit-tap-highlight-color: transparent;
}
.tabbar a.active { color: var(--accent); }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar .badge {
  position: absolute; top: 0; right: 8px; min-width: 16px; height: 16px; border-radius: 8px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

/* ── Kenar çubuğu (masaüstü) ── */
.sidebar {
  display: none; position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w); z-index: 50;
  background: color-mix(in srgb, var(--surface) 75%, transparent);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  border-right: 1px solid var(--hairline); padding: 22px 14px; flex-direction: column;
}
@media (min-width: 1024px) {
  .sidebar { display: flex; }
  .tabbar { display: none; }
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 20px; }
.sidebar .brand .logo { width: 38px; height: 38px; border-radius: 11px; background: var(--accent); display: flex; align-items: center; justify-content: center; color: #fff; }
.sidebar .brand b { font-size: 16px; letter-spacing: -0.3px; }
.sidebar .brand span { display: block; font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 12px;
  color: var(--ink-2); font-weight: 650; font-size: 14px; text-decoration: none; position: relative;
  transition: background .13s, color .13s;
}
.sidebar nav a:hover { background: var(--surface-2); }
.sidebar nav a.active { background: var(--accent-soft); color: var(--accent); }
.sidebar nav a svg { width: 21px; height: 21px; }
.sidebar nav a .badge {
  margin-left: auto; min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger);
  color: #fff; font-size: 11px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.sidebar .foot { padding: 10px; border-top: 1px solid var(--hairline); }

/* ── Toast ── */
.toast-host { position: fixed; top: calc(12px + env(safe-area-inset-top)); left: 0; right: 0; z-index: 999; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--ink); color: var(--bg); font-size: 13.5px; font-weight: 650;
  border-radius: 999px; padding: 10px 20px; box-shadow: var(--shadow-lift);
  animation: toastIn .3s cubic-bezier(.2,.8,.3,1.2) both; max-width: 86vw;
}
.toast.out { animation: toastOut .25s ease both; }
.toast.error { background: var(--danger); color: #fff; }
.toast.success { background: var(--success); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.92); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(.95); } }

/* ── İskelet yükleme ── */
.skeleton { position: relative; overflow: hidden; background: var(--surface-2); border-radius: 10px; min-height: 14px; }
.skeleton::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.5), transparent);
  animation: shimmer 1.3s infinite;
}
@media (prefers-color-scheme: dark) {
  .skeleton::after { background: linear-gradient(90deg, transparent, rgba(255,255,255,.07), transparent); }
}
@keyframes shimmer { from { transform: translateX(-100%);} to { transform: translateX(100%);} }

/* ── Boş durum ── */
.empty { text-align: center; padding: 44px 20px; color: var(--ink-3); }
.empty svg { width: 44px; height: 44px; margin-bottom: 10px; opacity: .5; }
.empty .e-title { font-weight: 700; font-size: 15px; color: var(--ink-2); }
.empty .e-sub { font-size: 13px; margin-top: 3px; }

/* ── Mesajlaşma ── */
.chat-scroll { display: flex; flex-direction: column; gap: 8px; padding: 6px 2px; }
.bubble {
  max-width: 78%; padding: 10px 14px; border-radius: 19px; font-size: 14.5px; line-height: 1.4;
  animation: bubbleIn .25s cubic-bezier(.2,.8,.3,1.1) both; word-wrap: break-word; white-space: pre-wrap;
}
.bubble.me { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.bubble.them { align-self: flex-start; background: var(--surface); border: 1px solid var(--hairline); border-bottom-left-radius: 6px; }
.bubble .b-time { display: block; font-size: 10.5px; opacity: .65; margin-top: 3px; text-align: right; }
@keyframes bubbleIn { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
.chat-compose {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) - 12px); z-index: 40;
  padding: 10px 16px calc(10px);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-top: 1px solid var(--hairline);
}
@media (min-width: 1024px) { .chat-compose { left: var(--sidebar-w); bottom: 0; } }
.chat-compose .row { display: flex; gap: 8px; max-width: 680px; margin: 0 auto; }
.chat-compose .row .input { border-radius: 999px; flex: 1; }
.chat-compose .send-btn { width: 44px; height: 44px; border-radius: 50%; padding: 0; flex-shrink: 0; }

/* ── Modal / sheet ── */
.sheet-back {
  position: fixed; inset: 0; background: rgba(0,0,0,.42); z-index: 90;
  animation: fadeIn .2s ease both; -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
}
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  position: fixed; z-index: 91; background: var(--surface);
  left: 0; right: 0; bottom: 0; max-height: 92dvh; overflow-y: auto;
  border-radius: 22px 22px 0 0; padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
  animation: sheetUp .32s cubic-bezier(.2,.8,.25,1) both;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--hairline-strong); margin: 4px auto 14px; }
@keyframes sheetUp { from { transform: translateY(60%); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 720px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 560px; border-radius: 22px; animation: popIn .25s cubic-bezier(.2,.8,.3,1.1) both; }
  @keyframes popIn { from { transform: translate(-50%, -46%) scale(.95); opacity: 0; } to { transform: translate(-50%, -50%) scale(1); opacity: 1; } }
  .sheet .grab { display: none; }
}

/* ── Grafik kapları ── */
.chart-box { position: relative; }
.chart-box svg { display: block; width: 100%; height: auto; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5; min-width: 120px;
  background: var(--surface); border: 1px solid var(--hairline-strong); border-radius: 12px;
  box-shadow: var(--shadow-lift); padding: 8px 11px; font-size: 12px;
  opacity: 0; transition: opacity .12s; transform: translate(-50%, 0);
}
.chart-tip.on { opacity: 1; }
.chart-tip .t-label { color: var(--ink-3); font-weight: 650; font-size: 11px; margin-bottom: 3px; }
.chart-tip .t-row { display: flex; align-items: center; gap: 6px; font-weight: 700; font-variant-numeric: tabular-nums; }
.chart-tip .t-key { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }

/* ── Ödeme dönemi ilerleme çubuğu ── */
.meter { height: 8px; border-radius: 4px; background: var(--accent-soft); overflow: hidden; }
.meter > div { height: 100%; border-radius: 4px; background: var(--accent); transition: width .8s cubic-bezier(.2,.8,.3,1); }

/* ── Yardımcılar ── */
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.muted { color: var(--ink-3); } .small { font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
.pos { color: var(--success); } .neg { color: var(--danger); }
.hide { display: none !important; }
.text-right { text-align: right; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Sayfa içi yumuşak geçiş */
.fade-swap { animation: pageIn .3s ease both; }

/* Masaüstünde imleç tablo satırları */
@media (hover: hover) {
  .list-row:hover { background: var(--surface-2); }
}

/* Yazdırma */
@media print {
  .tabbar, .sidebar, .btn, .chat-compose { display: none !important; }
  body { background: #fff; padding: 0; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}
