/* RIS Expertise — tanpa build step. */
:root {
  --bg: #f4f6f7;
  --panel: #ffffff;
  --ink: #1d2a30;
  --muted: #5d6b72;
  --line: #dde3e6;
  --line-strong: #c4cdd2;
  --accent: #0f6b74;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1f2;
  --cito: #b42318;
  --cito-soft: #fdecea;
  --ok: #1f7a3d;
  --ok-soft: #e6f4ea;
  --warn: #9a6400;
  --warn-soft: #fff4dc;
  --radius: 8px;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
h3 { font-size: .95rem; margin: 0 0 8px; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .9em; }
.small { font-size: .85rem; }

/* Bar atas */
.topbar {
  background: #13343a; color: #e8f1f2; display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 52px; position: sticky; top: 0; z-index: 10;
}
.topbar .brand { font-weight: 650; letter-spacing: .2px; white-space: nowrap; }
.topbar .brand small { font-weight: 400; color: #a9c3c6; margin-left: 6px; }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a {
  color: #cfe0e2; padding: 6px 10px; border-radius: 6px; white-space: nowrap; font-size: .93rem;
}
.topbar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; }
.topbar nav a.active { background: rgba(255,255,255,.14); color: #fff; }
.topbar .user { display: flex; align-items: center; gap: 10px; font-size: .9rem; white-space: nowrap; }
.topbar .user form { margin: 0; }
.topbar .user button { background: none; border: 1px solid rgba(255,255,255,.3); color: #e8f1f2; padding: 4px 10px; border-radius: 6px; cursor: pointer; }

main { max-width: 1440px; margin: 0 auto; padding: 20px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }

/* Panel */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel + .panel { margin-top: 16px; }
.panel.flush { padding: 0; overflow: hidden; }

/* Tombol */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  padding: 7px 14px; border-radius: 6px; font: inherit; font-size: .93rem; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: #f2f5f6; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #0c5a62; }
.btn.danger { color: var(--cito); border-color: #e8b4ae; }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Form */
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 4px; color: #33434a; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=search], input[type=url], select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 10px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid #8cc6cb; outline-offset: 0; border-color: var(--accent); }
textarea { resize: vertical; line-height: 1.5; }
.field { margin-bottom: 14px; }
.field .hint { font-size: .8rem; color: var(--muted); margin-top: 3px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.check input { width: auto; }
.error-text { color: var(--cito); font-size: .82rem; margin-top: 3px; }

/* Tabel */
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th {
  text-align: left; font-weight: 600; font-size: .8rem; color: var(--muted); text-transform: uppercase; letter-spacing: .3px;
  padding: 9px 12px; border-bottom: 1px solid var(--line); background: #f8fafa; white-space: nowrap;
}
table.list td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr:last-child td { border-bottom: none; }
table.list tr.clickable { cursor: pointer; }
table.list tr.clickable:hover td { background: #f5fafa; }
table.list tr.cito td:first-child { box-shadow: inset 3px 0 0 var(--cito); }
.table-wrap { overflow-x: auto; }

/* Badge */
.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; white-space: nowrap; border: 1px solid transparent; }
.badge.cito { background: var(--cito-soft); color: var(--cito); border-color: #f4c7c1; }
.badge.s-scheduled { background: #eef1f3; color: #44535a; }
.badge.s-arrived { background: var(--accent-soft); color: var(--accent); }
.badge.s-reading { background: var(--warn-soft); color: var(--warn); }
.badge.s-preliminary { background: var(--warn-soft); color: var(--warn); border-color: #f0d79e; }
.badge.s-final, .badge.s-amended { background: var(--ok-soft); color: var(--ok); }
.badge.s-cancelled { background: #f1f1f1; color: #888; text-decoration: line-through; }
.badge.o-sent { background: var(--ok-soft); color: var(--ok); }
.badge.o-pending { background: var(--warn-soft); color: var(--warn); }
.badge.o-dead, .badge.o-failed { background: var(--cito-soft); color: var(--cito); }

/* Tab filter */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 0; padding: 0 12px; background: #fbfcfc; }
.tabs a { padding: 10px 14px; color: var(--muted); border-bottom: 2px solid transparent; font-size: .93rem; }
.tabs a.active { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--ink); }
.tabs .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: #e5eaec; font-size: .75rem; text-align: center; }
.filters { display: flex; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; align-items: flex-end; }
.filters .field { margin: 0; }
.filters input, .filters select { min-width: 140px; }

/* Flash */
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; border: 1px solid; }
.flash.ok { background: var(--ok-soft); border-color: #b7dfc2; color: #165c2e; }
.flash.error { background: var(--cito-soft); border-color: #f4c7c1; color: #8f1d14; }

/* Halaman baca */
.reading { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
.patient-card dl { display: grid; grid-template-columns: 120px 1fr; gap: 6px 10px; margin: 0; font-size: .9rem; }
.patient-card dt { color: var(--muted); }
.patient-card dd { margin: 0; }
.patient-name { font-size: 1.15rem; font-weight: 650; margin-bottom: 2px; }
.editor textarea.findings { min-height: 360px; font-size: .98rem; }
.editor textarea.impression { min-height: 110px; font-size: .98rem; }
.editor .toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.editor .toolbar select { width: auto; min-width: 260px; }
.final-text { white-space: pre-wrap; font-size: .98rem; background: #fbfcfc; border: 1px solid var(--line); border-radius: 6px; padding: 12px; }
.version-list { list-style: none; margin: 0; padding: 0; font-size: .88rem; }
.version-list li { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; justify-content: space-between; gap: 8px; }
.version-list li:last-child { border-bottom: none; }
.sticky-actions { position: sticky; bottom: 0; background: linear-gradient(to top, #fff 75%, rgba(255,255,255,0)); padding-top: 12px; margin-top: 4px; }

/* Dialog PIN */
dialog { border: 1px solid var(--line); border-radius: 10px; padding: 20px; width: min(380px, 92vw); box-shadow: 0 12px 40px rgba(0,0,0,.18); }
dialog::backdrop { background: rgba(20, 40, 45, .45); }
dialog input.pin { font-size: 1.4rem; letter-spacing: 8px; text-align: center; font-family: var(--mono); }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(160deg, #13343a 0%, #1d4f57 55%, #f4f6f7 55%); }
.login-box { width: min(380px, 100%); background: #fff; border-radius: 12px; padding: 28px; box-shadow: 0 10px 40px rgba(0,0,0,.15); }
.login-box h1 { margin-bottom: 2px; }

/* Kunci API */
.secret { font-family: var(--mono); background: #10282d; color: #d9f2f4; padding: 10px 12px; border-radius: 6px; word-break: break-all; user-select: all; }

/* Paginasi */
.pager { display: flex; gap: 6px; justify-content: flex-end; padding: 12px; align-items: center; font-size: .88rem; }
.pager a, .pager span { padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.pager span.current { background: var(--accent); color: #fff; border-color: var(--accent); }
.pager span.disabled { color: #aaa; }

/* Verifikasi publik */
.verify { max-width: 560px; margin: 40px auto; }
.verify .stamp { font-size: 1.05rem; font-weight: 650; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.verify .stamp.valid { background: var(--ok-soft); color: var(--ok); }
.verify .stamp.invalid { background: var(--cito-soft); color: var(--cito); }

@media (max-width: 960px) {
  .reading { grid-template-columns: 1fr; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .topbar { gap: 12px; }
  .topbar .brand small { display: none; }
}
