/* Classic hospital theme: navy top bar, white pages, serif headings, thin grey rules, muted accents.
   Every screen, HMIS, ABDM and NHCX, uses these tokens and Bootstrap 5 components. */
:root {
    --app-navy: #1f3a5f;
    --app-navy-dark: #162b47;
    --app-maroon: #7a1f2b;
    --app-green: #2e6b4f;
    --app-gold: #b08d3c;
    --app-bg: #f6f5f1;
    --app-line: #d9d6cc;
    --app-ink: #24303f;
    --app-serif: Georgia, "Times New Roman", Cambria, serif;
    --bs-primary: var(--app-navy);
    --bs-primary-rgb: 31, 58, 95;
    --bs-link-color: #1f4f86;
    --bs-link-hover-color: var(--app-maroon);
    --bs-body-color: var(--app-ink);
    --bs-border-color: var(--app-line);
}
html { font-size: 14px; }
body { background: var(--app-bg); color: var(--app-ink); }
h1, h2, h3, h4, .h4, .h5, .page-title, .card-header, .app-brand, .journey-title { font-family: var(--app-serif); }
h1, .h4, .page-title { font-weight: 600; color: var(--app-navy); }

/* top bar and menu row */
.app-top { background: var(--app-navy); color: #fff; border-bottom: 3px solid var(--app-gold); }
.app-top .inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .55rem 1.25rem; }
.app-brand { color: #fff; font-size: 1.3rem; font-weight: 600; text-decoration: none; letter-spacing: .3px; }
.app-brand:hover { color: #fff; }
.app-brand small { font-family: system-ui, sans-serif; font-size: .75rem; font-weight: 400; color: #c9d6e6; margin-left: .5rem; letter-spacing: 0; }
.app-top-search { max-width: 360px; flex: 1; }
.app-top-search input { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); color: #fff; }
.app-top-search input::placeholder { color: #c9d6e6; }
.app-top-search input:focus { background: #fff; color: var(--app-ink); }
.app-menu { background: #fff; border-bottom: 1px solid var(--app-line); }
.app-menu .inner { display: flex; flex-wrap: wrap; gap: .1rem; padding: 0 1rem; }
.app-menu .nav-link { color: var(--app-ink); padding: .65rem .85rem; border-bottom: 3px solid transparent; border-radius: 0; font-weight: 500; }
.app-menu .nav-link:hover { color: var(--app-maroon); }
.app-menu .nav-link.active { color: var(--app-navy); border-bottom-color: var(--app-maroon); }
.app-menu .dropdown-menu { border-radius: 0; border-color: var(--app-line); }
.app-main { max-width: 1400px; margin: 0 auto; padding: 1.25rem 1.25rem 3rem; }
.breadcrumb { font-size: .85rem; }

/* cards, tables, buttons: thin rules, square-ish corners */
.card { border: 1px solid var(--app-line); border-radius: .25rem; box-shadow: none; margin-bottom: 1rem; background: #fff; }
.card-header { background: #fbfaf7; border-bottom: 1px solid var(--app-line); font-weight: 600; color: var(--app-navy); display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.table > thead th { font-size: .8rem; text-transform: uppercase; letter-spacing: .4px; color: #5d6673; border-bottom: 2px solid var(--app-line); background: #fbfaf7; }
.table-wrap { overflow-x: auto; }
.btn { border-radius: .2rem; }
.btn-primary { background: var(--app-navy); border-color: var(--app-navy); }
.btn-primary:hover, .btn-primary:focus { background: var(--app-navy-dark); border-color: var(--app-navy-dark); }
.btn-outline-primary { color: var(--app-navy); border-color: var(--app-navy); }
.btn-outline-primary:hover { background: var(--app-navy); border-color: var(--app-navy); color: #fff; }
.btn-success { background: var(--app-green); border-color: var(--app-green); }
.btn-danger, .btn-warning { border-radius: .2rem; }
.nav-tabs .nav-link.active { color: var(--app-navy); font-weight: 600; border-top: 2px solid var(--app-maroon); }
.form-control, .form-select { border-radius: .2rem; }
.req::after { content: " *"; color: var(--app-maroon); }

/* chips (badges) in tones info, success, warning, danger, neutral */
.chip { display: inline-block; padding: .12rem .55rem; border-radius: .2rem; font-size: .78rem; font-weight: 500; white-space: nowrap; border: 1px solid transparent; }
.chip-info { background: #eaf0f7; color: #1f4f86; border-color: #cddbeb; }
.chip-success { background: #e8f2ec; color: var(--app-green); border-color: #c9e0d2; }
.chip-warning { background: #fbf3e2; color: #8a5a00; border-color: #eedbb2; }
.chip-danger { background: #f8e8ea; color: var(--app-maroon); border-color: #ebc9ce; }
.chip-neutral { background: #f0efea; color: #4f5560; border-color: var(--app-line); }

/* tabs with a dot (something new from the payer) */
.nav-tabs .tab-dot::after { content: ""; display: inline-block; width: .5rem; height: .5rem; margin-left: .35rem; border-radius: 50%; background: var(--app-maroon); vertical-align: middle; }

.kv dt { font-weight: 500; color: #6c757d; font-size: .85rem; }
.kv dd { margin-bottom: .6rem; }
.stat-tile { background: #fff; border: 1px solid var(--app-line); border-top: 3px solid var(--app-navy); border-radius: .2rem; padding: .8rem 1rem; }
.stat-tile .v { font-family: var(--app-serif); font-size: 1.7rem; font-weight: 600; color: var(--app-navy); }
.stat-tile a { text-decoration: none; }

/* type-ahead list */
.typeahead { position: relative; }
.typeahead-list { position: absolute; z-index: 1000; left: 0; right: 0; max-height: 260px; overflow-y: auto; background: #fff; border: 1px solid var(--app-line); border-radius: .2rem; box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.typeahead-list button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: .4rem .75rem; color: var(--app-ink); }
.typeahead-list button:hover, .typeahead-list button.active { background: #eaf0f7; }

/* patient journey */
.journey-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; border-bottom: 1px solid var(--app-line); padding-bottom: .75rem; margin-bottom: 1rem; }
.journey-kicker { font-size: .75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--app-maroon); font-weight: 600; }
.journey-progress { text-align: right; }
.journey-progress-num { font-family: var(--app-serif); font-size: 2rem; font-weight: 600; color: var(--app-navy); line-height: 1; }
.journey-progress-num span { font-size: 1.1rem; color: #8a8f98; }
.next-banner { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; background: var(--app-navy); color: #fff; padding: 1rem 1.25rem; border-radius: .25rem; margin-bottom: 1.25rem; border-left: 6px solid var(--app-gold); }
.next-banner .fs-5 { font-family: var(--app-serif); }
.next-banner.done { background: var(--app-green); }
.journey { list-style: none; padding: 0; margin: 0; position: relative; }
.journey::before { content: ""; position: absolute; left: 19px; top: 8px; bottom: 8px; width: 2px; background: var(--app-line); }
.journey-step { position: relative; display: flex; gap: 1rem; align-items: flex-start; background: #fff; border: 1px solid var(--app-line); border-radius: .25rem; padding: .8rem 1rem .8rem 3.4rem; margin-bottom: .6rem; }
.journey-dot { position: absolute; left: 6px; top: .8rem; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: #fff; border: 2px solid #b9b6ab; color: #8a8f98; z-index: 1; }
.journey-body { flex: 1; min-width: 0; }
.journey-title { font-weight: 600; font-size: 1.05rem; color: var(--app-ink); }
.journey-state { font-size: .72rem; text-transform: uppercase; letter-spacing: .6px; padding: .1rem .45rem; border-radius: .2rem; background: #f0efea; color: #5d6673; }
.journey-detail { color: #5d6673; margin-top: .2rem; }
.journey-actions { display: flex; gap: .25rem; align-items: center; flex-wrap: wrap; }
.journey-step.done .journey-dot { background: var(--app-green); border-color: var(--app-green); color: #fff; }
.journey-step.done .journey-state { background: #e8f2ec; color: var(--app-green); }
.journey-step.next { border-color: var(--app-navy); box-shadow: 0 0 0 1px var(--app-navy); }
.journey-step.next .journey-dot { background: var(--app-navy); border-color: var(--app-navy); color: #fff; }
.journey-step.next .journey-state { background: var(--app-navy); color: #fff; }
.journey-step.waiting .journey-dot { border-color: var(--app-gold); color: var(--app-gold); }
.journey-step.waiting .journey-state { background: #fbf3e2; color: #8a5a00; }
.journey-step.skipped { background: #faf9f6; }
.journey-step.skipped .journey-title, .journey-step.skipped .journey-detail { color: #9a9ea6; }
.journey-step.skipped .journey-actions .btn-outline-primary { display: none; }

/* patient banner (record page) */
.patient-banner { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; background: #fff; border: 1px solid var(--app-line); border-left: 5px solid var(--app-navy); border-radius: .25rem; padding: 1rem 1.25rem; margin-bottom: 1rem; }
.patient-avatar { width: 56px; height: 56px; border-radius: 50%; background: var(--app-navy); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--app-serif); font-size: 1.3rem; font-weight: 600; flex-shrink: 0; border: 2px solid var(--app-gold); }
.min-w-0 { min-width: 0; }

/* patient master */
.master-list .list-group { max-height: 70vh; overflow-y: auto; }
.master-list .list-group-item.active { background: var(--app-navy); border-color: var(--app-navy); }
.master-list .list-group-item.active .master-sub { color: #c9d6e6; }
.master-sub { color: #6c757d; }
.master-pane { border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
.master-frame { width: 100%; min-height: 420px; border: 0; display: block; }
.master-steps li { padding: .25rem 0; border-bottom: 1px dotted var(--app-line); }
.master-steps li.skipped { color: #9a9ea6; }
.master-steps li.next { font-weight: 600; color: var(--app-navy); }
body.embedded { background: #fff; }
body.embedded .page-title, body.embedded h4:first-child { font-size: 1.15rem; }

/* front desk */
.desk-hero { background: #fff; border: 1px solid var(--app-line); border-top: 4px solid var(--app-navy); border-radius: .25rem; padding: 1.25rem; margin-bottom: 1rem; }
.desk-hero h1 { font-size: 1.6rem; }
.desk-steps { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .75rem; }
.desk-steps span { font-size: .8rem; background: #f0efea; border: 1px solid var(--app-line); padding: .2rem .55rem; border-radius: .2rem; color: #4f5560; }
.desk-steps span i { color: var(--app-maroon); }

@media (max-width: 768px) {
    .app-top .inner { flex-wrap: wrap; }
    .app-top-search { max-width: none; order: 3; flex-basis: 100%; }
    .journey-step { flex-direction: column; }
}
@media print { .app-top, .app-menu, .journey-actions, .next-banner .btn { display: none !important; } }

/* Visit screen (OPD / IPD): banner, facts strip, record tabs. Each tab = entry bar on top + grid of added items. */
.visit-banner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; align-items: flex-end; background: #fff; border: 1px solid var(--app-line); border-left: 4px solid var(--app-navy); border-radius: .25rem; padding: .9rem 1.1rem; margin-bottom: .75rem; }
.visit-kicker { font-size: .72rem; text-transform: uppercase; letter-spacing: 1px; color: var(--app-maroon); font-weight: 600; }
.visit-patient { color: #4b5563; }
.visit-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.visit-facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .5rem 1rem; background: #fbfaf7; border: 1px solid var(--app-line); border-radius: .25rem; padding: .7rem 1.1rem; margin-bottom: .75rem; }
.visit-facts span { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .5px; color: #8a8f98; }
.record-tabs { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding: .4rem .5rem 0; background: #fbfaf7; scrollbar-width: thin; }
.record-tabs .nav-link { white-space: nowrap; color: #4b5563; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; font-weight: 500; border-radius: .25rem .25rem 0 0; padding: .5rem .8rem; }
.record-tabs .nav-link.active { color: var(--app-navy); font-weight: 600; border-top: 3px solid var(--app-navy); }
.record-tabs .nav-link .badge { font-size: .7rem; margin-left: .2rem; }
.entry-bar { display: flex; flex-wrap: wrap; gap: .6rem .75rem; align-items: flex-end; background: #f3f6fa; border: 1px solid #d6e0ec; border-radius: .3rem; padding: .8rem; margin-bottom: 1rem; }
.entry-field { display: flex; flex-direction: column; min-width: 140px; flex: 0 1 180px; }
.entry-field.grow { flex: 1 1 260px; }
.entry-field.small-field { flex: 0 1 110px; min-width: 95px; }
.entry-field label { font-size: .75rem; font-weight: 600; color: #4b5563; margin-bottom: .2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.entry-field[hidden] { display: none; }
.entry-bar .unit { font-weight: 400; color: #8a8f98; }
.entry-break { flex-basis: 100%; height: 0; }
.lab-tests { display: flex; flex-direction: column; gap: .5rem; flex: 1 1 100%; }
.entry-row { display: flex; gap: .6rem; align-items: flex-end; flex-wrap: wrap; }
table.grid { border: 1px solid var(--app-line); margin-bottom: .5rem; background: #fff; }
table.grid thead th { background: var(--app-navy); color: #fff; font-weight: 500; font-size: .8rem; border-color: var(--app-navy); vertical-align: middle; min-width: 3rem; }
table.grid thead th .unit { color: #c9d4e3; font-weight: 400; }
table.grid tbody tr:nth-child(even) td { background: #faf9f6; }
table.grid tbody tr:hover td { background: #eef3f9; }
table.grid td { vertical-align: middle; }
table.grid .num { width: 2.5rem; text-align: center; color: #8a8f98; }
table.grid .act { width: 1%; white-space: nowrap; text-align: right; }
table.grid tr.empty td { text-align: center; color: #8a8f98; font-style: italic; padding: 1.2rem; background: #fff; }
table.kv-grid th { width: 180px; background: #fbfaf7; color: #5d6673; font-weight: 500; }
.kind-chip { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 1rem; background: #eef1f6; color: var(--app-navy); white-space: nowrap; }
.empty-note { padding: 1rem; background: #fbfaf7; border: 1px dashed var(--app-line); border-radius: .25rem; color: #5d6673; }
@media (max-width: 576px) { .entry-field, .entry-field.grow, .entry-field.small-field { flex: 1 1 100%; } .entry-bar > .btn { width: 100%; } }

/* Sign-in, facility registration, user menu */
.auth-body { background: var(--app-navy); min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px 24px; }
.auth-wrap { width: 100%; max-width: 420px; }
.auth-wrap.wide { max-width: 860px; }
.auth-brand { color: #fff; font-family: var(--app-serif); font-size: 1.6rem; font-weight: 600; text-align: center; margin-bottom: 1rem; }
.auth-brand small { display: block; font-family: system-ui, sans-serif; font-size: .8rem; font-weight: 400; color: #c9d4e3; letter-spacing: .5px; }
.auth-card { background: #fff; border-radius: .35rem; border-top: 4px solid var(--app-gold); padding: 1.6rem; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.auth-title { font-family: var(--app-serif); color: var(--app-navy); margin-bottom: 1rem; }
.auth-foot { color: #c9d4e3; text-align: center; font-size: .8rem; margin-top: 1rem; }
.setup-step { display: flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--app-navy); border-bottom: 1px solid var(--app-line); padding-bottom: .35rem; margin: 1rem 0 .75rem; }
.setup-step span { display: inline-flex; width: 26px; height: 26px; border-radius: 50%; background: var(--app-navy); color: #fff; align-items: center; justify-content: center; font-size: .85rem; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .75rem; margin-bottom: 1rem; }
.app-user { display: flex; align-items: center; gap: .5rem; margin-left: auto; }
.app-user .dropdown-toggle { color: #fff; text-decoration: none; display: flex; align-items: center; gap: .45rem; font-size: .9rem; }
.app-user .avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--app-gold); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; }
.app-user .who small { display: block; color: #c9d4e3; font-size: .72rem; line-height: 1.1; }
.branch-pill { background: rgba(255,255,255,.12); color: #fff; border: 1px solid rgba(255,255,255,.25); border-radius: 1rem; font-size: .78rem; padding: .15rem .65rem; }
.branch-pill select { background: transparent; color: #fff; border: 0; font-size: .78rem; padding: 0 .2rem; }
.branch-pill select option { color: #000; }

/* Company support visit banner (customer screens) */
.support-banner { background: var(--app-maroon); color: #fff; padding: .45rem 1rem; font-size: .88rem; text-align: center; }

/* Company console: a darker bar so staff always know which side they are on */
.platform-top { background: #2b2f36; }
.platform-body .app-menu .nav-link.active { border-bottom-color: var(--app-gold); }
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.kpi { background: #fff; border: 1px solid var(--app-line); border-radius: .3rem; padding: .8rem 1rem; }
.kpi .v { font-family: var(--app-serif); font-size: 1.6rem; color: var(--app-navy); line-height: 1.2; }
.kpi .l { font-size: .75rem; text-transform: uppercase; letter-spacing: .5px; color: #8a8f98; }
.kpi.warn .v { color: var(--app-maroon); }
