:root {
    --navy: #09234b;
    --blue: #0b5ed7;
    --sky: #eaf3ff;
    --yellow: #facc15;
    --green: #16a34a;
    --red: #dc2626;
    --muted: #667085;
    --line: #d8e2ef;
    --bg: #f4f8fc;
    --white: #ffffff;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Cairo", sans-serif;
    font-size: 14px;
    line-height: 1.25;
    color: var(--navy);
    background: var(--bg);
}

a {
    color: var(--blue);
    text-decoration: none;
}

.page-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.hospital-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 18px;
    padding: 14px clamp(16px, 4vw, 44px);
    background: var(--white);
    border-bottom: 2px solid #111827;
}

.hospital-logo {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #d71920;
    color: var(--white);
    font-size: 34px;
    font-weight: 700;
}

.hospital-title {
    text-align: center;
}

.hospital-title strong {
    display: block;
    font-size: 22px;
}

.hospital-title span {
    color: var(--muted);
}

.content {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 24px clamp(14px, 3vw, 34px) 72px;
    flex: 1;
}

.site-footer {
    display: flex;
    justify-content: center;
    gap: 18px;
    flex-wrap: wrap;
    padding: 12px 20px;
    border-top: 1px solid var(--line);
    background: var(--white);
    color: var(--muted);
    text-align: center;
}

.login-screen {
    min-height: 66vh;
    display: grid;
    place-items: center;
}

.login-card {
    width: min(460px, 100%);
    padding: 30px;
    border-radius: 8px;
    background: var(--white);
    box-shadow: 0 24px 70px rgba(9, 35, 75, .14);
    border: 1px solid var(--line);
}

.login-badge {
    width: 64px;
    height: 64px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: var(--navy);
    color: var(--yellow);
    font-size: 24px;
    font-weight: 700;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--blue);
    font-weight: 700;
}

.toolbar,
.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.tool-button,
.primary-button,
.ghost-button {
    border: 0;
    border-radius: 8px;
    padding: 10px 14px;
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
}

.tool-button {
    background: var(--navy);
    color: var(--white);
}

.tool-button.muted,
.ghost-button {
    background: var(--sky);
    color: var(--navy);
}

.primary-button {
    background: var(--blue);
    color: var(--white);
}

.primary-button.full {
    width: 100%;
}

.hero-panel,
.patient-header,
.room-board,
.table-panel,
.chart-card,
.note-panel,
.mini-form,
.contact-panel {
    padding: 20px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    margin-bottom: 18px;
}

.hero-panel,
.patient-header,
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.search-box,
.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.metric-card {
    padding: 18px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--navy), #143f7d);
    color: var(--white);
    box-shadow: 0 14px 34px rgba(9, 35, 75, .12);
}

.metric-card span {
    display: block;
    color: rgba(255, 255, 255, .78);
    margin-bottom: 8px;
}

.metric-card strong {
    font-size: 32px;
    line-height: 1;
}

