:root {
  --ink: #2b1d16;
  --muted: #7b6b60;
  --paper: #fffaf0;
  --cream: #f3e3c7;
  --line: #dfc9a9;
  --terracotta: #9b4f2f;
  --brown: #6f3f26;
  --olive: #586b45;
  --gold: #b7862b;
  --red: #923d33;
  --shadow: 0 14px 34px rgba(62, 38, 21, .12);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  font-family: "Source Sans 3", system-ui, sans-serif;
  background:
    linear-gradient(135deg, rgba(111,63,38,.08) 25%, transparent 25%) 0 0 / 26px 26px,
    linear-gradient(225deg, rgba(183,134,43,.08) 25%, transparent 25%) 0 0 / 26px 26px,
    #f8efdf;
  padding-bottom: 78px;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-header {
  background: linear-gradient(135deg, #5d351f, #8f5230 58%, #b7862b);
  color: #fff8e8;
  border-bottom: 6px solid rgba(43,29,22,.22);
}

.header-inner {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px 16px;
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 54px;
  height: 54px;
  border: 2px solid rgba(255,248,232,.72);
  display: grid;
  place-items: center;
  font-family: "Bebas Neue", sans-serif;
  font-size: 28px;
  letter-spacing: 1px;
  background: rgba(43,29,22,.18);
}

.kicker, .section-label {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: 12px;
  font-weight: 800;
  color: var(--gold);
}

.app-header .kicker { color: #f5d38b; }
h1, h2, h3 {
  margin: 0;
  font-family: "Bebas Neue", sans-serif;
  letter-spacing: .02em;
  line-height: .95;
}
h1 { font-size: clamp(34px, 8vw, 64px); }
h2 { font-size: clamp(28px, 6vw, 48px); }
h3 { font-size: 30px; }
.subtitle, .muted { margin: 6px 0 0; color: var(--muted); }
.app-header .subtitle { color: rgba(255,248,232,.84); }

.admin-pill, .action-btn, .print-tile {
  border: 1px solid rgba(43,29,22,.18);
  border-radius: 999px;
  padding: 10px 14px;
  background: #fff8e8;
  color: var(--brown);
  font-weight: 800;
  text-decoration: none;
  min-height: 44px;
}

.action-btn.primary { background: var(--brown); color: #fff8e8; }
.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.hero-panel, .admin-card, .shortcut-panel {
  background: rgba(255,250,240,.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 16px;
}
.hero-stats span {
  border: 1px solid var(--line);
  background: #fffdf8;
  padding: 10px;
  border-radius: 12px;
  text-align: center;
  font-weight: 800;
}
.hero-stats strong { display: block; font-size: 26px; color: var(--terracotta); }

.toolbar {
  display: grid;
  gap: 12px;
  margin: 18px 0 14px;
}
.toolbar-controls { display: grid; gap: 8px; }
.search-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fffdf8;
  color: var(--ink);
  padding: 12px 13px;
  min-height: 44px;
}

.tab-panel { display: none; }
.tab-panel.is-active { display: block; }
.page-shortcuts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.shortcut-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 0 0 12px;
  margin: -2px 0 4px;
}
.shortcut-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,250,240,.96);
  color: var(--brown);
  padding: 8px 7px;
  min-height: 40px;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 6px 14px rgba(62,38,21,.06);
  white-space: normal;
  line-height: 1.1;
  text-align: center;
  text-decoration: none;
}
.shortcut-chip.is-active {
  background: var(--brown);
  color: #fff8e8;
  border-color: var(--brown);
}
.section-shortcuts {
  margin-top: -4px;
}
.card-grid { display: grid; gap: 14px; }

.training-card {
  background: rgba(255,250,240,.97);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head {
  padding: 16px;
  background: linear-gradient(135deg, rgba(111,63,38,.12), rgba(183,134,43,.12));
  border-bottom: 1px solid var(--line);
}
.inline-title-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}
.inline-subtitle-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}
.inline-title-row h3 {
  min-width: 0;
}
.card-body { padding: 16px; }
.badge-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #f4e4ca;
  color: var(--brown);
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 800;
}
.phase {
  margin-top: 14px;
  border-top: 1px dashed rgba(123,107,96,.35);
  padding-top: 12px;
}
.phase h4 { margin: 0 0 8px; color: var(--brown); }
.clean-list { margin: 0; padding-left: 20px; }
.clean-list li { margin: 5px 0; }

