:root {
  --bg: #f3f5f7;
  --surface: #ffffff;
  --ink: #14212b;
  --muted: #5d6b77;
  --line: #e2e7ec;
  --brand: #0f3d5e;
  --brand-2: #1c5b86;
  --accent: #e8a33d;
  --ok: #1f8a5b;
  --ok-bg: #e6f4ec;
  --warn: #b26a00;
  --warn-bg: #fff3df;
  --bad: #c0392b;
  --bad-bg: #fdecea;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 33, 45, .06), 0 2px 8px rgba(16, 33, 45, .05);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d141a; --surface: #16212a; --ink: #e7edf2; --muted: #93a3b1; --line: #24323d;
    --brand: #0b2c44; --brand-2: #5fa8d8; --ok-bg: #12301f; --warn-bg: #3a2a0d; --bad-bg: #3a1714;
    --ok: #4fc08a; --warn: #f0b456; --bad: #f07a6c; color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
.num { font-variant-numeric: tabular-nums; }

/* ---- Üst çubuk ---- */
.top { position: sticky; top: 0; z-index: 10; background: var(--brand); color: #fff; padding: calc(10px + var(--safe-t)) 16px 10px; }
.top-row { display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 0 auto; }
.top h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: .2px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .back { background: none; border: 0; color: #fff; font-size: 22px; padding: 0 6px 0 0; cursor: pointer; line-height: 1; }
.top .sync { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 6px; background: rgba(255,255,255,.12); border: 0; color: #fff; border-radius: 999px; padding: 5px 10px; cursor: pointer; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #4fd08f; display: inline-block; }
.dot.off { background: #f0b456; }
.dot.err { background: #ff7a6b; }
.banner { max-width: 760px; margin: 8px auto 0; font-size: 12.5px; border-radius: 8px; padding: 6px 10px; }
.banner.demo { background: var(--accent); color: #2b1a00; font-weight: 600; }
.banner.err { background: #7a1f16; color: #fff; }
.banner.off { background: rgba(255,255,255,.15); }

main { max-width: 760px; margin: 0 auto; padding: 14px 16px calc(90px + var(--safe-b)); }

/* ---- Alt menü ---- */
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; background: var(--surface); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.nav-in { max-width: 760px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 9px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.nav a svg { width: 24px; height: 24px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.on { color: var(--brand-2); }

/* ---- Kartlar ---- */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 26px; font-weight: 750; margin-top: 2px; letter-spacing: -.5px; }
.stat.warn .v { color: var(--warn); }
.stat.bad .v { color: var(--bad); }
.stat.wide { grid-column: span 2; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; margin: 20px 2px 8px; }
.section-title h2 { font-size: 15px; margin: 0; }
.section-title a, .linkbtn { font-size: 13px; color: var(--brand-2); font-weight: 600; background: none; border: 0; padding: 0; cursor: pointer; }

/* ---- Listeler ---- */
.list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); cursor: pointer; }
.row:first-child { border-top: 0; }
.row:active { background: var(--bg); }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .r { text-align: right; flex-shrink: 0; }
.row .r .big { font-weight: 700; font-size: 16px; }
.row .r .s { font-size: 12px; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.more { display: block; width: 100%; padding: 12px; border: 0; border-top: 1px solid var(--line); background: var(--surface); color: var(--brand-2); font-weight: 600; cursor: pointer; }

.pill { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.in { color: var(--ok); }
.out { color: var(--bad); }

/* ---- Arama & filtreler ---- */
.toolbar { position: sticky; top: calc(56px + var(--safe-t)); z-index: 5; background: var(--bg); padding: 0 0 10px; margin-top: -2px; }
.search { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 12px; }
.search svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; flex-shrink: 0; }
.search input { flex: 1; border: 0; background: none; padding: 11px 0; outline: none; min-width: 0; font-size: 16px; }
.chips { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; cursor: pointer; color: var(--muted); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.dates { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.dates label { font-size: 12px; color: var(--muted); font-weight: 600; display: flex; flex-direction: column; gap: 3px; }
.dates input { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; font-size: 15px; }
.count { font-size: 12.5px; color: var(--muted); margin: 0 2px 8px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }

/* ---- Detay ---- */
.detail-head { padding: 16px; }
.detail-head .code { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.detail-head h2 { font-size: 19px; margin: 2px 0 10px; line-height: 1.25; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.kv div span { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.kv div b { font-weight: 650; }
.hero-num { font-size: 32px; font-weight: 800; letter-spacing: -.8px; }
.actions { display: flex; gap: 8px; margin: 12px 0 0; flex-wrap: wrap; }
.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 9px 12px; font-size: 13.5px; font-weight: 650; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---- Giriş ---- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(160deg, var(--brand) 0%, #164e74 55%, var(--bg) 55.2%); }
.login .box { width: 100%; max-width: 380px; background: var(--surface); border-radius: 18px; box-shadow: 0 10px 40px rgba(0,0,0,.15); padding: 26px 22px; }
.logo { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.logo img { width: 44px; height: 44px; border-radius: 11px; }
.logo b { font-size: 20px; letter-spacing: .4px; }
.logo small { display: block; color: var(--muted); font-size: 12.5px; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field input { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 12px; font-size: 16px; color: var(--ink); outline: none; }
.field input:focus { border-color: var(--brand-2); }
.login .btn.primary { width: 100%; justify-content: center; padding: 13px; font-size: 15px; margin-top: 6px; }
.msg { font-size: 13.5px; color: var(--bad); min-height: 20px; margin-top: 8px; }

.loading { padding: 40px; text-align: center; color: var(--muted); }
.spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand-2); border-radius: 50%; animation: s 0.8s linear infinite; margin: 0 auto 10px; }
@keyframes s { to { transform: rotate(360deg); } }
.foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 22px; }
.toast { position: fixed; left: 50%; bottom: calc(80px + var(--safe-b)); transform: translateX(-50%); background: #14212b; color: #fff; padding: 9px 14px; border-radius: 10px; font-size: 13.5px; z-index: 50; }

/* ---- PDF / yazdırma ---- */
.print-only { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; color: #000; font-size: 11px; }
  .top, .nav, .toolbar, .actions, .more, .no-print, .toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .print-only { display: block; }
  .card, .list { box-shadow: none; border: 1px solid #ccc; }
  .row { padding: 6px 8px; break-inside: avoid; }
  .print-table { width: 100%; border-collapse: collapse; }
  .print-table th, .print-table td { border-bottom: 1px solid #ddd; padding: 4px 6px; text-align: left; }
  .print-table td.n, .print-table th.n { text-align: right; white-space: nowrap; }
  .screen-only { display: none !important; }
}
.section-title a.btn { color: inherit; font-size: 13.5px; }