.metric-card.green {
    background: linear-gradient(135deg, #166534, var(--green));
}

.metric-card.yellow {
    background: linear-gradient(135deg, #854d0e, var(--yellow));
    color: #111827;
}

.metric-card.yellow span {
    color: rgba(17, 24, 39, .72);
}

.metric-card.blue {
    background: linear-gradient(135deg, #075985, var(--blue));
}

.filter-panel {
    display: grid;
    grid-template-columns: 180px 150px 210px minmax(240px, 1fr) auto auto;
    align-items: end;
    gap: 12px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    margin-bottom: 18px;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: inherit;
    font-size: 14px;
    background: var(--white);
    color: var(--navy);
}

textarea {
    min-height: 112px;
    resize: vertical;
}

.large-textarea {
    min-height: 220px;
}

label span {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-weight: 700;
}

.form-grid {
    display: grid;
    gap: 14px;
    margin-bottom: 14px;
}

.form-grid.two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid.four {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.full-label {
    display: block;
    margin-bottom: 14px;
}

.guidance-box,
.hint-box,
.alert {
    display: grid;
    gap: 6px;
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.guidance-box,
.hint-box {
    background: #fff8d6;
    border: 1px solid #fde68a;
}

.alert.success {
    background: #dcfce7;
    border: 1px solid #86efac;
}

.alert.danger {
    background: #fee2e2;
    border: 1px solid #fecaca;
}

.room-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.room-column {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.slot {
    display: inline-grid;
    gap: 2px;
    margin: 4px;
    padding: 7px 9px;
    border-radius: 8px;
    color: var(--white);
    font-weight: 700;
    min-width: 72px;
    min-height: 45px;
    vertical-align: top;
}

.slot small {
    font-size: 11px;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot.free {
    background: var(--green);
}

.slot.busy {
    background: var(--red);
}

.responsive-table {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

th,
td {
    padding: 11px 10px;
    border-bottom: 1px solid var(--line);
    text-align: right;
    vertical-align: top;
}

th {
    background: var(--sky);
    color: var(--navy);
}

.status {
    display: inline-flex;
    padding: 5px 8px;
    border-radius: 8px;
    color: var(--white);
    white-space: nowrap;
}

.status-active {
    background: var(--green);
}

.status-cancelled {
    background: #ca8a04;
}

.status-inactive {
    background: var(--red);
}

.danger-text,
.is-danger {
    color: var(--red);
    font-weight: 700;
}

.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 26px;
}

.actions {
    display: flex;
    gap: 10px;
}

.tabs {
    display: flex;
    overflow-x: auto;
    gap: 8px;
    margin-bottom: 14px;
}

.tab {
    border: 1px solid var(--line);
    background: var(--white);
    color: var(--navy);
    border-radius: 8px;
    padding: 10px 12px;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.tab.active {
    background: var(--navy);
    color: var(--white);
}

.tab-panel {
    display: none;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
    margin-bottom: 16px;
}

.tab-panel.active {
    display: block;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.summary-grid div {
    padding: 14px;
    background: var(--sky);
    border-radius: 8px;
}

.summary-grid span {
    display: block;
    color: var(--muted);
    margin-bottom: 5px;
}

.sticky-actions,
.form-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: flex-start;
    margin: 16px 0;
}

.split-panels {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.mini-form {
    display: grid;
    gap: 10px;
}

.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.chart-card.wide {
    grid-column: 1 / -1;
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.link-card {
    display: grid;
    gap: 8px;
    padding: 18px;
    border-radius: 8px;
    background: var(--white);
    border: 1px solid var(--line);
    color: var(--navy);
}

.link-card span {
    color: var(--blue);
    font-weight: 700;
}

.print-page {
    width: min(900px, 100%);
    margin: 0 auto;
    padding: 30px;
    background: var(--white);
    color: #111827;
}

.print-header,
.print-footer {
    text-align: center;
}

.pre-line {
    white-space: pre-line;
}

.medical-print-page {
    width: min(960px, 100%);
    margin: 0 auto;
    padding: 28px;
    background: var(--white);
    border: 1px solid var(--line);
    color: #111827;
}

.medical-print-header {
    display: grid;
    grid-template-columns: 64px 1fr 64px;
    align-items: center;
    text-align: center;
    border-bottom: 2px solid #111827;
    padding-bottom: 12px;
    margin-bottom: 16px;
}

.medical-print-header .print-logo {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    background: #d71920;
    color: #fff;
    font-size: 32px;
    font-weight: 700;
}

.medical-print-header h1 {
    font-size: 24px;
    margin-bottom: 4px;
}

.report-title {
    text-align: center;
    font-size: 20px;
    margin-bottom: 16px;
}

.print-info-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    border: 1px solid #111827;
    margin-bottom: 16px;
}

.print-info-grid div {
    padding: 8px;
    border-left: 1px solid #111827;
    border-bottom: 1px solid #111827;
    min-height: 54px;
}

.print-info-grid span,
.signature-grid span {
    display: block;
    color: #4b5563;
    font-size: 12px;
    margin-bottom: 4px;
}

.print-section {
    margin-bottom: 16px;
}

.print-section h3 {
    padding: 8px 10px;
    background: #eaf3ff;
    border-right: 4px solid var(--blue);
    margin-bottom: 10px;
}

.print-table {
    min-width: 0;
    border: 1px solid #111827;
}

.print-table th {
    width: 230px;
    background: #f3f4f6;
}

.print-table th,
.print-table td {
    border: 1px solid #111827;
}

.print-bullets {
    margin: 0;
    padding-right: 22px;
    line-height: 1.8;
}

.two-columns-print {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.signature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 30px;
}

.signature-grid div {
    border-top: 1px solid #111827;
    padding-top: 10px;
}

.medical-print-footer {
    margin-top: 28px;
    border-top: 1px solid #111827;
    padding-top: 8px;
    text-align: center;
    font-size: 12px;
}

@media (max-width: 900px) {
    .hospital-header {
        grid-template-columns: auto 1fr;
    }

    .hospital-header form {
        grid-column: 1 / -1;
    }

    .form-grid.two,
    .form-grid.three,
    .form-grid.four,
    .room-grid,
    .summary-grid,
    .split-panels,
    .charts-grid,
    .links-grid,
    .metric-grid,
    .filter-panel {
        grid-template-columns: 1fr;
    }

    .search-box,
    .filter-bar {
        width: 100%;
    }
}

@media print {
    body {
        background: white;
    }

    .hospital-header,
    .site-footer,
    .toolbar,
    .print-toolbar,
    .header-actions,
    .tabs,
    .sticky-actions,
    .split-panels,
    .filter-bar {
        display: none !important;
    }

    .content {
        padding: 0;
        width: 100%;
    }

    .print-page,
    .medical-print-page,
    .table-panel,
    .tab-panel {
        border: 0;
        box-shadow: none;
    }

    .medical-print-page {
        padding: 0;
    }

    table {
        min-width: 0;
        font-size: 12px;
    }

    @page {
        margin: 10mm;
    }
}