:root {
  --ink: #1b2233; --muted: #667085; --line: #d9dee7; --bg: #f4f6f9; --card: #ffffff;
  --brand: #13235b; --brand-2: #c9a54c; --ok: #127a46; --warn: #a15c00; --bad: #b42318;
  --radius: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); }
h1 { font-size: 1.3rem; margin: 0 0 .5rem; }
h2 { font-size: 1.05rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); font-size: .9rem; }
.bm { color: var(--muted); font-weight: normal; font-size: .85em; }
.bm-block { color: var(--muted); font-size: .9rem; }
[hidden] { display: none !important; }

/* ---------- customer */
.customer .brand { position: relative; background: var(--brand); color: #fff; padding: 18px 16px 16px; text-align: center; border-bottom: 3px solid var(--brand-2); }
.lang-ms .en, .lang-en .ms { display: none !important; }
.lang-switch { display: flex; justify-content: flex-end; gap: 0; margin: -6px 0 8px; }
.lang-switch button { font: inherit; font-size: .8rem; font-weight: 600; padding: 5px 12px; border: 1px solid rgba(255,255,255,.6); background: transparent; color: #fff; cursor: pointer; }
.lang-switch button:first-child { border-radius: 999px 0 0 999px; }
.lang-switch button:last-child { border-radius: 0 999px 999px 0; border-left: 0; }
.lang-switch button[aria-pressed="true"] { background: #fff; color: var(--brand); }
.brand-name { font-weight: 700; letter-spacing: .04em; }
.brand-sub { font-size: .85rem; opacity: .85; margin-top: 2px; }
.card { background: var(--card); max-width: 560px; margin: 16px auto; padding: 20px 16px 24px; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(16,24,40,.08); }
@media (max-width: 600px) { .card { margin: 0; border-radius: 0; box-shadow: none; } }
.steps { display: flex; gap: 6px; list-style: none; padding: 0; margin: 0 0 18px; }
.steps li { flex: 1; text-align: center; font-size: .8rem; padding: 6px 0; border-bottom: 3px solid var(--line); color: var(--muted); }
.steps li.active { border-color: var(--brand); color: var(--brand); font-weight: 600; }
.steps li.done { border-color: var(--ok); color: var(--ok); }
label { display: block; font-weight: 600; margin: 14px 0 4px; font-size: .95rem; }
input[type=text], input:not([type]), input[type=email], input[type=tel], input[type=password], input[type=search], select {
  width: 100%; font: inherit; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 1px; }
.err { color: var(--bad); font-size: .85rem; min-height: 1px; margin-top: 4px; }
.btn { display: inline-block; font: inherit; font-weight: 600; padding: 13px 18px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); cursor: pointer; text-decoration: none; text-align: center; }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:disabled { background: #9aa3b8; border-color: #9aa3b8; cursor: not-allowed; }
.btn.ghost { background: #fff; }
.btn.link { border: 0; background: none; color: var(--brand); padding: 8px 0; text-decoration: underline; font-weight: 500; }
.btn.danger { color: var(--bad); border-color: #f1b8b3; }
.btn.small { padding: 7px 12px; font-size: .85rem; }
#nextBtn { width: 100%; margin-top: 22px; }
.row { display: flex; gap: 10px; margin-top: 18px; }
.row .btn { flex: 1; }
.sig-modal { position: fixed; inset: 0; z-index: 10; background: rgba(16,24,40,.55); display: flex; align-items: flex-end; justify-content: center; }
.sig-sheet { background: #fff; width: 100%; max-width: 560px; max-height: 100%; overflow-y: auto; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); border-radius: 16px 16px 0 0; }
@media (min-width: 601px) { .sig-modal { align-items: center; } .sig-sheet { border-radius: var(--radius); } }
.sig-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.sig-top h1 { margin: 0; }
.sig-close { border: 0; background: none; font-size: 1.3rem; line-height: 1; padding: 8px; color: var(--muted); cursor: pointer; }
.sig-agree { font-size: .82rem; color: var(--muted); margin: 10px 0 0; }
.full-letter { margin-top: 6px; font-size: .88rem; }
.full-letter summary { color: var(--brand); text-decoration: underline; cursor: pointer; padding: 4px 0; }
.letter { max-height: 34vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-top: 6px; background: #fcfcfd; }
.letter ul { padding-left: 18px; margin: 0 0 8px; }
.letter p { margin: 0 0 8px; }
body.modal-open { overflow: hidden; }
.sig-wrap { position: relative; }
#sigPad { width: 100%; height: 200px; display: block; border: 2px dashed #9aa3b8; border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; }
.sig-line { position: absolute; left: 14px; right: 14px; bottom: 44px; border-bottom: 1px solid #c4cad6; color: #b0b7c5; font-size: .8rem; pointer-events: none; }
.done-icon { width: 64px; height: 64px; border-radius: 50%; background: var(--ok); color: #fff; font-size: 34px; line-height: 64px; text-align: center; margin: 12px auto 16px; }
#step3 { text-align: center; }
.foot { text-align: center; padding: 12px 16px 28px; }

/* ---------- staff */
.staff-top { background: var(--brand); color: #fff; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.staff-top a { color: #fff; text-decoration: none; }
.staff-top .spacer { flex: 1; }
.staff-top form { margin: 0; }
.staff-top .btn { padding: 6px 12px; font-size: .85rem; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }
.panel { background: #fff; border-radius: var(--radius); padding: 16px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(16,24,40,.06); }
.flash { background: #fff7e6; border: 1px solid #f5d79e; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.alert { background: #ecfdf3; border: 1px solid #abefc6; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.alert form { display: inline; }
.newlink { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
.newlink label { margin: 0 0 4px; }
@media (max-width: 700px) { .newlink { grid-template-columns: 1fr; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip { font-size: .8rem; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink); text-decoration: none; background: #fff; }
.chip.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.search { display: flex; gap: 8px; }
.search input { flex: 1; min-width: 240px; max-width: 360px; }
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
td a { color: var(--brand); }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: #eef1f6; color: var(--ink); white-space: nowrap; }
.badge.s-waiting { background: #eef4ff; color: #2e4a9e; }
.badge.s-submitted, .badge.s-generated { background: #f0f9ff; color: #026aa2; }
.badge.s-pending { background: #fff7e6; color: var(--warn); }
.badge.s-requested { background: #f4f3ff; color: #5925dc; }
.badge.s-completed { background: #ecfdf3; color: var(--ok); }
.badge.s-failed { background: #fef3f2; color: var(--bad); }
.badge.s-expired, .badge.s-cancelled { background: #f2f4f7; color: var(--muted); }
.errtext { color: var(--bad); font-size: .82rem; }
dl.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .88rem; }
dl.kv dd { margin: 0; word-break: break-all; }
@media (max-width: 600px) { dl.kv { grid-template-columns: 1fr; } dl.kv dd { margin-bottom: 8px; } }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions form { margin: 0; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.actions select, .actions input { width: auto; padding: 7px 10px; font-size: .85rem; }
.linkbox { font-family: Consolas, monospace; font-size: .85rem; background: #f7f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 10px; word-break: break-all; }
.msgbox { white-space: pre-wrap; font-size: .88rem; background: #f7f8fa; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.wa { background: #1fa855; border-color: #1fa855; color: #fff; }
.login { max-width: 380px; margin: 60px auto; }
.mono { font-family: Consolas, monospace; font-size: .8rem; }
.ok { color: var(--ok); font-weight: 600; }
.bad { color: var(--bad); font-weight: 600; }
