/* Apotek app styles. Tokens first; dark mode follows the system setting. */
:root {
  --bg: #eef3f1;
  --surface: #fbfdfc;
  --sunk: #e5edea;
  --ink: #142320;
  --muted: #52635e;
  --line: #d3dfdb;
  --accent: #0d6b63;
  --accent-ink: #ffffff;
  --accent-soft: #d6ece8;
  --ok: #24693a; --ok-bg: #dcefe0;
  --warn: #8a4f06; --warn-bg: #fbeacd;
  --bad: #a3271f; --bad-bg: #f8e0dc;
  --info: #23598a; --info-bg: #dce9f5;
  --off: #5f6b67; --off-bg: #e4eae8;
  --g-bebas: #24693a; --g-terbatas: #23598a; --g-keras: #a3271f; --g-oot: #7a3d91; --g-alkes: #5f6b67;
  --banner: #102a26; --banner-ink: #cfe7e1;
  --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%2352635e' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --shadow: rgba(16,48,42,.26);
  --font-display: "Sora", "Segoe UI", system-ui, sans-serif;
  --font-body: "Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513; --surface: #16201d; --sunk: #1e2a27; --ink: #e3eeeb; --muted: #9fb3ad; --line: #2b3a36;
    --accent: #6fd0c4; --accent-ink: #062320; --accent-soft: #173a35;
    --ok: #8fd3a0; --ok-bg: #18301f; --warn: #f0b765; --warn-bg: #382711; --bad: #f29a90; --bad-bg: #3a1b17;
    --info: #94c3ec; --info-bg: #172b3c; --off: #a9b6b2; --off-bg: #232e2b;
    --g-bebas: #8fd3a0; --g-terbatas: #94c3ec; --g-keras: #f29a90; --g-oot: #d5a6e8; --g-alkes: #a9b6b2;
    --banner: #081210; --banner-ink: #b9d6cf; --shadow: rgba(0,0,0,.5);
    --chev: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%239fb3ad' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 15px; line-height: 1.5; overflow-x: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.eyebrow { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 0; }
.tabs { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 10px 8px; font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab .n { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--warn-bg); color: var(--warn); font-size: 11.5px; text-align: center; }
.scr { padding: 16px; display: grid; gap: 14px; min-width: 0; align-content: start; }
.scr h2 { font-family: var(--font-display); font-size: 19px; line-height: 1.25; margin: 0; }
.scr h3 { font-size: 15px; margin: 0; }
.sub { font-size: 13px; color: var(--muted); margin: 0; }
.tiny { font-size: 12px; color: var(--muted); margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.btn { border: 0; border-radius: 10px; padding: 10px 14px; font-weight: 700; background: var(--accent); color: var(--accent-ink); }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 8px; white-space: nowrap; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn.quiet { background: transparent; color: var(--muted); border: 1px solid var(--line); font-weight: 600; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 600; color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.off { background: var(--off-bg); color: var(--off); }
.badge.acc { background: var(--accent-soft); color: var(--accent); }
/* tanda golongan obat: lingkaran berwarna seperti pada kemasan */
.gol { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.gol i { width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center; font-style: normal; font-size: 8px; line-height: 1; }
.gol.bebas { color: var(--g-bebas); } .gol.bebas i { background: currentColor; }
.gol.terbatas { color: var(--g-terbatas); } .gol.terbatas i { background: currentColor; }
.gol.keras { color: var(--g-keras); } .gol.keras i { background: currentColor; color: var(--surface); }
.gol.oot { color: var(--g-oot); } .gol.oot i { background: currentColor; }
.gol.alkes { color: var(--g-alkes); } .gol.alkes i { border-radius: 3px; }
.card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 8px; min-width: 0; }
.card.tint { background: var(--sunk); border-color: transparent; }
.card.warnbox { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.card.okbox { background: var(--ok-bg); border-color: transparent; }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; font-variant-numeric: tabular-nums; }
.kv span:first-child { color: var(--muted); }
.kv.total { font-weight: 700; font-size: 16px; border-top: 1px dashed var(--line); padding-top: 8px; }
.kv.total span:first-child { color: var(--ink); }
.mono { font-family: var(--font-mono); font-size: 12.5px; }
.num { font-variant-numeric: tabular-nums; }
input[type=text], input[type=number], input[type=search], input[type=password], input[type=date], select { width: 100%; min-width: 0; height: 40px; border: 1px solid var(--line); background: var(--sunk); border-radius: 8px; padding: 0 10px; font-size: 14.5px; line-height: normal; }
/* dropdown: tampilan sendiri, bukan bawaan browser */
select { -webkit-appearance: none; appearance: none; padding: 0 36px 0 12px; background-color: var(--sunk); background-image: var(--chev); background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px; cursor: pointer; text-overflow: ellipsis; white-space: nowrap; overflow: hidden; transition: border-color .15s, background-color .15s; }
select:hover { border-color: var(--muted); }
select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select:disabled { opacity: .55; cursor: not-allowed; }
select option { background: var(--surface); color: var(--ink); }
input[type=text]:focus-visible, input[type=number]:focus-visible, input[type=search]:focus-visible, input[type=password]:focus-visible, input[type=date]:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field label { min-height: 20px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.check input { flex: none; margin-top: 3px; }
.shiftbar { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; background: var(--sunk); border-radius: 10px; padding: 8px 12px; font-size: 13px; }
.authbox { max-width: 380px; margin: 8px auto; width: 100%; display: grid; gap: 14px; }
.authbox .head { display: grid; gap: 4px; justify-items: center; text-align: center; }
.logo-lockup { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.logo-lockup .mark { height: 52px; width: auto; }
/* wordmark is a mask, so it takes the text colour in light and dark mode */
.logo-lockup .word { width: 108px; height: 36px; background: var(--ink); -webkit-mask: url(/img/logo-word.png) left center / contain no-repeat; mask: url(/img/logo-word.png) left center / contain no-repeat; }
.pwrow { display: flex; gap: 6px; }
.pwrow input { flex: 1; }
.errbox { background: var(--bad-bg); color: var(--bad); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; }
.tbl { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 11.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 700; background: var(--sunk); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--sunk); }
tr.open td { background: var(--accent-soft); }

/* kasir */
.pos { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .pos { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); } }
.plist { display: grid; gap: 0; max-height: 430px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; }
.pitem { display: grid; gap: 4px; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 9px 12px; width: 100%; }
.polines { display: grid; gap: 8px; }
.poline { border: 1px solid var(--line); border-radius: 10px; padding: 10px; display: grid; gap: 6px; }
.ubtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.ubtn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 9px; font-size: 12.5px; font-weight: 600; color: var(--accent); display: inline-flex; gap: 5px; align-items: center; }
.ubtn b { color: var(--ink); font-variant-numeric: tabular-nums; }
.ubtn:hover { border-color: var(--accent); }
.ubtn:disabled { opacity: .45; cursor: not-allowed; }
.pitem:last-child { border-bottom: 0; }
.pitem b { font-size: 14px; }
.pitem .p { font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; text-align: right; }
.pitem .d { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pitem.out { opacity: .5; cursor: not-allowed; }
.line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.line:last-child { border-bottom: 0; }
.line b { font-size: 14px; }
.line .ctl { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.line select { width: auto; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.qty button { width: 30px; height: 30px; border: 0; background: var(--sunk); font-weight: 700; }
.qty span { min-width: 30px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.line .sum { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.fefo { font-size: 12px; color: var(--muted); grid-column: 1 / -1; }
.struk { font-family: var(--font-mono); font-size: 12.5px; background: var(--sunk); border-radius: 10px; padding: 14px; display: grid; gap: 3px; }
.struk .c { text-align: center; }
.struk .kv { font-size: 12.5px; }
.struk hr { border: 0; border-top: 1px dashed var(--line); width: 100%; margin: 4px 0; }

/* pemilik */
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.kpi { border: 1px solid var(--line); border-radius: 12px; padding: 12px; display: grid; gap: 2px; }
.kpi b { font-family: var(--font-display); font-size: 21px; font-variant-numeric: tabular-nums; line-height: 1.2; }
.kpi span { font-size: 12.5px; color: var(--muted); }
.alerts { display: grid; gap: 8px; }
.alert { display: grid; grid-template-columns: 6px minmax(0, 1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px 10px 0; overflow: hidden; background: transparent; text-align: left; width: 100%; }
.alert::before { content: ""; align-self: stretch; margin: -10px 0; }
.alert.warn::before { background: var(--warn); } .alert.bad::before { background: var(--bad); } .alert.info::before { background: var(--info); } .alert.ok::before { background: var(--ok); }
.alert b { display: block; font-size: 14px; }
.alert span { font-size: 12.5px; color: var(--muted); }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr) 70px; gap: 10px; align-items: center; font-size: 13px; }
.bar .t { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .track { height: 10px; background: var(--sunk); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 999px; }
.bar .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.two { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px -10px var(--shadow); z-index: 10; }

/* app shell */
.top { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1320px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 16px; min-width: 0; }
.brand .mark { height: 32px; width: auto; flex: none; }
.brand span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1 1 auto; min-width: 0; }
.nav button { background: none; border: 0; border-radius: 8px; padding: 8px 12px; font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap; }
.nav button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.me { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.main { max-width: 1320px; margin: 0 auto; padding: 16px 16px 64px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; min-width: 0; }
.panel > .tabs { padding: 0 14px; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.center .panel { width: 100%; max-width: 460px; padding: 22px; }
.tempbox { font-family: var(--font-mono); font-size: 20px; letter-spacing: .06em; background: var(--sunk); border-radius: 10px; padding: 10px 14px; text-align: center; user-select: all; }
input[type=email], input[type=tel] { width: 100%; min-width: 0; height: 40px; border: 1px solid var(--line); background: var(--sunk); border-radius: 8px; padding: 0 10px; font-size: 14.5px; }
input[type=email]:focus-visible, input[type=tel]:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input:disabled { opacity: .55; cursor: not-allowed; }
.loading { color: var(--muted); padding: 40px; text-align: center; }

/* print: only the 58 mm receipt built by printStruk() */
#prt { display: none; }
@media print {
  @page { size: 58mm auto; margin: 0; }
  body.printing { background: #fff; color: #000; margin: 0; }
  body.printing > :not(#prt) { display: none !important; }
  body.printing #prt { display: block; padding: 3mm 2mm; width: 54mm; font: 9pt/1.35 var(--font-mono); color: #000; }
  #prt div { white-space: pre; }
  #prt .b { font-weight: 700; }
}

/* phone: header scrolls away, expanded stock card stays inside the screen */
@media (max-width: 700px) {
  .top { position: static; }
  .me span { display: none; }
  .kartu { max-width: calc(100vw - 72px); }
}
