/* KOPIGIMBAL Cost & Inventory — palet brand sama dengan INVOICE KOPIGIMBAL */
@font-face { font-family: "Montserrat"; font-weight: 400; font-display: swap; src: url(../fonts/montserrat-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 500; font-display: swap; src: url(../fonts/montserrat-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 600; font-display: swap; src: url(../fonts/montserrat-latin-600-normal.woff2) format("woff2"); }
@font-face { font-family: "Montserrat"; font-weight: 700; font-display: swap; src: url(../fonts/montserrat-latin-700-normal.woff2) format("woff2"); }

:root {
  --espresso: #2B1D16;
  --roast: #4E342E;
  --gold: #D3AF37;
  --gold-dk: #8F7119;
  --latte: #F3E9DC;
  --foam: #FFFDF9;
  --paper: #FFFFFF;
  --line: #E6D8C6;
  --ink: #2B1D16;
  --ink-2: #6B5A50;
  --ok: #1E6B3A;   --ok-bg: #E3F1E6;
  --bad: #A8322A;  --bad-bg: #FBE7E3;
  --warn: #8A5A00; --warn-bg: #FBF0D6;
  /* komposisi harga */
  --c-bahan: #6F4E37;
  --c-pack: #B9A08A;
  --c-margin: #D3AF37;
  --c-loss: #A8322A;

  --r-s: 8px; --r-m: 12px; --r-l: 18px;
  --sidebar: 236px;
  --font: "Montserrat", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--foam); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.5; }
body { -webkit-tap-highlight-color: transparent; min-height: 100dvh; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--roast); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { font-size: 16px; } /* cegah auto-zoom iOS */
.num, td.num, .kpi b { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ------------------------------------------------------------ boot & login */
.boot { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--ink-2); }
.boot img { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .45; } }

