/* Moulana Hospital brand: Pantone 185 red #EA0029, Pantone 2935 blue #0055B8, typeface Poppins */
@font-face { font-family: "Poppins"; src: url("/fonts/Poppins-Light.ttf") format("truetype"); font-weight: 300; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("/fonts/Poppins-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("/fonts/Poppins-Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("/fonts/Poppins-SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Poppins"; src: url("/fonts/Poppins-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  /* brand */
  --mh-blue: #0055B8;
  --mh-blue-dark: #00468F;
  --mh-blue-deep: #003E8A;
  --mh-blue-tint: #E9EEF8;
  --mh-blue-tint-2: #D3DCEF;
  --mh-blue-mid: #7792D0;
  --mh-red: #EA0029;
  --mh-red-dark: #C2001F;
  --mh-red-tint: #FDECEC;

  --bg: #F4F6FA;
  --panel: #ffffff;
  --ink: #16233A;
  --ink-2: #44526B;
  --ink-3: #7A869C;
  --line: #E1E6EF;
  --line-2: #EDF0F6;
  --brand: var(--mh-blue);
  --brand-2: var(--mh-blue-dark);
  --brand-soft: var(--mh-blue-tint);
  --red: var(--mh-red-dark);
  --red-soft: var(--mh-red-tint);
  --amber: #A85F00;
  --amber-soft: #FFF3DD;
  --green: #127A3E;
  --green-soft: #E5F5EC;
  --blue: var(--mh-blue);
  --blue-soft: var(--mh-blue-tint);
  --teal: #0B6E82;
  --teal-soft: #E0F2F6;
  --violet: #5B3CC4;
  --violet-soft: #EFEAFD;
  --grey-soft: #EEF1F5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0, 40, 100, .05), 0 1px 3px rgba(0, 40, 100, .07);
  --shadow-lg: 0 14px 36px rgba(0, 35, 90, .2);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
body { font: 13.5px/1.5 "Poppins", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font-family: inherit; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; color: var(--ink); }
h1 { font-size: 21px; font-weight: 600; letter-spacing: -.2px; }
h2 { font-size: 15px; font-weight: 600; }
h3 { font-size: 13px; font-weight: 600; }
.muted { color: var(--ink-3); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.boot { padding: 40px; color: var(--ink-3); }
.hidden { display: none !important; }
code { font-size: 12px; background: var(--grey-soft); padding: 1px 5px; border-radius: 4px; }

/* Layout */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--mh-blue-deep); color: #D5E0F3; padding: 18px 12px 0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; overflow: hidden; }
.brandmark { padding: 4px 8px 6px; }
.brandmark img { display: block; width: 100%; max-width: 188px; height: auto; }
.brandmark .t2 { font-size: 11px; color: #A9BDE3; margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(255, 255, 255, .12); letter-spacing: .3px; }
.nav { margin-top: 10px; }
.nav a { position: relative; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: #D5E0F3; font-weight: 500; margin-bottom: 2px; }
.nav a:hover { background: rgba(255, 255, 255, .08); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(255, 255, 255, .14); color: #fff; }
.nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--mh-red); }
.nav .ico { width: 18px; text-align: center; opacity: .95; }
.nav .count { margin-left: auto; background: var(--mh-red); color: #fff; border-radius: 20px; font-size: 11px; padding: 0 7px; font-weight: 600; line-height: 18px; }
.side .foot { margin: auto -12px 0; padding: 46px 20px 18px; font-size: 12px; color: #DCE6F7; background: url("/brand/pattern-blue.png") top left / 420px auto repeat; position: relative; }
.side .foot::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, var(--mh-blue-deep) 0%, rgba(0, 62, 138, .55) 40%, rgba(0, 62, 138, .35) 100%); }
.side .foot > * { position: relative; }
.side .foot b { color: #fff; display: block; font-size: 13px; font-weight: 600; }
.side .foot a { color: #fff; margin-right: 12px; cursor: pointer; opacity: .85; }
.side .foot a:hover { opacity: 1; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; gap: 10px; align-items: center; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); border-top: 3px solid var(--mh-red); position: sticky; top: 0; z-index: 5; }
.topbar .search { flex: 1; max-width: 460px; background: var(--bg); }
.topbar .spacer { flex: 1; }
.menu-btn { display: none; }
.page { padding: 22px 26px 60px; max-width: 1500px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .grow { flex: 1; }

/* Controls */
input, select, textarea { font-size: 13px; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: #fff; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(0, 85, 184, .16); border-color: var(--brand); }
textarea { resize: vertical; min-height: 70px; }
input[type=checkbox] { width: auto; accent-color: var(--brand); }
label { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.field .hint { font-size: 11px; color: var(--ink-3); margin-top: 3px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 400; color: var(--ink); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 13px; border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .12s, border-color .12s; }
.btn:hover { background: #F6F8FC; border-color: var(--mh-blue-tint-2); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.accent { background: var(--mh-red); border-color: var(--mh-red); color: #fff; }
.btn.accent:hover { background: var(--mh-red-dark); }
.btn.danger { color: var(--mh-red-dark); border-color: #F5C2C7; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--grey-soft); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Cards & KPIs */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card > .hd { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.card > .hd .grow { flex: 1; }
.card > .bd { padding: 14px 16px; }
.card > .bd.flush { padding: 0; }
.cards { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-main { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--mh-blue); border-radius: var(--radius); padding: 11px 14px 12px; box-shadow: var(--shadow); }
.kpi .v { font-size: 26px; font-weight: 600; letter-spacing: -.5px; line-height: 1.15; margin-top: 2px; font-variant-numeric: tabular-nums; color: var(--mh-blue-deep); }
.kpi .l { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.kpi .s { font-size: 11.5px; color: var(--ink-3); margin-top: 2px; }
.kpi.warn { border-top-color: var(--mh-red); }
.kpi.warn .v { color: var(--mh-red-dark); }
.kpi.good { border-top-color: var(--green); }
.kpi.good .v { color: var(--green); }
.kpi.clickable { cursor: pointer; }
.kpi.clickable:hover { border-color: var(--mh-blue-tint-2); border-top-color: var(--mh-blue); box-shadow: 0 4px 14px rgba(0, 60, 140, .1); }
.kpi.warn.clickable:hover { border-top-color: var(--mh-red); }
.section-label { font-size: 11.5px; font-weight: 600; letter-spacing: .08em; color: var(--mh-blue); margin: 4px 0 8px; display: flex; align-items: center; gap: 8px; }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.alert.warn { background: var(--amber-soft); color: #6E3F00; }
.alert.info { background: var(--mh-blue-tint); color: #0B2F66; display: block; }
.alert.bad { background: var(--mh-red-tint); color: #8A0018; }

/* Tables */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; padding: 9px 12px; border-bottom: 1px solid var(--line); background: #F8FAFD; white-space: nowrap; }
.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.row-link { cursor: pointer; }
.tbl tr.row-link:hover td { background: #F3F7FD; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl tr.total td { font-weight: 600; background: var(--mh-blue-tint); color: var(--mh-blue-deep); }
.tbl .sub { font-size: 11.5px; color: var(--ink-3); }
.tbl b { font-weight: 600; }
.empty { padding: 28px; text-align: center; color: var(--ink-3); }

/* Badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; background: var(--grey-soft); color: var(--ink-2); }
.b-new { background: var(--mh-blue-tint); color: var(--mh-blue); }
.b-attempt { background: var(--amber-soft); color: var(--amber); }
.b-connected { background: var(--teal-soft); color: var(--teal); }
.b-rnr { background: var(--mh-red-tint); color: var(--mh-red-dark); }
.b-pending { background: var(--violet-soft); color: var(--violet); }
.b-lost { background: var(--grey-soft); color: var(--ink-3); }
.b-booked { background: var(--green-soft); color: var(--green); }
.b-follow { background: #FFF4D6; color: #7F5400; }
.b-invalid { background: #F1F1F1; color: #888; text-decoration: line-through; }
.sla { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.sla-within { background: var(--green-soft); color: var(--green); }
.sla-late { background: var(--amber-soft); color: var(--amber); }
.sla-uncalled { background: var(--mh-red-tint); color: var(--mh-red-dark); }
.sla-pending { background: var(--mh-blue-tint); color: var(--mh-blue); }
.sla-excluded { background: var(--grey-soft); color: var(--ink-3); }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 5px; background: var(--grey-soft); color: var(--ink-2); margin-left: 4px; }
.tag.repeat { background: var(--mh-red-tint); color: var(--mh-red-dark); font-weight: 600; }
.overdue { color: var(--mh-red-dark); font-weight: 600; }

/* Filters & chips */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.filters select, .filters input { width: auto; min-width: 130px; }
.filters input[type=search] { min-width: 220px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 20px; padding: 4px 13px; font-size: 12.5px; font-weight: 500; color: var(--ink-2); cursor: pointer; user-select: none; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--ink-2); font-weight: 500; border-bottom: 3px solid transparent; white-space: nowrap; cursor: pointer; }
.tabs a:hover { text-decoration: none; color: var(--brand); }
.tabs a.on { color: var(--brand); border-bottom-color: var(--mh-red); font-weight: 600; }
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 10px 12px; border-top: 1px solid var(--line-2); }
.bulkbar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--mh-blue-tint); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bulkbar select { width: auto; }

/* Lead page */
.lead-card { position: relative; overflow: hidden; }
.lead-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--mh-blue); }
.lead-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.lead-head .who { flex: 1; min-width: 260px; }
.lead-head .name { font-size: 22px; font-weight: 600; color: var(--mh-blue-deep); }
.lead-head .meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; color: var(--ink-2); }
.lead-head .meta .tag { margin-left: 0; }
.phone-big { font-size: 17px; font-weight: 600; color: var(--ink); letter-spacing: .4px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.call { background: #138A47; border-color: #138A47; color: #fff; }
.btn.call:hover { background: #0F7139; }
.btn.wa { background: #25D366; border-color: #25D366; color: #06301A; }
.btn.wa:hover { background: #1FBE5B; }
.status-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0 0; padding-top: 12px; border-top: 1px dashed var(--line); }
.status-row .chip.on { box-shadow: 0 0 0 3px rgba(0, 85, 184, .18); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 30px 1fr; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line-2); }
.timeline li:last-child { border-bottom: 0; }
.timeline .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; background: var(--grey-soft); }
.timeline .t-call .dot { background: var(--green-soft); }
.timeline .t-whatsapp .dot { background: #DCFCE7; }
.timeline .t-status .dot { background: var(--mh-blue-tint); }
.timeline .t-appointment .dot { background: var(--violet-soft); }
.timeline .t-followup .dot { background: #FFF4D6; }
.timeline .t-enquiry .dot { background: var(--mh-red-tint); }
.timeline .when { font-size: 11.5px; color: var(--ink-3); }
.timeline .body { white-space: pre-wrap; word-break: break-word; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; word-break: break-word; }
.task-row { display: flex; gap: 10px; align-items: center; padding: 9px 16px; border-bottom: 1px solid var(--line-2); flex-wrap: wrap; }
.task-row:last-child { border-bottom: 0; }
.task-row .grow { flex: 1; min-width: 160px; }
.task-row b { font-weight: 600; }

/* Bars */
.bars { display: grid; gap: 8px; }
.barrow { display: grid; grid-template-columns: 150px 1fr 60px; gap: 10px; align-items: center; font-size: 13px; }
.bar { height: 22px; background: var(--line-2); border-radius: 5px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--mh-blue); border-radius: 5px; }
.bars.funnel .barrow:last-child .bar > i, .bars.funnel .barrow:nth-last-child(2) .bar > i { background: var(--mh-red); }
.trend { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 8px; }
.trend .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.trend .stack { width: 100%; max-width: 30px; display: flex; flex-direction: column-reverse; border-radius: 4px 4px 0 0; overflow: hidden; }
.trend .a { background: var(--mh-blue-tint-2); }
.trend .b { background: var(--mh-red); }
.trend .lbl { font-size: 10px; color: var(--ink-3); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* Modal & toasts */
.modal-bg { position: fixed; inset: 0; background: rgba(0, 25, 60, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 50; overflow-y: auto; }
.modal { background: #fff; border-radius: 12px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; overflow: hidden; }
.modal.wide { max-width: 820px; }
.modal .hd { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; border-top: 4px solid var(--mh-blue); }
.modal .hd h2 { flex: 1; color: var(--mh-blue-deep); }
.modal .bd { padding: 16px 18px; }
.modal .ft { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; background: #FAFBFD; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink-3); }
#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: #16233A; color: #fff; padding: 10px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); max-width: 380px; font-size: 13px; cursor: pointer; }
.toast.err { background: var(--mh-red-dark); }
.toast.ok { background: var(--mh-blue); }
.dupwarn { background: var(--amber-soft); border: 1px solid #F3D49B; color: #6E3F00; padding: 8px 10px; border-radius: 8px; font-size: 13px; margin: -4px 0 12px; }

/* Auth (sign-in & first setup): identity-manual cover style */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px 150px; background: var(--mh-blue); position: relative; overflow: hidden; }
.auth::before { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 130px; background: url("/brand/pattern-blue.png") top left / 640px auto repeat; }
.auth::after { content: ""; position: absolute; left: 0; right: 0; bottom: 130px; height: 5px; background: var(--mh-red); }
.auth .box { background: #fff; border-radius: 14px; box-shadow: var(--shadow-lg); width: 100%; max-width: 410px; padding: 28px 30px 26px; position: relative; z-index: 1; }
.auth .logo { display: block; width: 230px; max-width: 80%; height: auto; margin: 0 auto 6px; }
.auth .tagline { text-align: center; font-size: 11.5px; color: var(--mh-blue); font-weight: 500; letter-spacing: .3px; margin: 0 0 18px; }
.auth h1 { margin-bottom: 4px; font-size: 18px; color: var(--mh-blue-deep); }
.auth p { margin: 0 0 18px; color: var(--ink-3); }
.auth .sub-title { text-align: center; font-weight: 600; color: var(--ink-2); padding-top: 14px; border-top: 1px solid var(--line); margin-bottom: 16px; }
.err-msg { color: var(--mh-red-dark); font-size: 13px; margin-bottom: 10px; min-height: 18px; }
.codebox { font-family: Consolas, Menlo, monospace; font-size: 12px; background: #F6F8FB; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; word-break: break-all; display: flex; gap: 8px; align-items: center; }
.codebox span { flex: 1; }
pre.log { font-family: Consolas, Menlo, monospace; font-size: 11px; white-space: pre-wrap; word-break: break-all; max-height: 160px; overflow: auto; margin: 4px 0 0; background: #F6F8FB; padding: 6px; border-radius: 6px; }
.section-title { margin: 22px 0 10px; }

/* Lead form (new / edit / quick edit) */
.field.full { grid-column: 1 / -1; }
.rq { color: var(--mh-red); font-weight: 600; }
.inline2 { display: flex; gap: 8px; }
.inline2 input[type=time] { max-width: 130px; }
.cond { padding-top: 12px; margin-top: 2px; border-top: 1px dashed var(--line); }
.qe-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 12px; margin-bottom: 14px; background: var(--mh-blue-tint); border-radius: 8px; color: var(--mh-blue-deep); }
.draftbar { justify-content: space-between; }
.tbl .sub.remark { max-width: 220px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1100px) {
  .cols-main, .cols-2, .cols-3 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: -250px; width: 240px; z-index: 40; transition: left .2s; }
  .side.open { left: 0; box-shadow: var(--shadow-lg); }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  .page { padding: 16px 16px 60px; }
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .barrow { grid-template-columns: 100px 1fr 50px; }
  .kv { grid-template-columns: 110px 1fr; }
}
@media print {
  .side, .topbar, .btn, .filters, .chips { display: none !important; }
  .shell { display: block; }
}

.drivebox { border: 1px solid var(--line); border-left: 4px solid var(--green); border-radius: 0; padding: 10px 12px; margin-bottom: 12px; background: var(--green-soft); }
.drivebox.warn { border-left-color: var(--amber); background: var(--amber-soft); }
