/* KASIR UMKM — tampilan (CSS) */
/* Konsep layout: header + tab di atas, isi di tengah (maks 1280px).
     Kasir = 2 kolom (menu | pesanan) di desktop, 1 kolom di HP. */
  :root {
    --bg: #F2F5F4;
    --surface: #FFFFFF;
    --surface-2: #E8EEEC;
    --line: #D5DEDB;
    --fg: #14201C;
    --muted: #52615C;
    --accent: #0F766E;
    --accent-ink: #FFFFFF;
    --accent-soft: #DCEFEA;
    --warn: #8F4508;
    --warn-soft: #FBEBD6;
    --danger: #B42318;
    --danger-soft: #FCE4E1;
    --shadow: 0 8px 30px rgba(20, 32, 28, 0.14);
    --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
    --r: 14px;
  }
  @media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
      --bg: #0E1513; --surface: #16201D; --surface-2: #1F2B28; --line: #2C3A36;
      --fg: #E6EEEB; --muted: #9DAEA9; --accent: #2EB5A4; --accent-ink: #04201B;
      --accent-soft: #123631; --warn: #F2B36B; --warn-soft: #3A2A15;
      --danger: #F28B82; --danger-soft: #3D1E1B; --shadow: 0 8px 30px rgba(0,0,0,0.5);
      color-scheme: dark;
    }
  }
  :root[data-theme="dark"] {
    --bg: #0E1513; --surface: #16201D; --surface-2: #1F2B28; --line: #2C3A36;
    --fg: #E6EEEB; --muted: #9DAEA9; --accent: #2EB5A4; --accent-ink: #04201B;
    --accent-soft: #123631; --warn: #F2B36B; --warn-soft: #3A2A15;
    --danger: #F28B82; --danger-soft: #3D1E1B; --shadow: 0 8px 30px rgba(0,0,0,0.5);
    color-scheme: dark;
  }

  * { box-sizing: border-box; }
  body { margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 15px; line-height: 1.45; }
  button, input, select, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; }
  :focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
  .angka { font-variant-numeric: tabular-nums; }

  /* ---------- Header & tab ---------- */
  body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
  .header {
    position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
    background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .header-dalam {
    max-width: 1280px; margin: 0 auto; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px;
    padding-block: 12px;
    padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  .merek { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .logo { width: 38px; height: 38px; flex: none; border-radius: 11px; background: var(--accent); color: var(--accent-ink); font-weight: 800; display: grid; place-items: center; font-size: 17px; }
  .merek b { display: block; font-size: 16px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .merek small { color: var(--muted); font-size: 12px; }
  .tab { display: flex; gap: 4px; overflow-x: auto; flex: 1 1 auto; scrollbar-width: none; }
  .tab button { height: 40px; padding: 0 14px; border: none; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; font-size: 14px; white-space: nowrap; }
  .tab button[aria-current="page"] { background: var(--accent-soft); color: var(--accent); font-weight: 800; }
  .status { font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
  .status.gagal { background: var(--danger-soft); color: var(--danger); }

  .isi {
    max-width: 1280px; margin: 0 auto;
    padding-block: 18px 110px;
    padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
    display: flex; flex-direction: column; gap: 16px;
  }
  .banner { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-radius: var(--r); background: var(--warn-soft); color: var(--warn); font-size: 14px; font-weight: 600; }

  /* ---------- Komponen umum ---------- */
  .btn { height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--fg); }
  .btn.utama { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  .btn.bahaya { color: var(--danger); border-color: var(--danger); background: var(--surface); }
  .btn.kecil { height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
  .btn:disabled { opacity: 0.45; cursor: not-allowed; }
  .input { width: 100%; height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-size: 15px; }
  textarea.input { height: auto; min-height: 120px; padding: 10px 12px; font-family: var(--mono); font-size: 12px; }
  .label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 700; color: var(--muted); }
  .kartu { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
  .kartu h2 { margin: 0; font-size: 17px; font-weight: 800; }
  .baris { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
  .redup { color: var(--muted); }
  .chips { display: flex; gap: 8px; flex-wrap: wrap; }
  .chip { height: 38px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 14px; }
  .chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
  .seg { display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); gap: 6px; }
  .seg button { height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); font-weight: 700; font-size: 14px; }
  .seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border: 2px solid var(--accent); }
  .pill { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; }
  .pill.warn { background: var(--warn-soft); color: var(--warn); }
  .pill.ok { background: var(--accent-soft); color: var(--accent); }
  .pill.batal { background: var(--danger-soft); color: var(--danger); }
  .kosong { padding: 28px 12px; text-align: center; color: var(--muted); font-size: 14px; }

  /* ---------- Halaman Kasir ---------- */
  .kasir { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
  .menu { flex: 999 1 520px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
  .grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .produk { position: relative; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); text-align: left; min-height: 100%; }
  .produk.dipilih { border: 2px solid var(--accent); padding: 9px; }
  .produk:disabled { opacity: 0.5; }
  .thumb { height: 76px; border-radius: 11px; background: var(--surface-2); color: var(--accent); display: grid; place-items: center; font-size: 22px; font-weight: 800; letter-spacing: 1px; }
  .produk .nama { font-weight: 700; font-size: 14px; line-height: 1.25; }
  .produk .harga { font-size: 14px; font-weight: 600; color: var(--muted); }
  .jumlah { position: absolute; top: 8px; right: 8px; min-width: 28px; height: 28px; padding: 0 7px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 13px; display: grid; place-items: center; }
  .panel { flex: 1 1 340px; max-width: 100%; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 80px); }
  .item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .item .kiri { flex: 1; min-width: 0; }
  .item .kiri b { display: block; font-size: 14px; }
  .item .kiri small { color: var(--muted); }
  .qty { display: flex; align-items: center; gap: 6px; }
  .qty button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 800; font-size: 18px; line-height: 1; }
  .qty span { min-width: 22px; text-align: center; font-weight: 800; }
  .total-besar { font-size: 28px; font-weight: 800; }
  .kembalian { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); font-weight: 800; }
  .kembalian.kurang { background: var(--danger-soft); color: var(--danger); }
  .tombol-bayar { height: 56px; font-size: 17px; }
  .bar-hp { display: none; }

  @media (max-width: 760px) {
    .panel { position: static; }
    .bar-hp {
      display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
      padding: 10px max(16px, env(safe-area-inset-right, 0px)) calc(10px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
      background: var(--surface); border-top: 1px solid var(--line);
    }
    .bar-hp button { flex: 1; height: 54px; border-radius: 14px; border: none; background: var(--fg); color: var(--bg); display: flex; align-items: center; justify-content: space-between; padding: 0 18px; font-weight: 800; font-size: 15px; }
  }

  /* ---------- Tabel ---------- */
  .gulir { overflow-x: auto; }
  table { width: 100%; border-collapse: collapse; font-size: 14px; }
  th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
  td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
  td.kanan, th.kanan { text-align: right; }
  .aksi { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }

  /* ---------- Laporan ---------- */
  .kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
  .kpi .kartu { gap: 4px; padding: 16px; }
  .kpi .nilai { font-size: 26px; font-weight: 800; }
  .kpi .judul { font-size: 13px; font-weight: 700; color: var(--muted); }
  .dua-kolom { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
  .dua-kolom > * { flex: 1 1 320px; }
  .batang-wadah { display: flex; align-items: flex-end; gap: 6px; height: 180px; overflow-x: auto; padding-top: 18px; }
  .batang { flex: 1 0 26px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 4px; height: 100%; font-size: 11px; color: var(--muted); }
  .batang i { display: block; width: 100%; max-width: 36px; border-radius: 6px 6px 2px 2px; background: var(--accent); min-height: 2px; }
  .meter { height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
  .meter i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }

  /* ---------- Modal & toast ---------- */
  .layar { position: fixed; inset: 0; z-index: 20; background: rgba(10, 16, 14, 0.5); display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
  .modal { width: min(460px, 100%); max-height: 100%; overflow-y: auto; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
  .modal h2 { margin: 0; font-size: 19px; }
  .struk { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; white-space: pre; overflow-x: auto; background: var(--surface-2); padding: 14px; border-radius: 12px; margin: 0; }
  .toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom, 0px)); z-index: 30; background: var(--fg); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 700; font-size: 14px; box-shadow: var(--shadow); max-width: calc(100% - 32px); }
  .form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .form-grid .penuh { grid-column: 1 / -1; }
  .centang { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 600; }
  .centang input { width: 20px; height: 20px; accent-color: var(--accent); }

  @media print {
    body * { visibility: hidden; }
    #struk-teks, #struk-teks * { visibility: visible; }
    #struk-teks { position: absolute; left: 0; top: 0; background: #fff; color: #000; }
  }
  @media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
