/* ABKA Bridge — tampilan konsol bridging alat medis */
:root {
  --bg: #eef3f2;
  --surface: #ffffff;
  --surface-2: #f6f9f8;
  --ink: #10302e;
  --ink-2: #4a615f;
  --ink-3: #7a8d8b;
  --line: #d3dedc;
  --line-2: #e4ecea;
  --teal: #0b7a70;
  --teal-dark: #075c54;
  --teal-soft: #dcefec;
  --amber: #9a6413;
  --amber-soft: #fbf0dc;
  --red: #b0382a;
  --red-soft: #f8e2de;
  --blue: #2a5797;
  --blue-soft: #e1eaf7;
  --side: #0f2b29;
  --side-ink: #b9d2ce;
  --side-active: #17423e;
  --radius: 10px;
  --font: "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Atkinson Hyperlegible Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); font-variant-numeric: tabular-nums; }
a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 1.55rem; font-weight: 700; }
h2 { font-size: 1.1rem; font-weight: 700; }
h3 { font-size: 0.98rem; font-weight: 700; }
p { margin: 0 0 0.75rem; }
small, .muted { color: var(--ink-2); }
.faint { color: var(--ink-3); }
code, .mono { font-family: var(--mono); font-size: 0.86em; }
:focus-visible { outline: 3px solid #49b3a8; outline-offset: 2px; }

/* ---------- Kerangka halaman ---------- */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; background: linear-gradient(90deg, var(--side) 248px, transparent 248px); }
.side { background: var(--side); color: var(--side-ink); padding: 18px 14px 24px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; color: #fff; }
.brand svg { flex: none; }
.brand b { display: block; font-size: 1.02rem; letter-spacing: 0.01em; }
.brand span { display: block; font-size: 0.74rem; color: var(--side-ink); }
.site-pill { margin: 0 6px 16px; padding: 9px 10px; border: 1px solid #24504b; border-radius: 8px; font-size: 0.82rem; }
.site-pill b { display: block; color: #fff; font-size: 0.88rem; }
.site-pill select { width: 100%; margin-top: 6px; background: #12332f; color: #fff; border: 1px solid #2c5d57; border-radius: 6px; padding: 5px; font: inherit; }
.nav-group { margin: 14px 0 4px; padding: 0 10px; font-size: 0.74rem; color: #7fa39e; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 7px; color: var(--side-ink); font-size: 0.93rem; }
.nav a:hover { background: #163b37; text-decoration: none; color: #fff; }
.nav a.active { background: var(--side-active); color: #fff; box-shadow: inset 3px 0 0 #3fc1b2; }
.nav svg { width: 18px; height: 18px; flex: none; opacity: 0.9; }
.main { min-width: 0; padding: 22px 30px 60px; }
.topbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.topbar .sub { color: var(--ink-2); margin-top: 4px; font-size: 0.93rem; max-width: 70ch; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 0.86rem; color: var(--ink-2); }
.userbox form { margin: 0; }
.btn.menu-toggle { display: none; margin-bottom: 10px; padding: 6px 8px; }
.menu-toggle svg { width: 20px; height: 20px; }

/* ---------- Komponen ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.card-head p { margin: 2px 0 0; font-size: 0.86rem; color: var(--ink-2); }
.card-body { padding: 16px 18px; }
.card-foot { padding: 12px 18px; border-top: 1px solid var(--line-2); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-side { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: 600 0.9rem var(--font); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; border-color: #b8c9c6; }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); color: #fff; }
.btn-danger { color: var(--red); border-color: #e7c2bc; }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 5px 10px; font-size: 0.82rem; border-radius: 7px; }
.btn-link { background: none; border: 0; padding: 0; color: var(--teal); font: inherit; cursor: pointer; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.78rem; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--teal-soft); color: var(--teal-dark); }
.badge-warn { background: var(--amber-soft); color: var(--amber); }
.badge-bad { background: var(--red-soft); color: var(--red); }
.badge-muted { background: #e9eeed; color: var(--ink-2); }
.tag { display: inline-block; padding: 1px 7px; border: 1px solid var(--line); border-radius: 5px; font-size: 0.76rem; color: var(--ink-2); background: var(--surface-2); }
.flag { display: inline-block; min-width: 54px; text-align: center; padding: 1px 7px; border-radius: 5px; font-size: 0.76rem; font-weight: 700; }
.flag-high { background: var(--red-soft); color: var(--red); }
.flag-low { background: var(--blue-soft); color: var(--blue); }
.flag-abn { background: var(--amber-soft); color: var(--amber); }
tr.abnormal td.val { font-weight: 700; }
tr.abnormal-high td.val { color: var(--red); }
tr.abnormal-low td.val { color: var(--blue); }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th { text-align: left; font-weight: 600; color: var(--ink-2); font-size: 0.8rem; padding: 9px 14px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 9px 14px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #f8fbfa; }
.table td.num, .table th.num { text-align: right; }
.table .nowrap { white-space: nowrap; }
.rowlink { cursor: pointer; }

.empty { padding: 36px 20px; text-align: center; color: var(--ink-2); }
.empty h3 { color: var(--ink); margin-bottom: 6px; }
.empty .btn { margin-top: 10px; }

.alert { padding: 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 0.92rem; border: 1px solid; }
.alert-success { background: var(--teal-soft); border-color: #b4dcd6; color: var(--teal-dark); }
.alert-error { background: var(--red-soft); border-color: #ebc0b8; color: var(--red); }
.alert-info { background: var(--blue-soft); border-color: #c4d4ec; color: var(--blue); }
.alert-warn { background: var(--amber-soft); border-color: #ecd3a6; color: var(--amber); }
.alert b { color: inherit; }

/* ---------- Formulir ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label, .field .label { display: block; font-weight: 600; font-size: 0.86rem; margin-bottom: 5px; }
.field .hint { font-size: 0.8rem; color: var(--ink-2); margin-top: 4px; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=url], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #c3d1ce; border-radius: 8px; background: #fff; color: var(--ink); font: 0.93rem var(--font);
}
textarea { font-family: var(--mono); font-size: 0.84rem; line-height: 1.5; min-height: 220px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); outline: 2px solid #bfe3de; outline-offset: 0; }
.check { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.filters .field { min-width: 150px; }
.filters .grow { flex: 1; min-width: 200px; }

/* ---------- Angka ringkas ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid var(--line-2); }
.stat { padding: 14px 18px; border-right: 1px solid var(--line-2); }
.stat:last-child { border-right: 0; }
.stat .n { font-size: 1.65rem; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: 0.82rem; color: var(--ink-2); margin-top: 3px; }
.stat.bad .n { color: var(--red); }
.stat.warn .n { color: var(--amber); }

/* ---------- Jejak data langsung (monitor) ---------- */
.trace-card { background: #0d2624; border-color: #0d2624; color: #cfe6e2; overflow: hidden; }
.trace-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px 4px; gap: 12px; flex-wrap: wrap; }
.trace-head h2 { color: #fff; }
.trace-head .live { display: inline-flex; align-items: center; gap: 7px; font-size: 0.82rem; color: #8fd5cb; }
.trace-head .live i { width: 8px; height: 8px; border-radius: 50%; background: #4fd1bf; display: inline-block; }
.trace-head .live.off { color: #e9b4a9; }
.trace-head .live.off i { background: #e07a66; }
#trace { display: block; width: 100%; height: 132px; }
.trace-legend { display: flex; gap: 16px; padding: 0 18px 12px; font-size: 0.78rem; color: #8fb4ae; flex-wrap: wrap; }
.trace-legend span::before { content: ""; display: inline-block; width: 10px; height: 3px; margin-right: 6px; vertical-align: middle; background: currentColor; }
.trace-legend .ok { color: #4fd1bf; } .trace-legend .warn { color: #e9b44c; } .trace-legend .bad { color: #ef7a62; }
.trace-card .stats { border-top-color: #1d3d3a; }
.trace-card .stat { border-right-color: #1d3d3a; }
.trace-card .stat .n { color: #fff; }
.trace-card .stat .l { color: #8fb4ae; }
.trace-card .stat.bad .n { color: #ef7a62; }
.trace-card .stat.warn .n { color: #e9b44c; }

.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 74px 1fr auto; gap: 10px; padding: 10px 18px; border-bottom: 1px solid var(--line-2); align-items: center; }
.feed li:last-child { border-bottom: 0; }
.feed .t { font-family: var(--mono); font-size: 0.82rem; color: var(--ink-2); }
.feed .d b { display: block; font-size: 0.92rem; }
.feed .d span { font-size: 0.82rem; color: var(--ink-2); }
.feed li.new { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: #e2f4f1; } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .feed li.new { animation: none; } }

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.dot-ok { background: #1aa392; } .dot-bad { background: #d0533f; } .dot-muted { background: #a9b8b6; } .dot-warn { background: #d69a2b; }

/* ---------- Pesan mentah & penerjemah ---------- */
.raw { font-family: var(--mono); font-size: 0.82rem; line-height: 1.6; background: #0f2523; color: #d6ebe7; padding: 14px 16px; border-radius: 8px; overflow-x: auto; white-space: pre; margin: 0; max-height: 460px; }
.raw .ctl { color: #e9b44c; }
.raw .seg { color: #6fd6c7; font-weight: 700; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 14px; font-size: 0.92rem; margin: 0; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
details.seg { border-bottom: 1px solid var(--line-2); }
details.seg summary { padding: 8px 14px; cursor: pointer; font-family: var(--mono); font-size: 0.84rem; list-style: none; display: flex; gap: 10px; }
details.seg summary::-webkit-details-marker { display: none; }
details.seg summary b { color: var(--teal-dark); min-width: 36px; }
details.seg summary span { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
details.seg[open] summary { background: var(--surface-2); }
.fields { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.fields td { padding: 5px 14px; border-top: 1px solid var(--line-2); vertical-align: top; }
.fields td:first-child { width: 72px; font-family: var(--mono); color: var(--ink-3); white-space: nowrap; }
.fields td:nth-child(2) { width: 210px; color: var(--ink-2); }
.fields td:last-child { font-family: var(--mono); overflow-wrap: anywhere; }

.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 14px 38px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--teal-soft); color: var(--teal-dark); font-weight: 700; font-size: 0.85rem; display: grid; place-items: center; }

.keybox { font-family: var(--mono); font-size: 0.95rem; padding: 12px 14px; background: var(--amber-soft); border: 1px dashed #d8b46b; border-radius: 8px; word-break: break-all; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px; border-top: 1px solid var(--line-2); font-size: 0.86rem; color: var(--ink-2); }

/* ---------- Halaman login & setup ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-art { background: var(--side); color: #cfe6e2; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-art h1 { color: #fff; font-size: 2rem; max-width: 18ch; margin-top: 18px; }
.auth-art p { max-width: 46ch; color: #a7c6c1; }
.auth-art canvas { width: 100%; height: 150px; display: block; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form .box { width: 100%; max-width: 420px; }
.auth-form h2 { font-size: 1.4rem; margin-bottom: 6px; }

@media print {
  .side, .topbar .userbox, .no-print, .menu-toggle { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  body { background: #fff; }
  .card { border: 0; }
}
@media (max-width: 1100px) {
  .g-side, .g3 { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(2) { border-right: 0; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 30; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform 0.2s; }
  .side.open { transform: none; }
  .btn.menu-toggle { display: inline-flex; }
  .shell { background: none; }
  .main { padding: 16px 16px 50px; }
  .g2, .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { margin-top: 6px; }
  .auth { grid-template-columns: 1fr; }
  .auth-art { padding: 28px 22px; }
  .feed li { grid-template-columns: 60px 1fr; }
  .feed li > :last-child { grid-column: 2; }
}
