:root {
  --navy: #0B1A33;
  --navy2: #16305C;
  --panel: #12264A;
  --panel-2: #183463;
  --line: rgba(255, 255, 255, 0.14);
  --text: #FFFFFF;
  --soft: #CBD5E1;
  --muted: #94A3B8;
  --accent: #3B82F6;
  --accent-soft: #93C5FD;
  --link: #60A5FA;
  --danger: #EF4444;
  --danger-soft: #FCA5A5;
  --ok: #34D399;
  --orange: #F97316;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: linear-gradient(180deg, var(--navy2), var(--navy)) fixed;
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--link); }
button, input, select, textarea { font: inherit; color: inherit; }
img { display: block; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; font-weight: 800; }
h2 { font-size: 19px; font-weight: 700; }
.muted { color: var(--muted); }
.soft { color: var(--soft); }
.small { font-size: 13px; }
.center { text-align: center; }
.hidden { display: none !important; }

/* ---------- Boot / spinner ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.2); border-top-color: #fff;
  animation: spin .8s linear infinite;
}
.spinner.sm { width: 20px; height: 20px; border-width: 2.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border: 0; border-radius: 12px; cursor: pointer;
  font-weight: 700; font-size: 16px; color: #fff; text-decoration: none; white-space: nowrap;
  background: linear-gradient(180deg, #60A5FA, var(--accent) 45%, #1D4ED8);
  box-shadow: 0 6px 14px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.35);
  transition: transform .08s ease, filter .15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; filter: none; transform: none; }
.btn.block { width: 100%; }
.btn.danger { background: linear-gradient(180deg, #F87171, var(--danger) 45%, #B91C1C); }
.btn.ghost {
  background: rgba(255,255,255,.08); box-shadow: none; border: 1px solid var(--line); font-weight: 600;
}
.btn.sm { min-height: 38px; padding: 0 14px; font-size: 14px; border-radius: 10px; }
.btn .spinner { width: 20px; height: 20px; border-width: 2.5px; }
.linkbtn {
  background: none; border: 0; padding: 6px 2px; cursor: pointer; color: var(--link);
  text-decoration: underline; text-underline-offset: 3px; font-size: 15px;
}
.linkbtn.danger { color: var(--danger-soft); }
.iconbtn {
  width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255,255,255,.06); display: grid; place-items: center; cursor: pointer;
}

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label, .label { font-size: 13px; font-weight: 700; color: var(--soft); letter-spacing: .02em; text-transform: uppercase; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 12px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(3, 10, 24, .45); outline: none;
}
textarea.input { min-height: 96px; resize: vertical; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(59,130,246,.3); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--soft); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex: none; }
.error { color: var(--danger-soft); font-size: 14px; margin: 8px 0 0; }
.search { margin-bottom: 14px; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-card {
  width: 100%; max-width: 420px; background: rgba(18, 38, 74, .75); border: 1px solid var(--line);
  border-radius: 20px; padding: 32px 26px; box-shadow: 0 24px 60px rgba(0,0,0,.4);
}
.brand { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 24px; text-align: center; }
.logo { width: 64px; height: 64px; border-radius: 16px; }
.logo.sm { width: 36px; height: 36px; border-radius: 10px; }
.auth-links { display: flex; flex-direction: column; align-items: center; gap: 2px; margin-top: 16px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 20px 14px; background: rgba(5, 13, 29, .55); border-right: 1px solid var(--line);
}
.sidebar .brandrow { display: flex; align-items: center; gap: 10px; padding: 0 8px 18px; font-weight: 800; font-size: 17px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  color: var(--soft); text-decoration: none; font-weight: 600;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: rgba(59,130,246,.22); color: #fff; }
.nav svg { width: 20px; height: 20px; flex: none; }
.sidebar .me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid var(--line); text-decoration: none; color: #fff; }
.sidebar .me .who { min-width: 0; }
.sidebar .me .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar { display: flex; justify-content: flex-end; padding: 18px 32px 0; max-width: 1100px; }
.topbar .mob { display: none; }
.sitebtn {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: rgba(255,255,255,.07); color: #fff;
  text-decoration: none; font-weight: 700; font-size: 14px; white-space: nowrap;
}
.sitebtn:hover { background: rgba(255,255,255,.15); }
#sitefloat { position: fixed; top: max(14px, env(safe-area-inset-top)); right: 16px; z-index: 50; }
body.in-shell #sitefloat { display: none; }
.topacts { display: inline-flex; align-items: center; gap: 8px; }
.langbtn { cursor: pointer; font-family: inherit; }
.main { padding-top: 12px !important; }
.main { min-width: 0; padding: 28px 32px 60px; max-width: 1100px; width: 100%; }
.scrim { display: none; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 40; left: 0; top: 0; bottom: 0; width: 270px; height: auto;
    transform: translateX(-100%); transition: transform .2s ease; background: #0A1730;
  }
  .shell.menu-open .sidebar { transform: none; }
  .shell.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(0,0,0,.5); }
  .topbar .mob { display: inline-flex; }
  .topbar span.mob { display: inline; }
  .topbar .topacts { margin-left: auto; }
  .topbar {
    display: flex; justify-content: flex-start; max-width: none; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20;
    padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
    background: rgba(11, 26, 51, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
    font-weight: 800;
  }
  .main { padding: 20px 16px 60px; padding-top: 20px !important; }
  .auth, .gate { padding-top: 72px; }
  .row2 { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .topbar .sitelabel { display: none; }
  .topbar .sitebtn { padding: 8px 10px; }
}

/* ---------- Page header ---------- */
.pagehead { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.pagehead h1 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--soft); text-decoration: none; font-weight: 600; margin-bottom: 10px; }
.back:hover { color: #fff; }

/* ---------- Cards and lists ---------- */
.card { background: rgba(18, 38, 74, .72); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.form-card { max-width: 620px; }
.list { background: rgba(18, 38, 74, .72); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.rowi {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 64px;
  border-top: 1px solid rgba(255,255,255,.55); color: inherit; text-decoration: none;
}
.list .rowi:first-child { border-top: 0; }
a.rowi:hover, button.rowi:hover { background: rgba(255,255,255,.05); }
button.rowi { width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; cursor: pointer; }
.rowi .grow { flex: 1; min-width: 0; }
.rowi .title { font-weight: 700; overflow-wrap: anywhere; }
.rowi .sub { color: var(--muted); font-size: 14px; overflow-wrap: anywhere; }
.chev { color: var(--muted); flex: none; }
.thumb { width: 52px; height: 52px; border-radius: 10px; object-fit: cover; flex: none; background: rgba(255,255,255,.08); }
.thumb.ph { display: grid; place-items: center; color: var(--muted); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; background: rgba(255,255,255,.1); color: var(--soft); white-space: nowrap; }
.pill.blue { background: rgba(59,130,246,.25); color: #BFDBFE; }
.pill.orange { background: rgba(249,115,22,.22); color: #FED7AA; }
.pill.green { background: rgba(52,211,153,.2); color: #A7F3D0; }
.pill.red { background: rgba(239,68,68,.2); color: var(--danger-soft); }
.qty { text-align: right; flex: none; }
.qty b { font-size: 18px; }
.empty { padding: 36px 20px; text-align: center; color: var(--muted); }
.section-title { margin: 26px 0 10px; font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .input { flex: 1; min-width: 180px; }
.toolbar select.input { flex: 0 1 220px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- Home ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; margin: 20px 0 26px; }
.tile {
  display: flex; flex-direction: column; gap: 10px; padding: 20px; border-radius: 16px; min-height: 124px;
  color: #fff; text-decoration: none; font-weight: 800; font-size: 19px;
  background: linear-gradient(180deg, #60A5FA, var(--accent) 45%, #1D4ED8);
  box-shadow: 0 8px 18px rgba(0,0,0,.35), inset 0 1px 0 rgba(255,255,255,.35);
}
.tile:hover { filter: brightness(1.07); }
.tile svg { width: 30px; height: 30px; }
.tile span { font-weight: 500; font-size: 14px; color: #DBEAFE; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat { padding: 16px; border-radius: 14px; background: rgba(18,38,74,.72); border: 1px solid var(--line); }
.stat b { display: block; font-size: 28px; font-weight: 800; }
.howto { margin: 0; padding-left: 20px; color: var(--soft); }
.howto li { margin: 6px 0; }

/* ---------- Client detail ---------- */
.infocards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin-bottom: 20px; }
.info { padding: 14px 16px; border-radius: 14px; background: rgba(18,38,74,.72); border: 1px solid var(--line); overflow-wrap: anywhere; }
.info .label { display: block; margin-bottom: 4px; }
.info .none { color: var(--muted); }

/* ---------- Stock move ---------- */
.move { max-width: 560px; }
.move-head { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.move-head img, .move-head .thumb { width: 88px; height: 88px; border-radius: 14px; }
.counter { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 22px 0; }
.counter button {
  width: 60px; height: 60px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer;
  background: rgba(255,255,255,.08); font-size: 30px; font-weight: 700; line-height: 1;
}
.counter button:hover { background: rgba(255,255,255,.14); }
.counter input { width: 130px; text-align: center; font-size: 34px; font-weight: 800; min-height: 64px; }
.counter input::-webkit-outer-spin-button, .counter input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.counter input[type=number] { -moz-appearance: textfield; }
.hint { padding: 12px 14px; border-radius: 12px; background: rgba(59,130,246,.14); color: #DBEAFE; font-size: 14px; }
.hint.warn { background: rgba(239,68,68,.16); color: var(--danger-soft); }

/* ---------- Photos ---------- */
.photo-edit { display: flex; align-items: center; gap: 16px; }
.photo-edit img, .photo-edit .thumb { width: 96px; height: 96px; border-radius: 14px; }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: rgba(255,255,255,.1); display: grid; place-items: center; flex: none; font-weight: 800; }
.avatar.lg { width: 96px; height: 96px; font-size: 34px; }

/* ---------- Checklist ---------- */
.checklist { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 12px; padding: 6px 12px; background: rgba(3,10,24,.3); }
.checklist .check { padding: 9px 0; border-top: 1px solid var(--line); }
.checklist .check:first-child { border-top: 0; }

/* ---------- Paywall ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.gate-card { width: 100%; max-width: 520px; text-align: center; }
.gate-icon { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; margin: 0 auto 18px; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.24); }
.gate-icon svg { width: 44px; height: 44px; }
.plans { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0; text-align: left; }
.plan { padding: 16px; border-radius: 14px; border: 1px solid var(--line); background: rgba(18,38,74,.72); }
.plan b { display: block; font-size: 20px; }
.steps { text-align: left; margin: 18px 0; padding-left: 22px; color: var(--soft); }
.steps li { margin: 8px 0; }

/* ---------- Modal + toast ---------- */
#modal .backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6); display: grid; place-items: center; padding: 16px; }
#modal .dialog { width: 100%; max-width: 420px; background: #13284D; border: 1px solid var(--line); border-radius: 18px; padding: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
#modal .dialog p { color: var(--soft); margin: 10px 0 18px; }
#modal .dialog .actions { justify-content: flex-end; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: calc(100% - 32px); max-width: 480px; }
#toast .t { padding: 12px 18px; border-radius: 12px; background: #1E3A6E; border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.4); font-weight: 600; animation: pop .18s ease; text-align: center; }
#toast .t.err { background: #5B1A1A; }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }
.setup-note { padding: 14px; border-radius: 12px; background: rgba(249,115,22,.12); border: 1px solid rgba(249,115,22,.35); color: #FED7AA; font-size: 14px; margin-bottom: 18px; }
