:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #64707d;
  --line: #e2e6ea;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #e6f4f2;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn: #b7791f;
  --warn-soft: #fdf4e3;
  --ok: #1e8449;
  --ok-soft: #e8f6ee;
  --info: #2563eb;
  --info-soft: #e8efff;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }

/* ---------- Layout ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar .inner { display: flex; align-items: center; gap: 12px; padding: 10px 16px; max-width: 1200px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; min-width: 0; }
.brand img { height: 36px; width: auto; max-width: 120px; object-fit: contain; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.spacer { flex: 1; }
.container { max-width: 820px; margin: 0 auto; padding: 16px; }
.container.wide { max-width: 1200px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.section-title { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.section-title .num {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex: none;
}
.section-title h2 { margin: 0; }

.grid { display: grid; gap: 12px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
.grid.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 720px) {
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  .grid.four { grid-template-columns: 1fr 1fr; }
}

/* ---------- Form ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
label .req { color: var(--danger); }
.field { margin-bottom: 12px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }
input, select, textarea {
  width: 100%;
  font: inherit;
  color: inherit;
  background: #fff;
  border: 1px solid #cfd6dd;
  border-radius: 9px;
  padding: 10px 12px;
  min-height: 44px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
input[type="checkbox"], input[type="radio"] { width: 18px; flex: none; height: 18px; min-height: 0; vertical-align: middle; margin: 0 6px 0 0; accent-color: var(--primary); }
.check { display: flex; align-items: center; font-weight: 500; }

.otp-input { font-size: 1.6rem; letter-spacing: .5em; text-align: center; font-weight: 700; max-width: 260px; margin: 0 auto; display: block; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  border-radius: 9px; padding: 9px 16px; min-height: 42px; text-decoration: none;
}
.btn:hover { background: #f7f9fa; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { min-height: 34px; padding: 5px 11px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn.lg { min-height: 50px; font-size: 1.05rem; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions.end { justify-content: flex-end; }

/* ---------- Items table ---------- */
.items { width: 100%; border-collapse: collapse; }
.items th { text-align: left; font-size: .8rem; color: var(--muted); font-weight: 600; padding: 0 6px 6px; }
.items td { padding: 4px 6px; vertical-align: top; }
.items td input { min-height: 40px; }
.items .col-qty { width: 90px; }
.items .col-price { width: 160px; }
.items .col-sub { width: 140px; text-align: right; padding-top: 14px; font-weight: 600; white-space: nowrap; }
.items .col-del { width: 44px; }
.total-row { display: flex; justify-content: space-between; align-items: center; border-top: 1px dashed var(--line); margin-top: 10px; padding-top: 12px; font-size: 1.1rem; }
.total-row strong { font-size: 1.3rem; color: var(--primary); }
@media (max-width: 720px) {
  .items thead { display: none; }
  .items, .items tbody, .items tr, .items td { display: block; width: 100%; }
  .items tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 10px; position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
  .items td { padding: 0; }
  .items td.col-name { grid-column: 1 / -1; padding-right: 44px; }
  .items .col-qty, .items .col-price { width: auto; }
  .items td.col-sub { grid-column: 1 / -1; text-align: right; padding: 0; }
  .items td.col-del { position: absolute; top: 8px; right: 8px; width: auto; }
  .items td[data-label]::before { content: attr(data-label); display: block; font-size: .75rem; color: var(--muted); }
}

