:root {
  /* Cays Media brand: sand #E1BB8C (from the logo / caysmediagroup.com), warm neutrals */
  --brand: #e1bb8c;
  --bg: #f7f6f5;
  --card: #ffffff;
  --text: #212529;
  --muted: #676767;
  --border: #e9e2d9;
  --primary: #e1bb8c;
  --on-primary: #212529;
  --primary-text: #7a5a30;
  --accent-soft: #f6ebdd;
  --ok: #26704a; --ok-bg: #e3f3ea;
  --warn: #8a5a00; --warn-bg: #fdf0d2;
  --bad: #a8321f; --bad-bg: #fbe4df;
  --info: #3a5a80; --info-bg: #e4edf7;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 15, .06), 0 4px 14px rgba(60, 40, 15, .05);
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #2b2620; --card: #363029; --text: #f4ece0; --muted: #c2b5a2; --border: #4b4338;
  --primary: #e1bb8c; --on-primary: #212529; --primary-text: #e8c79b; --accent-soft: #473c2e;
  --ok: #8fd9ae; --ok-bg: #24402f; --warn: #f1c46b; --warn-bg: #46381a;
  --bad: #f5a99b; --bad-bg: #4a2a24; --info: #a9c8ee; --info-bg: #263a52;
  --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 "Gotham", "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2 { font-family: "Exclusive Serif", "Cormorant Garamond", Georgia, "Times New Roman", serif; font-weight: 500; letter-spacing: .01em; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.05rem; margin: 1.4rem 0 .6rem; }
p { margin: .25rem 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.right { text-align: right; }
a { color: var(--primary-text); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* layout: left sidebar (desktop) / slide-in menu (mobile) */
.shell { min-height: 100dvh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.side {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; overflow-y: auto;
  background: var(--card); border-right: 1px solid var(--border); z-index: 30;
}
.side-brand { background: var(--brand); padding: calc(1.1rem + env(safe-area-inset-top)) 1rem 1.1rem; text-align: center; }
.side-brand img { height: 40px; width: auto; display: block; margin: 0 auto; }
.side nav { padding: .75rem .6rem; flex: 1; }
.nav-group { margin-bottom: .9rem; }
.nav-label { font-size: .7rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); padding: .2rem .8rem .3rem; }
.side nav a {
  display: flex; align-items: center; justify-content: space-between; gap: .4rem; padding: .6rem .8rem; border-radius: 10px;
  color: var(--text); text-decoration: none; font-weight: 600; min-height: 44px;
}
.side nav a:hover { background: var(--accent-soft); }
.side nav a[aria-current="page"] { background: var(--accent-soft); color: var(--primary-text); box-shadow: inset 3px 0 0 var(--primary); }
.side-foot { padding: .75rem .6rem calc(.75rem + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: grid; gap: .3rem; }
.side-foot .who { font-size: .85rem; padding: 0 .8rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot button, .side-foot a {
  background: none; border: 0; font: inherit; font-weight: 600; color: var(--text); text-align: left; padding: .5rem .8rem;
  border-radius: 10px; cursor: pointer; min-height: 40px; text-decoration: none; display: block;
}
.side-foot button:hover, .side-foot a:hover { background: var(--accent-soft); }
.content { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; padding-top: calc(.6rem + env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 20; background: var(--bg); border-bottom: 1px solid var(--border);
}
.topbar .spacer { flex: 1; }
.topbar .logo { display: none; height: 30px; width: auto; }
.menu-btn { display: none; background: none; border: 0; font: inherit; font-weight: 700; color: inherit; cursor: pointer; padding: .5rem .6rem; min-height: 44px; border-radius: 10px; }
.top-link { display: inline-flex; align-items: center; gap: .45rem; padding: .5rem .9rem; border-radius: 999px; font-weight: 650; text-decoration: none; color: var(--text); background: var(--card); border: 1px solid var(--border); min-height: 40px; }
.top-link[aria-current="page"] { background: var(--accent-soft); color: var(--primary-text); }
.badge { background: var(--primary); color: var(--on-primary); border-radius: 999px; font-size: .75rem; padding: 0 .45rem; min-width: 1.25rem; text-align: center; line-height: 1.25rem; }
.backdrop { display: none; }
main { width: 100%; max-width: 820px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; flex: 1; }
@media (max-width: 899px) {
  .shell { display: block; }
  .side { position: fixed; left: 0; top: 0; width: 270px; max-width: 85vw; transform: translateX(-102%); transition: transform .22s ease; box-shadow: 0 0 30px rgba(0,0,0,.25); }
  .shell.menu-open .side { transform: none; }
  .shell.menu-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
  .topbar { background: var(--brand); border-bottom: 0; padding: .5rem .75rem; padding-top: calc(.5rem + env(safe-area-inset-top)); }
  .topbar .logo { display: block; }
  .menu-btn { display: inline-flex; align-items: center; color: #212529; }
  .top-link { background: rgba(255,255,255,.8); color: #212529; border-color: transparent; }
  .badge { background: #212529; color: #fff; }
  main { padding: 1rem 1rem 3rem; }
}

/* cards & lists */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); margin-bottom: .75rem; }
.card.link { display: block; text-decoration: none; color: inherit; }
.card.link:active { transform: scale(.995); }
.row { display: flex; align-items: center; gap: .75rem; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }
.title { font-weight: 650; }
.amount { font-variant-numeric: tabular-nums; font-weight: 650; }
.stack > * + * { margin-top: .6rem; }
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

/* chips */
.chip { display: inline-block; font-size: .78rem; font-weight: 650; padding: .15rem .6rem; border-radius: 999px; background: var(--accent-soft); color: var(--primary-text); }
.chip.ok { background: var(--ok-bg); color: var(--ok); }
.chip.warn { background: var(--warn-bg); color: var(--warn); }
.chip.bad { background: var(--bad-bg); color: var(--bad); }
.chip.info { background: var(--info-bg); color: var(--info); }

/* forms */
label { display: block; font-weight: 600; font-size: .88rem; margin: .7rem 0 .25rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--card); border: 1.5px solid var(--border);
  border-radius: 10px; padding: .65rem .75rem; min-height: 46px;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 25%, transparent); }
input.needs { border-color: var(--warn); background: var(--warn-bg); }
textarea { min-height: 84px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem; font: inherit; font-weight: 650; cursor: pointer;
  background: var(--primary); color: var(--on-primary); border: 0; border-radius: 12px; padding: .7rem 1.1rem; min-height: 48px; text-decoration: none;
}
.btn.secondary { background: var(--accent-soft); color: var(--primary-text); }
.btn.ghost { background: transparent; color: var(--primary-text); border: 1.5px solid var(--border); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.small { min-height: 40px; padding: .4rem .8rem; font-size: .9rem; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.seg span { display: block; text-align: center; padding: .6rem .3rem; border: 1.5px solid var(--border); border-radius: 10px; font-weight: 600; font-size: .85rem; background: var(--card); cursor: pointer; }
.seg input:checked + span { border-color: var(--primary); background: var(--accent-soft); color: var(--primary-text); }
.seg input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }

/* auth */
.auth { max-width: 420px; margin: 0 auto; padding: 2rem 1.25rem; }
.auth-hero { background: var(--brand); text-align: center; padding: calc(2.2rem + env(safe-area-inset-top)) 1rem 2.4rem; border-radius: 0 0 28px 28px; }
.auth-hero img { height: 72px; width: auto; display: block; margin: 0 auto .6rem; }
.auth-hero .tagline { margin: 0; color: #fff; letter-spacing: .28em; text-transform: uppercase; font-size: .72rem; font-weight: 600; }
.auth h1 { text-align: center; }
.auth .muted { text-align: center; }
.auth .switch { text-align: center; margin-top: 1rem; }
.link-btn { background: none; border: 0; color: var(--primary-text); font: inherit; font-weight: 650; cursor: pointer; padding: .4rem; text-decoration: underline; }

/* messages */
.msg { padding: .75rem 1rem; border-radius: 12px; margin: .75rem 0; font-size: .92rem; }
.msg.bad { background: var(--bad-bg); color: var(--bad); }
.msg.ok { background: var(--ok-bg); color: var(--ok); }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.info { background: var(--info-bg); color: var(--info); }
.msg ul { margin: .3rem 0 0; padding-left: 1.2rem; }
#toast {
  position: fixed; left: 50%; bottom: calc(2rem + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--text); color: var(--bg); padding: .65rem 1rem; border-radius: 12px; font-weight: 600; z-index: 20; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* claim editor */
.line { display: grid; grid-template-columns: 60px minmax(0,1fr); gap: .75rem; }
.thumb { width: 60px; height: 80px; border-radius: 10px; background: var(--accent-soft); border: 1px solid var(--border); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--primary-text); font-weight: 700; text-decoration: none; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.fields { display: grid; grid-template-columns: minmax(0,1.15fr) minmax(0,1fr); gap: .5rem; }
.fields .full { grid-column: 1 / -1; }
.fields label { margin: 0 0 .15rem; font-size: .75rem; color: var(--muted); }
.fields input { min-height: 42px; padding: .45rem .5rem; min-width: 0; font-size: .95rem; }
.lineno { font-size: .75rem; font-weight: 700; color: var(--muted); }
.flags { display: flex; flex-wrap: wrap; gap: .3rem; margin-top: .4rem; }
.totalbar {
  position: sticky; bottom: calc(1rem + env(safe-area-inset-bottom)); background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: .8rem 1rem; box-shadow: 0 6px 24px rgba(60, 40, 15, .18); display: flex; align-items: center; gap: .75rem; margin-top: 1rem;
}
.totalbar .sum { white-space: nowrap; font-size: 1.2rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.drop { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: .35rem; }
.cal .dow { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 700; }
.cal button { min-height: 46px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.cal button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.cal .blank { visibility: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .25rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.roles { display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.roles label { display: flex; align-items: center; gap: .4rem; margin: 0; font-weight: 600; }
.roles input { width: 20px; height: 20px; min-height: 0; }

select.needs, textarea.needs { border-color: var(--warn); background: var(--warn-bg); }
.fields select, .fields textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line, #d9d6d2); border-radius: 8px; background: #fff; box-sizing: border-box; }

.pw { position: relative; }
.pw input { width: 100%; padding-right: 4.2rem; box-sizing: border-box; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: 0; color: var(--primary-text, #212529); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; padding: 6px 8px; }

/* My claims: filters and progress */
.filters { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0 1rem; }
.filters button { font: inherit; font-weight: 650; font-size: .88rem; padding: .45rem .9rem; border-radius: 999px; border: 1.5px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; min-height: 40px; }
.filters button[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.group-label { font-size: .75rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 1.2rem 0 .5rem; }
.track { display: flex; align-items: center; gap: .3rem; margin-top: .7rem; font-size: .72rem; color: var(--muted); flex-wrap: wrap; }
.track .step { display: inline-flex; align-items: center; gap: .3rem; }
.track .dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border); background: var(--card); }
.track .step.done { color: var(--text); font-weight: 650; }
.track .step.done .dot { background: var(--ok); border-color: var(--ok); }
.track .step.now .dot { background: var(--primary); border-color: var(--primary); }
.track .step.now { color: var(--text); font-weight: 650; }
.track .sep { width: 14px; height: 2px; background: var(--border); }
.track.returned .step.now .dot { background: var(--bad); border-color: var(--bad); }
