:root {
  --bg: #0d0f14;
  --surface: #15181f;
  --surface-2: #1b1f28;
  --line: #262b36;
  --text: #e8ecf4;
  --muted: #8891a4;
  --accent: #5b8cff;
  --accent-ink: #ffffff;
  --ok: #2fbf8f;
  --warn: #e0a92c;
  --err: #e2585a;
  --radius: 16px;
  --radius-sm: 10px;
  --tap: 48px;
  --pad: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  padding-bottom: env(safe-area-inset-bottom);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------------------------------------------------------------- header */

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 10px;
  padding: 12px var(--pad);
  background: rgba(13, 15, 20, .86);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 650; letter-spacing: -.2px; color: var(--text);
  font-size: 17px;
}
.brand:hover { text-decoration: none; }
.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(91, 140, 255, .18);
}

.nav { display: none; }

.topbar .spacer { flex: 1; }

.who {
  display: none;
  color: var(--muted); font-size: 13px; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ------------------------------------------------------------ bottom nav */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  display: flex;
  background: rgba(17, 20, 26, .96);
  backdrop-filter: saturate(140%) blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  flex: 1 1 0; min-width: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 9px 4px 10px;
  color: var(--muted); font-size: 11px; font-weight: 550;
  text-align: center; line-height: 1.1;
}
.tabbar a:hover { text-decoration: none; }
.tabbar a .ic { font-size: 19px; line-height: 1; }
.tabbar a.active { color: var(--accent); }
.tabbar a span.lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* ------------------------------------------------------------- container */

:root { --topbar-h: 63px; }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px var(--pad) 96px;
}

/* Halaman yang isinya tabel lebar atau dua kolom (konsol operator) minta ruang lebih. */
.wrap.wide { max-width: 1440px; }

h1 { font-size: 22px; line-height: 1.25; margin: 0 0 4px; letter-spacing: -.4px; }
h2 { font-size: 16px; margin: 0 0 12px; letter-spacing: -.2px; }
h3 { font-size: 14px; margin: 18px 0 6px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
p { margin: 0 0 12px; }
.sub { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .93em; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px var(--pad);
  margin-bottom: 14px;
}
.card > :last-child { margin-bottom: 0; }

/* --------------------------------------------------------------- layout */

.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------------------------------------------------------------- stats */

.stat {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
}
.stat .n { font-size: 23px; font-weight: 650; letter-spacing: -.6px; line-height: 1.2; }
.stat .l { color: var(--muted); font-size: 12.5px; margin-top: 1px; }
.col-sm-only { display: none; }
.stat.plain { background: transparent; border-color: transparent; padding: 0; }
.stat.plain .n { font-size: 21px; }
.grid > .stat.plain + .stat.plain { border-left: 1px solid var(--line); padding-left: 14px; }

/* -------------------------------------------------------------- buttons */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 18px;
  border: 1px solid transparent; border-radius: var(--radius-sm);
  background: var(--accent); color: var(--accent-ink);
  font: inherit; font-weight: 600; font-size: 15px;
  cursor: pointer; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: transparent; border-color: var(--line); color: var(--err); }
.btn.danger:hover { background: rgba(226, 88, 90, .1); }
.btn.sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .45; cursor: not-allowed; }
.btn.disabled:hover { filter: none; }

/* --------------------------------------------------------------- forms */

.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }

input:not([type=checkbox]):not([type=radio]):not([type=file]),
select, textarea {
  width: 100%; min-height: var(--tap); padding: 11px 13px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: 16px;
}
textarea { min-height: 108px; resize: vertical; line-height: 1.5; }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 19px) 50%, calc(100% - 14px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 38px; }
input:not([type=checkbox]):not([type=radio]):focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(91, 140, 255, .18); }
input::placeholder, textarea::placeholder { color: #5c6478; }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; padding: 0; background: none; border: 0; }

.hint { color: var(--muted); font-size: 13px; margin: 6px 0 0; }
.hint.strong { color: var(--text); }
.hint .mono { color: var(--text); }

/* ---------------------------------------------------------------- pills */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line);
  color: var(--muted); font-size: 12.5px; font-weight: 600; white-space: nowrap;
}
.pill.ok { color: var(--ok); border-color: rgba(47, 191, 143, .35); background: rgba(47, 191, 143, .1); }
.pill.warn { color: var(--warn); border-color: rgba(224, 169, 44, .35); background: rgba(224, 169, 44, .1); }
.pill.err { color: var(--err); border-color: rgba(226, 88, 90, .35); background: rgba(226, 88, 90, .1); }
.pill.live { color: var(--accent); border-color: rgba(91, 140, 255, .35); background: rgba(91, 140, 255, .12); }
.pill.live::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1 } 50% { opacity: .25 } }

/* --------------------------------------------------------------- flash */

