/* Rekap Kepatuhan Dapur — Zevyra Management
   Mobile-first. Mode terang/gelap: data-theme di <html>, default ikut perangkat. */

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("/static/fonts/PlusJakartaSans.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-Medium.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/static/fonts/JetBrainsMono-SemiBold.woff2") format("woff2");
  font-weight: 600;
  font-display: swap;
}

:root {
  --bg: #F6F7F6;
  --card: #FFFFFF;
  --line: #E3E7E5;
  --line-strong: #D5DBD9;
  --ink: #142220;
  --ink2: #2E3B39;
  --muted: #5A6966;
  --primary: #0F5F58;
  --primary-hover: #0A4540;
  --on-primary: #FFFFFF;
  --primary-soft: #E4F1EF;
  --danger: #B42318;
  --danger-soft: #FDECEA;
  --warn: #A15C07;
  --warn-soft: #FFF3E0;
  --chip: #EEF1F0;
  --dash: #8A9693;
  --tile: #33494A;
  --tile-ink: #E6EEEC;
  --disabled: #C9D6D3;
  --on-disabled: #2E4441;
  --shadow: 0 1px 2px rgba(20, 34, 32, 0.06);
  --radius: 14px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1716;
    --card: #172220;
    --line: #26332F;
    --line-strong: #34443F;
    --ink: #E7EEEC;
    --ink2: #C9D4D1;
    --muted: #A3B1AD;
    --primary: #5FC3B5;
    --primary-hover: #7FD3C7;
    --on-primary: #0B1F1C;
    --primary-soft: #173A36;
    --danger: #F2867A;
    --danger-soft: #3A1C19;
    --warn: #F0B060;
    --warn-soft: #3A2A12;
    --chip: #1F2C29;
    --dash: #6F7D79;
    --tile: #24312F;
    --tile-ink: #D7E2DF;
    --disabled: #26332F;
    --on-disabled: #8E9C98;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1716;
  --card: #172220;
  --line: #26332F;
  --line-strong: #34443F;
  --ink: #E7EEEC;
  --ink2: #C9D4D1;
  --muted: #A3B1AD;
  --primary: #5FC3B5;
  --primary-hover: #7FD3C7;
  --on-primary: #0B1F1C;
  --primary-soft: #173A36;
  --danger: #F2867A;
  --danger-soft: #3A1C19;
  --warn: #F0B060;
  --warn-soft: #3A2A12;
  --chip: #1F2C29;
  --dash: #6F7D79;
  --tile: #24312F;
  --tile-ink: #D7E2DF;
  --disabled: #26332F;
  --on-disabled: #8E9C98;
  --shadow: none;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
body.no-tabs { padding-bottom: 0; }
a { color: var(--primary); }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-in {
  max-width: 1200px; margin: 0 auto;
  padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-width: 0; }
.brand:hover { color: var(--ink); }
.zmark {
  width: 36px; height: 36px; border-radius: 9px; flex: none;
  background: var(--primary); color: var(--on-primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 800;
}
.brand-name { font-size: 15px; font-weight: 800; line-height: 1.15; }
.brand-sub { font-size: 12px; color: var(--muted); font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; position: relative; text-decoration: none;
}
.iconbtn:hover { color: var(--ink); background: var(--chip); }
.iconbtn svg { width: 20px; height: 20px; }
.badge {
  position: absolute; top: 4px; right: 4px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--danger); color: #fff; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.toptabs { display: none; gap: 4px; }
.toptabs a {
  padding: 10px 14px; border-radius: 10px; text-decoration: none;
  color: var(--muted); font-size: 14px; font-weight: 600;
}
.toptabs a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.role-pill { display: none; padding: 6px 10px; border-radius: 999px; background: var(--chip); color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }

/* Menu akun */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: 50px; min-width: 230px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.14); padding: 6px; z-index: 30;
}
.menu-panel .menu-item, .menu-panel button.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 44px; padding: 0 12px; border-radius: 8px; border: none;
  background: transparent; color: var(--ink); text-decoration: none;
  font-size: 14px; font-weight: 600; cursor: pointer; text-align: left;
}
.menu-panel .menu-item:hover { background: var(--chip); color: var(--ink); }
.menu-panel .menu-who { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-panel form { margin: 0; }

/* Tab bawah (HP) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--card); border-top: 1px solid var(--line);
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600;
}
.tabbar a svg { width: 22px; height: 22px; }
.tabbar a[aria-current="page"] { color: var(--primary); font-weight: 700; }

/* ---------- Halaman ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 18px 16px 28px; display: flex; flex-direction: column; gap: 18px; }
.page.narrow { max-width: 680px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); }
h1, .h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; margin: 0; line-height: 1.2; }
h2, .h2 { font-size: 17px; font-weight: 800; margin: 0; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card.dashed { border: 1.5px dashed var(--dash); box-shadow: none; }
.card.alert { border-color: var(--danger); }
.card-link { text-decoration: none; color: inherit; display: block; }
.card-link:hover { color: inherit; border-color: var(--line-strong); }

.flash { padding: 12px 14px; border-radius: 12px; font-size: 14px; font-weight: 600; }
.flash.ok { background: var(--primary-soft); color: var(--primary); }
.flash.err { background: var(--danger-soft); color: var(--danger); }
.flash.info { background: var(--chip); color: var(--ink2); }

/* Tombol */
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 15px; font-weight: 700; text-decoration: none; cursor: pointer;
  border: 1.5px solid var(--primary); background: var(--card); color: var(--primary);
}
.btn:hover { color: var(--primary-hover); border-color: var(--primary-hover); }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); }
.btn.big { min-height: 54px; font-size: 16px; width: 100%; }
.btn.quiet { border-color: var(--line-strong); color: var(--ink); }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--disabled); border-color: var(--disabled); color: var(--on-disabled); cursor: not-allowed; }
.btn svg { width: 20px; height: 20px; }

