:root {
  --bg: #eef3f1;
  --surface: #ffffff;
  --ink: #12201d;
  --muted: #5b6b67;
  --line: #dbe4e1;
  --primary: #0f766e;
  --primary-ink: #ffffff;
  --primary-soft: #d8efeb;
  --amber: #b45309;
  --amber-soft: #fdf0d9;
  --green: #15803d;
  --green-soft: #dcf3e3;
  --red: #b91c1c;
  --red-soft: #fde4e4;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 32, 29, .06), 0 4px 16px rgba(18, 32, 29, .05);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); line-height: 1.45; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
a { color: inherit; }
code { background: var(--primary-soft); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.warn-text { color: var(--amber); }

/* ---------- Tombol & input ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: .95rem;
  cursor: pointer; text-decoration: none; transition: background .15s, transform .05s, border-color .15s;
}
.btn:hover:not(:disabled) { border-color: #b9c7c3; background: #f6f9f8; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid rgba(15, 118, 110, .35); outline-offset: 1px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover:not(:disabled) { background: #0c625b; }
.btn.success { background: var(--green-soft); border-color: #b5e3c3; color: var(--green); }
.btn.amber { background: var(--amber-soft); border-color: #f3d39c; color: var(--amber); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-ghost { color: var(--red); border-color: transparent; background: transparent; }
.btn.danger-ghost:hover { background: var(--red-soft) !important; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 6px 12px; font-size: .85rem; border-radius: 8px; }
.btn.lg { padding: 14px 18px; font-size: 1.05rem; }
.btn.xl { padding: 18px 32px; font-size: 1.3rem; border-radius: 14px; }
.pill { background: rgba(255,255,255,.22); padding: 1px 9px; border-radius: 99px; font-size: .85rem; }

input, select {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); min-width: 0;
}
select { padding: 6px 8px; font-size: .85rem; border-radius: 8px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 500;
  transition: .2s; pointer-events: none; z-index: 100; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast[data-type="error"] { background: var(--red); }

.logo-mark {
  display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 12px;
  background: var(--primary); color: #fff; font-weight: 800; font-size: 1.3rem;
}
.logo-mark.sm { width: 30px; height: 30px; border-radius: 9px; font-size: .95rem; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.empty { color: var(--muted); font-size: .9rem; padding: 14px 4px; margin: 0; }

/* ================= CLIENT ================= */
.client-wrap { max-width: 520px; margin: 0 auto; padding: 20px 18px 48px; }
.client-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 28px; }
.client-title { font-size: 1.7rem; margin-bottom: 6px; }
.service-list { display: grid; gap: 12px; margin-top: 22px; }
.service-card {
  display: flex; align-items: center; gap: 16px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; font: inherit; color: inherit; cursor: pointer; box-shadow: var(--shadow);
  transition: border-color .15s, transform .1s;
}
.service-card:hover { border-color: var(--primary); }
.service-card:active { transform: scale(.99); }
.service-code {
  flex: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 14px;
  background: var(--primary-soft); color: var(--primary); font-weight: 800; font-size: 1.5rem;
}
.service-info { flex: 1; display: grid; gap: 2px; min-width: 0; }
.service-info b { font-size: 1.1rem; }
.service-info small { color: var(--muted); }
.service-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: .8rem; color: var(--muted); }
.service-go { flex: none; background: var(--primary); color: #fff; font-weight: 700; padding: 8px 14px; border-radius: 10px; font-size: .9rem; }

.ticket {
  background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden;
  border: 1px solid var(--line); position: relative;
}
.ticket-top { background: var(--primary); color: #fff; padding: 18px 22px; display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.ticket-org { font-weight: 700; }
.ticket-service { opacity: .9; }
.ticket-body { text-align: center; padding: 26px 20px 22px; }
.ticket-label { text-transform: uppercase; letter-spacing: .08em; font-size: .8rem; color: var(--muted); font-weight: 600; }
.ticket-number { font-size: clamp(4.5rem, 24vw, 7rem); font-weight: 800; color: var(--primary); letter-spacing: -.02em; line-height: 1.05; margin: 6px 0 14px; font-variant-numeric: tabular-nums; }
.ticket-status { display: inline-block; padding: 8px 14px; border-radius: 10px; font-weight: 600; background: var(--primary-soft); color: var(--primary); }
.ticket-status.next { background: var(--amber-soft); color: var(--amber); }
.ticket-status.called { background: var(--amber); color: #fff; }
.ticket-status.skipped { background: var(--red-soft); color: var(--red); }
.ticket-status.done { background: var(--green-soft); color: var(--green); }
.ticket[data-status="done"] .ticket-number { color: #9aa8a5; }
.ticket-cut { position: relative; border-top: 2px dashed var(--line); margin: 0 22px; }
.ticket-cut::before, .ticket-cut::after { content: ""; position: absolute; top: -14px; width: 26px; height: 26px; border-radius: 50%; background: var(--bg); }
.ticket-cut::before { left: -36px; } .ticket-cut::after { right: -36px; }
.ticket-meta { display: grid; grid-template-columns: 1fr 1fr; padding: 18px 22px 6px; gap: 12px; }
.ticket-meta div { display: grid; gap: 2px; }
.ticket-meta span { font-size: .8rem; color: var(--muted); }
.ticket-meta b { font-size: 1.1rem; }
.ticket-foot { padding: 10px 22px 20px; font-size: .85rem; color: var(--muted); }
.actions { display: grid; gap: 10px; margin-top: 18px; }
.called-banner {
  display: grid; gap: 2px; background: var(--amber); color: #fff; border-radius: var(--radius);
  padding: 16px 18px; margin-bottom: 14px; animation: pulse 1.4s ease-in-out infinite;
}
.called-banner b { font-size: 1.2rem; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px rgba(180, 83, 9, .18); } }

/* ================= DASHBOARD ================= */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--surface); padding: 32px; border-radius: 20px; box-shadow: var(--shadow); width: min(380px, 100%); display: grid; gap: 12px; text-align: center; justify-items: center; }
.login-card input { width: 100%; text-align: center; font-size: 1.3rem; letter-spacing: .3em; }
.form-error { color: var(--red); font-size: .9rem; min-height: 1.2em; }
.hint { font-size: .8rem; color: var(--muted); margin: 4px 0 0; }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 12px 24px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; }
.tabs button { border: 0; background: transparent; font: inherit; font-weight: 600; font-size: .9rem; padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.conn { font-size: .8rem; color: var(--green); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.conn.off { color: var(--red); }
.warn-bar { background: var(--amber-soft); color: var(--amber); padding: 10px 24px; font-size: .9rem; border-bottom: 1px solid #f3d39c; }

.page { padding: 22px 24px 48px; max-width: 1400px; margin: 0 auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 26px; }
.stat { display: flex; align-items: center; gap: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-code { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.stat-num { font-size: 1.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: .8rem; color: var(--muted); margin-top: 4px; }

.section-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2 { font-size: 1.15rem; }

.counter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; margin-bottom: 28px; }
.counter-card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; display: grid; gap: 14px; box-shadow: var(--shadow); transition: box-shadow .3s, border-color .3s; }
.counter-card header { display: grid; gap: 8px; }
.counter-card h3 { font-size: 1.15rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: .75rem; font-weight: 600; background: var(--bg); padding: 3px 9px; border-radius: 99px; color: var(--muted); }
.chip.warn { background: var(--amber-soft); color: var(--amber); }
.now { background: var(--bg); border-radius: 14px; padding: 14px; text-align: center; }
.counter-card.busy .now { background: var(--primary-soft); }
.now-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--muted); }
.now-num { font-size: 3.2rem; font-weight: 800; color: var(--primary); line-height: 1.1; font-variant-numeric: tabular-nums; }
.counter-card:not(.busy) .now-num { color: #b4c1be; }
.now-meta { font-size: .8rem; color: var(--muted); }
.counter-actions { display: grid; gap: 8px; }
.btn-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.btn-row .btn { padding: 9px 6px; font-size: .85rem; }
.counter-card.flash { border-color: var(--amber); box-shadow: 0 0 0 4px rgba(180, 83, 9, .2); }
.empty-card { background: var(--surface); border: 1px dashed var(--line); border-radius: 18px; padding: 28px; color: var(--muted); }

.queue-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 18px; }
.panel h3 { font-size: 1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.panel-note { font-size: .82rem; color: var(--muted); margin: 4px 0 10px; }
.count { background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: .85rem; padding: 2px 10px; border-radius: 99px; }
.count.amber { background: var(--amber-soft); color: var(--amber); }
.q-list { display: grid; max-height: 460px; overflow: auto; }
.q-row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--line); }
.q-row:first-child { border-top: 0; }
.q-num { flex: none; font-weight: 800; font-size: 1.05rem; min-width: 64px; font-variant-numeric: tabular-nums; color: var(--primary); }
.q-row.skipped .q-num { color: var(--amber); }
.q-num.sm { min-width: 54px; font-size: .95rem; }
.q-info { flex: 1; display: grid; min-width: 0; }
.q-info b { font-size: .88rem; font-weight: 600; }
.q-info small { color: var(--muted); font-size: .78rem; }
.q-act { display: flex; gap: 6px; align-items: center; flex: none; }
.call-row { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-top: 1px solid var(--line); font-size: .9rem; }
.call-row:first-child { border-top: 0; }
.call-row small { margin-left: auto; color: var(--muted); }
.tag { font-size: .72rem; background: var(--amber-soft); color: var(--amber); padding: 1px 7px; border-radius: 99px; font-weight: 600; }

