:root {
    --ink: #19232d; --muted: #6b7885; --line: #e4e9ed; --paper: #f6f8fa; --white: #fff;
    --blue: #1769aa; --blue-deep: #124e7e; --teal: #0f8b8d; --purple: #7156a8; --orange: #d98134;
    --shadow: 0 10px 30px rgba(25, 35, 45, .06); --radius: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 15px/1.55 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button, .button { cursor: pointer; }
.topbar { height: 76px; background: var(--white); border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 32px; position: sticky; top: 0; z-index: 5; }
.brand, .auth-brand { display: flex; align-items: center; gap: 11px; }
.brand strong, .auth-brand strong { display: block; letter-spacing: .04em; }
.brand small, .auth-brand small { display: block; color: var(--muted); font-size: 11px; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 11px; background: var(--blue); color: white; font-weight: 800; font-size: 20px; box-shadow: 0 5px 12px rgba(23,105,170,.25); }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.global-search { display: flex; width: min(30vw, 310px); border: 1px solid var(--line); border-radius: 9px; background: var(--paper); overflow: hidden; }
.global-search input { min-width: 0; width: 100%; border: 0; padding: 10px 12px; background: transparent; outline: 0; }
.global-search button { border: 0; background: transparent; padding: 0 12px; color: var(--blue); font-size: 20px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.avatar, .patient-avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: #dcecf7; color: var(--blue-deep); font-weight: 700; }
.logout-link { color: var(--muted); font-size: 13px; }
.app-shell { display: flex; min-height: calc(100vh - 76px); }
.sidebar { width: 235px; flex: 0 0 235px; background: #fbfcfd; border-right: 1px solid var(--line); padding: 30px 17px 20px; display: flex; flex-direction: column; }
.eyebrow { color: #85929d; font-size: 10px; font-weight: 800; letter-spacing: .14em; }
.sidebar nav { margin-top: 18px; }
.sidebar nav a { display: flex; align-items: center; gap: 13px; color: #697681; padding: 12px 13px; border-radius: 9px; margin: 3px 0; font-weight: 600; }
.sidebar nav a span { width: 17px; text-align: center; color: #91a0ab; font-size: 19px; }
.sidebar nav a.active, .sidebar nav a:hover { background: #eaf3fa; color: var(--blue-deep); }
.sidebar nav a.active span { color: var(--blue); }
.sidebar-foot { border-top: 1px solid var(--line); margin-top: auto; padding: 18px 10px 0; color: var(--muted); font-size: 12px; }
.role-label { color: var(--blue); font-weight: 800; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; }
.main-content { width: 100%; max-width: 1440px; padding: 38px 4.5vw 60px; margin: 0 auto; }
.page-heading, .profile-heading { display: flex; justify-content: space-between; align-items: end; gap: 24px; margin-bottom: 28px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(27px, 3vw, 38px); letter-spacing: -.035em; margin: 6px 0 6px; line-height: 1.1; }
h2 { font-size: 19px; letter-spacing: -.02em; margin: 4px 0 0; }
h3 { font-size: 16px; margin-bottom: 5px; }
.muted { color: var(--muted); }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 10px 17px; border-radius: 9px; border: 1px solid transparent; font-weight: 750; font-size: 13px; }
.button-primary { background: var(--blue); color: white; box-shadow: 0 6px 12px rgba(23,105,170,.17); }
.button-primary:hover { background: var(--blue-deep); }
.button-ghost { background: white; color: var(--blue-deep); border-color: var(--line); }
.button-wide { width: 100%; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 25px; }
.stat-card { padding: 20px 21px; border-radius: var(--radius); background: var(--white); box-shadow: var(--shadow); border-top: 3px solid var(--blue); }
.stat-card.teal { border-color: var(--teal); } .stat-card.purple { border-color: var(--purple); } .stat-card.orange { border-color: var(--orange); }
.stat-label { color: var(--muted); font-size: 12px; font-weight: 700; } .stat-value { font-size: 31px; font-weight: 800; letter-spacing: -.04em; margin: 7px 0 0; } .stat-detail { color: #9aa6af; font-size: 12px; }
.dashboard-grid, .profile-grid, .report-grid, .admin-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr); gap: 22px; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.text-link, .icon-link { color: var(--blue); font-size: 13px; font-weight: 750; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 500px; }
th { text-align: left; color: #8996a0; text-transform: uppercase; font-size: 10px; letter-spacing: .09em; padding: 0 12px 12px; }
td { padding: 14px 12px; border-top: 1px solid #edf0f2; color: #52616e; font-size: 13px; vertical-align: middle; }
.patient-link { color: var(--ink); font-weight: 750; display: inline-flex; flex-direction: column; }
.patient-link small { color: var(--blue); font-size: 11px; font-weight: 700; margin-top: 2px; }
.quick-panel { padding: 26px 23px; }
.quick-panel h2 { margin-bottom: 19px; }
.quick-action { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid #edf0f2; }
.quick-icon { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 9px; font-size: 19px; }
.blue-bg { background: #e7f2fa; color: var(--blue); } .teal-bg { background: #e5f5f1; color: var(--teal); } .purple-bg { background: #eeeaf8; color: var(--purple); }
.quick-action span:nth-child(2) { flex: 1; display: flex; flex-direction: column; } .quick-action strong { font-size: 13px; } .quick-action small { color: var(--muted); font-size: 11px; } .quick-action b { color: #9ba8b2; }
.flash { max-width: 780px; margin: -10px auto 20px; padding: 12px 16px; border-radius: 9px; font-size: 13px; font-weight: 650; }
.flash.success { background: #e6f5ed; color: #16704b; border: 1px solid #bfebd3; } .flash.error { background: #fff0ef; color: #a33c35; border: 1px solid #f3cbc7; }
.form-error { background: #fff0ef; color: #a33c35; border: 1px solid #f3cbc7; padding: 10px 13px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.form-panel { max-width: 1040px; margin: 0 auto; }
.section-heading { display: flex; gap: 12px; align-items: start; border-top: 1px solid var(--line); padding-top: 24px; margin-top: 26px; margin-bottom: 18px; }
.section-heading:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.section-heading p { color: var(--muted); margin: 4px 0 0; font-size: 13px; }
.section-number { display: grid; place-items: center; background: #eaf3fa; color: var(--blue); width: 27px; height: 27px; border-radius: 7px; font-size: 11px; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid.single { grid-template-columns: 1fr; gap: 15px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-full { grid-column: 1 / -1; }
.field > span { font-size: 12px; color: #566673; font-weight: 750; }
.field input, .field select, .field textarea { width: 100%; background: #fbfcfd; border: 1px solid #dce3e8; color: var(--ink); border-radius: 8px; padding: 11px 12px; outline: none; transition: border .15s, box-shadow .15s; }
.field textarea { min-height: 94px; resize: vertical; } .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23,105,170,.1); background: white; }
.field small { color: var(--muted); font-size: 11px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line); margin-top: 27px; padding-top: 20px; }
.search-hero { display: flex; align-items: center; background: white; border: 1px solid var(--line); border-radius: 12px; padding: 7px; margin-bottom: 22px; box-shadow: var(--shadow); }
.search-hero > span { color: var(--blue); font-size: 23px; padding: 0 10px; } .search-hero input { min-width: 0; flex: 1; border: 0; outline: 0; padding: 11px 6px; }
.result-caption { color: var(--muted); font-size: 13px; margin: 20px 0 11px; } .result-caption strong { color: var(--ink); }
.patient-cards { display: grid; gap: 10px; }
.patient-card { display: flex; align-items: center; gap: 14px; padding: 17px; background: white; border: 1px solid var(--line); border-radius: 11px; box-shadow: 0 4px 12px rgba(25,35,45,.03); }
.patient-card:hover { border-color: #a9cce3; transform: translateY(-1px); } .patient-card-main { flex: 1; } .patient-card-main h3 { margin: 1px 0; } .patient-card-main p { color: var(--muted); font-size: 12px; margin: 0; } .patient-code { color: var(--blue); font-weight: 800; font-size: 11px; letter-spacing: .07em; }
.patient-card-meta { display: flex; align-items: center; gap: 20px; color: var(--muted); font-size: 12px; } .patient-card-meta b { color: var(--blue); font-size: 18px; }
.empty-state { text-align: center; background: white; border: 1px dashed #ccd7df; padding: 68px 20px; border-radius: var(--radius); color: var(--muted); } .empty-state.compact { padding: 28px 14px; border: 0; background: transparent; box-shadow: none; } .empty-state h1, .empty-state h2, .empty-state h3 { color: var(--ink); font-size: 20px; margin-bottom: 6px; } .empty-state p { margin-bottom: 20px; font-size: 13px; } .empty-icon { display: grid; place-items: center; margin: 0 auto 14px; width: 45px; height: 45px; border-radius: 50%; background: #eaf3fa; color: var(--blue); font-size: 22px; font-weight: 800; }
.back-link { display: block; color: var(--blue); font-weight: 700; font-size: 13px; margin-bottom: 15px; } .profile-heading { align-items: end; flex-wrap: wrap; } .profile-main { display: flex; align-items: center; gap: 15px; flex: 1; } .patient-avatar.large { width: 62px; height: 62px; font-size: 25px; } .profile-main h1 { margin: 4px 0; } .profile-main p { color: var(--muted); margin: 0; }
.details-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px 24px; } .details-grid div { min-width: 0; } dt { color: #8b98a2; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; } dd { margin: 4px 0 0; color: #40505d; font-size: 13px; white-space: pre-line; }
.tag, .role-tag, .status { display: inline-block; border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 750; } .tag { color: var(--blue-deep); background: #eaf3fa; } .role-tag.admin { color: var(--purple); background: #eeeaf8; } .role-tag.doctor { color: var(--teal); background: #e5f5f1; } .role-tag.staff { color: var(--orange); background: #fff0df; } .status-active { color: #16704b; background: #e6f5ed; } .status-disabled { color: #8a5b20; background: #fff0df; }
.timeline { border-left: 2px solid #e6edf1; padding-left: 22px; margin-left: 8px; } .timeline-item { position: relative; padding: 0 0 27px; } .timeline-item:last-child { padding-bottom: 0; } .timeline-dot { position: absolute; left: -30px; top: 3px; width: 13px; height: 13px; border-radius: 50%; background: white; border: 3px solid var(--blue); } .timeline-date { color: var(--blue); font-size: 11px; font-weight: 800; } .timeline-date span { color: var(--muted); font-weight: 500; margin-left: 7px; } .timeline-item h3 { margin: 4px 0; } .timeline-item > p { color: #61707b; font-size: 13px; white-space: pre-line; margin-bottom: 9px; }
.visit-meta { display: flex; flex-wrap: wrap; gap: 7px; } .visit-meta span { display: inline-flex; flex-direction: column; padding: 7px 9px; background: #f5f7f8; border-radius: 7px; color: #5c6c77; font-size: 11px; } .visit-meta b { color: #8b98a2; font-size: 9px; text-transform: uppercase; letter-spacing: .07em; margin-bottom: 2px; }
.success-banner { display: flex; align-items: center; gap: 13px; padding: 15px 18px; border: 1px solid #bee8d0; background: #effaf4; color: #16704b; border-radius: 11px; margin-bottom: 22px; } .success-banner > span { font-size: 23px; } .success-banner p { margin: 2px 0 0; font-size: 12px; } .success-code { margin-left: auto; font-size: 19px; letter-spacing: .08em; }
.date-filter { display: flex; align-items: end; gap: 12px; margin-bottom: 18px; } .date-filter .field { width: 180px; } .date-preset { color: var(--blue); font-size: 12px; font-weight: 750; padding-bottom: 12px; } .report-period { color: var(--muted); font-size: 13px; margin: 18px 0; } .report-grid { margin-bottom: 22px; } .report-table { margin-top: 22px; }
.bar-row { margin: 15px 0; } .bar-row > div:first-child { display: flex; justify-content: space-between; font-size: 12px; color: #5e6d78; } .bar-row b { color: var(--ink); } .bar { height: 8px; background: #edf1f3; border-radius: 10px; margin-top: 7px; overflow: hidden; } .bar i { display: block; background: var(--blue); height: 100%; border-radius: 10px; }
.rank-list { list-style: none; padding: 0; margin: 0; } .rank-list li { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid #edf0f2; font-size: 13px; } .rank-list li:last-child { border-bottom: 0; } .rank { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: #f0f3f5; color: var(--muted); font-size: 11px; } .rank-list li span:nth-child(2) { flex: 1; } .rank-list b { color: var(--blue); }
.link-button { border: 0; background: transparent; color: var(--blue); font-weight: 700; font-size: 12px; padding: 0; } .admin-grid { grid-template-columns: minmax(0, 1.5fr) minmax(300px, .8fr); }
.auth-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at top right, #e4f1f8, transparent 42%), var(--paper); } .auth-card { width: min(100%, 430px); background: white; border: 1px solid var(--line); border-radius: 17px; padding: 35px; box-shadow: 0 20px 60px rgba(25,35,45,.1); } .auth-brand { margin-bottom: 42px; } .auth-card h1 { font-size: 29px; } .auth-foot { color: var(--muted); border-top: 1px solid var(--line); padding-top: 18px; margin: 23px 0 0; font-size: 12px; text-align: center; } .setup-card { width: min(100%, 520px); }

/* Medicine Stock & Dispensing */
.stock-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 11px; font-weight: 750; }
.stock-badge.in-stock { background: #e6f5ed; color: #16704b; }
.stock-badge.low-stock { background: #fff4e5; color: #b76e00; }
.stock-badge.out-of-stock { background: #fff0ef; color: #a33c35; }
.stock-badge i { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.stock-badge.in-stock i { background: #22c55e; }
.stock-badge.low-stock i { background: #f59e0b; }
.stock-badge.out-of-stock i { background: #ef4444; }

.inventory-tabs { display: flex; gap: 8px; margin-bottom: 20px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.inventory-tab { padding: 8px 16px; border-radius: 8px; font-weight: 700; font-size: 13px; color: var(--muted); }
.inventory-tab.active { background: #eaf3fa; color: var(--blue-deep); }

.badge-log { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.badge-log.restock { background: #e6f5ed; color: #16704b; }
.badge-log.dispensed { background: #fff0df; color: #d98134; }
.badge-log.adjustment { background: #eeeaf8; color: var(--purple); }

.dispense-builder { background: #fbfcfd; border: 1px solid var(--line); border-radius: 11px; padding: 18px; margin-top: 10px; }
.dispense-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(110px, 1fr) minmax(0, 2fr) 40px; gap: 12px; align-items: end; margin-bottom: 12px; }
.btn-remove-row { height: 42px; width: 40px; display: grid; place-items: center; border: 1px solid #f3cbc7; background: #fff5f5; color: #a33c35; border-radius: 8px; font-weight: 800; cursor: pointer; }
.btn-remove-row:hover { background: #fee2e2; }
.btn-add-row { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--blue); background: #eaf3fa; border: 1px dashed #a9cce3; border-radius: 8px; padding: 9px 15px; cursor: pointer; }
.btn-add-row:hover { background: #dcecf7; }
.med-chip { display: inline-flex; align-items: center; gap: 6px; background: #f0f7fb; border: 1px solid #d4e7f5; color: var(--blue-deep); padding: 4px 10px; border-radius: 8px; font-size: 12px; font-weight: 650; margin: 3px 4px 3px 0; }
.med-chip b { color: var(--blue); font-weight: 800; }

@media (max-width: 1050px) { .sidebar { width: 195px; flex-basis: 195px; } .topbar { padding: 0 20px; } .main-content { padding-left: 25px; padding-right: 25px; } .dashboard-grid, .profile-grid, .report-grid, .admin-grid { grid-template-columns: 1fr; } }
@media (max-width: 700px) { .topbar { height: auto; min-height: 70px; padding: 13px 15px; align-items: flex-start; } .topbar-actions { gap: 10px; flex: 1; justify-content: flex-end; } .global-search { display: none; } .user-chip { max-width: 32px; overflow: hidden; } .user-chip .avatar { flex: 0 0 32px; } .logout-link { font-size: 12px; } .app-shell { display: block; } .sidebar { width: 100%; height: auto; padding: 8px 10px; border-right: 0; border-bottom: 1px solid var(--line); } .sidebar .eyebrow, .sidebar-foot { display: none; } .sidebar nav { display: flex; margin: 0; gap: 4px; overflow-x: auto; } .sidebar nav a { white-space: nowrap; padding: 9px 10px; font-size: 12px; } .sidebar nav a span { font-size: 16px; } .main-content { padding: 25px 15px 40px; } .page-heading, .profile-heading { align-items: flex-start; flex-direction: column; gap: 14px; } .page-heading > .button, .profile-heading > .button { width: 100%; } .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; } .stat-card { padding: 15px; } .stat-value { font-size: 25px; } .panel { padding: 17px; } .form-grid, .details-grid { grid-template-columns: 1fr; } .field-full { grid-column: auto; } .search-hero { padding: 5px; } .search-hero .button { padding-left: 11px; padding-right: 11px; } .patient-card { align-items: flex-start; } .patient-card-meta { flex-direction: column; align-items: flex-end; gap: 7px; } .date-filter { align-items: stretch; flex-wrap: wrap; } .date-filter .field { width: calc(50% - 7px); } .date-filter .button { width: 100%; } .success-banner { flex-wrap: wrap; } .success-code { margin-left: 0; width: 100%; } .auth-card { padding: 25px 20px; } .dispense-row { grid-template-columns: 1fr; gap: 8px; border-bottom: 1px dashed var(--line); padding-bottom: 10px; } .btn-remove-row { width: 100%; height: 36px; } }
@media print { .topbar, .sidebar, .print-hide, .button, .flash { display: none !important; } body, .main-content { background: white; padding: 0; } .panel { box-shadow: none; border: 1px solid #ddd; } .report-grid { grid-template-columns: 1fr 1fr; } }