: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;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17130f; --card: #221c16; --text: #f2e9dc; --muted: #b3a592; --border: #3a3128;
    --primary: #e1bb8c; --on-primary: #212529; --primary-text: #e1bb8c; --accent-soft: #2f261c;
    --ok: #7fd1a1; --ok-bg: #1d3427; --warn: #f1c46b; --warn-bg: #3a2e14;
    --bad: #f19a8b; --bad-bg: #3d1f1a; --info: #9ec1ec; --info-bg: #1d2b3d;
    --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 */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; padding-top: calc(.6rem + env(safe-area-inset-top));
  background: var(--brand); position: sticky; top: 0; z-index: 5;
}
.topbar img { height: 34px; width: auto; display: block; }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: .9rem; color: #212529; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { display: flex; gap: .25rem; }
.nav a {
  display: flex; align-items: center; gap: .4rem; padding: .55rem .8rem; border-radius: 999px; color: var(--muted);
  text-decoration: none; font-weight: 600; min-height: 44px; white-space: nowrap;
}
.nav a[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; }
main { width: 100%; max-width: 760px; margin: 0 auto; padding: 1rem 1rem 6.5rem; flex: 1; }
@media (max-width: 640px) {
  .topbar .nav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--border);
    padding: .35rem .5rem calc(.35rem + env(safe-area-inset-bottom)); justify-content: space-around; z-index: 6; }
  .nav a { flex-direction: column; gap: 0; padding: .3rem .5rem; font-size: .75rem; border-radius: 12px; flex: 1; justify-content: center; }
}

/* 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(5.5rem + 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); }
@media (min-width: 641px) { #toast { bottom: 2rem; } }

/* 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(4.2rem + 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;
}
@media (min-width: 641px) { .totalbar { bottom: 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; }

/* brand tweaks: nav on the sand header (desktop) */
@media (min-width: 641px) {
  .topbar .nav a { color: #212529; }
  .topbar .nav a[aria-current="page"] { background: rgba(255, 255, 255, .8); color: #212529; }
}
.topbar .badge { background: #212529; color: #fff; }

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; }
