/* ReOrdiva design system — shared by landing, auth and app screens.
   Theme: <html data-theme="light|dark"> set before paint by /js/theme-init.js */
:root {
  --brand: #0e9f7e;          /* teal green (logo "Ordiva") */
  --brand-600: #0b8a6d;
  --brand-50: #e7f7f2;
  --navy: #12407e;           /* deep blue (logo "Re") */
  --blue: #1a73d9;
  --grad: linear-gradient(135deg, #12407e 0%, #1a73d9 45%, #0e9f7e 100%);
  --grad-soft: linear-gradient(135deg, #eaf3ff 0%, #e9f8f3 100%);

  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e3e9f1;
  --text: #0f1b2d;
  --text-2: #4a5a70;
  --text-3: #7b8aa0;

  --ok: #12a150;   --ok-bg: #e5f7ec;
  --warn: #c77700; --warn-bg: #fff4e0;
  --bad: #d93a3a;  --bad-bg: #fdecec;
  --info: #1a73d9; --info-bg: #e8f1fd;
  --violet: #7c4ddb; --violet-bg: #f1ebfd;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 38, 70, .05), 0 6px 20px rgba(16, 38, 70, .06);
  --shadow-lg: 0 10px 40px rgba(16, 38, 70, .14);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --head: "Poppins", "Inter", system-ui, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --brand: #22c39c;
  --brand-600: #1aa684;
  --brand-50: #0f2e29;
  --navy: #8db8ff;
  --blue: #5aa2ff;
  --grad: linear-gradient(135deg, #1b4f9c 0%, #1a73d9 45%, #13a585 100%);
  --grad-soft: linear-gradient(135deg, #0f1d33 0%, #0e2526 100%);

  --bg: #0b1220;
  --surface: #121b2d;
  --surface-2: #17223a;
  --border: #233149;
  --text: #e8eef8;
  --text-2: #a9b7cc;
  --text-3: #7385a0;

  --ok: #3fd07f;   --ok-bg: #11301f;
  --warn: #ffb44a; --warn-bg: #33270f;
  --bad: #ff6b6b;  --bad-bg: #3a1717;
  --info: #6aaeff; --info-bg: #13263f;
  --violet: #b69bff; --violet-bg: #251b3d;

  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 44px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s, color .25s;
}
h1, h2, h3, h4 { font-family: var(--head); line-height: 1.2; margin: 0 0 .5rem; color: var(--text); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; display: block; }
p { margin: 0 0 1rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }
.muted { color: var(--text-2); }
.small { font-size: .875rem; }
.xs { font-size: .78rem; }
.bold { font-weight: 600; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: .75rem; }
.row-wrap { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.between { justify-content: space-between; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: .5rem } .mt-2 { margin-top: 1rem } .mt-3 { margin-top: 1.5rem }
.mb-0 { margin-bottom: 0 } .mb-1 { margin-bottom: .5rem } .mb-2 { margin-bottom: 1rem } .mb-3 { margin-bottom: 1.5rem }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.logo-light { display: block; }
.logo-dark { display: none; }
:root[data-theme="dark"] .logo-light { display: none; }
:root[data-theme="dark"] .logo-dark { display: block; }

/* ───────── Buttons ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 46px; padding: .6rem 1.15rem; border-radius: 12px;
  border: 1px solid transparent; font: 600 .95rem/1.2 var(--font); cursor: pointer;
  background: var(--surface-2); color: var(--text); text-decoration: none !important;
  transition: transform .12s, box-shadow .2s, background-color .2s, opacity .2s;
  -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn:active { transform: scale(.97); }
.btn:disabled, .btn.disabled { opacity: .55; pointer-events: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -6px var(--brand); }
.btn-primary:hover { background: var(--brand-600); }
.btn-grad { background: var(--grad); color: #fff; box-shadow: 0 8px 22px -8px rgba(26, 115, 217, .7); }
.btn-grad:hover { filter: brightness(1.06); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--bad-bg); color: var(--bad); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-wa { background: #25d366; color: #fff; }
.btn-sm { min-height: 36px; padding: .35rem .8rem; font-size: .85rem; border-radius: 10px; }
.btn-lg { min-height: 56px; padding: .8rem 1.6rem; font-size: 1.05rem; border-radius: 14px; }
.btn-block { width: 100%; }
.btn-icon { min-width: 44px; min-height: 44px; padding: 0; border-radius: 12px; }
.btn i { font-size: 1.1em; }

/* ───────── Forms ───────── */
.field { display: flex; flex-direction: column; gap: .35rem; margin-bottom: 1rem; }
.field label, .label { font-weight: 600; font-size: .875rem; color: var(--text-2); }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: .7rem .9rem; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text);
  font: 500 1rem var(--font); outline: none; transition: border-color .2s, box-shadow .2s;
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
.input-group { position: relative; }
.input-group > i { position: absolute; left: .9rem; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-group > .input { padding-left: 2.6rem; }
.input-group > .addon { position: absolute; right: .35rem; top: 50%; transform: translateY(-50%); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.check { display: flex; align-items: center; gap: .55rem; cursor: pointer; font-weight: 500; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.err { color: var(--bad); font-size: .85rem; }
.alert { padding: .85rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 500; display: flex; gap: .6rem; align-items: flex-start; }
.alert-bad { background: var(--bad-bg); color: var(--bad); }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-info { background: var(--info-bg); color: var(--info); }

/* ───────── Cards ───────── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.15rem;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .9rem; }
.card-head h3 { font-size: 1.05rem; margin: 0; }
.card-flat { box-shadow: none; }
.card-hover { transition: transform .18s, box-shadow .18s; }
@media (hover: hover) { .card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); } }

/* ───────── Badges & chips ───────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .22rem .6rem; border-radius: 999px;
  font-size: .75rem; font-weight: 700; letter-spacing: .01em; white-space: nowrap;
  background: var(--surface-2); color: var(--text-2);
}
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-warn { background: var(--warn-bg); color: var(--warn); }
.b-bad { background: var(--bad-bg); color: var(--bad); }
.b-info { background: var(--info-bg); color: var(--info); }
.b-violet { background: var(--violet-bg); color: var(--violet); }
.b-brand { background: var(--brand-50); color: var(--brand); }
.chips { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .25rem; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: .35rem; min-height: 38px;
  padding: .35rem .85rem; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text-2); font-weight: 600; font-size: .85rem; cursor: pointer;
  text-decoration: none !important; transition: all .15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .count { background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 .45rem; font-size: .75rem; }
.chip.active .count { background: rgba(255,255,255,.25); }

/* Supplier pill under a medicine (inline change) */
.sup-pill {
  display: inline-flex; align-items: center; gap: .4rem; padding: .25rem .35rem .25rem .65rem; border-radius: 16px;
  background: var(--brand-50); color: var(--brand); font-weight: 700; font-size: .8rem; max-width: 100%; flex-wrap: wrap;
}
.sup-pill > span { min-width: 0; overflow-wrap: break-word; }
.sup-pill.none { background: var(--warn-bg); color: var(--warn); }
.sup-pill button {
  border: 0; background: var(--surface); color: var(--blue); font: 700 .75rem var(--font); border-radius: 999px;
  padding: .2rem .6rem; cursor: pointer; min-height: 26px;
}

/* ───────── Lists ───────── */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: .85rem; align-items: center; padding: .9rem .25rem; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.med-ico {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center;
  background: var(--grad-soft); color: var(--brand); font-size: 1.3rem;
}
.med-name { font-weight: 700; color: var(--text); }
.med-meta { font-size: .8rem; color: var(--text-3); }
.qty-big { font: 700 1.15rem var(--head); color: var(--text); text-align: right; white-space: nowrap; }
.qty-big small { font: 600 .75rem var(--font); color: var(--text-3); display: block; }

table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); padding: .6rem .7rem; border-bottom: 1px solid var(--border); }
.tbl td { padding: .75rem .7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl-wrap { overflow-x: auto; }

/* ───────── Qty stepper ───────── */
.stepper { display: inline-flex; align-items: stretch; border: 1.5px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--surface); }
.stepper button { width: 52px; border: 0; background: var(--surface-2); color: var(--text); font-size: 1.5rem; font-weight: 700; cursor: pointer; }
.stepper button:active { background: var(--brand-50); color: var(--brand); }
.stepper input { width: 72px; border: 0; text-align: center; font: 700 1.35rem var(--head); color: var(--text); background: transparent; outline: none; min-height: 52px; }
.unit-chips .chip { min-height: 34px; }

/* ───────── KPI ───────── */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .9rem; }
.kpi {
  position: relative; overflow: hidden; padding: 1rem; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); text-decoration: none !important; color: var(--text);
  display: flex; flex-direction: column; gap: .4rem; transition: transform .18s, box-shadow .18s;
  animation: rise .5s both;
}
@media (hover: hover) { .kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); } }
.kpi .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; font-size: 1.25rem; }
.kpi .val { font: 800 1.9rem/1 var(--head); }
.kpi .lbl { font-size: .82rem; color: var(--text-2); font-weight: 600; }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 100px; height: 100px; border-radius: 50%; background: currentColor; opacity: .04; }
.k-teal .ico { background: var(--brand-50); color: var(--brand); }
.k-blue .ico { background: var(--info-bg); color: var(--info); }
.k-amber .ico { background: var(--warn-bg); color: var(--warn); }
.k-red .ico { background: var(--bad-bg); color: var(--bad); }
.k-violet .ico { background: var(--violet-bg); color: var(--violet); }
.k-green .ico { background: var(--ok-bg); color: var(--ok); }

