/* =========================================================
   Dapur Rasa — Panel Pemilik
   ========================================================= */

:root {
  --cream: #fdf8f1;
  --card: #ffffff;
  --ink: #231a13;
  --ink-soft: #6f6257;
  --line: #ece0d3;
  --orange: #e2572c;
  --orange-soft: #fdf1e9;
  --green: #2f7d4f;
  --green-soft: #eaf5ee;
  --amber: #a9701a;
  --amber-soft: #fdf4e3;
  --red: #b23b2e;
  --red-soft: #fbecea;
  --shadow: 0 18px 40px -28px rgba(35, 26, 19, 0.45);
  --radius: 18px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body.admin {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.is-locked { overflow: hidden; }

h1, h2, h3 { font-family: var(--font-display); margin: 0; line-height: 1.15; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
canvas { display: block; }

/* ---------- Layout ---------- */
.admin-shell { display: grid; grid-template-columns: 258px minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 24px 18px;
  background: #221a14;
  color: #f6ece0;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px; }
.brand__mark {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(140deg, #f5b942, #e2572c);
  color: #2a1a10;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.95rem;
}
.brand strong { display: block; font-family: var(--font-display); font-size: 1.02rem; }
.brand small { display: block; font-size: 0.66rem; letter-spacing: 0.16em; text-transform: uppercase; color: #c7b6a3; }

.side-nav { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; }
.side-nav__item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: none;
  color: #cdbcaa;
  font-size: 0.86rem;
  font-weight: 600;
  text-align: left;
  transition: background 0.18s, color 0.18s;
}
.side-nav__item span { width: 18px; text-align: center; opacity: 0.75; }
.side-nav__item:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side-nav__item.is-active { background: #f6ece0; color: #221a14; }
.side-nav__item.is-active span { opacity: 1; color: var(--orange); }

.sidebar__foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 0 6px; }
.sidebar__foot p { font-size: 0.7rem; color: #9d8c7b; line-height: 1.5; }

.admin-main { padding: 26px clamp(18px, 3vw, 40px) 56px; min-width: 0; }

.admin-top {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}
.eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 700;
  margin-bottom: 6px;
}
.admin-top h1 { font-size: clamp(1.6rem, 2.6vw, 2.15rem); }
.admin-top__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.date-pill {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
}

/* ---------- Tombol ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 18px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.85rem;
  font-weight: 700;
  transition: transform 0.15s, background 0.18s, border-color 0.18s, color 0.18s;
}
.btn:hover { transform: translateY(-1px); }
.btn--primary { background: var(--orange); color: #fff; }
.btn--primary:hover { background: #cf4a22; }
.btn--outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn--outline:hover { border-color: #d6c3ae; }
.btn--ghost { background: rgba(255, 255, 255, 0.08); color: #f6ece0; border-color: rgba(255, 255, 255, 0.16); }
.btn--ghost:hover { background: rgba(255, 255, 255, 0.16); }
.btn--sm { padding: 7px 13px; font-size: 0.76rem; }
.btn--danger { background: var(--red-soft); color: var(--red); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; transform: none; }

.link-btn {
  border: none; background: none; padding: 0;
  font-size: 0.76rem; font-weight: 700;
  color: var(--orange);
  text-decoration: underline; text-underline-offset: 3px;
}

.icon-btn {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: #fff;
}
.icon-btn--sm { width: 26px; height: 26px; font-size: 1rem; line-height: 1; }
.icon-btn:hover { background: #fbf5ec; }

/* ---------- Halaman ---------- */
.page { display: none; animation: fade 0.22s ease; }
.page.is-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; margin-bottom: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px;
}
.card__head h2 { font-size: 1.02rem; }
.card__head .muted, .muted { font-size: 0.76rem; color: var(--ink-soft); font-weight: 600; }
.card + .card { margin-top: 16px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.kpi p { font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-soft); font-weight: 700; }
.kpi strong { display: block; font-family: var(--font-display); font-size: 1.5rem; margin: 6px 0 4px; }
.kpi small { font-size: 0.72rem; color: var(--ink-soft); }

/* ---------- Grafik ---------- */
.chart { display: flex; align-items: flex-end; gap: 10px; height: 190px; padding-top: 10px; }
.chart__col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 8px; height: 100%; }
.chart__bar {
  width: 100%;
  min-height: 4px;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #f0a03c, #e2572c);
  position: relative;
  transition: height 0.4s ease;
}
.chart__bar--flat { background: #efe3d5; }
.chart__val { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 0.64rem; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.chart__col small { font-size: 0.68rem; color: var(--ink-soft); font-weight: 600; }

/* ---------- Tabel ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
.table { width: 100%; font-size: 0.82rem; min-width: 520px; }
.table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 0.68rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.table td { padding: 11px 10px; border-bottom: 1px solid #f6eee4; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table td strong { font-weight: 700; }
.table .num { text-align: right; white-space: nowrap; }
.table__actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.table__sub { display: block; font-size: 0.7rem; color: var(--ink-soft); }

/* ---------- Badge & chip ---------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.badge--wait { background: var(--amber-soft); color: var(--amber); }
.badge--ok { background: var(--orange-soft); color: #a3451d; }
.badge--ship { background: #eaf0fb; color: #3a5ba8; }
.badge--done { background: var(--green-soft); color: var(--green); }
.badge--cancel { background: var(--red-soft); color: var(--red); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.chip {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ink-soft);
}
.chip.is-active { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Daftar ringkas ---------- */
.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 0.82rem; }
.alert-row__main { display: flex; align-items: center; gap: 9px; min-width: 0; }
.alert-row__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); flex-shrink: 0; }
.alert-row__dot--danger { background: var(--red); }
.alert-row__dot--ok { background: var(--green); }
.alert-row small { color: var(--ink-soft); font-size: 0.72rem; }

.pay-breakdown { display: flex; flex-direction: column; gap: 10px; }
.pay-row { font-size: 0.82rem; }
.pay-row__top { display: flex; justify-content: space-between; margin-bottom: 4px; }
.pay-row__bar { height: 7px; border-radius: 999px; background: #f4eade; overflow: hidden; }
.pay-row__fill { height: 100%; border-radius: 999px; background: var(--orange); }
.net { display: flex; justify-content: space-between; align-items: baseline; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); font-size: 0.82rem; color: var(--ink-soft); }
.net strong { font-family: var(--font-display); font-size: 1.15rem; color: var(--ink); }

.empty-note {
  padding: 22px 14px;
  text-align: center;
  font-size: 0.82rem;
  color: var(--ink-soft);
  border: 1px dashed var(--line);
  border-radius: 14px;
}

/* ---------- Form ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink-soft); }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--ink);
}
.field textarea { resize: vertical; min-height: 74px; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(226, 87, 44, 0.25); border-color: var(--orange); }
.field small { font-size: 0.7rem; color: var(--ink-soft); }
.field--readonly input { background: #f7f1e8; }

.form-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 18px; }
.form-note { font-size: 0.76rem; color: var(--ink-soft); margin-top: 12px; }

.radio-row { display: flex; gap: 10px; flex-wrap: wrap; }
.radio-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: #fff;
}
.radio-pill input { accent-color: var(--orange); }

.info-card {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 13px 15px;
  background: #fdfaf5;
  font-size: 0.8rem;
  color: var(--ink-soft);
  min-height: 96px;
}
.info-card strong { display: block; color: var(--ink); font-size: 0.92rem; margin-bottom: 4px; }
.info-card ul { margin: 8px 0 0; padding-left: 16px; }

/* Sales order entry */
.so-items { display: flex; flex-direction: column; gap: 8px; }
.so-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 82px 104px 110px 30px;
  gap: 8px;
  align-items: center;
}
.so-row select, .so-row input {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.84rem;
  background: #fff;
}
.so-price, .so-line { font-size: 0.82rem; text-align: right; }
.so-total {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line);
}
.so-total span { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); font-weight: 700; }
.so-total strong { font-family: var(--font-display); font-size: 1.4rem; }
.stock-note { margin-top: 12px; font-size: 0.8rem; }
.stock-note--ok { color: var(--green); }
.stock-note--warn { color: var(--red); }