/* Status */
.chip {
  display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 700;
}
.chip svg { width: 12px; height: 12px; }
.chip.ok { background: var(--primary-soft); color: var(--primary); }
.chip.bad { background: var(--danger-soft); color: var(--danger); }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.pending { border: 1.5px dashed var(--dash); color: var(--muted); padding: 4px 10px; }
.chip.off { background: var(--chip); color: var(--muted); }
.tag { padding: 5px 10px; border-radius: 8px; background: var(--chip); color: var(--ink2); font-size: 12px; font-weight: 600; }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.bad { background: var(--danger-soft); color: var(--danger); }

/* Ringkasan angka */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { padding: 14px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; }
.stat-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-value { font-family: var(--mono); font-size: 26px; font-weight: 600; line-height: 1.1; }
.stat-value small { font-size: 16px; color: var(--muted); }

.progress { height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.progress > div { height: 100%; border-radius: 999px; background: var(--primary); }

/* Kartu dapur */
.kitchens { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.kcard { display: flex; flex-direction: column; gap: 12px; }
.kname { font-size: 16px; font-weight: 800; }
.times { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.times.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.time { padding: 10px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line); }
.time-label { font-size: 11px; font-weight: 600; color: var(--muted); }
.time-value { font-family: var(--mono); font-size: 16px; font-weight: 600; }
.note { font-size: 14px; color: var(--ink2); white-space: pre-line; overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* Gambar */
.thumbs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.thumb {
  position: relative; aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden;
  background: var(--tile); color: var(--tile-ink); display: block;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .more {
  position: absolute; inset: 0; background: rgba(10, 20, 18, 0.62); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800;
}
.gallery { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.gallery .thumb { aspect-ratio: auto; height: 140px; }

/* Formulir */
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 14px; font-weight: 700; }
.hint { font-size: 12px; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 52px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: var(--card); color: var(--ink); padding: 0 14px; font-size: 16px;
}
textarea.input { padding: 12px 14px; min-height: 96px; line-height: 1.5; resize: vertical; }
select.input { font-weight: 600; appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 40px; }
.input:focus, .opt input:focus-visible + span, .btn:focus-visible, .iconbtn:focus-visible, a:focus-visible {
  outline: 3px solid var(--primary); outline-offset: 2px;
}
.input.mono { font-family: var(--mono); font-size: 18px; font-weight: 600; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts.cols-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.opts.cols-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.opt { position: relative; display: block; }
.opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opt span {
  min-height: 48px; padding: 8px 14px; border-radius: 10px;
  border: 1.5px solid var(--line-strong); background: var(--card); color: var(--ink);
  display: flex; align-items: center; justify-content: center; gap: 8px; text-align: center;
  font-size: 14px; font-weight: 500; cursor: pointer; height: 100%;
}
.opts.cols-3 .opt span { padding: 8px 6px; font-size: 13px; overflow-wrap: break-word; }
.opt input:checked + span { border: 2px solid var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.opt.big span { min-height: 56px; font-size: 16px; }
.opt.bad input:checked + span { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.opt svg { width: 18px; height: 18px; }
.err-text { color: var(--danger); font-size: 13px; font-weight: 600; }

/* Unggah */
.upgrid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.up { position: relative; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; background: var(--tile); }
.up img { width: 100%; height: 100%; object-fit: cover; }
.up .bar { position: absolute; left: 8px; right: 8px; bottom: 8px; height: 5px; border-radius: 999px; background: rgba(255,255,255,0.35); overflow: hidden; }
.up .bar > div { height: 100%; background: #fff; width: 0; transition: width 0.2s; }
.up .state { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px; color: #fff; font-size: 12px; font-weight: 700; background: rgba(10,20,18,0.45); }
.up.failed .state { background: rgba(180,35,24,0.75); }
.up .rm {
  position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 999px;
  border: none; background: rgba(10,20,18,0.7); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.up .rm svg { width: 16px; height: 16px; }
.up .dup { position: absolute; left: 4px; top: 4px; right: 40px; padding: 3px 6px; border-radius: 6px; background: var(--warn); color: #fff; font-size: 10px; font-weight: 700; }

.submitbar {
  position: sticky; bottom: calc(64px + env(safe-area-inset-bottom)); z-index: 10;
  background: var(--card); border-top: 1px solid var(--line);
  margin: 0 -16px -28px; padding: 12px 16px 16px; display: flex; flex-direction: column; gap: 6px;
}
.no-tabs .submitbar { bottom: 0; }

/* Daftar & tabel */
.list { display: flex; flex-direction: column; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.list > * { padding: 12px 16px; border-bottom: 1px solid var(--line); }
.list > *:last-child { border-bottom: none; }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.kv > :first-child { color: var(--muted); }
.kv > :last-child { font-weight: 700; text-align: right; }

/* Kalender */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal .dow { font-size: 11px; font-weight: 700; color: var(--muted); text-align: center; padding: 4px 0; }
.cal .day {
  aspect-ratio: 1 / 1; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  text-decoration: none; color: var(--ink); font-size: 13px; font-weight: 600; min-height: 40px;
}
.cal .day.blank { visibility: hidden; }
.cal .day.today { border: 2px solid var(--primary); }
.dot { width: 9px; height: 9px; border-radius: 999px; }
.dot.ok { background: var(--primary); }
.dot.bad { background: var(--danger); }
.dot.warn { background: var(--warn); }
.dot.pending { border: 1.5px dashed var(--dash); }
.dot.off { background: transparent; border: 1.5px solid var(--line-strong); width: 9px; height: 2px; border-radius: 1px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Lightbox */
.lightbox { border: none; padding: 0; margin: 0; width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none; background: #050908; color: #fff; }
.lightbox::backdrop { background: rgba(0,0,0,0.9); }
.lb-in { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.lb-in img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-btn { position: absolute; width: 48px; height: 48px; border-radius: 999px; border: none; background: rgba(255,255,255,0.14); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.lb-btn svg { width: 24px; height: 24px; }
.lb-close { top: calc(12px + env(safe-area-inset-top)); right: 12px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lb-count { position: absolute; bottom: calc(16px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; font-family: var(--mono); font-size: 13px; opacity: 0.85; }

/* Login */
.login { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login .card { width: 100%; max-width: 400px; padding: 24px; display: flex; flex-direction: column; gap: 18px; }

/* ---------- iPad & layar lebar ---------- */
@media (min-width: 700px) {
  body { font-size: 16px; }
  .role-pill { display: inline-flex; }
  .page { padding: 24px 24px 36px; gap: 22px; }
  h1, .h1 { font-size: 28px; }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .kitchens { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .upgrid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .gallery { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .gallery .thumb { height: 150px; }
  .submitbar { margin: 0 -24px -36px; padding: 12px 24px 18px; }
}
@media (min-width: 1024px) {
  body { padding-bottom: 0; }
  .tabbar { display: none; }
  .toptabs { display: flex; }
  .submitbar { bottom: 0; }
  .kitchens { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