.login { min-height: 100dvh; display: grid; grid-template-columns: 1fr; background: var(--espresso); }
.login-art { color: var(--latte); padding: 40px 32px 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 18px; }
.login-art img { width: 64px; height: 64px; }
.login-art h1 { font-size: 2rem; color: var(--foam); max-width: 14ch; }
.login-art p { max-width: 36ch; color: #CDBBA8; }
.login-card { background: var(--foam); border-radius: var(--r-l) var(--r-l) 0 0; margin-top: 28px; padding: 28px 24px 40px; display: grid; gap: 16px; align-content: start; }
@media (min-width: 900px) {
  .login { grid-template-columns: 1.1fr 1fr; }
  .login-art { padding: 64px; justify-content: center; }
  .login-art h1 { font-size: 2.8rem; }
  .login-card { margin: 0; border-radius: 0; padding: 64px; justify-content: center; grid-template-columns: minmax(0, 380px); align-content: center; }
}

/* ------------------------------------------------------------ shell */
.shell { min-height: 100dvh; }
.sidebar { display: none; }
.topbar { position: sticky; top: 0; z-index: 20; background: var(--espresso); color: var(--latte); display: flex; align-items: center; gap: 12px;
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px; }
.topbar img { width: 30px; height: 30px; }
.topbar .t { font-weight: 700; color: var(--foam); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.net { font-size: .75rem; padding: 3px 9px; border-radius: 999px; background: rgba(255,255,255,.1); color: var(--latte); border: 0; cursor: pointer; white-space: nowrap; }
.net.off { background: var(--bad); color: #fff; }
.net.q { background: var(--gold); color: var(--espresso); }

main { padding: 18px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 1180px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .sub { color: var(--ink-2); font-size: .9rem; margin-top: 2px; }

.bottomnav { position: fixed; z-index: 30; inset: auto 0 0 0; background: var(--paper); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); padding-bottom: env(safe-area-inset-bottom); }
.bottomnav a { display: grid; justify-items: center; gap: 2px; padding: 8px 2px 9px; font-size: .7rem; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.bottomnav a svg { width: 22px; height: 22px; }
.bottomnav a.on { color: var(--espresso); }
.bottomnav a.on svg { color: var(--gold-dk); }

.more-sheet .navlist { display: grid; gap: 4px; }

@media (min-width: 1000px) {
  .shell { display: grid; grid-template-columns: var(--sidebar) 1fr; }
  .topbar, .bottomnav { display: none; }
  .sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; background: var(--espresso); color: var(--latte); padding: 20px 12px; gap: 4px; overflow-y: auto; }
  .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
  .brand img { width: 38px; height: 38px; }
  .brand b { display: block; color: var(--foam); font-size: .95rem; }
  .brand span { font-size: .75rem; color: #B9A797; }
  main { padding: 28px 32px 48px; width: 100%; }
  .side-foot { margin-top: auto; padding: 12px 10px 0; border-top: 1px solid rgba(255,255,255,.08); font-size: .8rem; color: #B9A797; display: grid; gap: 8px; }
}
.navlink { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: var(--r-s); color: inherit; text-decoration: none; font-weight: 500; font-size: .92rem; }
.navlink svg { width: 20px; height: 20px; flex: none; opacity: .8; }
.sidebar .navlink:hover { background: rgba(255,255,255,.06); }
.sidebar .navlink.on { background: var(--gold); color: var(--espresso); font-weight: 700; }
.sidebar .navlink.on svg { opacity: 1; }
.more-sheet .navlink { color: var(--ink); padding: 12px; }
.more-sheet .navlink.on { background: var(--latte); font-weight: 700; }
.badge { margin-left: auto; min-width: 20px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .72rem; font-weight: 700; text-align: center; }

/* ------------------------------------------------------------ building blocks */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; }
.panel + .panel, .stack > * + * { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.grid { display: grid; gap: 16px; }
@media (min-width: 760px) { .g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g-side { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; } }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: var(--r-s); padding: 9px 16px;
  font-weight: 600; cursor: pointer; background: var(--latte); color: var(--espresso); min-height: 42px; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--espresso); color: var(--foam); }
.btn.gold { background: var(--gold); color: var(--espresso); }
.btn.ghost { background: transparent; border-color: var(--line); }
.btn.danger { background: var(--bad-bg); color: var(--bad); }
.btn.sm { min-height: 34px; padding: 5px 11px; font-size: .85rem; }
.btn.icon { padding: 0; width: 38px; min-height: 38px; }
.btn svg { width: 18px; height: 18px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.field { display: grid; gap: 5px; }
.field > span { font-size: .82rem; font-weight: 600; color: var(--roast); }
.field .hint { font-size: .78rem; color: var(--ink-2); }
.field .err { font-size: .78rem; color: var(--bad); }
.input, select.input, textarea.input { width: 100%; border: 1px solid var(--line); background: var(--paper); border-radius: var(--r-s); padding: 9px 11px; min-height: 42px; }
.input:focus { border-color: var(--gold-dk); outline: none; box-shadow: 0 0 0 3px rgba(211,175,55,.25); }
.input.bad { border-color: var(--bad); }
.input.num { text-align: right; }
.form-grid { display: grid; gap: 12px; }
@media (min-width: 600px) { .form-grid.c2 { grid-template-columns: 1fr 1fr; } .form-grid.c3 { grid-template-columns: repeat(3, 1fr); } .span2 { grid-column: span 2; } }
label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.check input { width: 18px; height: 18px; accent-color: var(--espresso); }

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .input { width: auto; flex: 1 1 180px; }
.toolbar input[type=month], .toolbar input[type=date], .toolbar select.input { flex: 0 1 auto; }
.seg { display: inline-flex; background: var(--latte); border-radius: var(--r-s); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 6px; font-weight: 600; font-size: .85rem; cursor: pointer; color: var(--ink-2); }
.seg button.on { background: var(--paper); color: var(--espresso); box-shadow: 0 1px 2px rgba(43,29,22,.12); }

/* tabel */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--paper); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .78rem; font-weight: 700; color: var(--roast); background: var(--latte); padding: 9px 12px; white-space: nowrap; position: sticky; top: 0; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable::after { content: "↕"; opacity: .35; margin-left: 4px; }
th.asc::after { content: "↑"; opacity: .9; } th.desc::after { content: "↓"; opacity: .9; }
td { padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.click { cursor: pointer; } tr.click:hover td { background: #FBF6EE; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-2); }

/* kartu daftar untuk ponsel */
.cards { display: grid; gap: 10px; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px 14px; display: grid; gap: 6px; }
.card.click { cursor: pointer; }
.card .row { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.card .row b { font-variant-numeric: tabular-nums; }

/* status */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.neutral { background: var(--latte); color: var(--roast); }

/* KPI */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 760px) { .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.kpi { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px 14px; display: grid; gap: 2px; min-width: 0; }
.kpi span { font-size: .8rem; color: var(--ink-2); }
.kpi b { font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi small { font-size: .76rem; color: var(--ink-2); }
.kpi.alert b { color: var(--bad); }

/* hero laba: kartu gelap tunggal */
.profit { background: var(--espresso); color: var(--latte); border-radius: var(--r-l); padding: 20px; display: grid; gap: 16px; }
.profit .big { font-size: 2.1rem; font-weight: 700; color: var(--foam); font-variant-numeric: tabular-nums; line-height: 1.1; }
.profit .lbl { font-size: .85rem; color: #CDBBA8; }
.flow { display: grid; gap: 6px; font-size: .88rem; }
.flow div { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
.flow div.tot { border-top: 1px solid rgba(255,255,255,.15); padding-top: 6px; font-weight: 700; color: var(--foam); }
.flow .neg { color: #E9B4AA; }

/* ------------------------------------------------------------ bar komposisi harga (elemen khas) */
.split { display: grid; gap: 6px; }
.split-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--latte); }
.split-bar i { display: block; height: 100%; }
.split-bar .b { background: var(--c-bahan); }
.split-bar .p { background: var(--c-pack); }
.split-bar .m { background: var(--c-margin); }
.split-bar .l { background: repeating-linear-gradient(45deg, var(--c-loss) 0 4px, #C9584F 4px 8px); }
.split-bar .t { width: 2px; background: var(--espresso); margin-left: -1px; position: relative; z-index: 1; }
.split.mini .split-bar { height: 8px; border-radius: 4px; min-width: 90px; }
.split-legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .78rem; color: var(--ink-2); }
.split-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.split-big .split-bar { height: 34px; border-radius: 10px; }
.split-big .nums { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.split-big .nums div { display: grid; }
.split-big .nums b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.split-big .nums span { font-size: .78rem; color: var(--ink-2); }

/* ------------------------------------------------------------ resep */
.rlines { display: grid; gap: 8px; }
.rline { display: grid; grid-template-columns: 1fr; gap: 8px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-s); background: var(--foam); }
.rline .cost { font-weight: 700; font-variant-numeric: tabular-nums; }
@media (min-width: 760px) { .rline { grid-template-columns: minmax(0, 2.4fr) 96px 90px 80px 110px 40px; align-items: center; } }
.rline-head { display: none; }
@media (min-width: 760px) { .rline-head { display: grid; grid-template-columns: minmax(0, 2.4fr) 96px 90px 80px 110px 40px; gap: 8px; padding: 0 10px; font-size: .76rem; font-weight: 700; color: var(--roast); } }

/* ------------------------------------------------------------ POS penjualan */
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.pos-item { text-align: left; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-m); padding: 10px 12px; cursor: pointer; display: grid; gap: 4px; min-height: 76px; }
.pos-item b { font-size: .88rem; line-height: 1.25; }
.pos-item span { font-size: .82rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.pos-item.in { border-color: var(--espresso); box-shadow: inset 0 0 0 1px var(--espresso); }
.pos-item .q { justify-self: start; background: var(--espresso); color: var(--foam); border-radius: 999px; padding: 0 8px; font-size: .75rem; font-weight: 700; }
.cart { display: grid; gap: 8px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r-s); }
.qty button { border: 0; background: none; width: 34px; height: 34px; cursor: pointer; font-size: 1.1rem; }
.qty input { width: 46px; text-align: center; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); height: 34px; }
.sticky-sum { position: static; }
@media (min-width: 1000px) { .sticky-sum { position: sticky; top: 20px; z-index: 5; } }
.mob-bar { position: fixed; z-index: 25; left: 12px; right: 12px; bottom: calc(68px + env(safe-area-inset-bottom)); background: var(--espresso); color: var(--foam);
  border-radius: var(--r-m); padding: 10px 12px 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; box-shadow: 0 8px 24px rgba(43,29,22,.3); }
.mob-bar b { font-variant-numeric: tabular-nums; }
@media (min-width: 1000px) { .mob-bar { display: none !important; } }

/* ------------------------------------------------------------ modal, toast */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(43,29,22,.45); display: grid; align-items: end; }
.modal { background: var(--foam); border-radius: var(--r-l) var(--r-l) 0 0; max-height: 92dvh; overflow: auto; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  width: 100%; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; position: sticky; bottom: -18px; background: var(--foam); padding: 10px 0 0; }
@media (min-width: 700px) {
  .overlay { align-items: center; justify-items: center; padding: 24px; }
  .modal { border-radius: var(--r-l); width: min(640px, 100%); max-height: 88dvh; padding: 22px 24px; }
  .modal.wide { width: min(920px, 100%); }
}
#toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); display: grid; gap: 8px; width: min(440px, calc(100% - 24px)); }
@media (min-width: 1000px) { #toasts { bottom: 24px; } }
.toast { background: var(--espresso); color: var(--foam); padding: 11px 14px; border-radius: var(--r-s); font-size: .9rem; box-shadow: 0 6px 20px rgba(43,29,22,.25); animation: up .18s ease-out; }
.toast.err { background: var(--bad); }
.toast.ok::before { content: "✓  "; color: var(--gold); font-weight: 700; }

.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-block { padding: 40px; display: grid; justify-items: center; gap: 10px; color: var(--ink-2); }
.skel { background: linear-gradient(90deg, var(--latte), #FAF4EB, var(--latte)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r-s); min-height: 70px; }
@keyframes sk { to { background-position: -200% 0; } }

.alert-item { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; padding: 10px 0; border-top: 1px solid var(--line); font-size: .88rem; }
.alert-item:first-child { border-top: 0; }
.alert-dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; background: var(--warn); }
.alert-dot.KRITIS { background: var(--bad); } .alert-dot.INFO { background: var(--ink-2); }

.chart-box { position: relative; height: 260px; }
.chart-box.tall { height: 340px; }
.note { background: var(--latte); border-radius: var(--r-s); padding: 10px 12px; font-size: .86rem; color: var(--roast); }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: .9rem; }
.kv dt { color: var(--ink-2); } .kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.only-desk { display: none; }
@media (min-width: 760px) { .only-desk { display: block; } .only-mob { display: none; } }
