/* ArmorKept Partner — warm, soft UI. */
:root {
  --bg: #F7F1E9;
  --surface: #FFFDF9;
  --sunk: #F1E9DF;
  --ink: #2B211A;
  --muted: #74665A;
  --line: #ECE2D6;
  --accent: #A84E28;
  --accent-ink: #8E3F1C;
  --accent-soft: #F8E6DA;
  --on-accent: #FFFFFF;
  --good: #3F6B45;
  --good-soft: #E5EFE2;
  --alert: #9F2A22;
  --alert-soft: #FAE1DC;
  --warn: #8A560E;
  --warn-soft: #FBEFD6;
  --hero: #3A2C23;
  --hero-ink: #FBF4EC;
  --hero-muted: #D9C7B6;
  --hero-chip: #4B3A2F;
  --shadow: 0 1px 2px rgba(74, 48, 26, .05), 0 8px 24px rgba(74, 48, 26, .07);
  --shadow-lg: 0 2px 6px rgba(74, 48, 26, .06), 0 18px 40px rgba(74, 48, 26, .12);
  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 14px;
  --display: Nunito, ui-rounded, system-ui, sans-serif;
  --body: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1E1814; --surface: #2A221C; --sunk: #231C17; --ink: #F5EDE4; --muted: #B9A898; --line: #3A2F27;
    --accent: #E8956A; --accent-ink: #F0B08C; --accent-soft: #42291C; --on-accent: #1E1814;
    --good: #8CC394; --good-soft: #233426; --alert: #F2A193; --alert-soft: #44221E; --warn: #E8B862; --warn-soft: #3D2E14;
    --hero: #120E0B; --hero-ink: #FBF4EC; --hero-muted: #C9B7A6; --hero-chip: #2A211B;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); --shadow-lg: 0 18px 40px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--body); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent-ink); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 30px; font-weight: 900; }
h2 { font-size: 20px; font-weight: 800; }
h3 { font-size: 17px; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* ---------- layout ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.main { flex: 1; width: 100%; max-width: 1180px; margin: 0 auto; padding: max(16px, env(safe-area-inset-top)) 16px calc(96px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 900; font-size: 19px; }
.brand img { width: 32px; height: 32px; border-radius: 10px; }
.cols { display: grid; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.section-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 8px 4px 0; }
.section-title .muted { font-size: 14px; }
.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); padding: 8px 4px 0; }

/* ---------- nav ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 -1px 0 var(--line); }
.tab { position: relative; height: 54px; border: 0; background: transparent; border-radius: 16px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11.5px; font-weight: 600; text-decoration: none; }
.tab svg { width: 24px; height: 24px; }
.tab[aria-current="page"] { color: var(--accent-ink); background: var(--accent-soft); }
.badge { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--alert); color: #fff; font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.tab .badge { position: absolute; top: 4px; left: calc(50% + 6px); }
@media (prefers-color-scheme: dark) { .badge { color: #1E1814; } }

@media (min-width: 900px) {
  .shell { flex-direction: row; }
  .tabbar { position: sticky; top: 0; height: 100vh; width: 248px; flex: none; display: flex; flex-direction: column; gap: 6px; padding: 24px 16px; box-shadow: 1px 0 0 var(--line); background: var(--surface); }
  .tabbar .brand { padding: 0 10px 18px; }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; padding: 0 14px; height: 50px; font-size: 15px; }
  .tab .badge { position: static; margin-left: auto; }
  .main { padding: 32px 32px 48px; }
  .cols.two { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
  .topbar .brand { display: none; }
}
.tabbar .brand { display: none; }
@media (min-width: 900px) { .tabbar .brand { display: flex; } }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 18px; }
.card.flush { padding: 0; overflow: hidden; }
.card.tint-alert { background: linear-gradient(var(--alert-soft), var(--alert-soft)) padding-box; }
.inset { background: var(--sunk); border-radius: var(--r-sm); padding: 12px 14px; }
.list > * + * { border-top: 1px solid var(--line); }
.item { display: flex; align-items: center; gap: 12px; padding: 14px 18px; min-height: 64px; }
.icon { width: 44px; height: 44px; flex: none; border-radius: 15px; display: flex; align-items: center; justify-content: center; background: var(--accent-soft); color: var(--accent-ink); }
.icon svg { width: 22px; height: 22px; }
.icon.alert { background: var(--alert-soft); color: var(--alert); }
.icon.warn { background: var(--warn-soft); color: var(--warn); }
.icon.good { background: var(--good-soft); color: var(--good); }
.icon.plain { background: var(--sunk); color: var(--muted); font-weight: 700; font-size: 14px; }
.title { font-weight: 600; font-size: 16px; }
.sub { font-size: 13.5px; color: var(--muted); }

/* hero */
.hero { background: var(--hero); color: var(--hero-ink); border-radius: var(--r-lg); padding: 20px; display: flex; flex-direction: column; gap: 14px; box-shadow: var(--shadow-lg); }
.hero .muted { color: var(--hero-muted); }
.hero h2 { font-size: 22px; }
.chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
@media (min-width: 600px) { .chips { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.chip { background: var(--hero-chip); border-radius: 14px; padding: 10px; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--hero-ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: #8FD19A; }
.dot.off { background: #F3A58E; }
.dot.idle { background: #C9B7A6; }

/* pills / status */
.pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border-radius: 14px; font-size: 12.5px; font-weight: 600; background: var(--sunk); color: var(--muted); white-space: nowrap; }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.alert { background: var(--alert-soft); color: var(--alert); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.accent { background: var(--accent-soft); color: var(--accent-ink); }

/* ---------- controls ---------- */
.btn { height: 48px; padding: 0 18px; border-radius: 16px; border: 0; background: var(--sunk); color: var(--ink); font-weight: 600; font-size: 15px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap; transition: transform .08s ease, filter .15s ease; }
.btn:active { transform: scale(.98); }
.btn:hover { filter: brightness(.97); }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 30%, transparent); }
.btn.danger { background: var(--alert-soft); color: var(--alert); }
.btn.ghost { background: transparent; color: var(--accent-ink); }
.btn.sm { height: 40px; padding: 0 14px; border-radius: 13px; font-size: 14px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 18px; height: 18px; }
.iconbtn { width: 44px; height: 44px; border-radius: 22px; border: 0; background: var(--surface); box-shadow: var(--shadow); display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }
.iconbtn svg { width: 20px; height: 20px; }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { height: 40px; padding: 0 15px; border-radius: 20px; border: 0; background: var(--surface); box-shadow: var(--shadow); font-weight: 600; font-size: 14px; color: var(--ink); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--bg); box-shadow: none; }

.times { display: flex; gap: 6px; flex-wrap: wrap; }
.times button { height: 40px; padding: 0 13px; border-radius: 13px; border: 0; background: var(--sunk); font-weight: 600; font-size: 14px; color: var(--ink); }
.times button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); box-shadow: inset 0 0 0 2px var(--accent); }
.stepper { display: flex; align-items: center; gap: 6px; background: var(--sunk); border-radius: 16px; padding: 4px; }
.stepper button { width: 44px; flex: none; height: 40px; border-radius: 12px; border: 0; background: var(--surface); box-shadow: var(--shadow); font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; color: var(--ink); }
.stepper output { flex: 1; text-align: center; font-family: var(--display); font-weight: 800; font-size: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.input { height: 50px; padding: 0 16px; border-radius: 16px; border: 0; background: var(--sunk); outline: 0; font-size: 16px; width: 100%; }
.input:focus { box-shadow: inset 0 0 0 2px var(--accent); }
textarea.input { height: 76px; padding: 12px 16px; resize: vertical; }
.search { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px; border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 15px; min-width: 0; }
.search svg { width: 18px; height: 18px; color: var(--muted); }

.switch { position: relative; width: 54px; height: 32px; border-radius: 16px; border: 0; padding: 0; background: var(--line); flex: none; transition: background .2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.18); transition: transform .2s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(22px); }

.progress { height: 8px; border-radius: 4px; background: var(--sunk); overflow: hidden; }
.progress span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }

