/* ============================================================
   SHANNA POS — global.css
   Design tokens, reset, dan komponen dasar.
   Palet chart & ink tervalidasi (CVD/contrast) — jangan ubah
   nilai --series-* / --grid / --axis tanpa re-run validator.
   ============================================================ */

/* ---------- 1. TOKENS: LIGHT (default) ---------- */
:root {
  color-scheme: light;

  /* Surfaces */
  --plane:        #f9f9f7;
  --surface-1:    #fcfcfb;
  --surface-2:    #f2f1ee;
  --surface-3:    #e9e8e3;
  --surface-inv:  #0b0b0b;

  /* Ink */
  --ink-1: #0b0b0b;
  --ink-2: #52514e;
  --ink-3: #898781;
  --ink-inv: #fcfcfb;

  /* Lines */
  --border:        rgba(11, 11, 11, .10);
  --border-strong: #e1e0d9;
  --grid:          #e1e0d9;
  --axis:          #c3c2b7;

  /* Brand (= chart slot 1 blue) */
  --brand:       #2a78d6;
  --brand-hover: #256abf;
  --brand-press: #1c5cab;
  --brand-ink:   #ffffff;
  --brand-wash:  #eaf2fd;
  --brand-ring:  rgba(42, 120, 214, .32);

  /* Status (fixed, never themed) */
  --good:     #0ca30c;
  --good-ink: #006300;
  --warn:     #fab219;
  --warn-ink: #7a5300;
  --serious:  #ec835a;
  --critical: #d03b3b;
  --critical-ink: #a02b2b;

  /* Chart series */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-mute: #c3c2b7;

  /* Elevation */
  --shadow-1: 0 1px 2px rgba(11, 11, 11, .05);
  --shadow-2: 0 2px 8px rgba(11, 11, 11, .06), 0 1px 2px rgba(11, 11, 11, .04);
  --shadow-3: 0 12px 32px rgba(11, 11, 11, .10), 0 2px 6px rgba(11, 11, 11, .05);

  /* Radius */
  --r-xs: 6px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-full: 999px;

  /* Spacing scale */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px;
  --s-9: 56px; --s-10: 72px;

  /* Type */
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "Segoe UI Mono", Menlo, monospace;

  /* Layout */
  --sidebar-w: 264px;
  --sidebar-w-compact: 76px;
  --topbar-h: 62px;
  --bottomnav-h: 62px;

  /* Motion */
  --ease: cubic-bezier(.4, 0, .2, 1);
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --t-fast: 120ms;
  --t-med: 220ms;
}

/* ---------- 2. TOKENS: DARK ---------- */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --plane:       #0d0d0d;
    --surface-1:   #1a1a19;
    --surface-2:   #232322;
    --surface-3:   #2c2c2a;
    --surface-inv: #fcfcfb;
    --ink-1: #ffffff;
    --ink-2: #c3c2b7;
    --ink-3: #898781;
    --ink-inv: #0b0b0b;
    --border:        rgba(255, 255, 255, .10);
    --border-strong: #2c2c2a;
    --grid:          #2c2c2a;
    --axis:          #383835;
    --brand:       #3987e5;
    --brand-hover: #5598e7;
    --brand-press: #6da7ec;
    --brand-ink:   #0b0b0b;
    --brand-wash:  rgba(57, 135, 229, .14);
    --brand-ring:  rgba(57, 135, 229, .38);
    --good-ink: #0ca30c;
    --warn-ink: #fab219;
    --critical-ink: #e66767;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-mute: #383835;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
    --shadow-2: 0 2px 8px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-3: 0 12px 32px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --plane:       #0d0d0d;
  --surface-1:   #1a1a19;
  --surface-2:   #232322;
  --surface-3:   #2c2c2a;
  --surface-inv: #fcfcfb;
  --ink-1: #ffffff;
  --ink-2: #c3c2b7;
  --ink-3: #898781;
  --ink-inv: #0b0b0b;
  --border:        rgba(255, 255, 255, .10);
  --border-strong: #2c2c2a;
  --grid:          #2c2c2a;
  --axis:          #383835;
  --brand:       #3987e5;
  --brand-hover: #5598e7;
  --brand-press: #6da7ec;
  --brand-ink:   #0b0b0b;
  --brand-wash:  rgba(57, 135, 229, .14);
  --brand-ring:  rgba(57, 135, 229, .38);
  --good-ink: #0ca30c;
  --warn-ink: #fab219;
  --critical-ink: #e66767;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-mute: #383835;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-3: 0 12px 32px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .4);
}