.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; align-items: start; }
.settings-grid .panel h3 { margin-bottom: 4px; }
.cfg-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.cfg-main { flex: 1; display: grid; }
.cfg-main small { color: var(--muted); }
.code-badge { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-weight: 800; }
.counter-cfg .cfg-name { width: 150px; font-weight: 600; }
.counter-cfg .checks { flex: 1; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: .88rem; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.stack-form { display: grid; gap: 10px; margin-top: 14px; padding-top: 16px; border-top: 1px solid var(--line); }
.stack-form h4 { font-size: .9rem; }
.grid-2 { display: grid; grid-template-columns: 110px 1fr; gap: 10px; }
.row-form { display: flex; gap: 10px; margin-top: 10px; }
.row-form input { flex: 1; }
.danger-zone { border-color: #f1c6c6; }

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .page { padding: 16px 14px 40px; }
  .top-actions { margin-left: 0; width: 100%; }
  .settings-grid { grid-template-columns: 1fr; }
  .q-row { flex-wrap: wrap; }
  .q-act { width: 100%; justify-content: flex-end; }
}

/* ================= LAYAR TV ================= */
body.display { background: #0b2b28; color: #fff; min-height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
.start-overlay { position: fixed; inset: 0; background: rgba(5, 25, 22, .94); display: grid; place-items: center; text-align: center; z-index: 50; color: #cfe3df; }
.d-head { display: flex; justify-content: space-between; align-items: center; padding: 2.2vh 3vw; }
.d-brand { display: flex; align-items: center; gap: 16px; font-size: clamp(1.2rem, 2.4vw, 2.2rem); font-weight: 700; }
.d-brand .logo-mark { background: #14b8a6; color: #0b2b28; }
.d-clock { text-align: right; }
.d-clock #clock { font-size: clamp(1.6rem, 3.4vw, 3rem); font-weight: 800; font-variant-numeric: tabular-nums; }
.d-clock #date { color: #8fb9b2; font-size: clamp(.8rem, 1.2vw, 1.1rem); }
.d-main { flex: 1; display: grid; grid-template-columns: 1.3fr 1fr; gap: 2.4vw; padding: 0 3vw 2vh; min-height: 0; }
.d-current { background: #fff; color: var(--ink); border-radius: 28px; display: grid; place-content: center; text-align: center; padding: 3vh 2vw; }
.d-label { text-transform: uppercase; letter-spacing: .12em; font-weight: 700; color: var(--muted); font-size: clamp(1rem, 1.8vw, 1.6rem); }
.d-num { font-size: clamp(6rem, 15vw, 16rem); font-weight: 800; color: var(--primary); line-height: 1; margin: 2vh 0; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.d-to { font-size: clamp(1.4rem, 3vw, 3rem); font-weight: 700; }
.d-current.flash { animation: dflash 1s ease-in-out 3; }
@keyframes dflash { 50% { background: #fde68a; } }
.d-counters { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1.4vw; align-content: start; overflow: auto; }
.d-counter { background: #12413c; border-radius: 20px; padding: 2.2vh 1.6vw; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.d-counter.active { background: #14b8a6; color: #06201d; }
.d-cname { font-size: clamp(1rem, 1.7vw, 1.6rem); font-weight: 600; }
.d-cnum { font-size: clamp(1.8rem, 3.6vw, 3.6rem); font-weight: 800; font-variant-numeric: tabular-nums; }
.d-foot { display: flex; gap: 3vw; padding: 2vh 3vw; background: #06201d; color: #a7cfc8; font-size: clamp(.9rem, 1.4vw, 1.3rem); flex-wrap: wrap; }
.d-foot b { color: #5eead4; }
.d-foot-note { margin-left: auto; }
@media (max-width: 900px) { .d-main { grid-template-columns: 1fr; } body.display { overflow: auto; } }
.inline-form { display: inline; margin: 0; }
.login-card .login-input { letter-spacing: normal; font-size: 1rem; text-align: left; }
.login-card .check { justify-self: start; }

/* ================= LAPORAN ================= */
.tabs a { text-decoration: none; font-weight: 600; font-size: .9rem; padding: 7px 14px; border-radius: 8px; color: var(--muted); }
.tabs a.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.report-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.report-head h1 { font-size: 1.5rem; margin-bottom: 4px; }
.report-head p { margin: 0; }
.report-actions { display: flex; gap: 8px; }
.report-filters { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px; }
.report-filters label { display: inline-flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--muted); font-weight: 600; }
.report-filters input, .report-filters select { padding: 7px 10px; font-size: .9rem; border-radius: 8px; }
.presets { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 10px; flex-wrap: wrap; }
.presets button { border: 0; background: transparent; font: inherit; font-size: .85rem; font-weight: 600; padding: 6px 12px; border-radius: 7px; color: var(--muted); cursor: pointer; }
.presets button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.report-body { transition: opacity .15s; }
.report-body.loading { opacity: .5; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.kpi-label { font-size: .82rem; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.9rem; font-weight: 800; margin: 4px 0 2px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.chart-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; margin-bottom: 16px; }
.chart-grid.single { grid-template-columns: 1fr; }
.chart { position: relative; min-height: 230px; }
.chart svg { display: block; max-width: 100%; height: auto; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .grid.base { stroke: #b9c7c3; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--primary); }
.chart .hit { fill: transparent; cursor: default; }
.chart .hit.on { fill: rgba(15, 118, 110, .07); }
.chart-tip { position: absolute; pointer-events: none; background: var(--ink); color: #fff; border-radius: 8px; padding: 8px 10px; font-size: .8rem; display: grid; gap: 2px; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.18); z-index: 5; }
.table-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.table-grid .wide { grid-column: 1 / -1; }
.table-grid h3 { margin-bottom: 10px; }
.table-wrap { overflow-x: auto; }
.rtable { width: 100%; border-collapse: collapse; font-size: .88rem; }
.rtable th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rtable td { padding: 9px 8px; border-bottom: 1px solid var(--line); }
.rtable tr:last-child td { border-bottom: 0; }
.rtable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rtable small { color: var(--muted); }
.empty-state { text-align: center; padding: 40px 20px; }
.report-note { margin-top: 16px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } .table-grid { grid-template-columns: 1fr; } }
@media print {
  body.report-page { background: #fff; }
  .report-page .topbar, .report-page .report-filters, .report-page .report-actions, .chart-tip { display: none !important; }
  .report-page .page { padding: 0; max-width: none; }
  .report-page .panel, .report-page .kpi { break-inside: avoid; box-shadow: none; }
  .chart-grid { grid-template-columns: 1fr; }
  .table-grid { grid-template-columns: 1fr 1fr; }
  .chart .bar { fill: #0f766e; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
