/*
 * AZO Korporatsiya PWA — AZO Partners dizayn tili (iOS uslubi, monoxrom aksent).
 * Tokenlar partners-app-feel.css dan olingan qiymatlarga mos.
 */
:root {
  color-scheme: light;
  --canvas: #f2f2f7;
  --surface: #ffffff;
  --surface-muted: #f2f2f7;
  --fill: rgba(118, 118, 128, 0.12);
  --fill-strong: rgba(118, 118, 128, 0.2);
  --ink: #1c1c1e;
  --ink-2: #48484a;
  --muted: #8e8e93;
  --border: rgba(60, 60, 67, 0.12);
  --border-strong: rgba(60, 60, 67, 0.22);
  --accent: #1c1c1e;
  --on-accent: #ffffff;
  --ok: #248a3d;
  --ok-fill: #34c759;
  --ok-surface: rgba(52, 199, 89, 0.12);
  --late: #b25f00;
  --late-fill: #ff9500;
  --late-surface: rgba(255, 149, 0, 0.14);
  --absent: #c2362f;
  --absent-fill: #d03b3b;
  --absent-surface: rgba(255, 59, 48, 0.1);
  --wait: #6d6d72;
  --wait-fill: #c7c7cc;
  --danger: #d70015;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-pill: 999px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 0 0 0.5px rgba(0, 0, 0, 0.06), 0 10px 30px -10px rgba(0, 0, 0, 0.18);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: #000000;
    --surface: #1c1c1e;
    --surface-muted: #2c2c2e;
    --fill: rgba(118, 118, 128, 0.24);
    --fill-strong: rgba(118, 118, 128, 0.32);
    --ink: #f2f2f7;
    --ink-2: #c7c7cc;
    --muted: #8e8e93;
    --border: rgba(84, 84, 88, 0.5);
    --border-strong: rgba(120, 120, 124, 0.6);
    --accent: #f2f2f7;
    --on-accent: #1c1c1e;
    --ok: #34c759;
    --late: #ff9f0a;
    --absent: #ff453a;
    --surface-muted: #2c2c2e;
    --shadow: none;
    --shadow-md: 0 0 0 0.5px rgba(255, 255, 255, 0.08), 0 10px 30px -12px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
h1, h2, h3, p { margin: 0; }
a { color: inherit; }

#app { min-height: 100dvh; display: flex; flex-direction: column; }

/* ── Top bar ── */
.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0)) 16px 10px;
  background: color-mix(in srgb, var(--canvas) 82%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
}
.appbar-logo { width: 30px; height: 30px; border-radius: 8px; flex: none; }
.appbar-title { font-size: 17px; font-weight: 680; letter-spacing: -0.02em; }
.appbar-sub { font-size: 12px; color: var(--muted); margin-top: -2px; }
.appbar-spacer { flex: 1; }
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--ink);
  flex: none;
}
.icon-btn:active { transform: scale(0.94); }

.main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 16px 16px 40px; }

/* ── Cards & groups ── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title { font-size: 17px; font-weight: 680; letter-spacing: -0.01em; }
.card-note { font-size: 13px; color: var(--muted); }
.section-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 18px 4px 8px; text-transform: none; }

.group { background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 10px 14px;
  text-align: left;
  background: transparent;
  color: inherit;
  position: relative;
}
.row + .row::before {
  content: '';
  position: absolute;
  top: 0; right: 0; left: 58px;
  height: 1px;
  background: var(--border);
}
button.row:active { background: var(--fill); }
.row-ava {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 40px; height: 40px;
  border-radius: 11px;
  background: var(--accent);
  color: var(--on-accent);
}
.row-ava .ms { font-size: 22px; }
.row-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.row-name { font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { display: flex; align-items: center; gap: 8px; flex: none; color: var(--muted); }
.row-side .ms { font-size: 20px; opacity: 0.5; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  padding: 0 18px;
  border-radius: var(--radius);
  background: var(--fill);
  color: var(--ink);
  font-size: 16px;
  font-weight: 600;
  width: 100%;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:active { transform: scale(0.98); opacity: 0.85; }
.btn:disabled { opacity: 0.4; }
.btn--primary { background: var(--accent); color: var(--on-accent); }
.btn--ghost { background: transparent; }
.btn--sm { min-height: 38px; font-size: 14px; width: auto; padding: 0 14px; }
.link { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; background: none; padding: 0; }

/* ── Fields ── */
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 16px;
}
.input:focus { outline: none; border-color: var(--accent); }
textarea.input { padding: 12px 14px; min-height: 92px; resize: vertical; line-height: 1.45; }
.input-pw { position: relative; }
.input-pw .input { padding-right: 46px; }
.input-pw .reveal { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); }
.err { color: var(--danger); font-size: 13px; min-height: 1.1em; margin: 2px 2px 0; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 2px 0; }