.flash {
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px;
  border: 1px solid var(--line); background: var(--surface-2); font-size: 14.5px;
}
.flash.ok { border-color: rgba(47, 191, 143, .35); background: rgba(47, 191, 143, .1); color: #b6f0da; }
.flash.err { border-color: rgba(226, 88, 90, .35); background: rgba(226, 88, 90, .1); color: #f6c9ca; }
.flash strong { color: inherit; }
.flash a { color: inherit; text-decoration: underline; }

/* --------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }

/* Di layar HP, label dan nilainya ditumpuk supaya nilainya tidak terpotong. */
@media (max-width: 640px) {
  table.stack-sm, table.stack-sm tbody, table.stack-sm tr, table.stack-sm th, table.stack-sm td { display: block; width: 100%; }
  table.stack-sm tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  table.stack-sm tr:last-child { border-bottom: 0; }
  table.stack-sm th { border-bottom: 0; padding: 0 0 5px; white-space: normal; }
  table.stack-sm td { border-bottom: 0; padding: 0; }
}

.rowval { margin-left: 8px; word-break: break-word; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }

.vars-box {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 11px 13px;
  margin-bottom: 16px; font-size: 13.5px; color: var(--muted); line-height: 1.7;
}
.vars-box strong { color: var(--text); }
.vars-box .mono { color: var(--text); }

/* ------------------------------------------------------- grup formulir */

.card > h2 .step {
  display: inline-flex; align-items: center; justify-content: center;
  width: 19px; height: 19px; border-radius: 50%; margin-right: 8px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: 0;
}

.opt {
  color: var(--muted); font-weight: 500; font-size: 11.5px;
  text-transform: none; letter-spacing: 0; margin-left: 4px;
}

.script {
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 12px 13px; margin: 0;
  font-size: 14px; line-height: 1.6; white-space: pre-wrap;
}

/* --------------------------------------------------------------- digits */

/* ------------------------------------------------------- konsol operator */

.console { display: grid; grid-template-columns: 1fr; gap: 14px; }

/* Di HP panel tampil lebih dulu supaya tombol yang ditekan penerima langsung terlihat. */
.console-live { order: -1; }

@media (min-width: 1000px) {
  .console { grid-template-columns: 3fr 2fr; align-items: start; }
  .console-form { order: -1; }
  /* Panel menempel di bawah navbar, bukan di bawahnya (navbar z-index 40). */
  .console-live { order: 0; position: sticky; top: calc(var(--topbar-h, 63px) + 14px); }
}

.live-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.live-timer { color: var(--muted); font-size: 13px; }
.live-dest { font-size: 17px; font-weight: 650; margin: 0 0 4px; word-break: break-all; }

/* ----------------------------------------------------------- daftar suara */

.voice-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.voice-main { flex: 1 1 240px; min-width: 0; }
.voice-name { font-weight: 650; letter-spacing: -.2px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.voice-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.voice-actions form { margin: 0; }
.voice-row .voice-audio, .voice-row .voice-note { flex: 1 1 100%; }

.digits { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; min-height: 44px; align-items: center; }
.digit {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 11px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 19px; font-weight: 650;
}

/* ------------------------------------------------------------------ log */

.log { max-height: 320px; overflow-y: auto; font-size: 14px; }
.log .item { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.log .item:last-child { border-bottom: 0; }
.log .t { color: var(--muted); font-family: ui-monospace, monospace; font-size: 12.5px; flex: 0 0 62px; padding-top: 2px; }
.log .m { flex: 1; }
.log .item.dtmf .m { color: var(--accent); font-weight: 600; }
.log .item.error .m { color: var(--err); }

/* ----------------------------------------------------------- accordion */

details.acc { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
details.acc > summary {
  cursor: pointer; list-style: none; color: var(--muted);
  font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px;
}
details.acc > summary::-webkit-details-marker { display: none; }
details.acc > summary::after { content: "▾"; margin-left: auto; transition: transform .15s; }
details.acc[open] > summary::after { transform: rotate(180deg); }
details.acc > summary:hover { color: var(--text); }
details.acc > *:not(summary) { margin-top: 14px; }

/* ------------------------------------------------------------- desktop */

@media (min-width: 760px) {
  :root { --pad: 24px; }
  .wrap { padding: 26px 24px 60px; }
  .grid.cols-2 { grid-template-columns: 1fr 1fr; }
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
  h1 { font-size: 26px; }
  .card { padding: 22px 24px; }
  .tabbar { display: none; }
  .nav { display: flex; gap: 4px; margin-left: 14px; }
  .nav a {
    padding: 8px 13px; border-radius: 9px; color: var(--muted);
    font-size: 14.5px; font-weight: 600;
  }
  .nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
  .nav a.active { background: var(--surface-2); color: var(--text); }
  .who { display: block; }
  .wrap { padding-bottom: 60px; }
}

@media (max-width: 759px) {
  .grid.cols-4, .grid.cols-3 { grid-template-columns: 1fr 1fr; }
  .col-sm-hide { display: none !important; }
  .col-sm-only { display: inline; }
  table { font-size: 13.5px; }
  th, td { padding: 10px 7px; }
  th { font-size: 11px; }
  td.nowrap, th.nowrap { white-space: nowrap; }
  .log .t { flex-basis: 54px; }
  .stat .n { font-size: 21px; }
  .row > .btn { flex: 1 1 auto; }
  h1 { font-size: 21px; }
}
