:root {
  --orange: #f16606;
  --green: #419d29;
  --red: #c2410c;
  --ink: #2a2620;
  --muted: #7a7166;
  --line: #e8e1d6;
  --bg: #f7f3ec;
  --card: #ffffff;
  --chip: #f1ebe0;
  color-scheme: light;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
[hidden] { display: none !important; }
h2 { font-size: 15px; margin: 0 0 10px; }
.muted { color: var(--muted); font-weight: 400; }
.error { color: var(--red); margin: 0; }

.brand { font-size: 17px; display: flex; align-items: center; gap: 8px; }
.brand b { color: var(--orange); }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--green); display: inline-block; }

.btn, .btn-primary {
  font: inherit; border-radius: 8px; padding: 7px 12px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
.btn:hover { border-color: #cfc5b6; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: 600; }

/* Sign in */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border-radius: 14px; padding: 28px;
  display: grid; gap: 14px; box-shadow: 0 20px 50px rgba(42, 38, 32, .12);
}
.login-card label { display: grid; gap: 4px; font-weight: 600; font-size: 13px; }
.login-card input, .filters input, .filters select {
  font: inherit; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink);
}

/* Layout */
.topbar {
  position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 20px; flex-wrap: wrap;
}
.topbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.page { padding: 18px 20px 40px; display: grid; gap: 16px; max-width: 1600px; margin: 0 auto; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.panel-head.wrap { flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 800px) { .two-col { grid-template-columns: 1fr; } }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 24px; font-weight: 700; margin-top: 2px; }
.kpi .sub { color: var(--muted); font-size: 12px; }

/* Chart */
.chart { width: 100%; overflow-x: auto; }
.chart svg { display: block; width: 100%; min-width: 560px; height: 180px; }
.legend { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-left: 8px; }
.sw-signup { background: var(--orange); }
.sw-active { background: var(--green); }

/* Bars list */
.bar-row { display: grid; grid-template-columns: 150px 1fr 70px; gap: 8px; align-items: center; font-size: 13px; margin: 4px 0; }
.bar-track { background: var(--chip); border-radius: 4px; height: 10px; overflow: hidden; }
.bar-fill { background: var(--orange); height: 100%; display: block; width: 0; }
.bar-row .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Filters + table */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[type=search] { min-width: 220px; }
.check { display: flex; gap: 4px; align-items: center; font-size: 13px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; max-height: 70vh; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; vertical-align: top; }
th {
  position: sticky; top: 0; background: #faf7f2; z-index: 1; cursor: pointer; user-select: none;
  font-size: 12px; color: var(--muted); font-weight: 600;
}
th.sorted { color: var(--ink); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #fbf6ee; }
.name { font-weight: 600; }
.email { color: var(--muted); font-size: 12px; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--chip); font-size: 11px; margin-right: 3px; }
.chip.ios { background: #e8eefc; color: #1d4ed8; }
.chip.android { background: #e6f4e2; color: #2f7a1d; }
.chip.web { background: #fdeee2; color: #b24a04; }
.chip.pro { background: var(--green); color: #fff; }
.chip.bad { background: #fde5dc; color: var(--red); }
.chip.ok { background: #e6f4e2; color: #2f7a1d; }
.chip.test { background: #eee; color: #777; }
.note { font-size: 12px; margin: 10px 2px 0; }

/* Drawer */
.scrim { position: fixed; inset: 0; background: rgba(42, 38, 32, .25); z-index: 9; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(720px, 100%); background: var(--card); z-index: 10;
  box-shadow: -20px 0 50px rgba(42, 38, 32, .15); display: flex; flex-direction: column;
}
.drawer-head { display: flex; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 18px; margin: 0; }
.drawer-body { overflow-y: auto; padding: 16px 20px 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.drawer-body > section { min-width: 0; }
.drawer-body h3 { font-size: 13px; margin: 0 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 14px; }
.fact .k { color: var(--muted); font-size: 11px; }
.fact .v { font-size: 13px; word-break: break-word; }
.mini { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
.mini table { font-size: 12px; }
.mini--spaced { margin-top: 12px; }
.mini th { position: static; cursor: default; }
.mini tbody tr { cursor: default; }

/* Full meal plan — a week is too wide for the user drawer, so it gets the screen */
.sheet {
  position: fixed; inset: 0; background: var(--card); z-index: 20;
  display: flex; flex-direction: column;
}
.plan-day { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.plan-day > h3 { display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; }
.plan-day > h3 .muted { text-transform: none; letter-spacing: 0; }
.slot { border-top: 1px solid var(--line); padding: 8px 0 2px; }
.slot:first-of-type { border-top: 0; }
.slot > summary { cursor: pointer; display: grid; gap: 4px 12px; grid-template-columns: 130px minmax(0, 1fr) auto; align-items: baseline; }
.slot > summary::marker { color: var(--muted); }
.slot .slot-name { color: var(--muted); font-size: 12px; text-transform: capitalize; }
.slot .dish { font-weight: 500; min-width: 0; }
.slot .nums { font-size: 12px; color: var(--muted); white-space: nowrap; }
/* Publish-as-sample panel, above the week it publishes */
.sample-panel { flex: none; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--bg); }
.sample-panel h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.sample-form { display: grid; gap: 10px; }
.sample-form label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.sample-form input[type=text], .sample-form textarea {
  font: inherit; font-size: 13px; color: var(--ink); padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); resize: vertical;
}
.sample-labels { display: flex; flex-wrap: wrap; gap: 6px 16px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 10px; margin: 0; }
.sample-labels legend { font-size: 11px; color: var(--muted); padding: 0 4px; }
.sample-labels .check { display: flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--ink); }
.sample-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sample-actions .btn, .sample-actions .btn-primary { text-decoration: none; }
.sample-actions #s-state { font-size: 12px; }

.photo-box { margin: 8px 0 2px; font-size: 12px; }
.meal-photo { display: block; width: min(320px, 100%); border-radius: 8px; border: 1px solid var(--line); }
.card-text {
  margin: 8px 0 4px; padding: 10px 12px; background: var(--bg); border-radius: 8px;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap; overflow-x: auto; max-height: 460px; overflow-y: auto;
}

@media (max-width: 600px) {
  .slot > summary { grid-template-columns: minmax(0, 1fr); }
  .page { padding: 12px 16px 32px; }
  .topbar { padding: 10px 16px; }
  .filters input[type=search] { min-width: 0; width: 100%; }
  .bar-row { grid-template-columns: 110px 1fr 60px; }
}
