/* Resident App. Look ported from the approved MyBase demo (Base Student Living: warm off-white, near-black, gold, Inter).
   Colours are set per install from client.json (--bg, --ink, --accent); the defaults below are Base's.
   Contrast: body and muted text >= 4.5:1 on --bg; gold is used for accents and fills under dark text, never as text. */
:root {
  --bg: #f4f1ec;
  --surface: #ffffff;
  --surface-2: #faf8f4;
  --ink: #1a1714;
  --ink-2: #4a443d;
  --ink-3: #6b645b;
  --accent: #B89559;
  --accent-text: #7a5f2f;
  --line: #e6e0d6;
  --ok: #2b7350;
  --ok-bg: #e3f1e9;
  --warn: #9a5a14;
  --warn-bg: #fbf0dc;
  --danger: #b5482f;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 1px 2px rgba(26,23,20,.04), 0 6px 22px rgba(26,23,20,.07);
  --tab-h: 64px;
  --maxw: 520px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg); color: var(--ink);
  font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; overscroll-behavior-y: none;
}
#app { min-height: 100dvh; max-width: var(--maxw); margin: 0 auto; position: relative; background: var(--bg); }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; line-height: 1.25; }
p { margin: 0 0 12px; }
a { color: var(--accent-text); }
.muted { color: var(--ink-3); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
.center { text-align: center; }
.mt-6 { margin-top: 6px; } .mt-10 { margin-top: 10px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-18 { margin-top: 18px; } .mt-22 { margin-top: 22px; }
.overdue { color: var(--danger); font-weight: 600; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
svg.i { width: 20px; height: 20px; flex: 0 0 auto; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons / inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px;
  width: 100%; border: 0; cursor: pointer; font-family: inherit; font-size: 16px; font-weight: 600; text-decoration: none;
  padding: 14px 18px; border-radius: var(--radius-sm); background: var(--ink); color: #fff;
  transition: transform .06s ease, opacity .2s ease, background-color .2s ease;
}
.btn:hover { background: #000; }
.btn:active { transform: scale(.985); }
.btn[disabled], .btn.disabled { opacity: .5; cursor: default; pointer-events: none; }
.btn-gold { background: var(--accent); color: #1a1714; }
.btn-gold:hover { background: #a9874c; }
.btn-ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface-2); border-color: #d6cdbf; }
.btn-sm { width: auto; min-height: 40px; padding: 8px 14px; font-size: 14px; border-radius: 10px; }
.btn + .btn, .btn + .alt { margin-top: 10px; }
.alt { display: block; text-align: center; font-size: 14px; font-weight: 600; color: var(--accent-text); padding: 8px; }

label.field { display: block; margin: 0 0 14px; }
label.field > span { display: block; font-size: 14px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; font-family: inherit; font-size: 16px; color: var(--ink);
  background: var(--surface); border: 1px solid #d9d1c4; border-radius: var(--radius-sm);
  padding: 13px 14px; outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(184,149,89,.25); }
input.code { font-size: 26px; letter-spacing: 10px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.seg { display: flex; gap: 8px; margin-bottom: 16px; }
.seg button {
  flex: 1; min-height: 46px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px;
  font-family: inherit; font-size: 15px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.seg button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 14px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 14px; font-size: 15px; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--ink); flex: 0 0 auto; }
.err { color: var(--danger); font-size: 14px; margin: 4px 0 12px; }
.err:empty { display: none; }

/* ---------- sign-in ---------- */
.auth { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center;
  padding: calc(32px + env(safe-area-inset-top)) 22px calc(32px + env(safe-area-inset-bottom)); }
.auth .brand { text-align: center; margin-bottom: 28px; }
.auth .brand img { width: 84px; height: 84px; border-radius: 20px; box-shadow: var(--shadow); }
.auth .brand h1 { font-size: 26px; margin-top: 14px; }
.auth .brand .sub { color: var(--ink-3); font-size: 15px; margin-top: 4px; }
.auth-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; box-shadow: var(--shadow); }
.auth-card h2 { font-size: 19px; margin-bottom: 4px; }
.auth-card p.lead { color: var(--ink-3); font-size: 15px; margin: 0 0 18px; }
.auth .help { text-align: center; font-size: 14px; color: var(--ink-3); margin-top: 18px; }
.linkbtn { background: none; border: 0; color: var(--accent-text); font-family: inherit; font-size: 15px; font-weight: 600; cursor: pointer; padding: 10px; }

/* ---------- frame ---------- */
.view { padding: 0 0 calc(var(--tab-h) + env(safe-area-inset-bottom) + 20px); min-height: 100dvh; }
.appbar { position: sticky; top: 0; z-index: 20; background: rgba(244,241,236,.9); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: calc(env(safe-area-inset-top) + 12px) 20px 12px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.appbar img { width: 36px; height: 36px; border-radius: 9px; }
.appbar h2 { font-size: 18px; }
.appbar .greet { font-size: 13px; color: var(--ink-3); }
.appbar .back { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-left: -10px;
  border: 0; background: none; color: var(--ink); cursor: pointer; border-radius: 12px; }
.appbar .back:hover { background: rgba(26,23,20,.05); }
.wrap { padding: 18px 20px 0; }

/* ---------- home ---------- */
.hero { background: linear-gradient(160deg, #211d18, #39322a); color: #fff; border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); position: relative; overflow: hidden; display: flex; gap: 18px; align-items: center; }
.hero::after { content: ""; position: absolute; right: -40px; top: -40px; width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(184,149,89,.38), transparent 70%); pointer-events: none; }
.hero .eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); font-weight: 700; }
.hero h3 { font-size: 21px; margin: 6px 0 4px; }
.hero .meta { font-size: 14px; color: rgba(255,255,255,.75); }
.ring { position: relative; width: 84px; height: 84px; flex: 0 0 auto; }
.ring svg { width: 84px; height: 84px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 8; }
.ring .track { stroke: rgba(255,255,255,.14); }
.ring .bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring .num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring .num b { font-size: 22px; line-height: 1; }
.ring .num span { font-size: 11px; color: rgba(255,255,255,.7); margin-top: 3px; }

.next { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px 16px; box-shadow: var(--shadow); }
.next .lbl { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-text); }
.next h3 { font-size: 18px; margin: 4px 0 6px; }
.next p { color: var(--ink-2); font-size: 15px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .05em; margin: 24px 0 10px; }

.steps { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.steps li + li { border-top: 1px solid var(--line); }
.steps a { display: flex; align-items: center; gap: 14px; padding: 13px 14px; color: var(--ink); text-decoration: none; min-height: 60px; transition: background-color .15s ease; }
.steps a:hover { background: var(--surface-2); }
.dot { width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; border: 2px solid #d9d1c4; color: var(--ink-2); background: var(--surface); }
.dot.done { background: var(--ink); border-color: var(--ink); color: #fff; }
.dot.done svg.i { width: 16px; height: 16px; stroke-width: 3; }
.steps .t { flex: 1; min-width: 0; }
.steps .t b { display: block; font-size: 15.5px; font-weight: 600; }
.steps .t span { display: block; font-size: 13.5px; color: var(--ink-3); }
.steps .done-row .t b { color: var(--ink-2); }
.steps .chev { color: #b3aa9c; }

/* ---------- step detail ---------- */
.stepno { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent-text); }
.step-h { font-size: 24px; margin: 6px 0 12px; }
.body { font-size: 16px; color: var(--ink-2); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin: 16px 0; }
.status { display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 15px; font-weight: 600; margin: 14px 0; }
.status.ok { background: var(--ok-bg); color: var(--ok); }
.status.todo { background: var(--warn-bg); color: var(--warn); }
.status.info { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); font-weight: 500; }
.amount { font-size: 30px; font-weight: 700; letter-spacing: -.01em; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv .k { font-size: 13px; color: var(--ink-3); }
.kv .v { font-size: 16px; font-weight: 600; word-break: break-all; }
.copy { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line);
  background: var(--surface); border-radius: 10px; font-family: inherit; font-size: 14px; font-weight: 600; color: var(--ink); cursor: pointer; }
.copy:hover { background: var(--surface-2); }
.actions { margin-top: 20px; }
.tickrow { margin-top: 18px; }

/* ---------- lists ---------- */
.links { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.links li + li { border-top: 1px solid var(--line); }
.links a { display: flex; align-items: center; gap: 12px; padding: 15px 16px; color: var(--ink); text-decoration: none; font-weight: 500; min-height: 54px; }
.links a:hover { background: var(--surface-2); }
.links a span { flex: 1; }
.links svg.i { color: #9d9486; }

/* ---------- tabs ---------- */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; max-width: var(--maxw); margin: 0 auto; height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom); background: var(--surface); border-top: 1px solid var(--line); display: flex; z-index: 30; }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-decoration: none; }
.tabs a svg.i { width: 23px; height: 23px; }
.tabs a.on { color: var(--ink); }

/* ---------- feedback ---------- */
.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 18px); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; z-index: 60;
  box-shadow: var(--shadow); max-width: 88%; text-align: center; }
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-load { display: flex; justify-content: center; padding: 60px; }
.center-load .spinner { border-color: var(--line); border-top-color: var(--accent); width: 28px; height: 28px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }
@media (min-width: 700px) { body { background: #ebe6de; } #app { box-shadow: 0 0 0 1px var(--line); } }