/* ---------- 3. RESET ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-1);
  background: var(--plane);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
}
img, svg, video, canvas { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; padding: 0; }
h1, h2, h3, h4, h5 { line-height: 1.25; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: clamp(1.9rem, 1.2rem + 2.4vw, 3.1rem); letter-spacing: -.025em; }
h2 { font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.1rem); letter-spacing: -.02em; }
h3 { font-size: 1.15rem; }
h4 { font-size: 1rem; }
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
::selection { background: var(--brand-ring); }
[hidden] { display: none !important; }

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--surface-3); border-radius: var(--r-full);
  border: 3px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--axis); background-clip: content-box; }

/* ---------- 4. UTILITIES ---------- */
.container { width: 100%; max-width: 1200px; margin-inline: auto; padding-inline: var(--s-5); }
.container-wide { max-width: 1360px; }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { display: grid; place-items: center; }
.gap-1 { gap: var(--s-1); } .gap-2 { gap: var(--s-2); } .gap-3 { gap: var(--s-3); }
.gap-4 { gap: var(--s-4); } .gap-5 { gap: var(--s-5); } .gap-6 { gap: var(--s-6); }
.mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); }
.text-2 { color: var(--ink-2); } .text-3 { color: var(--ink-3); }
.text-sm { font-size: .875rem; } .text-xs { font-size: .78rem; }
.text-right { text-align: right; } .text-center { text-align: center; }
.strong { font-weight: 700; }
.semibold { font-weight: 600; }
.nums { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.eyebrow {
  font-size: .72rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--ink-3);
}
.hr { height: 1px; background: var(--border); border: 0; }

/* ---------- 5. BUTTONS ---------- */
.btn {
  --btn-bg: var(--surface-1);
  --btn-ink: var(--ink-1);
  --btn-bd: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 42px; padding: 0 var(--s-5);
  font-size: .925rem; font-weight: 600; line-height: 1; white-space: nowrap;
  color: var(--btn-ink); background: var(--btn-bg);
  border: 1px solid var(--btn-bd); border-radius: var(--r-sm);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
  user-select: none;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }
.btn svg { width: 18px; height: 18px; flex: none; }

.btn-primary {
  --btn-bg: var(--brand); --btn-ink: var(--brand-ink); --btn-bd: transparent;
  box-shadow: var(--shadow-1);
}
.btn-primary:hover { background: var(--brand-hover); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-outline { --btn-bg: transparent; }
.btn-danger { --btn-bg: var(--critical); --btn-ink: #fff; --btn-bd: transparent; }
.btn-danger:hover { background: #b93333; }
.btn-lg { height: 50px; padding: 0 var(--s-6); font-size: 1rem; border-radius: var(--r-md); }
.btn-sm { height: 34px; padding: 0 var(--s-3); font-size: .84rem; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: var(--r-sm); }
.btn-block { width: 100%; }

/* ---------- 6. CARD ---------- */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}
.card-pad { padding: var(--s-5); }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 1rem; }
.card-head .sub { font-size: .8rem; color: var(--ink-3); font-weight: 500; }
.card-body { padding: var(--s-5); }
.card-foot { padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); }

