/* PIC N SNACK — Food Safety & Compliance System */

:root {
  --bg: #FBFAFC;
  --surface: #FFFFFF;
  --surface-2: #F5F3F8;
  --surface-3: #EEEBF3;
  --ink: #16131C;
  --ink-2: #4A4453;
  --ink-3: #7C7488;
  --rule: #E3DFE9;
  --rule-strong: #CFC8D8;
  --accent: #B4126A;
  --accent-soft: #FCE9F2;
  --ok: #12704A;
  --ok-soft: #E4F5EC;
  --warn: #8F5A00;
  --warn-soft: #FBEFD9;
  --crit: #A81F16;
  --crit-soft: #FAE8E5;
  --shadow: 0 1px 2px rgba(22,19,28,.06), 0 8px 24px -14px rgba(22,19,28,.2);

  /* Business Insights dashboard — its own identity, deliberately distinct
     from the app's pink compliance-module accent. */
  --ins-accent: #1F6FEB;
  --ins-accent-soft: #E8F0FE;
  --ins-accent-2: #2FB8AC;

  --display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --body: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --rail: 236px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131017;
    --surface: #1B1721;
    --surface-2: #241F2C;
    --surface-3: #2C2635;
    --ink: #F2EFF5;
    --ink-2: #B9B1C3;
    --ink-3: #8B8397;
    --rule: #322B3C;
    --rule-strong: #453C51;
    --accent: #FF7CB2;
    --accent-soft: #3A1128;
    --ok: #52D493;
    --ok-soft: #102D20;
    --warn: #E8AC42;
    --warn-soft: #33250D;
    --crit: #FF8D82;
    --crit-soft: #3B1613;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -14px rgba(0,0,0,.75);
    --ins-accent: #6FA8FF;
    --ins-accent-soft: #16233D;
    --ins-accent-2: #4FD3C4;
  }
}

:root[data-theme="dark"] {
  --bg: #131017;
  --surface: #1B1721;
  --surface-2: #241F2C;
  --surface-3: #2C2635;
  --ink: #F2EFF5;
  --ink-2: #B9B1C3;
  --ink-3: #8B8397;
  --rule: #322B3C;
  --rule-strong: #453C51;
  --accent: #FF7CB2;
  --accent-soft: #3A1128;
  --ok: #52D493;
  --ok-soft: #102D20;
  --warn: #E8AC42;
  --warn-soft: #33250D;
  --crit: #FF8D82;
  --crit-soft: #3B1613;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px -14px rgba(0,0,0,.75);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ============ layout ============ */

.shell { display: flex; min-height: 100vh; }

.rail {
  width: var(--rail);
  flex: 0 0 var(--rail);
  background: var(--surface);
  border-right: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  padding: 20px 18px 16px;
  border-bottom: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.brand .name {
  font-family: var(--display);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -.01em;
}
.brand .sub {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.nav { padding: 10px 10px 16px; display: flex; flex-direction: column; gap: 1px; flex: 1; }

.nav a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13.5px;
  line-height: 1.3;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.nav .grp {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding: 14px 10px 5px;
}

.nav .dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex: 0 0 auto;
}
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.crit { background: var(--crit); }

.railfoot {
  padding: 12px;
  border-top: 1px solid var(--rule);
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.main { flex: 1; min-width: 0; padding: 30px 36px 90px; max-width: 1200px; }

/* ============ typography ============ */

h1 {
  font-family: var(--display);
  font-size: 31px;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.12;
  margin: 0;
  text-wrap: balance;
}
h2 {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -.01em;
  margin: 0;
}
h3 { font-size: 14.5px; font-weight: 650; margin: 0; }

p { margin: 0; max-width: 74ch; text-wrap: pretty; }

.page-head {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-bottom: 20px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--ink);
}
.page-head .kicker {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--accent);
}
.page-head p { color: var(--ink-2); font-size: 15px; }

section.block { display: flex; flex-direction: column; gap: 14px; margin-bottom: 34px; }

.muted { color: var(--ink-3); }
.small { font-size: 13px; }

/* ============ pills & chips ============ */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .06em; text-transform: uppercase; font-weight: 600;
  padding: 3px 8px; border-radius: 999px; white-space: nowrap;
  border: 1px solid transparent;
}
.pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.pill.ok   { color: var(--ok);   background: var(--ok-soft);   border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.pill.crit { color: var(--crit); background: var(--crit-soft); border-color: color-mix(in srgb, var(--crit) 28%, transparent); }
.pill.flat { color: var(--ink-3); background: var(--surface-2); border-color: var(--rule); }
.pill.flat::before { display: none; }

/* ============ cards ============ */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 11px;
  padding: 16px 17px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  box-shadow: var(--shadow);
}
.card.wide { grid-column: 1 / -1; }