/* ---------- Data tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #fafbfc; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: #f7faf9; }

/* ---------- Badges ---------- */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; background: #eef1f4; color: #47515c; }
.badge.menunggu_verifikasi { background: #eef1f4; color: #5b6570; }
.badge.baru { background: var(--info-soft); color: var(--info); }
.badge.diterima { background: var(--warn-soft); color: var(--warn); }
.badge.selesai, .badge.lunas, .badge.p-diterima { background: var(--ok-soft); color: var(--ok); }
.badge.ditolak, .badge.p-ditolak { background: var(--danger-soft); color: var(--danger); }
.badge.menunggu_konfirmasi, .badge.p-menunggu { background: #fff1d6; color: #9a5b00; }
.badge.sebagian { background: var(--primary-soft); color: var(--primary); }
.badge.belum_bayar { background: #f3f4f6; color: #6b7280; }

/* ---------- Alerts ---------- */
.alert { border-radius: 10px; padding: 11px 14px; margin-bottom: 12px; font-size: .92rem; border: 1px solid transparent; }
.alert.info { background: var(--info-soft); color: #1e3a8a; border-color: #c9d8ff; }
.alert.warn { background: var(--warn-soft); color: #7a4b05; border-color: #f2ddb0; }
.alert.ok { background: var(--ok-soft); color: #14532d; border-color: #bfe5cc; }
.alert.err { background: var(--danger-soft); color: #7f1d1d; border-color: #f5c2bd; }
.dev-otp { font-family: ui-monospace, Consolas, monospace; font-size: 1.1rem; font-weight: 700; letter-spacing: .15em; }

/* ---------- Key/value ---------- */
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: .93rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
@media (max-width: 520px) { .kv { grid-template-columns: 1fr; } .kv dt { margin-top: 6px; } }
.pre { white-space: pre-wrap; word-break: break-word; }
.msg-preview { white-space: pre-wrap; background: #e7f8e3; border: 1px solid #cbeac3; border-radius: 10px; padding: 10px 12px; font-size: .9rem; }

/* ---------- Stats ---------- */
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat .label { font-size: .8rem; color: var(--muted); }
.stat .value { font-size: 1.45rem; font-weight: 800; margin-top: 2px; }
a.stat { text-decoration: none; color: inherit; display: block; }

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 18px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .t { font-size: .78rem; color: var(--muted); }

.steps { display: flex; gap: 6px; margin: 4px 0 16px; }
.steps .s { flex: 1; text-align: center; font-size: .75rem; color: var(--muted); }
.steps .s .bar { height: 5px; border-radius: 4px; background: var(--line); margin-bottom: 5px; }
.steps .s.done .bar { background: var(--primary); }
.steps .s.done { color: var(--text); font-weight: 600; }

/* ---------- Staff app shell ---------- */
.shell { display: flex; min-height: calc(100vh - 57px); }
.sidenav { width: 230px; flex: none; background: var(--card); border-right: 1px solid var(--line); padding: 12px 8px; }
.sidenav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; color: var(--text); text-decoration: none; font-weight: 500; }
.sidenav a:hover { background: #f3f5f7; }
.sidenav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
.sidenav .ico { width: 20px; text-align: center; }
.main { flex: 1; min-width: 0; padding: 16px; }
.count-dot { background: var(--danger); color: #fff; border-radius: 999px; font-size: .7rem; font-weight: 700; padding: 1px 6px; margin-left: auto; }
.bottomnav { display: none; }
@media (max-width: 860px) {
  .sidenav { display: none; }
  .main { padding: 12px 12px 84px; }
  .bottomnav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
  }
  .bottomnav a { flex: 1; text-align: center; padding: 7px 2px 8px; font-size: .7rem; color: var(--muted); text-decoration: none; position: relative; }
  .bottomnav a .ico { display: block; font-size: 1.25rem; line-height: 1.3; }
  .bottomnav a.active { color: var(--primary); font-weight: 700; }
  .bottomnav .count-dot { position: absolute; top: 3px; left: 54%; margin: 0; }
}

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: center; }
.toolbar input, .toolbar select { width: auto; flex: 1 1 160px; min-height: 40px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; }
.chip { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 13px; font-size: .85rem; cursor: pointer; font-weight: 600; color: var(--muted); }
.chip.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Order cards (list on mobile) */
.olist { display: grid; gap: 10px; }
.ocard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; cursor: pointer; box-shadow: var(--shadow); }
.ocard:hover { border-color: #b9d9d5; }
.ocard .row1 { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.ocard .code { font-weight: 700; font-family: ui-monospace, Consolas, monospace; font-size: .88rem; }
.ocard .name { font-weight: 600; }
.ocard .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 50; display: flex; align-items: flex-start; justify-content: center; padding: 24px 12px; overflow-y: auto; }
.modal { background: var(--card); border-radius: 14px; width: 100%; max-width: 720px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal.sm { max-width: 460px; }
.modal .mh { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); border-radius: 14px 14px 0 0; z-index: 2; }
.modal .mh h2 { margin: 0; font-size: 1.05rem; flex: 1; }
.modal .mb { padding: 16px; }
@media (max-width: 600px) {
  .modal-bg { padding: 0; }
  .modal { border-radius: 0; min-height: 100vh; }
  .modal .mh { border-radius: 0; }
}

.toast-wrap { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(92vw, 420px); }
.toast { background: #1f2937; color: #fff; border-radius: 10px; padding: 11px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: .92rem; }
.toast.err { background: #991b1b; }
.toast.ok { background: #166534; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; }
.login-card .logo { text-align: center; margin-bottom: 12px; }
.login-card .logo img { max-height: 64px; max-width: 200px; }

.empty { text-align: center; padding: 30px 10px; color: var(--muted); }
.proof-thumb { max-width: 160px; max-height: 160px; border-radius: 8px; border: 1px solid var(--line); display: block; margin-top: 6px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 20px 16px 30px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

.bank-row { grid-template-columns: 1fr 1fr 1fr auto; margin-bottom: 8px; }
.sticky-save { position: sticky; bottom: 10px; z-index: 5; }
@media (max-width: 720px) {
  .bank-row { grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
  .sticky-save { bottom: 76px; }
}
