/* Kinetic Care — gaya antarmuka pengelola & portal pasien.
   Prinsip: rapi, tenang, mudah dibaca di layar klinik; kontras memadai; tanpa pustaka luar. */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --line: #dde3ec;
  --text: #16202e;
  --muted: #64748b;
  --brand: #0f766e;
  --brand-soft: #e6f4f2;
  --accent: #1d4ed8;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #b91c1c;
  --danger-soft: #fee2e2;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --font: "Inter", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Atribut hidden harus menang atas aturan display pada kelas (.login/.app memakai display:grid). */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0 0 0.4rem; line-height: 1.25; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.98rem; }
p { margin: 0 0 0.6rem; }
a { color: var(--accent); }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }

/* ── boot & login ─────────────────────────────────────────── */

.boot, .login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.boot-card, .login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 1.6rem;
  width: 100%;
  max-width: 420px;
}

.login-card { max-width: 460px; }
.boot-card { text-align: center; }

.brand { display: flex; gap: 0.7rem; align-items: center; margin-bottom: 1rem; }
.brand-mark {
  width: 44px; height: 44px; flex: 0 0 44px;
  border-radius: 12px;
  background: linear-gradient(140deg, #0f766e, #115e59);
  color: #fff; font-weight: 700; letter-spacing: 0.5px;
  display: grid; place-items: center;
}
.brand-mark.small { width: 34px; height: 34px; flex-basis: 34px; border-radius: 10px; font-size: 0.85rem; }

form label { display: block; font-size: 0.85rem; font-weight: 600; margin: 0.7rem 0 0.25rem; }
input, select, textarea {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  font: inherit;
  background: var(--surface);
  color: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }
textarea { min-height: 74px; resize: vertical; }

button {
  font: inherit;
  padding: 0.55rem 0.85rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: inherit;
  cursor: pointer;
}
button:hover { background: var(--surface-2); }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
button.primary:hover { background: #115e59; }
button.ghost { background: transparent; }
button.danger { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
button[disabled] { opacity: 0.55; cursor: not-allowed; }
button.full { width: 100%; margin-top: 1rem; }

.error { color: var(--danger); background: var(--danger-soft); border-radius: 9px; padding: 0.5rem 0.65rem; font-size: 0.86rem; }
.success { color: var(--ok); background: var(--ok-soft); border-radius: 9px; padding: 0.5rem 0.65rem; font-size: 0.86rem; }

details { margin-top: 1rem; border-top: 1px dashed var(--line); padding-top: 0.8rem; }
summary { cursor: pointer; font-weight: 600; font-size: 0.9rem; }

/* ── kerangka aplikasi ────────────────────────────────────── */

.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.7rem 1.1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  flex-wrap: wrap;
}
.topbar .brand { margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.chip {
  background: var(--brand-soft); color: #0f5f59; border-radius: 999px;
  padding: 0.2rem 0.6rem; font-size: 0.78rem; font-weight: 600;
}
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.netral { background: #eef2f7; color: #475569; }

.tabs {
  display: flex; gap: 0.35rem; padding: 0.55rem 1.1rem 0;
  background: var(--surface); border-bottom: 1px solid var(--line);
  overflow-x: auto; scrollbar-width: thin;
}
.tabs button {
  border: 1px solid transparent; border-bottom: none; border-radius: 9px 9px 0 0;
  padding: 0.5rem 0.75rem; color: var(--muted); font-size: 0.9rem; white-space: nowrap;
}
.tabs button[aria-current="true"] {
  background: var(--bg); border-color: var(--line); color: var(--text); font-weight: 600;
}

.content { padding: 1.1rem; flex: 1; }

.footer {
  display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: 0.6rem 1.1rem; border-top: 1px solid var(--line); background: var(--surface);
}

.loading, .empty {
  background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 1.2rem; color: var(--muted); text-align: center;
}

/* ── kartu, kisi, tabel ───────────────────────────────────── */

.grid { display: grid; gap: 0.9rem; }
.grid.k2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid.k3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.grid.k4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.95rem 1rem; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}
.card > header { display: flex; align-items: baseline; justify-content: space-between; gap: 0.6rem; margin-bottom: 0.6rem; }
.card h2, .card h3 { margin: 0; }

.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 0.9rem; }
.stat .label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.stat .value { font-size: 1.35rem; font-weight: 700; margin-top: 0.15rem; }
.stat .note { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }
.stat.warn { border-color: #fcd34d; background: #fffdf5; }
.stat.danger { border-color: #fecaca; background: #fff6f6; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: var(--surface-2); }
.table-wrap { overflow-x: auto; }

.bar { height: 8px; border-radius: 999px; background: #e9eef5; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); }

.toolbar { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 0.9rem; }
.toolbar .field { min-width: 150px; }
.toolbar .field label { margin-top: 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 0.45rem 0; border-bottom: 1px solid var(--line); display: flex; gap: 0.6rem; justify-content: space-between; }
.list li:last-child { border-bottom: none; }

.pill { font-size: 0.74rem; border-radius: 999px; padding: 0.12rem 0.5rem; background: #eef2f7; color: #475569; white-space: nowrap; }
.pill.terjadwal { background: #e0e7ff; color: #3730a3; }
.pill.menunggu { background: var(--warn-soft); color: var(--warn); }
.pill.terapi { background: var(--brand-soft); color: #0f5f59; }
.pill.selesai { background: var(--ok-soft); color: var(--ok); }
.pill.dibatalkan { background: var(--danger-soft); color: var(--danger); }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 0.6rem 0.9rem; border-radius: 10px;
  font-size: 0.88rem; max-width: min(560px, 92vw); box-shadow: var(--shadow); z-index: 50;
}
.toast.error { background: var(--danger); }
.toast.ok { background: #0f5132; }

.modal { border: none; border-radius: 14px; padding: 1.1rem; max-width: min(560px, 94vw); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(15, 23, 42, 0.45); }
.modal-body { max-height: 60vh; overflow-y: auto; }
.modal-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin: 0.9rem 0 0; padding: 0; }

.hint { background: var(--brand-soft); border-radius: 10px; padding: 0.55rem 0.7rem; font-size: 0.84rem; color: #0f5f59; }
.hint.warn { background: var(--warn-soft); color: var(--warn); }

.badge-row { display: flex; gap: 0.35rem; flex-wrap: wrap; }

@media (max-width: 720px) {
  .content { padding: 0.8rem; }
  .topbar, .tabs, .footer { padding-left: 0.8rem; padding-right: 0.8rem; }
  .stat .value { font-size: 1.2rem; }
}

@media print {
  .topbar, .tabs, .footer, .toolbar, button { display: none !important; }
  body { background: #fff; }
  .card { break-inside: avoid; box-shadow: none; }
}