.card .label {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
}
.card .big {
  font-family: var(--display);
  font-size: 34px; line-height: 1; font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.card .big.crit { color: var(--crit); }
.card .big.warn { color: var(--warn); }
.card .big.ok   { color: var(--ok); }
.card .foot { font-size: 12.5px; color: var(--ink-2); }

/* meter */
.meter { height: 5px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.meter span.ok { background: var(--ok); }
.meter span.warn { background: var(--warn); }
.meter span.crit { background: var(--crit); }

/* ============ tables ============ */

.scroller { overflow-x: auto; border: 1px solid var(--rule); border-radius: 11px; background: var(--surface); }

table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 13px; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600;
  background: var(--surface-2); white-space: nowrap;
  position: sticky; top: 0; z-index: 1;
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
td.tight { white-space: nowrap; }

/* ============ forms & controls ============ */

.bar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; }

input[type="text"], input[type="date"], input[type="search"],
input[type="email"], input[type="password"], input[type="number"], select, textarea {
  font-family: var(--body); font-size: 13.5px;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule-strong); border-radius: 7px;
  padding: 6px 9px;
}
textarea { width: 100%; min-height: 68px; resize: vertical; line-height: 1.5; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
input[type="search"] { min-width: 220px; }

label.fld { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--ink-2); }
label.fld input, label.fld select { width: 100%; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }

button {
  font-family: var(--body); font-size: 13px; font-weight: 550;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule-strong); border-radius: 7px;
  padding: 6px 12px; cursor: pointer;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
