:root {
  --ink: #1B1F23; --ink2: #3D444C; --muted: #5B6470; --line: #E3E5E8; --line2: #EEF0F2; --bg: #F7F8F9;
  --accent: #8A5A2B; --accent-ink: #5C3A1A; --accent-soft: #F1EBE4; --link: #7A4E24;
  --ok-bg: #E7F1EA; --ok: #225A2E; --err-bg: #FBEAEA; --err: #8E1F1F;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.45; }
a { color: var(--link); }
a:hover { color: var(--accent-ink); }
h1 { font-size: 28px; line-height: 1.2; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2, .h2 { font-size: 16px; margin: 0; font-weight: 600; }
.h2 { font-size: 19px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.strong { font-weight: 600; color: var(--ink); text-decoration: none; }
.lg { font-size: 17px; }
.num { text-align: right; }
.pad { padding: 16px 20px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 24px 20px 56px; display: flex; flex-direction: column; gap: 20px; }
.wrap.narrow { max-width: 640px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
[hidden] { display: none !important; }

/* Top bar */
.topbar { background: #fff; border-bottom: 1px solid var(--line); }
.topbar-in { flex-direction: row; align-items: center; padding-top: 10px; padding-bottom: 10px; gap: 20px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; }
.brand.big { font-size: 20px; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 8px 12px; border-radius: 6px; color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14px; }
.nav a.on { background: var(--accent-soft); color: var(--accent-ink); }
.me { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 16px; background: var(--line); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; }

/* Controls */
label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
label.check { flex-direction: row; align-items: center; gap: 10px; font-weight: 400; min-height: 44px; }
label.check input { width: 20px; height: 20px; accent-color: var(--accent); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: 14px; font-weight: 500; padding: 0; margin-bottom: 8px; }
input:not([type=checkbox]):not([type=radio]):not([type=file]), select, textarea {
  font: inherit; font-size: 16px; font-weight: 400; color: var(--ink); background: #fff;
  border: 1px solid #CDD1D6; border-radius: 10px; padding: 0 14px; height: 48px; width: 100%;
}
textarea { height: auto; padding: 12px 14px; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #C9A27A; outline-offset: 1px; }
input.pin { height: 64px; font-size: 30px; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 16px;
  border-radius: 8px; border: 1px solid #CDD1D6; background: #fff; color: var(--ink); font: inherit; font-weight: 500;
  text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--bg); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.danger { color: var(--err); border-color: #E2B4B4; }
.btn.xl { height: 56px; font-size: 17px; border-radius: 12px; width: 100%; }
.btn.block { width: 100%; }
.btn.sm { height: 36px; font-size: 13px; padding: 0 12px; }
.btn[disabled] { opacity: .6; cursor: progress; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--link); cursor: pointer; min-height: 32px; }
.link.center { width: 100%; min-height: 44px; }
.chip { display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line); color: var(--ink2); text-decoration: none; font-size: 13px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.error { background: var(--err-bg); color: var(--err); padding: 10px 14px; border-radius: 8px; margin: 0; }
.notice { background: var(--ok-bg); color: var(--ok); padding: 10px 14px; border-radius: 8px; margin: 0; }
form.inline { display: inline; margin-right: 12px; }
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }

/* Layout pieces */
.crumbs { font-size: 13px; color: var(--muted); }
.head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.title-row { display: flex; align-items: center; gap: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions form { margin: 0; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.link-card { display: flex; flex-direction: column; gap: 6px; color: var(--ink); text-decoration: none; }
.link-card:hover { border-color: #C9A27A; color: var(--ink); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat { font-size: 26px; font-weight: 650; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 10px; min-width: 0; }
.panel-head { padding: 14px 20px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.side { flex: 1 1 280px; max-width: 380px; display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 999 1 560px; }
.bar { height: 8px; background: var(--line2); border-radius: 4px; overflow: hidden; }
.bar.big { height: 10px; }
.bar > div { height: 100%; background: var(--accent); }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.open { background: var(--ok-bg); color: var(--ok); }
.pill.done { background: var(--line2); color: var(--ink2); }
.defs { margin: 6px 0 0; display: grid; grid-template-columns: 100px 1fr; gap: 8px 12px; font-size: 14px; border-top: 1px solid var(--line2); padding-top: 14px; }
.defs dt { color: var(--muted); }
.defs dd { margin: 0; }
.defs.boxed { background: var(--bg); border: 0; border-radius: 12px; padding: 16px 18px; font-size: 15px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; padding: 12px; white-space: nowrap; }
td { padding: 12px; border-top: 1px solid var(--line2); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 20px; }
th:last-child, td:last-child { padding-right: 20px; }

/* Auth + phone screens */
.auth { max-width: 420px; margin: 0 auto; padding: 64px 24px 32px; display: flex; flex-direction: column; gap: 20px; min-height: 100dvh; background: #fff; }
.auth .foot { margin-top: auto; }
.phone { max-width: 560px; margin: 0 auto; background: #fff; min-height: 100dvh; display: flex; flex-direction: column; }
.phone-head { padding: 12px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 4px; padding-top: max(12px, env(safe-area-inset-top)); }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-radio { flex-direction: row; }
.chip-radio input { position: absolute; opacity: 0; pointer-events: none; }
.chip-radio span { display: inline-flex; align-items: center; height: 44px; padding: 0 16px; border-radius: 22px; border: 1px solid #CDD1D6; font-size: 15px; font-weight: 500; cursor: pointer; }
.chip-radio input:checked + span { border: 2px solid var(--accent); background: var(--accent-soft); color: var(--accent-ink); padding: 0 15px; }
.chip-radio input:focus-visible + span { outline: 3px solid #C9A27A; }
.stepper { display: flex; gap: 10px; }
.stepper .step { width: 56px; height: 56px; font-size: 24px; flex: none; }
.stepper input { height: 56px !important; text-align: center; font-size: 24px !important; font-weight: 650 !important; }
.photo-btn { position: relative; height: 64px; border: 1px dashed #A9AFB6; background: var(--bg); border-radius: 10px; align-items: center; justify-content: center; color: var(--ink2); cursor: pointer; }
.photo-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.photo-btn.has { border-style: solid; border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.done { align-items: center; text-align: center; padding: 72px 24px 28px; gap: 16px; }
.done .defs { width: 100%; text-align: left; }
.done .bottom { width: 100%; margin-top: auto; }
.tick { width: 80px; height: 80px; border-radius: 40px; background: var(--ok-bg); display: flex; align-items: center; justify-content: center; }
.sync-banner { background: #FFF4DB; color: #6B4A00; padding: 10px 20px; font-size: 14px; text-align: center; }
.sync-banner.ok { background: var(--ok-bg); color: var(--ok); }

/* Wider screens: the phone-first screens become a centred card instead of a bare phone-width column. */
@media (min-width: 721px) {
  .auth, .phone {
    min-height: 0; margin: 48px auto; border: 1px solid var(--line); border-radius: 14px;
    box-shadow: 0 1px 2px rgba(27, 31, 35, .04), 0 8px 24px rgba(27, 31, 35, .06);
  }
  .auth { max-width: 440px; padding: 40px 40px 32px; }
  .auth .foot { margin-top: 8px; }
  .phone { max-width: 600px; overflow: hidden; }
  .phone-head { padding: 16px 20px; }
  .phone .pad { padding: 24px 28px 28px; }
  .done { padding: 48px 40px 32px; }
  .done .bottom { margin-top: 8px; flex-direction: row; flex-wrap: wrap; }
  .done .bottom > * { flex: 1 1 200px; }
  .done .bottom form { flex-basis: 100%; }
}

.mobile-only { display: none; }
@media (max-width: 720px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex; flex-direction: column; }
  a.mobile-only { display: inline-flex; }
  .wrap { padding: 16px 14px 40px; gap: 16px; }
  h1 { font-size: 24px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .side { max-width: none; }
  .head .actions .btn { height: 40px; }
}
