:root {
  --bg: #eef5f8;
  --card: #ffffff;
  --ink: #0c2a3a;
  --muted: #5c7686;
  --line: #d9e5ec;
  --brand: #0b4f6c;
  --brand-2: #0a7ea4;
  --accent: #19b6c9;
  --ok: #17895a;
  --warn: #c77700;
  --bad: #c93a3a;
  --ok-bg: #e4f5ec;
  --warn-bg: #fff2d9;
  --bad-bg: #fde8e8;
  --soft: #e3f1f6;
  --shadow: 0 1px 2px rgba(12, 42, 58, .06), 0 4px 14px rgba(12, 42, 58, .06);
  --r: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #081821;
    --card: #10252f;
    --ink: #e6f2f7;
    --muted: #8fa9b7;
    --line: #1f3a47;
    --brand: #0d6283;
    --brand-2: #3ab4d8;
    --soft: #153341;
    --ok: #4cc58d;
    --warn: #f0b04a;
    --bad: #ff7b7b;
    --ok-bg: #12352a;
    --warn-bg: #3a2c10;
    --bad-bg: #3d1b1b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
  overscroll-behavior-y: contain;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.boot { display: grid; place-items: center; min-height: 100dvh; }
.drop {
  width: 46px; height: 46px; background: var(--brand-2);
  border-radius: 0 60% 60% 60%; transform: rotate(45deg);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { transform: rotate(45deg) scale(.8); opacity: .6; } }

/* Çərçivə */
.shell { max-width: 640px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; padding: calc(10px + var(--safe-t)) 14px 12px;
  display: flex; align-items: center; gap: 10px;
}
.top h1 { font-size: 19px; margin: 0; flex: 1; font-weight: 650; letter-spacing: .1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .back { background: rgba(255,255,255,.16); border: 0; color: #fff; width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; }
.chip-sync {
  border: 0; border-radius: 999px; padding: 6px 11px; font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,.18); color: #fff; display: inline-flex; align-items: center; gap: 6px;
}
.chip-sync i { width: 8px; height: 8px; border-radius: 50%; background: #5ee0a0; display: inline-block; }
.chip-sync.pending i { background: #ffc857; }
.chip-sync.offline i { background: #b6c6cf; }
.chip-sync.error i { background: #ff7b7b; }
.chip-sync.busy i { animation: pulse2 .8s infinite; }
@keyframes pulse2 { 50% { opacity: .25; } }

main { flex: 1; padding: 14px 14px 110px; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: var(--safe-b);
}
.tabs-in { max-width: 640px; margin: 0 auto; display: flex; }
.tabs a {
  flex: 1; text-align: center; text-decoration: none; color: var(--muted);
  padding: 8px 2px 7px; font-size: 11.5px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabs a svg { width: 24px; height: 24px; }
.tabs a.on { color: var(--brand-2); }
.tabs a.on svg { stroke-width: 2.4; }

/* Kartlar */
.card { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
.card h2, h2.sec { font-size: 13px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin: 0 0 10px; font-weight: 700; }
h2.sec { margin: 18px 4px 8px; }
.hello { margin: 2px 4px 12px; }
.hello b { font-size: 22px; display: block; }
.hello span { color: var(--muted); font-size: 14px; }

.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border-radius: var(--r); padding: 12px 14px; box-shadow: var(--shadow); }
.kpi small { color: var(--muted); font-size: 12.5px; font-weight: 600; display: block; }
.kpi b { font-size: 22px; display: block; margin-top: 2px; letter-spacing: -.3px; }
.kpi b.neg { color: var(--bad); }
.kpi b.pos { color: var(--ok); }
.kpi em { font-style: normal; font-size: 12.5px; color: var(--muted); }

.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.tile {
  border: 0; border-radius: var(--r); padding: 16px 12px; background: var(--card); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px; text-decoration: none; color: var(--ink);
  font-weight: 650; font-size: 17px; min-height: 92px;
}
.tile .ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--soft); color: var(--brand-2); }
.tile.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.tile.primary .ico { background: rgba(255,255,255,.2); color: #fff; }
.tile:active { transform: scale(.98); }

/* Siyahı */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line);
  background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; text-decoration: none; color: inherit;
}
.row:last-child { border-bottom: 0; }
.row .ico { width: 38px; height: 38px; flex: none; border-radius: 12px; display: grid; place-items: center; background: var(--soft); color: var(--brand-2); }
.row .ico.sale { background: var(--ok-bg); color: var(--ok); }
.row .ico.out { background: var(--warn-bg); color: var(--warn); }
.row .mid { flex: 1; min-width: 0; }
.row .mid b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .mid small { color: var(--muted); font-size: 13px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amt { font-weight: 650; white-space: nowrap; text-align: right; }
.row .amt small { display: block; color: var(--muted); font-weight: 500; font-size: 12px; }
.row.link::after { content: "›"; color: var(--muted); font-size: 22px; margin-left: 2px; }
.day { font-size: 13px; font-weight: 700; color: var(--muted); margin: 16px 4px 4px; }

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

.alert { padding: 11px 13px; border-radius: 12px; font-size: 14.5px; margin-bottom: 10px; background: var(--warn-bg); color: var(--warn); font-weight: 550; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.ok { background: var(--ok-bg); color: var(--ok); }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; font-size: 15px; }

/* Formlar */
.field { margin-bottom: 14px; }
.field > label, .lbl { display: block; font-size: 13.5px; font-weight: 650; color: var(--muted); margin: 0 2px 6px; }
.in {
  width: 100%; height: 52px; border: 1.5px solid var(--line); border-radius: 14px; padding: 0 14px;
  background: var(--card); font-size: 18px; outline: none; appearance: none; -webkit-appearance: none;
}
.in:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-2) 22%, transparent); }
textarea.in { height: 70px; padding: 10px 14px; font-size: 16px; resize: none; }
select.in {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' fill='none' stroke='%235c7686' stroke-width='2'%3E%3Cpath d='M1 1l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 38px;
}
.in.big { height: 64px; font-size: 28px; font-weight: 650; text-align: center; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 13px; color: var(--muted); margin: 5px 3px 0; }
.hint.bad { color: var(--bad); font-weight: 600; }

.quick { display: flex; gap: 8px; margin-top: 8px; }
.quick button {
  flex: 1; height: 42px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--card);
  font-weight: 650; font-size: 15px; color: var(--brand-2);
}
.quick button:active { background: var(--soft); }

.seg { display: flex; background: var(--soft); border-radius: 14px; padding: 4px; gap: 4px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 11px 4px; border-radius: 11px; font-weight: 650; font-size: 15px; color: var(--muted); }
.seg input:checked + span { background: var(--card); color: var(--brand-2); box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label input { position: absolute; opacity: 0; pointer-events: none; }
.chips label span {
  display: inline-block; padding: 11px 16px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--card); font-weight: 600; font-size: 15px;
}
.chips label input:checked + span { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.chips.sm label span { padding: 7px 13px; font-size: 14px; }

.total {
  display: flex; justify-content: space-between; align-items: baseline;
  background: var(--soft); border-radius: 14px; padding: 12px 16px; margin-bottom: 14px;
}
.total span { color: var(--muted); font-weight: 650; }
.total b { font-size: 26px; letter-spacing: -.4px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 56px;
  border: 0; border-radius: 16px; font-weight: 700; font-size: 18px; background: var(--soft); color: var(--brand-2);
  text-decoration: none;
}
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.sm { height: 44px; font-size: 15px; border-radius: 12px; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.985); }
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 10px 14px calc(10px + var(--safe-b));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.savebar > div { max-width: 640px; margin: 0 auto; }

.uses { font-size: 14px; }
.uses div { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.uses div:last-child { border-bottom: 0; }
.uses .short { color: var(--bad); font-weight: 700; }

/* Anbar */
.stockrow { padding: 12px 2px; border-bottom: 1px solid var(--line); }
.stockrow:last-child { border-bottom: 0; }
.stockrow .h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.stockrow b { font-weight: 650; }
.stockrow .n { font-size: 20px; font-weight: 700; }
.bar { height: 7px; background: var(--soft); border-radius: 99px; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; }
.bar.warn i { background: var(--warn); }
.bar.bad i { background: var(--bad); }
.stockrow small { color: var(--muted); font-size: 12.5px; }

/* Hesabat */
.range { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.range::-webkit-scrollbar { display: none; }
.range label input { position: absolute; opacity: 0; pointer-events: none; }
.range label span { white-space: nowrap; display: block; padding: 9px 15px; border-radius: 999px; background: var(--card); border: 1.5px solid var(--line); font-weight: 650; font-size: 14.5px; }
.range label input:checked + span { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.kv { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv:last-child { border-bottom: 0; }
.kv span { color: var(--muted); }
.kv b { text-align: right; }
.kv.total-row { font-size: 18px; }
.kv.total-row span { color: var(--ink); font-weight: 650; }
.chart { width: 100%; height: 120px; display: block; }
.chart rect { fill: var(--brand-2); }
.chart text { fill: var(--muted); font-size: 9px; }

/* Aşağıdan açılan pəncərə */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet .bk { position: absolute; inset: 0; background: rgba(5, 20, 28, .5); animation: fade .18s; }
.sheet .pn {
  position: relative; width: 100%; max-width: 640px; max-height: 88dvh; overflow-y: auto; background: var(--bg);
  border-radius: 22px 22px 0 0; padding: 8px 16px calc(18px + var(--safe-b)); animation: up .22s ease-out;
}
.sheet .grab { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 12px; font-size: 19px; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.toast {
  position: fixed; left: 50%; bottom: calc(86px + var(--safe-b)); transform: translateX(-50%); z-index: 60;
  background: #0c2a3a; color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 600; font-size: 15px;
  max-width: 90vw; box-shadow: 0 8px 24px rgba(0,0,0,.25); animation: up .2s;
}
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }

/* Giriş */
.login { max-width: 420px; margin: 0 auto; padding: calc(40px + var(--safe-t)) 20px 30px; }
.login .logo { width: 72px; height: 72px; border-radius: 20px; margin: 0 auto 14px; display: block; }
.login h1 { text-align: center; margin: 0 0 4px; font-size: 28px; }
.login p.sub { text-align: center; color: var(--muted); margin: 0 0 26px; }


.rrow { display: grid; grid-template-columns: 1.5fr 1fr 48px; gap: 8px; margin-bottom: 8px; align-items: center; }
.rrow .in { height: 46px; font-size: 16px; padding: 0 10px; }
.rrow select.in { padding-right: 30px; }
.rrow .btn { height: 46px; padding: 0; }

.row .mid small.meta { font-size: 12px; opacity: .8; }