/* ── Segmented ── */
.seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--fill); border-radius: var(--radius-sm); }
.seg button { padding: 7px 14px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

/* ── Stat tiles ── */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.kpi b { display: block; font-size: 30px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.05; }
.kpi span { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
.kpi.ok b { color: var(--ok); }
.kpi.late b { color: var(--late); }
.kpi.absent b { color: var(--absent); }

/* ── Trend chart ── */
.chart { display: block; width: 100%; }
.chart-cols { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 6px; }
.chart-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.chart-stack { width: 100%; max-width: 26px; display: flex; flex-direction: column-reverse; gap: 2px; border-radius: 5px 5px 0 0; overflow: hidden; background: var(--fill); min-height: 3px; }
.chart-seg { width: 100%; }
.chart-seg.on { background: var(--ok-fill); }
.chart-seg.late { background: var(--late-fill); }
.chart-seg.absent { background: var(--absent-fill); }
.chart-x { font-size: 10px; color: var(--muted); white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.legend i { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.legend .on { background: var(--ok-fill); }
.legend .late { background: var(--late-fill); }
.legend .absent { background: var(--absent-fill); }

/* ── Attendance people ── */
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; }
.pill .ms { font-size: 14px; }
.pill.on { background: var(--ok-surface); color: var(--ok); }
.pill.late { background: var(--late-surface); color: var(--late); }
.pill.absent { background: var(--absent-surface); color: var(--absent); }
.pill.wait { background: var(--fill); color: var(--wait); }
.kind-tag { font-size: 11px; color: var(--muted); font-weight: 600; }
.shop-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.shop-name { font-size: 16px; font-weight: 680; }
.shop-meta { font-size: 12px; color: var(--muted); }
.shop-counts { display: flex; gap: 8px; margin: 8px 0 2px; flex-wrap: wrap; }

/* ── Status tags ── */
.tag { padding: 3px 9px; border-radius: 8px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tag.warn { background: var(--late-surface); color: var(--late); }
.tag.ok { background: var(--ok-surface); color: var(--ok); }
.tag.off { background: var(--fill); color: var(--muted); }

/* ── Checklist ── */
.check {
  display: inline-grid; place-items: center; flex: none;
  width: 26px; height: 26px; border-radius: 8px;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--on-accent);
}
.check.on { background: var(--accent); border-color: var(--accent); }
.check .ms { font-size: 18px; font-weight: 700; }

/* ── Empty / loading ── */
.empty { text-align: center; padding: 12vh 20px; color: var(--muted); }
.empty .ms { font-size: 44px; opacity: 0.5; }
.empty h2 { font-size: 20px; color: var(--ink); margin: 10px 0 6px; }
.skel { height: 60px; border-radius: var(--radius); background: var(--fill); margin-bottom: 10px; animation: pulse 1.3s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.5; } }

/* ── Gate (login) ── */
.gate { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; max-width: 440px; margin: 0 auto; padding: 24px 20px calc(24px + env(safe-area-inset-bottom, 0)); }
.gate-logo { width: 56px; height: 56px; border-radius: 15px; margin-bottom: 18px; }
.gate h1 { font-size: 30px; font-weight: 720; letter-spacing: -0.03em; margin-bottom: 4px; }
.gate-lede { color: var(--muted); margin-bottom: 24px; }
.gate .btn { margin-top: 4px; }
.gate-switch { margin-top: 18px; text-align: center; }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: var(--radius-pill);
  background: var(--ink); color: var(--canvas);
  font-size: 14px; font-weight: 500; box-shadow: var(--shadow-md);
  z-index: 60; animation: toast-in 0.2s ease;
}
.toast.err { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ── Sheet ── */
.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,0.4); display: flex; align-items: flex-end; justify-content: center; animation: fade 0.2s ease; }
.sheet { width: 100%; max-width: 560px; max-height: 92dvh; background: var(--canvas); border-radius: 20px 20px 0 0; display: flex; flex-direction: column; animation: sheet-up 0.26s cubic-bezier(0.32,0.72,0,1); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 16px; border-bottom: 1px solid var(--border); }
.sheet-head h2 { font-size: 18px; font-weight: 680; }
.sheet-body { overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.sheet-foot { display: flex; gap: 10px; padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0)); border-top: 1px solid var(--border); }
.sheet-foot .btn { flex: 1; }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet-up { from { transform: translateY(100%); } }
@media (min-width: 620px) { .sheet-back { align-items: center; } .sheet { border-radius: 20px; } }

/* ── Bottom tabs ── */
.tabs {
  position: sticky; bottom: 0; z-index: 20;
  display: flex;
  background: color-mix(in srgb, var(--canvas) 86%, transparent);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px; color: var(--muted); font-size: 11px; font-weight: 600; position: relative; }
.tab .ms { font-size: 24px; }
.tab.on { color: var(--accent); }
.tab-badge { position: absolute; top: 4px; left: 54%; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--absent-fill); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }

.ms { font-family: 'Material Symbols Outlined'; font-weight: normal; font-style: normal; line-height: 1; letter-spacing: normal; text-transform: none; display: inline-block; white-space: nowrap; direction: ltr; -webkit-font-feature-settings: 'liga'; font-feature-settings: 'liga'; -webkit-font-smoothing: antialiased; }
.row-gap { height: 8px; }
.date-field { margin: 0; flex: 1; }
.card-head .btn--sm { align-self: flex-end; }
.btn--danger { color: var(--danger); }
/* Above the bottom tabs, one line on a phone where it fits. */
.toast { bottom: calc(76px + env(safe-area-inset-bottom, 0)); width: max-content; text-align: center; }
.news-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.card-note .ms { font-size: 16px; vertical-align: -3px; }
.btn .ms { font-size: 20px; }
.gate-switch { display: flex; justify-content: center; flex-wrap: wrap; gap: 6px; }
.gate .btn--ghost { margin-top: 8px; }
.empty p { max-width: 420px; margin: 0 auto; }
.chart-stack { height: 130px; justify-content: flex-start; background: transparent; }
.chart-stack .chart-seg:first-child { border-radius: 0 0 0 0; }
.chart-stack:empty { background: var(--fill); height: 3px; }

/* ── Windows install CTA ── */
a.install-win {
  display: flex; align-items: center; gap: 12px; text-decoration: none; color: inherit;
  margin-bottom: 12px; cursor: pointer;
}
a.install-win:hover { border-color: var(--accent); }
a.install-win .row-side { color: var(--accent); }
