/* Polyflex. Rəng yalnız dəyişənlərlə; açıq tema [data-theme="light"].
   Telefon birinci: alt menyu (.tabbar); 900px-dən geniş ekranda yan menyu (.side). */
:root {
  --bg: #111418;
  --panel: #191d23;
  --panel-2: #20262d;
  --line: #2c333c;
  --text: #e9edf1;
  --muted: #95a0ab;
  --accent: #c9a24a;
  --accent-ink: #1a1408;
  --ok: #4fb57a;
  --ok-bg: rgba(79, 181, 122, .14);
  --warn: #e0a33a;
  --warn-bg: rgba(224, 163, 58, .14);
  --bad: #e5675d;
  --bad-bg: rgba(229, 103, 93, .14);
  --info: #5aa2e0;
  --info-bg: rgba(90, 162, 224, .14);
  --radius: 12px;
  --tabbar-h: 62px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f1ec;
  --panel: #ffffff;
  --panel-2: #f7f5f0;
  --line: #e2ddd2;
  --text: #1d2126;
  --muted: #687380;
  --accent: #9a7420;
  --accent-ink: #ffffff;
  --ok: #24804c;
  --ok-bg: rgba(36, 128, 76, .1);
  --warn: #a8690a;
  --warn-bg: rgba(168, 105, 10, .1);
  --bad: #bf3b30;
  --bad-bg: rgba(191, 59, 48, .09);
  --info: #2867a8;
  --info-bg: rgba(40, 103, 168, .09);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h2 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Karkas ---------- */
.main {
  padding: 0 16px calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom));
  min-width: 0;
}
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 14px 0 12px;
}
.page-title { font-size: 20px; margin: 0; flex: 1 1 auto; min-width: 0; }
.topbar-tools { display: flex; align-items: center; gap: 4px; margin-left: auto; min-width: 0; }
.topbar-tools form { margin: 0; }
.who { color: var(--muted); font-size: 13px; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.btn-icon {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 10px;
  background: transparent; color: var(--muted); border: 1px solid var(--line); cursor: pointer;
}
.btn-icon:hover { color: var(--text); }

.side { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--panel); border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 11px; min-width: 0; text-decoration: none;
}
.tabbar a span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 2px; }
.tabbar a.on { color: var(--accent); }

/* Telefonda /menu: yan menyu tam siyahı kimi açılır */
.menu-open .side {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px 16px 0;
}
.menu-open .side a { font-size: 16px; padding: 14px 12px; background: var(--panel); border: 1px solid var(--line); }
.menu-open .side .brand { display: none; }

@media (min-width: 900px) {
  .side, .menu-open .side {
    display: flex; flex-direction: column; gap: 2px;
    position: fixed; top: 0; bottom: 0; left: 0; width: 220px;
    padding: 16px 12px; background: var(--panel); border-right: 1px solid var(--line);
    overflow-y: auto;
  }
  .menu-open .side a { font-size: 15px; padding: 10px 12px; background: none; border: 0; }
  .menu-open .side .brand { display: flex; }
  .tabbar { display: none; }
  .main { margin-left: 220px; padding: 0 28px 40px; }
}
.side a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px; color: var(--muted); text-decoration: none; min-width: 0;
}
.side a span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side a:hover { background: var(--panel-2); color: var(--text); }
.side a.on { background: var(--panel-2); color: var(--accent); }
.side .brand { color: var(--text); font-weight: 700; font-size: 17px; margin-bottom: 14px; }