.onboarding-grid .training-card {
  border-left: 7px solid var(--terracotta);
}
.timeline-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.recipe-photo {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: linear-gradient(135deg, #dbc39c, #936143);
}
.recipe-meta, .card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.small-btn {
  border: 1px solid var(--line);
  background: #fffdf8;
  color: var(--brown);
  border-radius: 999px;
  padding: 8px 10px;
  font-weight: 800;
}
.inline-edit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 9px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 1;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.logout-btn {
  background: #a94438;
  color: #fff;
  border-color: #a94438;
  font-weight: 800;
  font-size: 13px;
  padding: 8px 16px;
  white-space: nowrap;
}
[data-inline-title] {
  border-radius: 8px;
}
.inline-title-editing {
  outline: 2px solid var(--gold);
  background: #fffdf8;
  padding: 2px 5px;
}

.table-wrap {
  overflow-x: auto;
  background: rgba(255,250,240,.97);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; min-width: 760px; background: #fffdf8; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; }
th { background: var(--brown); color: #fff8e8; }
.ingredient-table {
  min-width: 0;
  table-layout: fixed;
}
.ingredient-table td {
  padding: 11px 12px;
  font-size: 18px;
}
.ingredient-table td:first-child {
  width: 58%;
  text-align: left;
  font-weight: 700;
}
.ingredient-table td:last-child {
  width: 42%;
  text-align: right;
  color: var(--brown);
  font-weight: 800;
}
.shift-off { color: var(--red); font-weight: 900; }
.shift-on { color: var(--olive); font-weight: 900; }

.print-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.print-tile {
  border-radius: var(--radius);
  min-height: 92px;
  background: rgba(255,250,240,.97);
  box-shadow: var(--shadow);
  text-align: left;
}
.print-list { display: grid; gap: 8px; margin-top: 16px; }

.mobile-tabs {
  position: fixed;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
  padding: 7px;
  background: rgba(255,250,240,.96);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.mobile-tab {
  border: 0;
  border-radius: 13px;
  min-height: 44px;
  background: transparent;
  color: var(--muted);
  font-weight: 900;
}
.mobile-tab.is-active { background: var(--brown); color: #fff8e8; }
.desktop-rail { display: none; }

.detail-modal {
  width: min(720px, calc(100% - 24px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}
.detail-modal::backdrop { background: rgba(43,29,22,.5); }
.modal-close {
  float: right;
  border: 0;
  background: transparent;
  font-size: 22px;
  font-weight: 900;
}

.hidden { display: none !important; }
.error-text { color: var(--red); font-weight: 800; }
.form-row { display: grid; gap: 6px; margin: 12px 0; }
.editor-layout { display: grid; gap: 14px; }
.record-list { display: grid; gap: 8px; align-content: start; }
.record-btn {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #fffdf8;
  padding: 10px;
  text-align: left;
  font-weight: 800;
}
.record-btn.is-active { background: var(--cream); border-color: var(--gold); }
.editor-form { display: grid; gap: 12px; }
.editor-form textarea { min-height: 140px; resize: vertical; }
.field-hint {
  color: var(--muted);
  font-weight: 700;
}
.editor-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255,253,248,.72);
  padding: 10px;
}
.editor-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.editor-section-head h3 {
  font-size: 24px;
}
.bahan-table {
  display: grid;
  gap: 7px;
}
.bahan-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(86px, .8fr) 38px;
  gap: 6px;
  align-items: center;
}
.bahan-head {
  display: none;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.small-btn.danger {
  color: var(--red);
  border-color: rgba(146,61,51,.35);
}
.bahan-row .search-input {
  min-height: 40px;
  padding: 9px 10px;
  border-radius: 11px;
}
.bahan-remove {
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  border-radius: 11px;
  overflow: hidden;
  text-indent: -999px;
  position: relative;
}
.bahan-remove::after {
  content: "x";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-indent: 0;
  font-size: 18px;
  font-weight: 900;
}
.schedule-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

/* ══ MOBILE: ringkas & padat, minim scroll ══ */
@media (max-width: 759px) {
  body { padding-bottom: 62px; }
  .app-shell { padding: 8px; }

  /* Header */
  .header-inner { padding: 8px 10px; grid-template-columns: 34px 1fr auto; gap: 6px; }
  .brand-mark { width: 34px; height: 34px; font-size: 17px; }
  h1 { font-size: clamp(24px, 7vw, 40px); }
  h2 { font-size: clamp(20px, 5.5vw, 30px); }
  h3 { font-size: 20px; }
  .app-header .subtitle { font-size: 13px; }

  /* Hero & panels */
  .hero-panel, .admin-card, .shortcut-panel { padding: 10px 12px; margin-bottom: 10px; }
  .hero-stats { gap: 5px; margin-top: 8px; }
  .hero-stats span { padding: 4px 3px; border-radius: 8px; }
  .hero-stats strong { font-size: 18px; }

  /* Kicker & labels */
  .kicker, .section-label { margin: 0 0 1px; font-size: 10px; }
  .subtitle, .muted { margin: 3px 0 0; font-size: 13px; }

  /* Toolbar */
  .toolbar { gap: 6px; margin: 8px 0; }
  .search-input { padding: 8px 10px; min-height: 36px; font-size: 14px; border-radius: 10px; }

  /* Shortcuts */
  .page-shortcuts { gap: 4px; }
  .shortcut-strip { gap: 4px; padding: 0 0 6px; margin: -1px 0 2px; }
  .shortcut-chip { font-size: 10px; padding: 4px 5px; min-height: 30px; border-radius: 12px; }
  .section-shortcuts { margin-top: -2px; }
  .section-shortcuts .shortcut-chip { font-size: 9px; padding: 3px 5px; min-height: 26px; }

  /* Cards */
  .card-grid { gap: 8px; }
  .card-head { padding: 10px 12px; }
  .card-body { padding: 10px 12px; }
  .onboarding-grid .training-card { border-left-width: 5px; }

  /* Badges */
  .badge-row { gap: 4px; margin-top: 6px; }
  .badge { padding: 2px 6px; font-size: 10px; }

  /* Phase */
  .phase { margin-top: 8px; padding-top: 6px; }
  .phase h4 { margin: 0 0 4px; font-size: 14px; }
  .clean-list { padding-left: 16px; }
  .clean-list li { margin: 2px 0; line-height: 1.2; font-size: 13px; }

  /* Timeline */
  .timeline-meta { gap: 4px; margin-top: 4px; }
  .timeline-meta .badge { font-size: 10px; padding: 2px 6px; }

  /* Recipe */
  .recipe-photo { aspect-ratio: 16 / 6; }
  .recipe-meta, .card-actions { margin-top: 6px; gap: 4px; }

  /* Ingredient table */
  .ingredient-table td { padding: 6px 7px; font-size: 13px; }

  /* Table */
  th, td { padding: 7px 8px; font-size: 13px; }

  /* Mobile tabs */
  .mobile-tabs { left: 5px; right: 5px; bottom: 5px; gap: 3px; padding: 4px; border-radius: 14px; }
  .mobile-tab { min-height: 32px; font-size: 10px; border-radius: 10px; font-weight: 800; }

  /* Print */
  .print-grid { gap: 6px; }
  .print-tile { min-height: 58px; padding: 6px 8px; font-size: 12px; }
  .print-list { gap: 5px; margin-top: 10px; }

  /* Schedule */
  .schedule-grid { gap: 5px; }

  /* Inline edit — mungil */
  .inline-edit-btn { min-height: 26px; padding: 2px 5px; font-size: 10px; border-radius: 7px; }
  .inline-title-row, .inline-subtitle-row { gap: 4px; }

  /* Admin panel */
  .admin-pill, .action-btn, .print-tile { padding: 6px 10px; min-height: 34px; font-size: 13px; }

  /* Small buttons */
  .small-btn { padding: 5px 7px; font-size: 12px; }

  /* Resep modal detail */
  .detail-modal { margin: 8px; }
}

@media (min-width: 760px) {
  body { padding-bottom: 0; }
  .app-shell { padding: 24px 24px 56px 292px; }
  .mobile-tabs { display: none; }
  .desktop-rail {
    display: grid;
    position: fixed;
    top: 128px;
    left: 16px;
    width: 236px;
    gap: 8px;
    z-index: 10;
  }
  .rail-link {
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255,250,240,.94);
    color: var(--brown);
    font-weight: 900;
    text-align: left;
    padding: 0 14px;
    box-shadow: 0 8px 18px rgba(62,38,21,.08);
  }
  .rail-link.is-active { background: var(--brown); color: #fff8e8; }
  .toolbar {
    grid-template-columns: 1fr minmax(280px, 460px);
    align-items: end;
  }
  .toolbar-controls { grid-template-columns: 1fr auto auto; }
  .hero-panel {
    display: grid;
    grid-template-columns: 1fr 420px;
    align-items: end;
  }
  .hero-stats { grid-template-columns: repeat(5, 1fr); }
  .page-shortcuts { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .onboarding-grid { grid-template-columns: 1fr; }
  .operasional-grid { grid-template-columns: 1fr; }
  .recipe-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .print-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .editor-layout { grid-template-columns: 280px 1fr; }
  .shortcut-strip {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
  .shortcut-chip {
    font-size: 14px;
    padding: 9px 10px;
  }
  .bahan-row { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 74px; }
  .bahan-remove {
    width: auto;
    min-width: 74px;
    text-indent: 0;
  }
  .bahan-remove::after { content: ""; }
  .bahan-head {
    display: grid;
  }
  .schedule-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* ── Admin mode: tombol edit hanya muncul saat login ── */
.inline-edit-btn,
[data-edit-ui],
[data-edit-title] {
  display: none;
}
body.inline-admin-enabled .inline-edit-btn,
body.inline-admin-enabled [data-edit-ui],
body.inline-admin-enabled [data-edit-title] {
  display: inline-flex;
}

@media print {
  .app-header, .desktop-rail, .mobile-tabs, .toolbar, .admin-pill, .card-actions, .print-grid, .shortcut-panel, .shortcut-strip,
  .inline-edit-btn, [data-edit-ui], [data-edit-title] { display: none !important; }
  body { background: #fff; padding: 0; }
  .app-shell { width: 100%; padding: 0; }
  .tab-panel { display: block !important; break-before: page; }
  .training-card, .hero-panel, .table-wrap { box-shadow: none; break-inside: avoid; }
}
