:root {
  --bg: #0E1512;
  --surface: #18231D;
  --surface-low: #131D18;
  --line: #263329;
  --line-strong: #4A5D52;
  --text: #EAF2EC;
  --text-soft: #C9D8CE;
  --muted: #9DB3A5;
  --accent: #3DDC84;
  --on-accent: #052E16;
  --accent-dim: #12301F;
  --warn: #FACC15;
  --warn-dim: #2A2414;
  --warn-line: #5A4A12;
  --danger: #FCA5A5;
  --danger-dim: #2A1818;
  --danger-line: #5C2626;
  --info: #93C5FD;
  --info-dim: #1C2433;
  --radius: 18px;
  font-family: 'Noto Sans Lao', 'Noto Sans Thai', system-ui, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
h1 { margin: 0; font-size: 28px; font-weight: 700; }
h2 { margin: 0; font-size: 18px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

/* ---------- layout ---------- */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.side {
  flex: 1 1 220px; max-width: 100%; background: var(--surface-low); border-right: 1px solid var(--line);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--accent); display: grid; place-items: center; }
.brand-name { font-size: 17px; font-weight: 700; display: block; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 12px;
  color: var(--text-soft); text-decoration: none; min-height: 44px;
}
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.active { background: var(--accent-dim); color: var(--accent); font-weight: 700; }
.nav-link .label { flex: 1; }
.badge { background: var(--warn); color: #2A2105; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.badge.red { background: var(--danger); color: #3B0A0A; }
.side-foot { margin-top: auto; padding: 16px 8px 0; display: flex; flex-direction: column; gap: 8px; }
.main { flex: 999 1 560px; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 22px; }
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.demo-banner { background: var(--info-dim); color: var(--info); padding: 10px 16px; border-radius: 12px; font-size: 14px; }

@media (max-width: 860px) {
  .side { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; padding: 10px; gap: 6px; border-right: none; border-bottom: 1px solid var(--line); }
  .brand, .side-foot { display: none; }
  .nav-link { flex-shrink: 0; }
  .main { padding: 20px 16px 40px; }
  .col-side.alerts-first { order: -1; }
}

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.grid-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; gap: 4px; }
.tile .value { font-size: 26px; font-weight: 700; }
.tile .value.accent { color: var(--accent); }
.alert { border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 4px; text-decoration: none; color: var(--text); }
.alert.warn { background: var(--warn-dim); border: 1px solid var(--warn-line); }
.alert.warn .k { color: #FDE68A; }
.alert.danger { background: var(--danger-dim); border: 1px solid var(--danger-line); }
.alert.danger .k { color: var(--danger); }
.alert.info { background: var(--info-dim); border: 1px solid #2B3A55; }
.alert.info .k { color: var(--info); }
.alert .v { font-size: 20px; font-weight: 700; }
.alert .go { font-size: 14px; font-weight: 600; }
.cols { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.col-main { flex: 999 1 560px; min-width: 0; }
.col-side { flex: 1 1 280px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.btn {
  min-height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--text); font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:hover { border-color: var(--text-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
.btn.primary:hover { background: #5BE59A; }
.btn.warn { border-color: var(--warn); color: var(--warn); }
.btn.danger { border-color: var(--danger-line); color: var(--danger); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; min-height: 52px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn { min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--text-soft); font-size: 13px; cursor: pointer; }
.chip-btn.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 700; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.pill.green { background: var(--accent-dim); color: var(--accent); }
.pill.yellow { background: var(--warn-dim); color: var(--warn); }
.pill.red { background: var(--danger-dim); color: var(--danger); }
.pill.grey { background: #1C2822; color: var(--text-soft); }
.pill.blue { background: var(--info-dim); color: var(--info); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tab { min-height: 44px; padding: 0 16px; background: transparent; border: none; border-bottom: 3px solid transparent; color: var(--muted); cursor: pointer; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 700; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px 8px; border-bottom: 1px solid #1C2822; vertical-align: middle; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: #1B2721; }
.empty { padding: 36px 8px; text-align: center; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--muted); }
.input, textarea.input, select.input {
  min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg);
  color: var(--text); padding: 10px 12px; font-size: 15px; width: 100%;
}
.input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
textarea.input { min-height: 76px; resize: vertical; }
.search { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 0 14px; min-height: 44px; min-width: min(280px, 100%); }
.search input { flex: 1; border: none; outline: none; background: transparent; min-height: 42px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; font-size: 14px; }
.kv .k { color: var(--muted); }
.kv .v { font-weight: 600; word-break: break-word; }

.switch { position: relative; width: 56px; height: 32px; flex-shrink: 0; border-radius: 999px; border: none; padding: 3px; background: var(--line-strong); cursor: pointer; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: var(--text); transition: left .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { left: 27px; background: var(--on-accent); }

/* riders */
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: transparent; width: 100%; text-align: left; cursor: pointer; }
.list-item.active { border: 2px solid var(--accent); background: var(--surface); }
.avatar { width: 44px; height: 44px; flex-shrink: 0; border-radius: 50%; background: var(--accent-dim); color: var(--accent); display: grid; place-items: center; font-weight: 700; }
.docs { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.doc { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 600; }
.doc .img { aspect-ratio: 4 / 3; border-radius: 14px; border: 1.5px dashed var(--line-strong); background: var(--bg); display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.doc .img img { width: 100%; height: 100%; object-fit: cover; }
.doc a.img { border-style: solid; }
.doc .missing { color: var(--danger); font-weight: 400; }

/* modal + toast */
dialog { border: 1px solid var(--line); border-radius: 22px; background: var(--surface); color: var(--text); padding: 0; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
dialog::backdrop { background: rgba(0, 0, 0, .6); }
.modal-head { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.modal-actions .btn { flex: 1 1 160px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: none; background: transparent; color: var(--muted); cursor: pointer; font-size: 22px; }
.timeline { display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.timeline div { display: flex; gap: 10px; }
.proof { width: 100%; max-height: 320px; object-fit: contain; border-radius: 14px; background: var(--bg); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface); border: 1px solid var(--line-strong); padding: 12px 18px; border-radius: 14px; z-index: 50; max-width: calc(100vw - 32px); box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.error { border-color: var(--danger-line); color: var(--danger); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .card { width: min(420px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
