:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #64716e;
  --line: #dfe7e4;
  --soft: #f4f8f6;
  --white: #ffffff;
  --teal: #0f766e;
  --teal-dark: #0b5c56;
  --teal-soft: #e5f5f2;
  --blue-soft: #eaf2ff;
  --blue: #2f67ad;
  --amber-soft: #fff6df;
  --amber: #a66308;
  --red-soft: #fff0ef;
  --red: #b53b36;
  --shadow: 0 18px 45px rgba(23, 55, 48, .08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; color: var(--ink); background: #edf3f0; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 15% 10%, #d7efea, transparent 35%), linear-gradient(145deg, #f7fbf9, #e6efeb); }
.login-card { width: min(100%, 400px); padding: 38px; border: 1px solid rgba(255,255,255,.8); border-radius: 26px; background: rgba(255,255,255,.94); box-shadow: var(--shadow); }
.brand-mark { width: 54px; height: 54px; display: grid; place-items: center; border-radius: 17px; background: var(--teal); color: white; font-weight: 800; font-size: 26px; box-shadow: 0 8px 18px rgba(15,118,110,.22); }
.brand-mark.small { width: 38px; height: 38px; border-radius: 12px; font-size: 18px; box-shadow: none; }
.eyebrow { margin: 24px 0 5px; color: var(--teal); font-size: 11px; letter-spacing: .16em; font-weight: 800; }
.login-card h1 { margin: 0; font-size: 38px; letter-spacing: -.04em; }
.login-subtitle { margin: 5px 0 28px; color: var(--muted); }
.login-form { display: grid; gap: 8px; }
.login-form label { margin-top: 8px; font-size: 13px; font-weight: 700; }
input, select { width: 100%; height: 42px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; color: var(--ink); background: white; outline: none; transition: border .2s, box-shadow .2s; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,118,110,.11); }
.form-error { min-height: 18px; margin: 4px 0 0; color: var(--red); font-size: 12px; }
.privacy-note { margin: 22px 0 0; text-align: center; color: #85908e; font-size: 11px; }

.button { height: 42px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid transparent; border-radius: 10px; padding: 0 15px; font-weight: 750; font-size: 13px; text-decoration: none; cursor: pointer; transition: transform .15s, background .15s, border .15s; }
.button:active { transform: translateY(1px); }
.button:disabled { cursor: wait; opacity: .6; }
.button.primary { color: white; background: var(--teal); }
.button.primary:hover { background: var(--teal-dark); }
.button.secondary { color: var(--teal-dark); border-color: #a9d6cf; background: white; }
.button.ghost { color: var(--muted); border-color: var(--line); background: transparent; }
.button.danger { color: var(--red); border-color: #efc5c2; background: var(--red-soft); }
.button.danger:hover { border-color: #d99591; background: #ffe4e1; }
.button.wide { width: 100%; margin-top: 8px; }
.button.compact { height: 34px; padding: 0 11px; font-size: 12px; }
.button-icon { font-size: 18px; line-height: 1; }

.app-shell { min-height: 100vh; }
.topbar { height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(20px, calc((100vw - 1440px) / 2)); border-bottom: 1px solid rgba(205,219,214,.8); background: rgba(255,255,255,.88); backdrop-filter: blur(14px); position: sticky; top: 0; z-index: 10; }
.brand-row, .top-actions, .hero-actions { display: flex; align-items: center; gap: 12px; }
.brand-row > div:last-child { display: grid; }
.brand-row strong { font-size: 15px; }
.brand-row span { color: var(--muted); font-size: 11px; }
.connection { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.connection i { width: 7px; height: 7px; border-radius: 50%; background: #23a26d; box-shadow: 0 0 0 4px #e3f5ed; }
.connection.error i { background: var(--red); box-shadow: 0 0 0 4px var(--red-soft); }

.content { width: min(1440px, calc(100% - 40px)); margin: 0 auto; padding: 34px 0 50px; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 22px; margin-bottom: 22px; }
.hero-row .eyebrow { margin-top: 0; }
.hero-row h1 { margin: 0 0 5px; font-size: clamp(27px, 3vw, 38px); letter-spacing: -.04em; }
.muted { margin: 0; color: var(--muted); font-size: 13px; }

.progress-panel { margin: 0 0 18px; padding: 16px 18px; border: 1px solid #b8ddd6; border-radius: 14px; background: var(--teal-soft); }
.progress-copy { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.progress-track { height: 7px; margin-top: 11px; border-radius: 99px; overflow: hidden; background: rgba(15,118,110,.14); }
.progress-track span { display: block; width: 3%; height: 100%; border-radius: inherit; background: var(--teal); transition: width .35s ease; }
.progress-panel p { margin: 8px 0 0; color: var(--teal-dark); font-size: 11px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { min-height: 116px; display: grid; align-content: center; padding: 18px; border: 1px solid var(--line); border-radius: 15px; background: white; box-shadow: 0 8px 22px rgba(30,65,57,.035); }
.stat-card span { color: var(--muted); font-size: 12px; font-weight: 650; }
.stat-card strong { margin: 2px 0; font-size: 30px; letter-spacing: -.04em; }
.stat-card small { color: #899390; font-size: 10px; }
.stat-card.waiting { border-top: 3px solid #db9d36; }
.stat-card.service { border-top: 3px solid #4088cb; }
.stat-card.partial { border-top: 3px solid #c7564e; }

.register-panel { border: 1px solid var(--line); border-radius: 17px; overflow: hidden; background: white; box-shadow: var(--shadow); }
.filter-row { display: grid; grid-template-columns: minmax(210px, 1.5fr) repeat(4, minmax(135px,.75fr)) minmax(130px,.7fr) auto; gap: 9px; padding: 14px; border-bottom: 1px solid var(--line); }
.search-field { position: relative; }
.search-field span { position: absolute; left: 13px; top: 8px; color: #899390; font-size: 20px; }
.search-field input { padding-left: 39px; }
.table-wrap { min-height: 300px; overflow-x: auto; position: relative; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { padding: 11px 12px; text-align: left; white-space: nowrap; color: #6d7875; background: #f7faf8; font-size: 10px; text-transform: uppercase; letter-spacing: .06em; }
td { padding: 13px 12px; border-top: 1px solid #edf1ef; vertical-align: top; }
tbody tr:hover { background: #fbfdfc; }
.patient-name { display: block; min-width: 135px; font-size: 13px; font-weight: 760; }
.patient-meta, .cell-sub { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.address-cell { max-width: 180px; line-height: 1.4; }
.diagnosis-cell { min-width: 210px; max-width: 300px; line-height: 1.45; }
.diagnosis-cell strong { color: var(--teal-dark); }
.badge { display: inline-flex; align-items: center; border-radius: 99px; padding: 4px 8px; font-size: 10px; font-weight: 750; white-space: nowrap; }
.badge.bpjs, .badge.complete { color: #17634e; background: #e1f4eb; }
.badge.tunai { color: #74510c; background: var(--amber-soft); }
.badge.asuransi { color: var(--blue); background: var(--blue-soft); }
.badge.unknown, .badge.pending { color: #68716f; background: #edf1ef; }
.badge.partial { color: var(--red); background: var(--red-soft); }
.badge.archived { color: #5e6871; background: #e9edf0; }
.badge.mrs, .badge.mrs_rujuk { color: #17634e; background: #e1f4eb; }
.badge.rujuk { color: #74510c; background: var(--amber-soft); }
.badge.baru { color: var(--blue); background: var(--blue-soft); }
.badge.lama { color: #68716f; background: #edf1ef; }
.disposition-cell { min-width: 100px; max-width: 180px; }
.disposition-cell .badge { white-space: normal; line-height: 1.3; }
.action-cell { min-width: 82px; }
.state-panel { min-height: 260px; display: grid; place-content: center; gap: 5px; text-align: center; color: var(--muted); }
.state-panel strong { color: var(--ink); font-size: 14px; }
.state-panel span { font-size: 12px; }
.table-footer { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.pagination { display: flex; align-items: center; gap: 12px; }

.toast { position: fixed; right: 22px; bottom: 22px; z-index: 30; max-width: min(360px, calc(100vw - 44px)); padding: 13px 16px; border-radius: 12px; color: white; background: #20302c; box-shadow: 0 14px 35px rgba(0,0,0,.2); font-size: 12px; }
.toast.error { background: #8f2f2b; }

@media (max-width: 1050px) {
  .filter-row { grid-template-columns: 1.5fr repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 700px) {
  .topbar { padding: 0 14px; }
  .connection { display: none; }
  .content { width: calc(100% - 24px); padding-top: 22px; }
  .hero-row { align-items: flex-start; flex-direction: column; }
  .hero-actions { width: 100%; }
  .hero-actions .button { flex: 1; }
  .stat-grid { gap: 8px; }
  .stat-card { min-height: 96px; padding: 14px; }
  .filter-row { grid-template-columns: 1fr 1fr; }
  .search-field, #doctorFilter { grid-column: 1 / -1; }
  table, tbody { display: block; }
  thead { display: none; }
  tbody { padding: 8px; }
  tbody tr { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
  td { display: block; padding: 0; border: 0; }
  td::before { content: attr(data-label); display: block; margin-bottom: 3px; color: #82908c; font-size: 9px; text-transform: uppercase; letter-spacing: .06em; }
  td:nth-child(2), td:nth-child(4), td:nth-child(9), td:nth-child(11) { grid-column: 1 / -1; }
  .address-cell, .diagnosis-cell { max-width: none; }
  .table-footer { align-items: flex-start; flex-direction: column; }
  .pagination { width: 100%; justify-content: space-between; }
}

@media (max-width: 430px) {
  .login-card { padding: 28px 24px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .filter-row { grid-template-columns: 1fr; }
  .search-field, #doctorFilter { grid-column: auto; }
  .hero-actions { flex-direction: column-reverse; }
  .hero-actions .button { width: 100%; }
}