@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes shimmer { 0% { background-position: -400px 0; } 100% { background-position: 400px 0; } }
.skel { border-radius: 10px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 800px 100%; animation: shimmer 1.2s infinite linear; min-height: 18px; }
.anim-rise { animation: rise .45s both; }

/* ───────── Empty state ───────── */
.empty { text-align: center; padding: 2.2rem 1rem; color: var(--text-2); }
.empty .ill { width: 76px; height: 76px; margin: 0 auto .8rem; border-radius: 50%; display: grid; place-items: center; background: var(--grad-soft); color: var(--brand); font-size: 2rem; }
.empty h4 { margin-bottom: .25rem; }

/* ───────── Toast ───────── */
#toasts { position: fixed; z-index: 1000; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: .5rem; align-items: center; pointer-events: none; width: min(92vw, 420px); }
.toast { pointer-events: auto; display: flex; gap: .6rem; align-items: center; padding: .8rem 1rem; border-radius: 14px; background: #10203a; color: #fff; box-shadow: var(--shadow-lg); font-weight: 600; animation: rise .3s both; width: 100%; }
.toast.ok i { color: #4ee28e; } .toast.bad i { color: #ff8a8a; } .toast.info i { color: #8fc2ff; }
@media (min-width: 992px) { #toasts { bottom: 24px; left: auto; right: 24px; transform: none; align-items: flex-end; } }

/* ───────── Modal / bottom sheet ───────── */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(8, 15, 30, .5); z-index: 900; display: flex; align-items: flex-end; justify-content: center; animation: fade .2s both; backdrop-filter: blur(2px); }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; background: var(--surface); color: var(--text);
  border-radius: 22px 22px 0 0; padding: 1.25rem 1.25rem calc(1.25rem + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg); animation: sheetUp .28s cubic-bezier(.2, .9, .3, 1.1) both;
}
.sheet::before { content: ""; display: block; width: 44px; height: 5px; border-radius: 3px; background: var(--border); margin: -0.4rem auto .9rem; }
.sheet-head { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.sheet-head h3 { margin: 0; font-size: 1.15rem; }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 22px; animation: rise .25s both; }
  .sheet::before { display: none; }
}

