:root {
  --brand: #1f5135;
  --brand-2: #2d6a4a;
  --brand-soft: #e7f0ea;
  --ink: #1c2421;
  --muted: #5d6b65;
  --line: #d9e0dc;
  --bg: #f5f7f6;
  --card: #fff;
  --ok: #1d7a46;
  --ok-bg: #e3f4ea;
  --warn: #8a5a00;
  --warn-bg: #fff3d6;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --info: #1f5f99;
  --info-bg: #e6f0fa;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.45; }
a { color: var(--brand-2); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pad { padding: 1.5rem; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.grow { flex: 1; }
[hidden] { display: none !important; }

/* Header */
#top { background: var(--brand); color: #fff; }
.topbar { max-width: 1240px; margin: 0 auto; padding: .6rem 1.25rem; display: flex; align-items: center; gap: .9rem; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 1.1rem; color: #fff; text-decoration: none; display: flex; align-items: center; gap: .5rem; }
.brand svg { width: 26px; height: 26px; }
.demo-tag { background: #f2c94c; color: #3b2f00; font-size: .72rem; font-weight: 700; padding: .15rem .5rem; border-radius: 99px; letter-spacing: .02em; }
.topnav { display: flex; gap: .15rem; flex-wrap: wrap; flex-basis: 100%; margin: -.2rem 0 -.1rem -.55rem; }
.topnav a { color: #dfeee5; text-decoration: none; padding: .4rem .55rem; border-radius: 6px; font-size: .92rem; }
.topnav a:hover { background: rgba(255,255,255,.1); color: #fff; }
.topnav a.active { background: rgba(255,255,255,.18); color: #fff; }
.topbar select { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.3); border-radius: 6px; padding: .3rem .4rem; font: inherit; font-size: .88rem; }
.topbar select option { color: var(--ink); }
.usermenu { position: relative; }
.usermenu > button { background: none; border: 1px solid rgba(255,255,255,.3); color: #fff; border-radius: 6px; padding: .3rem .6rem; font: inherit; font-size: .88rem; cursor: pointer; }
.usermenu .menu { position: absolute; right: 0; top: 110%; background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.12); min-width: 230px; z-index: 20; padding: .35rem; }
.usermenu .menu button, .usermenu .menu .who { display: block; width: 100%; text-align: left; background: none; border: 0; padding: .5rem .6rem; font: inherit; font-size: .9rem; border-radius: 6px; cursor: pointer; }
.usermenu .menu .who { cursor: default; border-bottom: 1px solid var(--line); border-radius: 0; margin-bottom: .25rem; }
.usermenu .menu button:hover { background: var(--bg); }
#subhead { background: var(--brand-soft); border-bottom: 1px solid var(--line); }
#subhead .inner { max-width: 1240px; margin: 0 auto; padding: .45rem 1.25rem; font-size: .88rem; display: flex; gap: 1.5rem; flex-wrap: wrap; }
#subhead b { color: var(--brand); }

main { max-width: 1240px; margin: 0 auto; padding: 1.25rem; }

/* Cards and tiles */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem; margin-bottom: 1rem; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .75rem; }
.tile { border: 1px solid var(--line); border-radius: 8px; padding: .8rem .9rem; background: #fff; text-decoration: none; color: inherit; display: block; }
a.tile:hover { border-color: var(--brand-2); box-shadow: 0 2px 8px rgba(31,81,53,.08); }
.tile .k { font-size: .8rem; color: var(--muted); }
.tile .v { font-size: 1.35rem; font-weight: 650; margin: .2rem 0; font-variant-numeric: tabular-nums; }
.section-head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; }
.section-head h2 { margin: 0; }

/* Status chips */
.chip { display: inline-block; padding: .12rem .55rem; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.s-approved, .s-paid, .s-done { background: var(--ok-bg); color: var(--ok); }
.s-pending { background: var(--info-bg); color: var(--info); }
.s-draft, .s-open { background: var(--warn-bg); color: var(--warn); }
.s-returned, .s-missing, .s-closed-missing { background: var(--bad-bg); color: var(--bad); }
.s-not_open, .s-closed, .s-none { background: #eef1ef; color: var(--muted); }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: .55rem .6rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: #fafbfa; }
tbody tr:hover { background: #fafcfb; }
tfoot td { font-weight: 650; border-top: 2px solid var(--line); }
.table-wrap { overflow-x: auto; }

/* Buttons and inputs */
button, .btn { font: inherit; font-size: .9rem; border-radius: 7px; padding: .45rem .9rem; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .35rem; }
button:hover, .btn:hover { border-color: #b8c4be; }
button.primary, .btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-2); }
button.danger { color: var(--bad); border-color: #f0c2bd; }
button.sm, .btn.sm { padding: .25rem .6rem; font-size: .82rem; }
button:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; font-size: .92rem; padding: .45rem .55rem; border: 1px solid #c5cfca; border-radius: 6px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid #8fbfa3; outline-offset: 0; border-color: var(--brand-2); }
input:disabled, select:disabled, textarea:disabled { background: #f3f5f4; color: #44504b; }
textarea { width: 100%; min-height: 70px; }
label.field { display: block; margin-bottom: .9rem; }
label.field > span { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .25rem; }
label.field input[type=text], label.field input[type=email], label.field input[type=tel], label.field input[type=number], label.field input[type=time], label.field select { width: 100%; max-width: 420px; }
.req { color: var(--bad); }
.help { font-size: .8rem; color: var(--muted); margin-top: .2rem; }
.checkline { display: flex; gap: .5rem; align-items: flex-start; margin: .3rem 0; font-weight: 400; }
.checkline input { margin-top: .25rem; }
.field-error input, .field-error select { border-color: var(--bad); }
.field-error .errtext { color: var(--bad); font-size: .8rem; margin-top: .2rem; }

/* Tabs */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }

/* Form layout with left navigation */
.formlayout { display: grid; grid-template-columns: 220px 1fr 300px; gap: 1rem; align-items: start; }
.leftnav { position: sticky; top: 1rem; }
.leftnav a { display: flex; justify-content: space-between; padding: .45rem .7rem; border-radius: 6px; text-decoration: none; color: var(--ink); font-size: .9rem; }
.leftnav a:hover { background: var(--brand-soft); }
.leftnav .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-top: .4rem; }
.leftnav .dot.bad { background: var(--bad); }
@media (max-width: 1050px) { .formlayout { grid-template-columns: 1fr; } .leftnav { position: static; } }

/* Banners */
.banner { border-radius: 8px; padding: .7rem .9rem; margin-bottom: 1rem; font-size: .92rem; }
.banner.info { background: var(--info-bg); color: #163f66; }
.banner.warn { background: var(--warn-bg); color: #5c3c00; }
.banner.bad { background: var(--bad-bg); color: #7a1a12; }
.banner.ok { background: var(--ok-bg); color: #145232; }
.checks { list-style: none; padding: 0; margin: 0; }
.checks li { padding: .35rem 0 .35rem 1.4rem; position: relative; font-size: .88rem; border-bottom: 1px dashed var(--line); }
.checks li:last-child { border-bottom: 0; }
.checks li::before { position: absolute; left: 0; top: .35rem; font-weight: 700; }
.checks li.error::before { content: "✕"; color: var(--bad); }
.checks li.warning::before { content: "!"; color: var(--warn); left: .3rem; }
.checks li.ok::before { content: "✓"; color: var(--ok); }

/* Claim grid */
.sitecard { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 1rem; background: #fff; }
.sitecard header { padding: .65rem .9rem; background: #fafbfa; border-bottom: 1px solid var(--line); border-radius: 8px 8px 0 0; }
.sitecard .body { padding: .8rem .9rem; }
.sitefacts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin-bottom: .8rem; }
.sitefacts label { font-size: .78rem; color: var(--muted); display: block; }
.sitefacts input { width: 100%; text-align: right; }
.mealgrid td, .mealgrid th { padding: .35rem .4rem; }
.mealgrid input { width: 100%; min-width: 80px; text-align: right; font-variant-numeric: tabular-nums; }
.mealgrid .na { color: #b0b8b4; text-align: center; }
.cep { background: #ede7fb; color: #4b2a9a; }
.totalbar { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line); padding: .75rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; box-shadow: 0 -4px 14px rgba(0,0,0,.05); border-radius: 8px 8px 0 0; }
.totalbar .amt { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.saved { font-size: .8rem; color: var(--muted); }

/* Bars */
.bar { height: 8px; background: var(--brand-soft); border-radius: 99px; overflow: hidden; min-width: 80px; }
.bar > i { display: block; height: 100%; background: var(--brand-2); }

/* Login */
.login { max-width: 980px; margin: 2rem auto; }
.login .hero { background: var(--brand); color: #fff; border-radius: 14px; padding: 1.6rem 1.8rem; margin-bottom: 1.25rem; }
.login .hero h1 { font-size: 1.7rem; }
.login .hero p { color: #dfeee5; margin: .4rem 0 0; max-width: 680px; }
.usercards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.usercard { text-align: left; display: block; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: .85rem 1rem; cursor: pointer; width: 100%; }
.usercard:hover { border-color: var(--brand-2); box-shadow: 0 2px 10px rgba(31,81,53,.1); }
.usercard b { display: block; }
.usercard .t { color: var(--muted); font-size: .85rem; }
.rolebadge { float: right; font-size: .72rem; font-weight: 700; padding: .1rem .45rem; border-radius: 99px; background: var(--brand-soft); color: var(--brand); text-transform: uppercase; letter-spacing: .03em; }

/* Toasts and dialogs */
#toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 50; }
.toast { background: var(--ink); color: #fff; padding: .65rem 1rem; border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.2); font-size: .9rem; max-width: 380px; }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
dialog { border: 0; border-radius: 12px; padding: 1.25rem 1.4rem; max-width: 480px; width: 92vw; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(20,30,25,.45); }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .85rem; }
.timeline li { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: .78rem; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem; }