:root[data-theme="dark"] button.primary,
:root:not([data-theme="light"]) button.primary { color: #2A0616; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) button.primary { color: #fff; } }
button.primary:hover { filter: brightness(1.08); }
button.sm { font-size: 12px; padding: 4px 9px; }

/* tri-state check control */
.tri { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 6px; overflow: hidden; }
.tri button {
  border: 0; border-radius: 0; padding: 3px 8px; font-size: 11px;
  font-family: var(--mono); letter-spacing: .04em; background: var(--surface); color: var(--ink-3);
}
.tri button + button { border-left: 1px solid var(--rule); }
.tri button.on.yes { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.tri button.on.no  { background: var(--crit-soft); color: var(--crit); font-weight: 700; }
.tri button.on.na  { background: var(--surface-3); color: var(--ink-2); font-weight: 700; }

/* checkbox rows */
.checks { display: flex; flex-direction: column; gap: 2px; }
.chk {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--rule); border-radius: 9px;
  background: var(--surface);
}
.chk input { margin-top: 3px; accent-color: var(--accent); width: 15px; height: 15px; flex: 0 0 auto; }
.chk.done { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.chk label { cursor: pointer; font-size: 13.5px; }

/* ============ detail panel ============ */

.panel {
  background: var(--surface); border: 1px solid var(--rule);
  border-radius: 11px; padding: 18px; display: flex; flex-direction: column; gap: 16px;
  box-shadow: var(--shadow);
}

.kv { display: grid; grid-template-columns: 190px 1fr; gap: 8px 16px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); font-family: var(--mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; padding-top: 2px; }
.kv dd { margin: 0; }
.kv dd.gap { color: var(--crit); font-style: italic; }

.rowlist { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 13px; border: 1px solid var(--rule); border-radius: 9px; background: var(--surface);
}
.row .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.row .txt .t { font-size: 13.5px; font-weight: 550; }
.row .txt .d { font-size: 12px; color: var(--ink-3); }
.row.done { opacity: .55; }

/* method cards */
.method { border: 1px solid var(--rule); border-radius: 10px; background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 7px; }
.method.na { background: var(--surface-2); border-style: dashed; }
.method .hd { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.method .area { font-family: var(--mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.method p { font-size: 13.5px; color: var(--ink-2); }

/* callout */
.note {
  border-left: 3px solid var(--accent); background: var(--accent-soft);
  border-radius: 0 9px 9px 0; padding: 13px 16px;
  display: flex; flex-direction: column; gap: 6px;
}
.note .tag { font-family: var(--mono); font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 600; }
.note p { font-size: 13.5px; }

.note.crit { border-left-color: var(--crit); background: var(--crit-soft); }
.note.crit .tag { color: var(--crit); }

.empty { padding: 30px; text-align: center; color: var(--ink-3); font-size: 13.5px; }

/* toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 9px 16px; border-radius: 999px; font-size: 13px; font-weight: 550;
  box-shadow: var(--shadow); z-index: 50; opacity: 0; pointer-events: none;
}
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: no-preference) { .toast { transition: opacity .2s ease; } }

/* ============ responsive ============ */

@media (max-width: 880px) {
  .shell { flex-direction: column; }
  .rail { width: 100%; flex: none; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--rule); }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .grp { display: none; }
  .main { padding: 22px 18px 70px; }
  .kv { grid-template-columns: 1fr; gap: 3px 0; }
  .kv dd { margin-bottom: 8px; }
}

/* ============ preview mode ============ */

.demotoggle {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 7px;
  border: 1px solid var(--rule-strong); background: var(--surface-2);
  font-size: 12.5px; cursor: pointer;
}
.demotoggle input { accent-color: var(--crit); width: 15px; height: 15px; }

.demobar {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--crit-soft);
  border: 2px solid var(--crit);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 22px;
}
.demobar strong {
  font-family: var(--mono); font-size: 12px;
  letter-spacing: .12em; color: var(--crit);
}
.demobar span { font-size: 12.5px; color: var(--ink-2); }

/* Diagonal watermark across the content while previewing. */
body.is-demo .main { position: relative; }
body.is-demo .main::before {
  content: "SAMPLE DATA — NOT REAL RECORDS";
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) rotate(-24deg);
  font-family: var(--mono); font-size: 46px; font-weight: 700;
  letter-spacing: .06em;
  color: var(--crit);
  opacity: .1;
  white-space: nowrap;
  pointer-events: none;
  z-index: 40;
}

/* ============ print ============ */

@media print {
  :root { --bg: #fff; --surface: #fff; --surface-2: #fff; --ink: #000; --ink-2: #222; --ink-3: #555; --rule: #bbb; --shadow: none; }
  .rail, .bar button, .railfoot, .toast { display: none !important; }

  /* The sample-data warning must survive printing. */
  .demobar {
    display: block !important;
    border: 3px solid #000 !important;
    padding: 10px !important;
    margin-bottom: 16px !important;
  }
  .demobar strong { color: #000 !important; font-size: 14px !important; }
  body.is-demo .main::before {
    position: fixed; opacity: .16 !important; color: #000 !important;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  body.is-demo table tbody tr td:first-child::after {
    content: " · SAMPLE";
    font-family: var(--mono); font-size: 8px; color: #666;
  }
  .main { padding: 0; max-width: none; }
  .card, .panel, .scroller, .method, .chk, .row { break-inside: avoid; box-shadow: none; }
  thead th { position: static; }
  a { text-decoration: none; color: #000; }
}

/* ============ admin gate ============ */

.gate {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.gate-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 32px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.gate-brand { display: flex; flex-direction: column; gap: 3px; }
.gate-brand .name {
  font-family: var(--display);
  font-size: 20px; font-weight: 600; letter-spacing: -.01em;
}
.gate-brand .sub {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
}

.gate-card h1 {
  font-family: var(--display);
  font-size: 25px; font-weight: 600; letter-spacing: -.015em; margin: 0;
}

.gate-intro { font-size: 13.5px; color: var(--ink-2); }

.gate-card form { display: flex; flex-direction: column; gap: 13px; }
.gate-card .fld input { padding: 9px 11px; font-size: 14px; }

.gate-btn { width: 100%; padding: 10px; font-size: 14px; margin-top: 4px; }

.gate-msg {
  font-size: 13px;
  color: var(--crit);
  background: var(--crit-soft);
  border: 1px solid color-mix(in srgb, var(--crit) 28%, transparent);
  border-radius: 7px;
  padding: 8px 11px;
  margin: 0;
}

.gate-code {
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.5;
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  padding: 11px;
  color: var(--ink);
  resize: vertical;
}

.gate-row { display: flex; gap: 9px; }
.gate-row button { flex: 1; padding: 9px; }

.gate-note { font-size: 12px; color: var(--ink-3); margin: 0; }

.tool-picker { display: flex; flex-direction: column; gap: 11px; }
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  width: 100%;
  padding: 15px 16px;
  background: var(--surface-2);
  border: 1px solid var(--rule-strong);
  border-radius: 10px;
  cursor: pointer;
}
.tool-card:hover { border-color: var(--accent, var(--ink-3)); }
.tool-card .t { font-family: var(--display); font-size: 15.5px; font-weight: 600; }
.tool-card .d { font-size: 12.5px; color: var(--ink-2); }

#logout { color: var(--ink-3); }
#switchtool { color: var(--ink-3); }

@media print { .gate { display: none !important; } }

/* ---------------- Business Insights dashboard ---------------- */

.ins-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.ins-kpi {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ins-kpi-label { font-size: 12px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.ins-kpi-value { font-family: var(--display); font-size: 26px; font-weight: 600; color: var(--ink); }
.ins-kpi-ok   { color: var(--ok); }
.ins-kpi-warn { color: var(--warn); }
.ins-kpi-crit { color: var(--crit); }
a.ins-kpi-link { text-decoration: none; transition: border-color .15s, transform .15s; }
a.ins-kpi-link:hover { border-color: var(--ins-accent); transform: translateY(-1px); }

.ins-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 16px;
  margin-bottom: 22px;
}
@media (max-width: 900px) { .ins-grid { grid-template-columns: 1fr; } }

/* Three equal cards — used by "When you sell best" (weekday/hour/month),
   unlike .ins-grid above which is deliberately lopsided (one wide chart
   card + two narrow ones) for the original revenue/channel/category row. */
.ins-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 22px;
}
@media (max-width: 900px) { .ins-grid-3 { grid-template-columns: 1fr; } }

.ins-best-pick { font-family: var(--display); font-size: 22px; font-weight: 600; color: var(--ins-accent); margin-bottom: 4px; }

.ins-card {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 14px;
  padding: 18px 20px 20px;
  box-shadow: var(--shadow);
}
.ins-card-wide { grid-column: 1 / 2; }
@media (max-width: 900px) { .ins-card-wide { grid-column: 1; } }
.ins-card h3 {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 14px;
  color: var(--ink);
}
.ins-card canvas { max-height: 260px; }

.ins-compliance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.ins-compliance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  text-decoration: none;
  color: var(--ink);
  font-size: 13.5px;
  transition: background .15s;
}
.ins-compliance-row:hover { background: var(--surface-3); }