/* report */
.days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; color: var(--hero-muted); }
.day i { width: 100%; height: 40px; border-radius: 11px; background: #8FD19A; }
.day i.hit { background: #F3A58E; }
.day i.tamper { background: #F2CF7A; }
.day i.none { background: var(--hero-chip); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12.5px; color: var(--hero-muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend b { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 600px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 16px; }
.stat b { display: block; font-family: var(--display); font-weight: 900; font-size: 30px; line-height: 1.1; }
.stat.alert b { color: var(--alert); }
.bullets { display: flex; flex-direction: column; gap: 10px; }
.bullets div { display: flex; gap: 10px; font-size: 15px; }
.bullets div::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 8px; flex: none; }
.bullets div.alert::before { background: var(--alert); }

/* auth */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 420px; padding: 28px; display: flex; flex-direction: column; gap: 16px; border-radius: 30px; }
.auth .logo { width: 64px; height: 64px; border-radius: 20px; box-shadow: var(--shadow); }
.err { color: var(--alert); font-size: 14px; min-height: 1.2em; }

/* person switcher */
.person { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 14px 0 6px; border-radius: 23px; background: var(--surface); box-shadow: var(--shadow); border: 0; font-weight: 600; font-size: 15px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; font-family: var(--display); font-weight: 900; font-size: 15px; flex: none; }
.person select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; font-weight: 600; font-size: 15px; padding-right: 18px; outline: 0; }
.person svg { width: 14px; height: 14px; margin-left: -16px; pointer-events: none; color: var(--muted); }

.empty { text-align: center; padding: 28px 18px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty svg { width: 36px; height: 36px; color: var(--accent); }

#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 16px; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-lg); transition: all .25s ease; pointer-events: none; z-index: 50; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 900px) { #toast { bottom: 32px; } }

.skeleton { height: 120px; border-radius: var(--r-lg); background: linear-gradient(90deg, var(--sunk), var(--surface), var(--sunk)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
