/* LiveCue platform — shared tokens and components (admin + customer back office). */
:root {
  --bg: #F5F6F8;
  --ink: #172033;
  --muted: #5B6474;
  --line: #E3E6EB;
  --line-soft: #EEF0F3;
  --field: #D5D9E0;
  --accent: #0F6F7C;
  --accent-hover: #0B5560;
  --side: #121A2B;
  --side-active: #22304A;
  --side-ink: #C9CFDA;
  --side-muted: #A9B1C1;
  --ok-bg: #E6F4EC; --ok: #1F6B44;
  --warn-bg: #FFF1D6; --warn: #7A4A00;
  --bad-bg: #FDE8E7; --bad: #9B1C14;
  --info-bg: #E3F1F3; --info: #0B5560;
  --gray-bg: #EEF0F3; --gray: #454E5E;
  --danger: #B42318; --danger-hover: #912018;
  --focus: 0 0 0 3px rgba(15, 111, 124, .35);
  --radius: 12px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans Thai", "Segoe UI", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
h1 { margin: 0; font-size: 24px; line-height: 1.25; }
h2 { margin: 0; font-size: 16px; }
h3 { margin: 0; font-size: 14px; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 600; }
.nowrap { white-space: nowrap; }
.break { word-break: break-all; }
.hidden { display: none !important; }
.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; }
.skip { position: absolute; left: 8px; top: -60px; z-index: 50; background: #fff; padding: 8px 12px; border-radius: 8px; }
.skip:focus { top: 8px; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--side); color: #E6E9EF; padding: 22px 14px; display: flex; flex-direction: column; gap: 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; color: #fff; flex: none; }
.brand b { display: block; font-size: 15px; }
.brand span { display: block; font-size: 12px; color: var(--side-muted); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 42px; padding: 0 12px; border-radius: 8px; color: var(--side-ink); font-size: 14px; text-decoration: none; }
.nav a:hover { background: #1A2438; color: #fff; }
.nav a[aria-current="page"] { background: var(--side-active); color: #fff; font-weight: 600; }
.badge { min-width: 20px; padding: 1px 7px; border-radius: 999px; background: #F2B33D; color: #2A1B00; font-size: 12px; font-weight: 700; text-align: center; }
.side-foot { margin-top: auto; padding: 12px; border-radius: 10px; background: #1A2438; display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--side-muted); }
.side-foot b { color: #E6E9EF; }
.side-foot button { align-self: flex-start; }
.main { min-width: 0; padding: 28px 32px 56px; }
.page { max-width: 1240px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-head .crumb { font-size: 13px; color: var(--muted); }
.page-head .lead { font-size: 13px; color: var(--muted); max-width: 760px; }
.head-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.row.between { justify-content: space-between; }
.row.end { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack.tight { gap: 6px; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(360px, 1fr)); gap: 16px; }
.split { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); gap: 16px; align-items: start; }

/* ---------- cards ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.card.pad-s { padding: 14px 16px; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.card.danger-zone { border-color: #F1B8B3; background: #FFFBFA; }
a.card { text-decoration: none; color: inherit; }
a.card:hover { border-color: var(--accent); color: inherit; }
.stat { gap: 6px; }
.stat .label { font-size: 13px; color: var(--muted); }
.stat .num { font-size: 30px; font-weight: 700; line-height: 1.1; }
.stat .pill { align-self: flex-start; }
.note { padding: 12px 14px; border-radius: 10px; background: var(--gray-bg); color: var(--gray); font-size: 13px; }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.info { background: var(--info-bg); color: var(--info); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 13px; border: 1px dashed var(--line); border-radius: 10px; }
.error-box { padding: 14px 16px; border-radius: 10px; background: var(--bad-bg); color: var(--bad); font-size: 13px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.loading { padding: 24px; color: var(--muted); font-size: 13px; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t td.actions { white-space: nowrap; text-align: right; }
.t td.actions .btn + .btn { margin-left: 6px; }
.t .sub { font-size: 12px; color: var(--muted); }

dl.kv { display: grid; grid-template-columns: minmax(110px, max-content) minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; min-width: 0; word-break: break-word; }

/* ---------- pills ---------- */
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.6; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.gray { background: var(--gray-bg); color: var(--gray); }
.pills { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--field); background: #fff; color: var(--ink); font: inherit; font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #B9BFC9; background: #FAFBFC; color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--gray-bg); }
.btn.link { border: 0; background: none; color: var(--accent); padding: 0 4px; min-height: 40px; text-decoration: underline; }
.btn.sm { min-height: 40px; padding: 0 10px; font-size: 12.5px; }
.btn.side-btn { background: transparent; border-color: #34405A; color: #E6E9EF; min-height: 40px; }
.btn.side-btn:hover { background: #22304A; color: #fff; }
.btn[disabled], .btn[aria-disabled="true"] { background: #E3E6EB; border-color: #E3E6EB; color: #5B6474; cursor: not-allowed; }
.btn.wide { width: 100%; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: #E9ECF0; border-radius: 10px; align-self: flex-start; }
.tab { min-height: 40px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent; background: transparent; font: inherit; font-size: 13px; font-weight: 600; color: var(--gray); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.tab[aria-selected="true"] { background: #fff; border-color: var(--field); color: var(--ink); }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; min-width: 0; }
.field > span:first-child, .field legend { font-weight: 600; color: var(--ink); }
.field .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea, .input {
  min-height: 42px; border: 1px solid var(--field); border-radius: 8px; padding: 0 12px; font: inherit; font-size: 14px; background: #fff; color: var(--ink); width: 100%; }
.field textarea { padding: 10px 12px; min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--accent); box-shadow: var(--focus); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
fieldset.field { border: 0; padding: 0; margin: 0; }
.check { display: flex; align-items: flex-start; gap: 10px; min-height: 40px; font-size: 14px; cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--accent); flex: none; }
.radio-row { display: flex; flex-wrap: wrap; gap: 8px; }
.radio-row label { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 14px; border: 1px solid var(--field); border-radius: 8px; cursor: pointer; background: #fff; }
.radio-row input { accent-color: var(--accent); width: 18px; height: 18px; margin: 0; }
.radio-row label:has(input:checked) { border-color: var(--accent); background: var(--info-bg); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--field); border-radius: 8px; background: #fff; padding: 0 12px; min-height: 42px; }
.search input { border: 0; outline: none; font: inherit; font-size: 13px; min-width: 180px; background: transparent; min-height: 40px; }
.search:focus-within { border-color: var(--accent); box-shadow: var(--focus); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.toolbar select { min-height: 42px; border: 1px solid var(--field); border-radius: 8px; padding: 0 10px; font: inherit; font-size: 13px; background: #fff; }
.form-error { color: var(--bad); font-size: 13px; min-height: 0; }
.form-error:empty { display: none; }

/* ---------- quota bars ---------- */
.meter { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.meter-top { display: flex; justify-content: space-between; gap: 8px; }
.bar { height: 8px; border-radius: 999px; background: var(--gray-bg); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 999px; }
.bar.warn > i { background: #C77D00; }
.bar.bad > i { background: var(--danger); }

/* ---------- dialog / toast ---------- */
dialog.dlg { border: 0; border-radius: 14px; padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px); color: var(--ink); box-shadow: 0 20px 60px rgba(18, 26, 43, .25); }
dialog.dlg::backdrop { background: rgba(18, 26, 43, .45); }
dialog.dlg form { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
dialog.dlg .dlg-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; max-width: min(420px, calc(100vw - 32px)); }
.toast { padding: 12px 16px; border-radius: 10px; background: #172033; color: #fff; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.toast.bad { background: var(--danger); }
.toast.ok { background: #1F6B44; }

/* ---------- queue (review) ---------- */
.queue { display: flex; flex-direction: column; gap: 8px; }
.qrow { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: #fff; text-align: left; font: inherit; color: inherit; cursor: pointer; width: 100%; min-height: 44px; }
.qrow:hover { border-color: #B9BFC9; }
.qrow[aria-current="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(15, 111, 124, .18); }
.qrow .qtop { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; font-size: 13px; }
.qrow .qsub { font-size: 12px; color: var(--muted); }

/* ---------- auth pages ---------- */
.auth { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 32px 16px; gap: 20px; }
.auth-top { width: min(460px, 100%); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.auth-card { width: min(460px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.auth-card.wide { width: min(640px, 100%); }
.auth-card h1 { font-size: 22px; }
.secret { font-family: var(--mono); font-size: 18px; letter-spacing: 1px; padding: 12px 14px; border-radius: 10px; background: var(--gray-bg); word-break: break-all; }
.uri { font-family: var(--mono); font-size: 12px; padding: 10px 12px; border-radius: 10px; background: var(--gray-bg); word-break: break-all; }
.steps-dots { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.dot { width: 26px; height: 26px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; background: #E3E6EB; color: var(--gray); }
.dot.on { background: var(--accent); color: #fff; }
.lang { display: flex; gap: 4px; }
.lang button { min-height: 40px; min-width: 44px; padding: 0 10px; border: 1px solid var(--field); border-radius: 8px; background: #fff; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink); }
.lang button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  .split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; height: auto; padding: 14px 12px; gap: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav a { min-height: 40px; }
  .side-foot { margin-top: 0; }
  .main { padding: 20px 16px 48px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 480px) {
  h1 { font-size: 20px; }
  .card { padding: 16px; }
  .auth-card { padding: 20px; }
  .search input { min-width: 0; width: 100%; }
  .search { width: 100%; }
  dl.kv { grid-template-columns: minmax(0, 1fr); gap: 2px 0; }
  dl.kv dd { margin-bottom: 8px; }
}

.page > div:empty { display: none; }
.shell { background: linear-gradient(to right, var(--side) 232px, transparent 232px); }
@media (max-width: 900px) { .shell { background: none; } }