.form-grid .col-span-2 { grid-column: span 2; }

.sr-input {
  width: 100%;
  max-width: 110px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.84rem;
  text-align: right;
}

/* ---------- Modal dokumen ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background: rgba(28, 20, 14, 0.55);
  backdrop-filter: blur(3px);
  overflow-y: auto;
}
.modal[hidden] { display: none; }
.doc-modal__box {
  width: min(760px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, 0.6);
}
.doc-modal__bar { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 12px; }

/* ---------- Dokumen ---------- */
.doc {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 26px 28px;
  color: #241a13;
  font-size: 0.84rem;
}
.doc__head { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; border-bottom: 2px solid #241a13; padding-bottom: 14px; }
.doc__brand { display: flex; gap: 11px; align-items: center; }
.doc__mark {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  background: #241a13; color: #f5b942;
  font-family: var(--font-display); font-weight: 700;
}
.doc__brand strong { display: block; font-family: var(--font-display); font-size: 1rem; }
.doc__brand small { display: block; font-size: 0.68rem; color: #6f6257; }
.doc__title { text-align: right; }
.doc__title h2 { font-size: 1.05rem; letter-spacing: 0.04em; text-transform: uppercase; }
.doc__title p { font-size: 0.78rem; font-weight: 700; color: #a3451d; margin-top: 3px; }

.doc__meta { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 22px; margin: 16px 0; }
.doc__meta div { display: flex; gap: 6px; font-size: 0.78rem; }
.doc__meta dt { color: #6f6257; min-width: 104px; }
.doc__meta dd { margin: 0; font-weight: 600; }

.doc__table { width: 100%; font-size: 0.78rem; margin-top: 6px; }
.doc__table th { background: #f7f1e8; text-align: left; padding: 7px 9px; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.05em; }
.doc__table td { padding: 7px 9px; border-bottom: 1px solid #f0e6da; }
.doc__table .num { text-align: right; }
.doc__table tfoot td { font-weight: 700; border-bottom: none; }

.doc__note { margin-top: 12px; font-size: 0.76rem; color: #6f6257; background: #fdfaf5; border: 1px dashed #e8dbcb; border-radius: 10px; padding: 9px 12px; }
.doc__sign { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 26px; text-align: center; font-size: 0.74rem; color: #6f6257; }
.doc__sign span { display: block; margin-bottom: 34px; }
.doc__sign strong { display: block; border-top: 1px solid #c9b7a4; padding-top: 6px; font-weight: 600; color: #241a13; }
.doc__foot { margin-top: 18px; font-size: 0.66rem; color: #9a8a7a; text-align: center; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  padding: 11px 20px;
  border-radius: 999px;
  background: #241a13;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 80;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Responsif ---------- */
@media (max-width: 1080px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 820px) {
  .admin-shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; padding: 16px; }
  .side-nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .side-nav__item { white-space: nowrap; padding: 8px 12px; }
  .sidebar__foot { flex-direction: row; align-items: center; justify-content: space-between; }
  .sidebar__foot p { display: none; }
  .admin-main { padding: 20px 16px 44px; }
  .form-grid, .form-grid--3 { grid-template-columns: minmax(0, 1fr); }
  .form-grid .col-span-2 { grid-column: auto; }
  .so-row { grid-template-columns: minmax(0, 1fr) 70px 88px 30px; }
  .so-row .so-line { grid-column: 2 / 4; text-align: left; }
  .so-row .so-price { display: none; }
  .field input, .field select, .field textarea, .so-row select, .so-row input { font-size: 16px; }
  .doc { padding: 18px 16px; }
  .doc__head { flex-direction: column; }
  .doc__title { text-align: left; }
  .doc__meta { grid-template-columns: minmax(0, 1fr); }
  .doc__sign { grid-template-columns: minmax(0, 1fr); gap: 22px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: minmax(0, 1fr); }
  .admin-top__actions { width: 100%; }
  .admin-top__actions .btn { flex: 1; }
}

/* ---------- Cetak ---------- */
@media print {
  body.admin { background: #fff; }
  .sidebar, .admin-top, .pages, .toast, .doc-modal__bar { display: none !important; }
  #docModal {
    position: static;
    display: block !important;
    padding: 0;
    background: #fff;
    backdrop-filter: none;
  }
  .doc-modal__box { box-shadow: none; border-radius: 0; padding: 0; width: 100%; }
  .doc { border: none; border-radius: 0; padding: 0; font-size: 11pt; }
}
