@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800;900&display=swap');

:root {
    --reports-ink: #14233c;
    --reports-muted: #6a778c;
    --reports-primary: #1f4e79;
    --reports-primary-dark: #173b5e;
    --reports-accent: #14a3a8;
    --reports-accent-soft: #e8f8f8;
    --reports-bg: #f4f7fb;
    --reports-card: #ffffff;
    --reports-line: #dfe7f0;
    --reports-success: #138a63;
    --reports-warning: #c17a13;
    --reports-shadow: 0 18px 48px rgba(20, 35, 60, .09);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body.reports-app,
body.reports-auth-body {
    margin: 0;
    min-height: 100vh;
    font-family: "Cairo", sans-serif;
    color: var(--reports-ink);
    background:
        radial-gradient(circle at 90% 0%, rgba(20, 163, 168, .09), transparent 26%),
        var(--reports-bg);
}
a { text-decoration: none; }

.reports-topbar {
    position: sticky;
    top: 0;
    z-index: 70;
    border-bottom: 1px solid rgba(223, 231, 240, .9);
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(16px);
}
.reports-topbar-inner {
    width: min(1520px, calc(100% - 32px));
    min-height: 76px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 24px;
}
.reports-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--reports-ink);
}
.reports-brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: linear-gradient(145deg, var(--reports-primary), var(--reports-accent));
    color: #fff;
    font-weight: 900;
    box-shadow: 0 12px 28px rgba(31, 78, 121, .18);
}
.reports-brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.reports-brand strong,
.reports-brand small { display: block; }
.reports-brand strong { font-size: 16px; font-weight: 900; }
.reports-brand small { margin-top: 3px; color: var(--reports-muted); font-size: 11px; }