/* ───────── Search dropdown ───────── */
.search-box { position: relative; }
.search-box .input { min-height: 56px; font-size: 1.05rem; padding-left: 3rem; border-radius: 16px; box-shadow: var(--shadow); }
.search-box > i { position: absolute; left: 1.05rem; top: 50%; transform: translateY(-50%); font-size: 1.2rem; color: var(--text-3); }
.search-box .scan-btn { position: absolute; right: .4rem; top: 50%; transform: translateY(-50%); }
.results { position: absolute; z-index: 50; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); max-height: min(62vh, 520px); overflow-y: auto; animation: fade .15s both; }
.results .r { display: flex; gap: .75rem; align-items: center; padding: .75rem .9rem; cursor: pointer; border-bottom: 1px solid var(--border); }
.results .r:last-child { border-bottom: 0; }
.results .r:hover, .results .r.on { background: var(--surface-2); }
.results mark { background: color-mix(in srgb, var(--brand) 22%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.results .r .tag { margin-left: auto; }
.results .foot { padding: .7rem .9rem; font-size: .85rem; color: var(--text-2); background: var(--surface-2); }

/* ───────── App shell ───────── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 252px; z-index: 40; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 1rem .8rem;
}
.sidebar .brand { padding: .3rem .6rem 1rem; }
.sidebar .brand img { height: 38px; width: auto; }
.nav { display: flex; flex-direction: column; gap: .2rem; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: .75rem; padding: .7rem .8rem; border-radius: 12px; color: var(--text-2);
  font-weight: 600; text-decoration: none !important; transition: background-color .15s, color .15s;
}
.nav a i { font-size: 1.2rem; width: 22px; text-align: center; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--brand-50); color: var(--brand); }
.nav .sep { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); padding: .9rem .8rem .3rem; font-weight: 700; }
.nav .cnt { margin-left: auto; background: var(--bad); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .45rem; min-width: 20px; text-align: center; }
.side-foot { border-top: 1px solid var(--border); padding-top: .8rem; font-size: .75rem; color: var(--text-3); text-align: center; }

.main { flex: 1; min-width: 0; margin-left: 252px; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: .6rem;
  padding: .7rem 1.25rem; padding-top: calc(.7rem + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 1.2rem; margin: 0; }
.topbar .sub { font-size: .78rem; color: var(--text-3); }
.topbar .m-logo { display: none; height: 30px; width: auto; }
.icon-btn {
  position: relative; width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-2); display: grid; place-items: center; cursor: pointer; font-size: 1.15rem; text-decoration: none !important;
}
.icon-btn:hover { color: var(--text); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--bad); color: #fff; font-size: .65rem; font-weight: 800; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--surface); }
.avatar { width: 42px; height: 42px; border-radius: 12px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; cursor: pointer; border: 0; }
.content { padding: 1.25rem; width: 100%; max-width: 1280px; margin: 0 auto; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.1rem; }
.page-title h2 { font-size: 1.45rem; margin: 0; }

.bottom-nav {
  display: none; position: fixed; z-index: 60; left: 0; right: 0; bottom: 0; background: var(--surface); border-top: 1px solid var(--border);
  padding: .35rem .4rem calc(.35rem + env(safe-area-inset-bottom)); justify-content: space-around; align-items: flex-end;
  box-shadow: 0 -6px 20px rgba(16, 38, 70, .06);
}
.bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .3rem 0; color: var(--text-3); font-size: .68rem; font-weight: 700; text-decoration: none !important; }
.bottom-nav a i { font-size: 1.35rem; }
.bottom-nav a.active { color: var(--brand); }
.bottom-nav .fab {
  flex: 0 0 auto; width: 62px; height: 62px; border-radius: 20px; margin-top: -26px; background: var(--grad); color: #fff;
  display: grid; place-items: center; font-size: 1.9rem; box-shadow: 0 10px 24px -6px rgba(14, 159, 126, .65);
}
.bottom-nav .fab i { font-size: 1.9rem; }

.dropdown { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 230px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); padding: .4rem; z-index: 80; animation: fade .15s both; }
.menu a, .menu button { display: flex; width: 100%; align-items: center; gap: .65rem; padding: .65rem .75rem; border-radius: 10px; color: var(--text); font: 600 .9rem var(--font); background: none; border: 0; cursor: pointer; text-decoration: none !important; }
.menu a:hover, .menu button:hover { background: var(--surface-2); }
.menu .who { padding: .6rem .75rem .7rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }

.trial-bar { display: flex; align-items: center; gap: .6rem; justify-content: center; flex-wrap: wrap; padding: .55rem 1rem; font-size: .88rem; font-weight: 600; background: var(--warn-bg); color: var(--warn); text-align: center; }
.trial-bar a { font-weight: 800; }
.offline-bar { display: none; padding: .45rem 1rem; text-align: center; font-size: .85rem; font-weight: 700; background: var(--bad); color: #fff; }
body.is-offline .offline-bar { display: block; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 1100px) { .grid-3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

@media (max-width: 991px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .bottom-nav { display: flex; }
  .topbar { padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top)); }
  .topbar .m-logo.logo-light { display: block; }
  :root[data-theme="dark"] .topbar .m-logo.logo-light { display: none; }
  :root[data-theme="dark"] .topbar .m-logo.logo-dark { display: block; }
  .topbar .t-title { display: none; }
  .content { padding: 1rem; padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
  .hide-m { display: none !important; }
}
@media (min-width: 992px) { .hide-d { display: none !important; } }

/* Theme toggle */
.theme-toggle { position: relative; }
.theme-toggle .bi-sun-fill { display: none; }
:root[data-theme="dark"] .theme-toggle .bi-sun-fill { display: inline; }
:root[data-theme="dark"] .theme-toggle .bi-moon-stars-fill { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
}
@media print {
  .no-print, .sidebar, .topbar, .bottom-nav, #toasts, .trial-bar { display: none !important; }
  .main { margin: 0 !important; }
  body { background: #fff; }
}

/* ───────── Install guide (illustrated phones) ───────── */
.guide-tabs { display: flex; gap: .4rem; background: var(--surface-2); padding: .3rem; border-radius: 14px; margin-bottom: 1rem; }
.guide-tab { flex: 1; min-height: 42px; border: 0; border-radius: 11px; background: transparent; color: var(--text-2); font: 700 .9rem var(--font); cursor: pointer; display: inline-flex; gap: .4rem; align-items: center; justify-content: center; }
.guide-tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.guide-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
@media (min-width: 900px) { .install-page .guide-steps { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.gstep { display: flex; flex-direction: column; gap: .6rem; }
.gtxt { font-size: .85rem; color: var(--text-2); line-height: 1.4; }
.gtxt svg { display: inline; vertical-align: -3px; color: var(--blue); }
.gnum { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--grad); color: #fff; font-size: .75rem; font-weight: 800; margin-right: .35rem; }
.phone {
  position: relative; aspect-ratio: 9 / 15; border-radius: 22px; border: 6px solid #1c2638; background: #f6f8fb; overflow: hidden;
  box-shadow: var(--shadow); display: flex; flex-direction: column; color: #0f1b2d; font-size: .7rem;
}
:root[data-theme="dark"] .phone { border-color: #3a4a66; }
.phone .hl { outline: 2.5px solid #ff7a00; outline-offset: 1px; border-radius: 8px; animation: pulse 1.6s infinite; }
.phone .ring { display: inline-grid; place-items: center; padding: 2px 4px; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 122, 0, .45); } 50% { box-shadow: 0 0 0 6px rgba(255, 122, 0, 0); } }
.ph-bar { display: flex; align-items: center; gap: .3rem; padding: .45rem .5rem; background: #fff; border-bottom: 1px solid #e6ebf2; }
.ph-bar.ios { border: 0; border-top: 1px solid #e6ebf2; justify-content: center; }
.ph-url { flex: 1; background: #eef2f7; border-radius: 8px; padding: .2rem .45rem; font-size: .62rem; color: #4a5a70; white-space: nowrap; overflow: hidden; text-align: center; }
.ph-dots { font-size: 1rem; font-weight: 900; padding: 0 .35rem; color: #333; }
.ph-body { flex: 1; padding: .7rem; display: flex; flex-direction: column; gap: .4rem; }
.ph-body.dim { opacity: .35; }
.ph-logo { height: 18px; width: 70%; background: url(/img/logo.png) left center / contain no-repeat; }
.ph-line { height: 7px; border-radius: 4px; background: #dfe6ef; }
.ph-line.w70 { width: 70%; } .ph-line.w50 { width: 50%; }
.ph-cta { margin-top: auto; background: linear-gradient(135deg, #12407e, #0e9f7e); color: #fff; border-radius: 8px; padding: .35rem; text-align: center; font-weight: 700; }
.ph-menu { position: absolute; top: 34px; right: 6px; width: 74%; background: #fff; border-radius: 10px; box-shadow: 0 8px 22px rgba(0, 0, 0, .18); padding: .25rem; }
.ph-menu .mi, .ph-share .mi { display: flex; align-items: center; gap: .4rem; padding: .38rem .45rem; border-radius: 7px; font-weight: 600; }
.ph-share .mi { justify-content: space-between; background: #fff; margin-bottom: .25rem; }
.ph-share { flex: 1; background: #eef1f6; padding: .55rem; display: flex; flex-direction: column; justify-content: flex-end; }
.ph-tool { display: flex; justify-content: space-around; align-items: center; padding: .35rem .2rem .5rem; background: #fff; color: #1a73d9; font-size: .9rem; }
.ph-dialog { position: absolute; left: 8%; right: 8%; bottom: 14%; background: #fff; border-radius: 12px; padding: .55rem; box-shadow: 0 10px 26px rgba(0, 0, 0, .22); }
.ph-btn { background: #1a73d9; color: #fff; border-radius: 7px; padding: .18rem .55rem; font-weight: 800; }
.ph-appicon { width: 26px; height: 26px; border-radius: 7px; }
.ph-appicon.lg { width: 40px; height: 40px; border-radius: 10px; }
.ph-nav { display: flex; justify-content: space-between; align-items: center; gap: .3rem; white-space: nowrap; font-size: .58rem; padding: .55rem .4rem; background: #fff; border-bottom: 1px solid #e6ebf2; }
.ph-addcard { min-width: 0; overflow: hidden; display: flex; gap: .5rem; align-items: center; margin: .6rem; padding: .5rem; background: #fff; border-radius: 10px; }
.ph-input { border-bottom: 1px solid #dfe6ef; padding-bottom: .15rem; margin-bottom: .2rem; font-weight: 700; }
.phone.home { background: linear-gradient(160deg, #12407e, #0e9f7e); justify-content: center; }
.phone.home.ios { background: linear-gradient(160deg, #4b2c83, #1a73d9); }
.ph-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; padding: 14px; }
.ph-grid span { min-width: 0; min-height: 0; aspect-ratio: 1; border-radius: 9px; background: rgba(255, 255, 255, .22); }
.ph-grid .app { background: #fff; display: grid; place-items: center; overflow: hidden; }
.ph-grid .app img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-caption { color: #fff; text-align: center; font-weight: 700; font-size: .7rem; margin-top: -4px; }