/* ---------- Kartlar, torlar ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px; min-width: 0;
}
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 10px; }
.card-head h2 { margin: 0; flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1200px) { .grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.kpis { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 14px; }
@media (min-width: 600px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .kpis { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
/* Kart içində kiçik 3-lük blok: geniş ekranın 6 sütunlu qaydası ona düşməsin (1280px-də mətn çıxırdı) */
.kpis.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.kpi {
  display: block; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; color: var(--text); text-decoration: none; min-width: 0;
}
.kpi:hover { border-color: var(--accent); text-decoration: none; }
.kpi .v { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
/* Mebleg kartlari: "-2.423,87 ₼" 26px-de 160px-lik karta sigmirdi (ay hesabati). Kicik srift +
   genis ekranda 6 yox 3 sutun; cox boyuk reqem setre bolunur, kenara cixmir. */
.kpis.money .v { font-size: clamp(16px, 4.6vw, 22px); white-space: normal; overflow-wrap: anywhere; } /* .num nowrap-ini acir */
@media (min-width: 1100px) { .kpis.money { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.kpi .l { font-size: 12.5px; color: var(--muted); line-height: 1.3; }
.kpi.hot { border-color: var(--warn); }
.kpi.hot .v { color: var(--warn); }

/* ---------- Siyahılar (telefonda cədvəl əvəzinə sətir-kart) ---------- */
.rows { display: flex; flex-direction: column; }
.row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px;
  padding: 11px 2px; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; min-width: 0;
}
.rows > .row:first-child { border-top: 0; }
a.row:hover { background: var(--panel-2); text-decoration: none; }
.row .main-col { flex: 1 1 200px; min-width: 0; }
.row .title { font-weight: 600; overflow-wrap: anywhere; }
.row .sub { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.row .end { margin-left: auto; text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap;
}
.st-new { background: var(--info-bg); color: var(--info); border-color: transparent; }
.st-approved, .st-in_work { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.st-ready, .st-notified, .st-loading { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.st-shipped { background: var(--panel-2); color: var(--muted); }
.st-cancelled { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.b-low { background: var(--bad-bg); color: var(--bad); border-color: transparent; }

table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { padding: 8px 6px; border-top: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 12.5px; border-top: 0; }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl-wrap { overflow-x: auto; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }

/* ---------- Formalar ---------- */
form { margin: 0; }
.fields { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 160px; min-width: 0; }
.field.wide { flex-basis: 100%; }
.field.narrow { flex: 0 1 120px; }
.field > label { font-size: 12.5px; color: var(--muted); }
input, select, textarea {
  width: 100%; min-width: 0; font: inherit; color: var(--text);
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px;
  min-height: 44px;
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.check { display: flex; align-items: center; gap: 8px; min-height: 44px; }
.check input { width: 20px; min-height: 20px; height: 20px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
  text-decoration: none; text-align: center; max-width: 100%;
}
.btn:hover { text-decoration: none; border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.flash { border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.flash-error { background: var(--bad-bg); color: var(--bad); }
.short-list { margin: 8px 0 0; padding-left: 18px; color: var(--text); }
.short-list li { overflow-wrap: anywhere; }

details.card > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; align-items: center; gap: 8px; min-height: 28px; }
details.card > summary::before { content: "+"; color: var(--accent); font-weight: 700; width: 14px; }
details.card[open] > summary::before { content: "−"; }
details.card[open] > summary { margin-bottom: 12px; }

/* Sifariş mərhələ zolağı */
.steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 14px; padding: 0; list-style: none; }
.steps li { font-size: 12px; padding: 4px 9px; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.steps li.done { color: var(--ok); border-color: transparent; background: var(--ok-bg); }
.steps li.cur { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 700; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 14px; border-left: 2px solid var(--line); position: relative; min-width: 0; overflow-wrap: anywhere; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }

.line-row { display: grid; gap: 8px; grid-template-columns: minmax(0, 1fr); padding: 10px; border: 1px dashed var(--line); border-radius: 10px; margin-bottom: 8px; }
@media (min-width: 700px) { .line-row { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 2fr) minmax(0, 1fr) auto; align-items: end; } }

/* Giriş */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 380px; margin-inline: auto; }
.login .brand-big { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 700; margin-bottom: 18px; justify-content: center; }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot.in { background: var(--ok); }
.dot.away { background: var(--warn); }
.dot.left { background: var(--muted); }
.dot.absent { background: var(--bad); }
.empty { color: var(--muted); padding: 10px 2px; }

/* ---------- Giriş-çıxış: QR skaner pəncərəsi ----------
   Üst zolaq / video / alt zolaq — «Bağla» düyməsi HƏMİŞƏ ekranda qalsın (AlphaTime).
   [hidden] açıq yazılır: display qaydası hidden atributunu ləğv edirdi. */
.scan-wrap { position: fixed; inset: 0; z-index: 50; background: #000; display: flex; flex-direction: column; }
.scan-wrap[hidden] { display: none; }
.scan-top, .scan-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; background: var(--panel); color: var(--text); flex: none; }
.scan-top { padding-top: calc(12px + env(safe-area-inset-top)); }
.scan-bottom { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.scan-wrap video { flex: 1 1 auto; min-height: 0; width: 100%; object-fit: cover; }
/* Tabel */
.tabel { border-collapse: collapse; font-size: 12px; }
.tabel th, .tabel td { border: 1px solid var(--line); padding: 3px 4px; text-align: center; min-width: 26px; white-space: nowrap; }
.tabel th.n, .tabel td.n { text-align: left; position: sticky; left: 0; background: var(--panel); z-index: 1; min-width: 120px; }
.c-geldi { background: var(--ok-bg); color: var(--ok); }
.c-gecikdi { background: var(--warn-bg); color: var(--warn); }
.c-gelmedi { background: var(--bad-bg); color: var(--bad); }
.c-mezuniyyet, .c-icazeli { background: var(--info-bg); color: var(--info); }
.c-istirahet, .c-iscideyil, .c-gelecek { color: var(--muted); }
/* Söndürülmüş düymə AKTİV kimi görünməsin (giriş-çıxış: QR skan edilməyib) */
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; border-color: var(--line); }