.reports-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
}
.reports-nav-link {
    padding: 10px 13px;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    border-radius: 12px;
    color: #415169;
    font-size: 13px;
    font-weight: 800;
    transition: .2s ease;
}
.reports-nav-link:hover { color: var(--reports-primary); background: #eef4fa; }
.reports-nav-link.active {
    color: #fff;
    background: linear-gradient(135deg, var(--reports-primary), #296793);
    box-shadow: 0 10px 24px rgba(31, 78, 121, .2);
}
.reports-user { display: flex; align-items: center; gap: 9px; }
.reports-user-avatar {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--reports-accent-soft);
    color: #08777b;
    font-weight: 900;
}
.reports-user-copy strong,
.reports-user-copy small { display: block; }
.reports-user-copy strong {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
}
.reports-user-copy small { color: var(--reports-muted); font-size: 10px; }
.reports-logout {
    padding: 8px 10px;
    border: 1px solid var(--reports-line);
    border-radius: 10px;
    background: #fff;
    color: var(--reports-ink);
    font-family: inherit;
    font-weight: 800;
    cursor: pointer;
}
.mobile-menu-btn { display: none; }

.reports-page {
    width: min(1460px, calc(100% - 36px));
    min-height: calc(100vh - 150px);
    margin: 0 auto;
    padding: 28px 0 56px;
}
.reports-page-heading {
    margin-bottom: 20px;
    padding: 23px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border: 1px solid rgba(223, 231, 240, .9);
    border-radius: 22px;
    background: rgba(255, 255, 255, .94);
    box-shadow: 0 14px 34px rgba(20, 35, 60, .05);
}
.reports-page-heading h1 {
    margin: 3px 0 6px;
    font-size: clamp(24px, 3vw, 34px);
    line-height: 1.2;
    font-weight: 900;
}
.reports-page-heading p { margin: 0; color: var(--reports-muted); }
.reports-kicker { color: var(--reports-accent) !important; font-size: 12px; font-weight: 900; }
.reports-page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn,
.primary-button,
.ghost-button,
.tool-button {
    min-height: 42px;
    padding: 10px 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 0;
    border-radius: 12px;
    font-family: inherit;
    font-weight: 900;
    cursor: pointer;
    transition: transform .2s ease, box-shadow .2s ease;
}
.btn:hover,
.primary-button:hover,
.ghost-button:hover { transform: translateY(-1px); }
.btn-primary,
.primary-button {
    color: #fff !important;
    background: linear-gradient(135deg, var(--reports-primary), #296793);
    box-shadow: 0 10px 22px rgba(31, 78, 121, .18);
}
.btn-light,
.ghost-button {
    border: 1px solid var(--reports-line);
    color: var(--reports-ink) !important;
    background: #fff;
}
.alert { margin-bottom: 16px; padding: 14px 16px; border-radius: 14px; font-weight: 700; }
.alert-success { border: 1px solid #aee5d0; color: #0c684a; background: #effbf6; }
.alert-danger { border: 1px solid #efbaba; color: #9a2f2f; background: #fff2f2; }

.reports-hero {
    margin-bottom: 18px;
    padding: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 28px;
    border-radius: 25px;
    color: #fff;
    background:
        linear-gradient(115deg, rgba(20, 163, 168, .2), transparent 48%),
        linear-gradient(135deg, #142f4e, #1f4e79);
    box-shadow: var(--reports-shadow);
}
.reports-hero h2 { margin: 9px 0; font-size: clamp(25px, 3vw, 38px); }
.reports-hero p { max-width: 720px; margin: 0; color: rgba(255,255,255,.78); line-height: 1.9; }
.reports-hero-badge {
    padding: 5px 10px;
    border: 1px solid rgba(255,255,255,.18);
    border-radius: 999px;
    color: #b8ffff;
    background: rgba(255,255,255,.08);
    font-size: 11px;
    font-weight: 900;
}
.reports-hero-actions { display: flex; gap: 9px; flex-wrap: wrap; }
.reports-hero .btn-light { border-color: rgba(255,255,255,.22); color: #fff !important; background: rgba(255,255,255,.08); }

.reports-metrics {
    margin-bottom: 18px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}
.reports-metrics-three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.reports-metric {
    min-height: 150px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--reports-line);
    border-radius: 20px;
    background: var(--reports-card);
    box-shadow: 0 12px 30px rgba(20, 35, 60, .05);
}
.reports-metric span { color: var(--reports-muted); font-weight: 800; }
.reports-metric strong { margin: 10px 0 8px; font-size: 38px; line-height: 1; font-weight: 900; }
.reports-metric small { margin-top: auto; color: #8490a1; line-height: 1.6; }
.reports-metric-primary { border-color: #cbdceb; background: linear-gradient(150deg, #fff, #eef5fb); }
.reports-metric-primary strong { color: var(--reports-primary); }
.reports-metric-success strong { color: var(--reports-success); }
.reports-metric-warning strong { color: var(--reports-warning); }

.reports-dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(320px, .8fr);
    gap: 18px;
}
.reports-panel {
    padding: 21px;
    border: 1px solid var(--reports-line);
    border-radius: 22px;
    background: var(--reports-card);
    box-shadow: 0 14px 36px rgba(20, 35, 60, .055);
}
.reports-panel-heading {
    margin-bottom: 17px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
}
.reports-panel-heading span { color: var(--reports-accent); font-size: 11px; font-weight: 900; }
.reports-panel-heading h2 { margin: 4px 0 0; font-size: 20px; }
.reports-panel-heading a { color: var(--reports-primary); font-weight: 900; }
.records-list { display: grid; gap: 8px; }
.record-row {
    padding: 13px 12px;
    display: grid;
    grid-template-columns: 50px minmax(180px, 1.2fr) minmax(130px, .8fr) 105px 92px;
    align-items: center;
    gap: 12px;
    border: 1px solid transparent;
    border-radius: 14px;
    color: var(--reports-ink);
    background: #f8fafc;
    transition: .2s ease;
}
.record-row:hover { border-color: #cdddeb; background: #f1f7fb; transform: translateX(-2px); }
.record-number,
.table-serial {
    display: inline-grid;
    place-items: center;
    min-width: 42px;
    height: 34px;
    border-radius: 10px;
    color: var(--reports-primary);
    background: #e9f1f8;
    font-weight: 900;
}
.record-main strong,
.record-main small,
.record-date small,
.table-patient-link strong,
.table-patient-link small { display: block; }
.record-main small,
.record-date,
.record-doctor,
.table-patient-link small { color: var(--reports-muted); font-size: 11px; }
.record-completion {
    padding: 6px 9px;
    display: inline-flex;
    justify-content: center;
    border-radius: 999px;
    white-space: nowrap;
    font-size: 11px;
    font-weight: 900;
}
.record-completion.completed { color: #08704f; background: #def6ec; }
.record-completion.pending { color: #9a630e; background: #fff0d3; }

.monthly-bars { height: 250px; display: flex; align-items: end; justify-content: space-between; gap: 10px; }
.monthly-bar-item { height: 100%; flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.monthly-bar-track { width: 100%; height: 190px; display: flex; align-items: end; overflow: hidden; border-radius: 10px; background: #eef3f8; }
.monthly-bar-track span { width: 100%; min-height: 5px; border-radius: 10px; background: linear-gradient(180deg, var(--reports-accent), var(--reports-primary)); }
.monthly-bar-item strong { font-size: 12px; }
.monthly-bar-item small { color: var(--reports-muted); font-size: 10px; }

.reports-filter-card {
    margin-bottom: 18px;
    padding: 18px;
    border: 1px solid var(--reports-line);
    border-radius: 19px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(20, 35, 60, .045);
}
.reports-filter-grid {
    display: grid;
    grid-template-columns: minmax(250px, 1.5fr) 150px 150px 190px 160px auto;
    align-items: end;
    gap: 11px;
}
.reports-filter-grid-stats { grid-template-columns: repeat(4, minmax(160px, 1fr)) auto; }
.reports-filter-grid label > span,
.record-form label > span {
    margin-bottom: 6px;
    display: block;
    color: var(--reports-muted);
    font-size: 12px;
    font-weight: 800;
}
.reports-filter-actions { display: flex; gap: 7px; }

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid #d6e0eb;
    border-radius: 11px;
    padding: 10px 12px;
    outline: 0;
    font-family: inherit;
    color: var(--reports-ink);
    background: #fff;
    transition: border .2s ease, box-shadow .2s ease;
}
textarea { min-height: 120px; resize: vertical; }
input:focus,
select:focus,
textarea:focus { border-color: var(--reports-accent); box-shadow: 0 0 0 4px rgba(20, 163, 168, .1); }

.reports-table { min-width: 980px; }
.reports-table th { padding: 12px; color: #536278; background: #f3f7fb; font-size: 11px; font-weight: 900; }
.reports-table td { padding: 13px 12px; }
.table-patient-link { color: var(--reports-ink); }
.table-actions { display: flex; gap: 8px; }
.table-actions a { color: var(--reports-primary); font-size: 12px; font-weight: 900; }

.record-form-intro {
    margin-bottom: 17px;
    padding: 23px 25px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 21px;
    color: #fff;
    background: linear-gradient(130deg, #1a385b, #245e89);
}
.record-form-intro span { color: #aee7e9; font-size: 11px; font-weight: 900; }
.record-form-intro h2 { margin: 5px 0; }
.record-form-intro p { max-width: 760px; margin: 0; color: rgba(255,255,255,.76); }
.record-form-intro-icon { font-size: 52px; color: #8ce1e4; }
.record-form { display: grid; gap: 16px; }
.record-form-section {
    padding: 22px;
    border: 1px solid var(--reports-line);
    border-radius: 21px;
    background: #fff;
    box-shadow: 0 11px 30px rgba(20,35,60,.045);
}
.record-form-section-title { margin-bottom: 18px; display: flex; align-items: center; gap: 12px; }
.record-form-section-title > span {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 13px;
    color: #fff;
    background: var(--reports-primary);
    font-weight: 900;
}
.record-form-section-title h3 { margin: 0; font-size: 19px; }
.record-form-section-title p { margin: 3px 0 0; color: var(--reports-muted); }
.record-file-field a { margin-top: 8px; display: inline-block; color: var(--reports-primary); font-weight: 900; }
.record-form-actions {
    position: sticky;
    bottom: 12px;
    z-index: 20;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    gap: 9px;
    border: 1px solid rgba(214,224,235,.9);
    border-radius: 16px;
    background: rgba(255,255,255,.94);
    box-shadow: 0 16px 35px rgba(20,35,60,.1);
    backdrop-filter: blur(12px);
}

.patient-header,
.tab-panel,
.note-panel,
.important-links-section,
.chart-card,
.table-panel {
    border-radius: 20px !important;
    border-color: var(--reports-line) !important;
    box-shadow: 0 12px 30px rgba(20,35,60,.045);
}
.tabs { padding: 7px; border: 1px solid var(--reports-line); border-radius: 15px; background: #fff; }
.tab { border: 0 !important; border-radius: 10px !important; background: transparent !important; }
.tab.active { color: #fff !important; background: var(--reports-primary) !important; }
.report-access-message { border-radius: 14px !important; }

.stats-bars { display: grid; gap: 11px; }
.stats-bar-row { display: grid; grid-template-columns: 90px 1fr 38px; align-items: center; gap: 10px; }
.stats-bar-row span { color: var(--reports-muted); font-size: 11px; }
.stats-bar-row > div { height: 9px; overflow: hidden; border-radius: 999px; background: #edf2f7; }
.stats-bar-row i { height: 100%; display: block; border-radius: inherit; background: linear-gradient(90deg, var(--reports-accent), var(--reports-primary)); }
.stats-bar-row strong { text-align: center; }

.medical-pagination {
    margin-top: 18px;
    padding-top: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    border-top: 1px solid var(--reports-line);
}
.medical-pagination-summary { color: var(--reports-muted); font-size: 12px; }
.medical-pagination-controls { display: flex; gap: 5px; flex-wrap: wrap; }
.pagination-button,
.pagination-number,
.pagination-dots {
    min-width: 38px;
    height: 38px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--reports-line);
    border-radius: 10px;
    color: var(--reports-ink);
    background: #fff;
    font-size: 12px;
    font-weight: 900;
}
.pagination-current { color: #fff; border-color: var(--reports-primary); background: var(--reports-primary); }
.pagination-disabled { opacity: .45; cursor: not-allowed; }

.reports-footer {
    padding: 17px 24px;
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    border-top: 1px solid var(--reports-line);
    color: var(--reports-muted);
    background: #fff;
    font-size: 11px;
}

.reports-auth-shell {
    width: min(1120px, calc(100% - 36px));
    min-height: 100vh;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    align-items: center;
    gap: 60px;
    padding: 40px 0;
}
.reports-auth-intro { padding: 32px; }
.reports-auth-emblem {
    width: 78px;
    height: 78px;
    margin-bottom: 22px;
    display: grid;
    place-items: center;
    overflow: hidden;
    border-radius: 23px;
    color: #fff;
    background: linear-gradient(140deg, var(--reports-primary), var(--reports-accent));
    box-shadow: 0 18px 44px rgba(31,78,121,.2);
}
.reports-auth-emblem img { width: 100%; height: 100%; object-fit: cover; }
.reports-auth-intro h1 { max-width: 650px; margin: 8px 0 15px; font-size: clamp(36px, 5vw, 64px); line-height: 1.25; font-weight: 900; }
.reports-auth-intro > p { max-width: 670px; color: var(--reports-muted); line-height: 2; }
.reports-auth-kicker { color: var(--reports-accent) !important; font-size: 12px; font-weight: 900; }
.reports-auth-features { margin-top: 25px; display: flex; gap: 8px; flex-wrap: wrap; }
.reports-auth-features span { padding: 8px 11px; border: 1px solid var(--reports-line); border-radius: 999px; color: #526178; background: #fff; font-size: 11px; font-weight: 800; }
.reports-auth-card { padding: 30px; border: 1px solid var(--reports-line); border-radius: 27px; background: rgba(255,255,255,.96); box-shadow: var(--reports-shadow); }
.reports-auth-card h2 { margin: 5px 0; font-size: 28px; }
.reports-auth-card > div > p:last-child { color: var(--reports-muted); }
.reports-auth-form { margin-top: 22px; display: grid; gap: 15px; }
.reports-auth-form label > span { margin-bottom: 6px; display: block; color: var(--reports-muted); font-size: 12px; font-weight: 800; }
.reports-remember { display: flex !important; align-items: center; gap: 7px; }
.reports-remember input { width: 17px; min-height: 17px; }
.reports-remember span { margin: 0 !important; }
.reports-auth-submit { width: 100%; }

@media (max-width: 1120px) {
    .reports-topbar-inner { grid-template-columns: 1fr auto; }
    .reports-nav,
    .reports-user-copy { display: none; }
    .mobile-menu-btn { display: inline-flex; }
    .reports-dashboard-grid { grid-template-columns: 1fr; }
    .reports-filter-grid,
    .reports-filter-grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .reports-filter-actions { grid-column: 1 / -1; }
    .record-row { grid-template-columns: 48px minmax(170px, 1fr) 110px 92px; }
    .record-doctor { display: none; }
}
@media (max-width: 820px) {
    .reports-page { width: calc(100% - 20px); padding-top: 14px; }
    .reports-page-heading,
    .reports-hero { padding: 18px; align-items: flex-start; flex-direction: column; }
    .reports-metrics,
    .reports-metrics-three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .reports-auth-shell { grid-template-columns: 1fr; gap: 10px; }
    .reports-auth-intro { padding: 20px 5px; }
    .reports-auth-intro h1 { font-size: 38px; }
}
@media (max-width: 600px) {
    .reports-topbar-inner { width: calc(100% - 20px); min-height: 66px; }
    .reports-brand small,
    .reports-user,
    .reports-brand > span:last-child { display: none; }
    .reports-metrics,
    .reports-metrics-three,
    .reports-filter-grid,
    .reports-filter-grid-stats { grid-template-columns: 1fr; }
    .record-row { grid-template-columns: 42px 1fr auto; }
    .record-date { display: none; }
    .medical-pagination { align-items: stretch; flex-direction: column; }
    .medical-pagination-controls { justify-content: center; }
    .reports-auth-card { padding: 22px; }
}
@media print {
    .reports-topbar,
    .reports-page-heading,
    .reports-footer,
    .print-toolbar,
    .record-form-actions { display: none !important; }
    .reports-page { width: 100%; padding: 0; }
}

/* =========================================================
   Loader and responsive navigation
   ========================================================= */
.page-loader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(244, 247, 251, .96);
    backdrop-filter: blur(12px);
    transition: opacity .24s ease, visibility .24s ease;
}
.page-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.loader-card {
    min-width: min(310px, 100%);
    padding: 28px;
    border: 1px solid var(--reports-line);
    border-radius: 24px;
    text-align: center;
    background: #fff;
    box-shadow: var(--reports-shadow);
}
.loader-ring {
    width: 52px;
    height: 52px;
    margin: 0 auto 14px;
    border: 5px solid #d9e8f3;
    border-top-color: var(--reports-accent);
    border-radius: 50%;
    animation: reports-spin .8s linear infinite;
}
.loader-title { font-size: 18px; font-weight: 900; }
.loader-subtitle { margin-top: 5px; color: var(--reports-muted); font-size: 12px; }
@keyframes reports-spin { to { transform: rotate(360deg); } }

.reports-mobile-nav { display: none; }
@media (max-width: 1120px) {
    .reports-mobile-nav {
        position: sticky;
        top: 76px;
        z-index: 65;
        margin: 0 12px;
        padding: 10px;
        border: 1px solid var(--reports-line);
        border-top: 0;
        border-radius: 0 0 18px 18px;
        background: rgba(255, 255, 255, .98);
        box-shadow: 0 16px 32px rgba(20, 35, 60, .1);
    }
    body.mobile-nav-open .reports-mobile-nav {
        display: grid;
        gap: 7px;
    }
    .reports-mobile-nav .mobile-nav-link {
        padding: 12px 14px;
        display: flex;
        align-items: center;
        gap: 9px;
        border-radius: 12px;
        color: #415169;
        background: #f6f9fc;
    }
    .reports-mobile-nav .mobile-nav-link.active {
        color: #fff;
        background: linear-gradient(135deg, var(--reports-primary), #296793);
    }
}
@media (max-width: 600px) {
    .reports-mobile-nav { top: 66px; }
}