/* ---------- 7. BADGE / PILL ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 23px; padding: 0 9px;
  font-size: .74rem; font-weight: 700; letter-spacing: .01em;
  border-radius: var(--r-full);
  background: var(--surface-2); color: var(--ink-2);
  border: 1px solid var(--border);
}
.badge svg { width: 13px; height: 13px; }
.badge-good     { background: color-mix(in srgb, var(--good) 14%, transparent);     color: var(--good-ink);     border-color: color-mix(in srgb, var(--good) 30%, transparent); }
.badge-warn     { background: color-mix(in srgb, var(--warn) 18%, transparent);     color: var(--warn-ink);     border-color: color-mix(in srgb, var(--warn) 38%, transparent); }
.badge-critical { background: color-mix(in srgb, var(--critical) 13%, transparent); color: var(--critical-ink); border-color: color-mix(in srgb, var(--critical) 30%, transparent); }
.badge-brand    { background: var(--brand-wash); color: var(--brand); border-color: color-mix(in srgb, var(--brand) 26%, transparent); }

/* ---------- 8. TOAST ---------- */
.toast-stack {
  position: fixed; z-index: 9000;
  right: var(--s-5); bottom: var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-2);
  max-width: min(380px, calc(100vw - 2 * var(--s-5)));
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--ink-3);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-3);
  pointer-events: auto;
  animation: toast-in var(--t-med) var(--ease-out);
}
.toast.is-out { animation: toast-out var(--t-med) var(--ease) forwards; }
.toast .t-ico { flex: none; width: 18px; height: 18px; margin-top: 2px; }
.toast .t-msg { font-size: .9rem; color: var(--ink-1); }
.toast .t-x { flex: none; color: var(--ink-3); padding: 2px; border-radius: var(--r-xs); }
.toast .t-x:hover { color: var(--ink-1); background: var(--surface-2); }
.toast-success  { border-left-color: var(--good); }
.toast-success .t-ico { color: var(--good-ink); }
.toast-error    { border-left-color: var(--critical); }
.toast-error .t-ico { color: var(--critical-ink); }
.toast-warn     { border-left-color: var(--warn); }
.toast-warn .t-ico { color: var(--warn-ink); }
.toast-info     { border-left-color: var(--brand); }
.toast-info .t-ico { color: var(--brand); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(16px); } }

