/* ============================================================
   MEDICALBUREAU.CO.ZA — Light Blue & White theme
   ============================================================ */
:root {
  --blue-950: #082F49;
  --blue-900: #0C4A6E;
  --blue-800: #075985;
  --blue-700: #0369A1;
  --blue-600: #0284C7;
  --blue-500: #0EA5E9;
  --blue-400: #38BDF8;
  --blue-200: #BAE6FD;
  --blue-100: #E0F2FE;
  --blue-50:  #F0F9FF;
  --ink:      #0F2A43;
  --muted:    #5B7A94;
  --border:   #DCEBF7;
  --white:    #FFFFFF;
  --green:    #059669;
  --amber:    #D97706;
  --red:      #DC2626;
  --radius:   14px;
  --shadow:   0 1px 2px rgba(8,47,73,.05), 0 8px 24px -12px rgba(2,132,199,.18);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(180deg, var(--blue-50) 0%, #F7FBFF 320px);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 600; }
small { color: var(--muted); }

/* ---------- Topbar ---------- */
.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(2,132,199,.06), 0 6px 18px -14px rgba(2,132,199,.25);
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner {
  max-width: 1280px; margin: 0 auto; padding: 10px 20px;
  display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none !important; }
.brand-logo { width: 42px; height: 42px; border-radius: 10px; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 17px; color: var(--blue-950); letter-spacing: -.02em; }
.brand-text .accent { color: var(--blue-500); }
.brand-text small { font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--blue-600); font-weight: 600; }
.mainnav { display: flex; gap: 2px; flex: 1; flex-wrap: wrap; }
.mainnav a {
  color: var(--blue-900); font-weight: 600; font-size: 13.5px;
  padding: 8px 11px; border-radius: 9px; white-space: nowrap;
}
.mainnav a:hover { background: var(--blue-50); text-decoration: none; color: var(--blue-700); }
.mainnav a.active { background: var(--blue-600); color: #fff; box-shadow: 0 4px 12px -4px rgba(2,132,199,.5); }
.topbar-right { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-chip { display: flex; align-items: center; gap: 9px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-400), var(--blue-700));
  color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 14px;
}
.user-meta { display: flex; flex-direction: column; line-height: 1.15; }
.user-meta strong { font-size: 13px; color: var(--blue-950); }
.user-meta small { font-size: 11px; }
.logout-form { display: inline; }
.nav-toggle { display: none; background: none; border: 1px solid var(--border); border-radius: 8px; padding: 9px 10px; cursor: pointer; }
.nav-toggle span { display: block; width: 18px; height: 2px; background: var(--blue-700); margin: 4px 0; border-radius: 2px; }

/* ---------- Layout ---------- */
.container { max-width: 1280px; margin: 0 auto; padding: 24px 20px 48px; flex: 1; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { color: var(--muted); font-size: 13.5px; margin-top: 3px; }
.card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px;
}
.card + .card { margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-6 { display: grid; grid-template-columns: repeat(6, 1fr); gap: 16px; }
@media (max-width: 1100px) { .grid-6 { grid-template-columns: repeat(3, 1fr); } .grid-3 { grid-template-columns: 1fr; } }
@media (max-width: 760px)  { .grid-2, .grid-6 { grid-template-columns: 1fr; } }

/* ---------- KPI ---------- */
.kpi { display: flex; gap: 14px; align-items: flex-start; }
.kpi-icon {
  width: 42px; height: 42px; border-radius: 11px; flex: none;
  background: var(--blue-100); color: var(--blue-700);
  display: grid; place-items: center;
}
.kpi-icon svg { width: 21px; height: 21px; }
.kpi-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kpi-value { font-size: 22px; font-weight: 800; color: var(--blue-950); letter-spacing: -.02em; }
.kpi-sub { font-size: 12px; color: var(--muted); }
.kpi-green .kpi-icon { background: #D1FAE5; color: var(--green); }
.kpi-amber .kpi-icon { background: #FEF3C7; color: var(--amber); }
.kpi-red   .kpi-icon { background: #FEE2E2; color: var(--red); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  font-weight: 700; font-size: 13.5px; padding: 9px 16px;
  transition: all .15s ease; text-decoration: none !important; line-height: 1.2;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--blue-600); color: #fff; box-shadow: 0 6px 16px -6px rgba(2,132,199,.55); }
.btn-primary:hover { background: var(--blue-700); }
.btn-soft { background: var(--blue-100); color: var(--blue-800); }
.btn-soft:hover { background: var(--blue-200); }
.btn-ghost { background: var(--white); color: var(--blue-800); border-color: var(--border); }
.btn-ghost:hover { background: var(--blue-50); border-color: var(--blue-200); }
.btn-danger { background: #FEE2E2; color: var(--red); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-success { background: #D1FAE5; color: var(--green); }
.btn-success:hover { background: var(--green); color: #fff; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 720px; }
table.data th {
  background: var(--blue-50); color: var(--blue-900); font-size: 11.5px;
  text-transform: uppercase; letter-spacing: .05em; text-align: left;
  padding: 11px 13px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 11px 13px; border-bottom: 1px solid #EEF6FC; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #F7FBFF; }
.td-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
th.td-num { text-align: right; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.var-pos { color: var(--green); font-weight: 700; }
.var-neg { color: var(--red); font-weight: 700; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; border: 1px solid transparent; white-space: nowrap;
}

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--blue-900); margin-bottom: 5px; }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; color: var(--ink); background: #FBFDFF; outline: none;
  transition: border .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--blue-400); box-shadow: 0 0 0 3px rgba(14,165,233,.15); background: #fff;
}
.field textarea { min-height: 70px; resize: vertical; }
.field small { display: block; margin-top: 4px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filter-bar .field { min-width: 170px; flex: 1; }
.filter-bar .field:first-child { flex: 2; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: 11px; font-size: 14px; font-weight: 600; margin-bottom: 16px; border: 1px solid; }
.flash-success { background: #ECFDF5; color: #065F46; border-color: #A7F3D0; }
.flash-error { background: #FEF2F2; color: #991B1B; border-color: #FECACA; }
.flash-info { background: var(--blue-50); color: var(--blue-900); border-color: var(--blue-200); }

/* ---------- Funnel (pipeline) ---------- */
.funnel { display: flex; flex-direction: column; gap: 9px; }
.funnel-row { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 10px; font-size: 13px; }
.funnel-row .lbl { font-weight: 700; color: var(--blue-900); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.funnel-track { background: var(--blue-50); border-radius: 999px; height: 16px; overflow: hidden; border: 1px solid var(--border); }
.funnel-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--blue-400), var(--blue-600)); min-width: 4px; }
.funnel-row .num { font-weight: 800; text-align: right; color: var(--blue-950); }
.f-c-draft { background: #94A3B8; } .f-c-submitted { background: var(--blue-400); }
.f-c-approved { background: #34D399; } .f-c-adjusted { background: #FBBF24; }
.f-c-rejected { background: #F87171; } .f-c-billed { background: #22D3EE; }
.f-c-reconciled { background: #2DD4BF; } .f-c-remitted { background: var(--blue-700); }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(8,47,73,.45); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal-overlay[hidden] { display: none; }
.modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 520px;
  box-shadow: 0 24px 64px -16px rgba(8,47,73,.4); padding: 22px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { font-size: 16px; }
.modal-x { background: var(--blue-50); border: none; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; color: var(--blue-800); font-size: 15px; font-weight: 700; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* ---------- ICD-10 autocomplete ---------- */
.icd-wrap { position: relative; }
.icd-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30;
  background: #fff; border: 1px solid var(--blue-200); border-radius: 11px;
  box-shadow: 0 16px 40px -12px rgba(2,132,199,.3); overflow: hidden;
}
.icd-results[hidden] { display: none; }
.icd-results div { padding: 9px 13px; cursor: pointer; font-size: 13px; display: flex; gap: 10px; }
.icd-results div:hover, .icd-results div.sel { background: var(--blue-50); }
.icd-results .code { font-weight: 800; color: var(--blue-700); min-width: 58px; font-family: ui-monospace, Consolas, monospace; }

/* ---------- Footer ---------- */
.footer { border-top: 1px solid var(--border); background: var(--white); margin-top: auto; }
.footer .container { display: flex; justify-content: space-between; gap: 10px; padding: 16px 20px; font-size: 12.5px; color: var(--muted); flex-wrap: wrap; }

/* ---------- Public (landing / login) ---------- */
body.public {
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(56,189,248,.22), transparent 60%),
    radial-gradient(700px 380px at -10% 30%, rgba(14,165,233,.14), transparent 55%),
    linear-gradient(180deg, var(--blue-50), #fff 480px);
}
.pub-topbar { background: rgba(255,255,255,.8); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40; }
.pub-topbar .topbar-inner { padding: 12px 20px; }
.hero { max-width: 1080px; margin: 0 auto; padding: 72px 20px 40px; text-align: center; }
.hero .eyebrow {
  display: inline-flex; align-items: center; gap: 8px; background: var(--blue-100); color: var(--blue-800);
  border: 1px solid var(--blue-200); padding: 6px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-bottom: 20px;
}
.hero h1 { font-size: clamp(34px, 5.4vw, 54px); line-height: 1.08; letter-spacing: -.03em; color: var(--blue-950); max-width: 820px; margin: 0 auto 18px; }
.hero h1 .grad { background: linear-gradient(92deg, var(--blue-700), var(--blue-400)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero p { font-size: 17px; color: var(--muted); max-width: 640px; margin: 0 auto 28px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.btn-lg { padding: 13px 26px; font-size: 15px; border-radius: 12px; }
.pub-section { max-width: 1080px; margin: 0 auto; padding: 44px 20px; }
.pub-section > h2 { font-size: 28px; letter-spacing: -.02em; color: var(--blue-950); text-align: center; margin-bottom: 8px; }
.pub-section > p.sub { text-align: center; color: var(--muted); margin-bottom: 30px; }
.svc-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 900px) { .svc-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .svc-grid { grid-template-columns: 1fr; } }
.svc {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s;
}
.svc:hover { transform: translateY(-3px); }
.svc .kpi-icon { margin-bottom: 14px; }
.svc h3 { font-size: 16px; margin-bottom: 6px; color: var(--blue-950); }
.svc p { font-size: 13.5px; color: var(--muted); }
.pipeline-steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; counter-reset: step; }
@media (max-width: 900px) { .pipeline-steps { grid-template-columns: repeat(2, 1fr); } }
.step {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 16px; position: relative; box-shadow: var(--shadow);
}
.step .n {
  width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--blue-500), var(--blue-700));
  color: #fff; font-weight: 800; font-size: 14px; display: grid; place-items: center; margin-bottom: 12px;
}
.step h4 { font-size: 14.5px; color: var(--blue-950); margin-bottom: 4px; }
.step p { font-size: 12.5px; color: var(--muted); }
.pub-footer { border-top: 1px solid var(--border); background: var(--white); }
.pub-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 18px 20px; font-size: 12.5px; color: var(--muted); }

/* ---------- Auth pages ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .card { padding: 30px 28px; }
.auth-logo { width: 64px; height: 64px; border-radius: 16px; margin: 0 auto 14px; display: block; }
.auth-title { text-align: center; font-size: 20px; margin-bottom: 4px; color: var(--blue-950); }
.auth-sub { text-align: center; color: var(--muted); font-size: 13.5px; margin-bottom: 22px; }
.demo-cred {
  margin-top: 18px; background: var(--blue-50); border: 1px dashed var(--blue-200);
  border-radius: 10px; padding: 11px 14px; font-size: 12.5px; color: var(--blue-900);
}
.demo-cred code { font-weight: 700; }
.auth-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 13px; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 20px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: var(--blue-200); margin-bottom: 10px; }
.summary-strip { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.summary-strip .pill {
  background: var(--blue-50); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 15px; font-size: 12.5px; font-weight: 700; color: var(--blue-900);
}
.summary-strip .pill b { color: var(--blue-700); }
.remit-lines td { font-size: 13px; }
.remit-line-row { display: grid; grid-template-columns: 1.2fr 1fr .8fr auto; gap: 8px; margin-bottom: 8px; align-items: center; }
.remit-line-row input { padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; font: inherit; background: #FBFDFF; }
@media (max-width: 700px) { .remit-line-row { grid-template-columns: 1fr 1fr; } }
@media (max-width: 900px) {
  .nav-toggle { display: block; }
  .mainnav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: #fff; flex-direction: column; padding: 12px; border-bottom: 1px solid var(--border);
    box-shadow: 0 20px 40px -20px rgba(8,47,73,.3);
  }
  .mainnav.open { display: flex; }
  .user-meta { display: none; }
}