/* ---------- 9. MODAL ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 8000;
  display: grid; place-items: center;
  padding: var(--s-4);
  background: rgba(11, 11, 11, .5);
  backdrop-filter: blur(3px);
  animation: fade-in var(--t-fast) var(--ease);
}
.modal {
  width: 100%; max-width: 460px;
  max-height: calc(100vh - 2 * var(--s-6));
  display: flex; flex-direction: column;
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: modal-in var(--t-med) var(--ease-out);
}
.modal-md { max-width: 620px; }
.modal-lg { max-width: 860px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); padding: var(--s-5) var(--s-5) var(--s-3); }
.modal-head h3 { font-size: 1.1rem; }
.modal-head .sub { font-size: .85rem; color: var(--ink-2); margin-top: 2px; }
.modal-body { padding: var(--s-2) var(--s-5) var(--s-5); overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-4) var(--s-5); border-top: 1px solid var(--border); }
@keyframes fade-in  { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.98); } }

/* ---------- 10. LOADING / SKELETON / STATES ---------- */
.spinner {
  width: 18px; height: 18px; flex: none;
  border: 2px solid var(--brand-ring);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner-lg { width: 34px; height: 34px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.overlay-loading {
  position: fixed; inset: 0; z-index: 8500;
  display: grid; place-items: center; gap: var(--s-3);
  background: color-mix(in srgb, var(--plane) 78%, transparent);
  backdrop-filter: blur(2px);
}
.overlay-loading .txt { font-size: .9rem; color: var(--ink-2); font-weight: 600; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-xs);
}
.skeleton-text { height: 12px; margin-block: 6px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }
@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

.state {
  display: grid; place-items: center; gap: var(--s-3);
  padding: var(--s-8) var(--s-5); text-align: center;
}
.state .ico {
  width: 52px; height: 52px; display: grid; place-items: center;
  border-radius: var(--r-md); background: var(--surface-2); color: var(--ink-3);
}
.state .ico svg { width: 26px; height: 26px; }
.state h4 { font-size: 1rem; }
.state p { font-size: .875rem; color: var(--ink-2); max-width: 42ch; }
.state-error .ico { background: color-mix(in srgb, var(--critical) 12%, transparent); color: var(--critical-ink); }

/* ---------- 11. SEGMENTED CONTROL ---------- */
.seg {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.seg button {
  height: 30px; padding: 0 var(--s-3);
  font-size: .82rem; font-weight: 600; color: var(--ink-2);
  border-radius: var(--r-xs);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.seg button:hover { color: var(--ink-1); }
.seg button[aria-selected="true"] {
  background: var(--surface-1); color: var(--ink-1);
  box-shadow: var(--shadow-1);
}

/* ---------- 12. DROPDOWN ---------- */
.dd { position: relative; }
.dd-menu {
  position: absolute; z-index: 500; min-width: 216px;
  padding: var(--s-2);
  background: var(--surface-1);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-3);
  animation: modal-in var(--t-fast) var(--ease-out);
}
.dd-menu[data-align="right"] { right: 0; }
.dd-menu[data-align="left"] { left: 0; }
.dd-menu[data-side="bottom"] { top: calc(100% + 6px); }
.dd-menu[data-side="top"] { bottom: calc(100% + 6px); }
.dd-item {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%; padding: 9px var(--s-3);
  font-size: .9rem; text-align: left; color: var(--ink-1);
  border-radius: var(--r-xs);
}
.dd-item:hover { background: var(--surface-2); text-decoration: none; }
.dd-item svg { width: 17px; height: 17px; flex: none; color: var(--ink-3); }
.dd-item[aria-checked="true"] { color: var(--brand); font-weight: 600; }
.dd-item[aria-checked="true"] svg { color: var(--brand); }
.dd-item-danger { color: var(--critical-ink); }
.dd-item-danger svg { color: var(--critical-ink); }
.dd-label { padding: var(--s-2) var(--s-3) var(--s-1); font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.dd-sep { height: 1px; margin: var(--s-2) calc(-1 * var(--s-2)); background: var(--border); }

/* ---------- 14. STATUS JARINGAN & ANTREAN OFFLINE (FASE 8) ---------- */

/*
  Pil status di topbar. Saat online dan antrean kosong, elemennya
  ber-`hidden` — kasir tidak perlu lampu hijau yang selalu menyala; yang perlu
  terlihat justru keadaan yang menuntut tindakan.
*/
.net-pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 11px;
  font-size: .78rem; font-weight: 700; white-space: nowrap;
  border-radius: var(--r-full);
  border: 1px solid color-mix(in srgb, var(--warn) 38%, transparent);
  background: color-mix(in srgb, var(--warn) 16%, transparent);
  color: var(--warn-ink);
  cursor: pointer;
}
.net-pill:hover { background: color-mix(in srgb, var(--warn) 26%, transparent); }
.net-pill svg { width: 15px; height: 15px; flex: none; }
.net-pill .n {
  display: inline-grid; place-items: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  font-size: .7rem; font-weight: 800;
  border-radius: var(--r-full);
  background: var(--warn-ink); color: var(--plane);
}
/* Sudah online tapi masih ada nota menunggu: nada netral, bukan peringatan. */
.net-pill.is-syncing {
  border-color: color-mix(in srgb, var(--brand) 30%, transparent);
  background: var(--brand-wash); color: var(--brand);
}
.net-pill.is-syncing .n { background: var(--brand); color: var(--brand-ink); }
/* Ada nota yang ditolak server dan menunggu keputusan kasir. */
.net-pill.is-failed {
  border-color: color-mix(in srgb, var(--critical) 34%, transparent);
  background: color-mix(in srgb, var(--critical) 13%, transparent);
  color: var(--critical-ink);
}
.net-pill.is-failed .n { background: var(--critical-ink); color: var(--plane); }
.net-pill .spin { animation: spin 1.1s linear infinite; }

/* Garis tipis di paling atas layar selama offline — terlihat di semua modul. */
body.is-offline::before {
  content: ""; position: fixed; z-index: 9500;
  top: 0; left: 0; right: 0; height: 3px;
  background: var(--warn);
  pointer-events: none;
}

/* Daftar isi antrean di dalam modal. */
.outbox-list { display: flex; flex-direction: column; gap: var(--s-2); }
.outbox-row {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3);
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-1);
}
.outbox-row .ob-main { min-width: 0; flex: 1; }
.outbox-row .ob-no { font-weight: 700; font-size: .86rem; }
.outbox-row .ob-meta { font-size: .76rem; color: var(--ink-3); }
.outbox-row .ob-err {
  margin-top: 3px; font-size: .76rem; line-height: 1.45;
  color: var(--critical-ink);
}
.outbox-row.is-failed { border-color: color-mix(in srgb, var(--critical) 34%, transparent); }
