/* ============================================================
   Hospital Management System — interface styles
   Palette is built around a deep clinical teal, a cool paper
   background, and four triage colours that carry real meaning.
   ============================================================ */

:root {
    --ink:        #16232e;
    --ink-soft:   #55697a;
    --canvas:     #eef2f5;
    --surface:    #ffffff;
    --line:       #d7e0e7;
    --brand:      #0d5c63;
    --brand-dark: #08403f;
    --brand-tint: #e3f0f0;

    --red:    #b5342a;
    --amber:  #a3661a;
    --blue:   #24628f;
    --green:  #1c7048;
    --violet: #64429b;
    --grey:   #64748b;

    --radius: 10px;
    --shadow: 0 1px 2px rgba(22, 35, 46, .08), 0 8px 24px -18px rgba(22, 35, 46, .5);
    --sans: "Inter", "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--sans);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: .98rem; }
p  { margin: 0 0 .75rem; }
.muted { color: var(--ink-soft); }
.small { font-size: .84rem; }
.center { text-align: center; }
.right  { text-align: right; }
.mono   { font-family: var(--mono); font-size: .88em; letter-spacing: -.01em; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }

:focus-visible {
    outline: 3px solid #7fc4c9;
    outline-offset: 2px;
}

/* ---------------------------- layout --------------------------- */
.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 244px;
    background: linear-gradient(180deg, #10333c 0%, #0c2a32 100%);
    color: #cfe0e3;
    display: flex;
    flex-direction: column;
    z-index: 30;
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.15rem 1.1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand-mark {
    width: 30px; height: 30px;
    display: grid; place-items: center;
    border-radius: 8px;
    background: #d7453e;
    color: #fff;
    font-size: 1.3rem; font-weight: 700; line-height: 1;
}
.brand-text { color: #fff; font-weight: 620; font-size: .95rem; }

.nav { padding: .7rem .6rem; flex: 1; overflow-y: auto; }
.nav-link {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .55rem .65rem;
    margin-bottom: 2px;
    border-radius: 8px;
    color: #b9ced3;
    text-decoration: none;
    font-size: .9rem;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-link.is-active { background: #d7453e; color: #fff; font-weight: 560; }
.nav-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .5;
    flex: none;
}
.nav-link.is-active .nav-dot { opacity: 1; }

.sidebar-foot {
    padding: .9rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
}
.who { display: flex; flex-direction: column; min-width: 0; }
.who strong { color: #fff; font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span  { font-size: .75rem; color: #8fa9af; }
.signout { color: #ffb3ae; font-size: .8rem; text-decoration: none; white-space: nowrap; }
.signout:hover { text-decoration: underline; }

.shell { margin-left: 244px; min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 20;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: .8rem 1.4rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}
.topbar h1 { margin: 0; flex: 1; }
.topbar-meta { display: flex; align-items: center; gap: .9rem; }
.clock { color: var(--ink-soft); font-size: .85rem; }

.content { flex: 1; padding: 1.4rem; max-width: 1240px; width: 100%; }
.foot { padding: 1rem 1.4rem 1.6rem; color: var(--ink-soft); font-size: .8rem; }

.nav-toggle, .hamburger { display: none; }

/* ----------------------------- cards --------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.1rem;
    overflow: hidden;
}
.card-head {
    padding: .85rem 1.1rem;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: .75rem;
}
.card-head h2, .card-head h3 { margin: 0; flex: 1; }
.card-body { padding: 1.1rem; }
.pad-lg { padding: 2rem; }

.grid { display: grid; gap: 1.1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }

/* ------------------------- stat tiles -------------------------- */
.stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--brand);
    border-radius: var(--radius);
    padding: .95rem 1.1rem;
    box-shadow: var(--shadow);
}
.stat .value { font-size: 1.75rem; font-weight: 680; line-height: 1.1; }
.stat .label { color: var(--ink-soft); font-size: .84rem; }
.stat.red    { border-left-color: var(--red); }
.stat.amber  { border-left-color: var(--amber); }
.stat.blue   { border-left-color: var(--blue); }
.stat.green  { border-left-color: var(--green); }
.stat.violet { border-left-color: var(--violet); }

/* --------------------------- tables ---------------------------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th {
    text-align: left;
    padding: .6rem .85rem;
    background: #f5f8fa;
    border-bottom: 1px solid var(--line);
    color: var(--ink-soft);
    font-weight: 600;
    white-space: nowrap;
}
table.data td {
    padding: .65rem .85rem;
    border-bottom: 1px solid #edf1f4;
    vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: #f9fbfc; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }

.empty { padding: 2.2rem 1rem; text-align: center; color: var(--ink-soft); }
.empty strong { display: block; color: var(--ink); margin-bottom: .25rem; }

/* ---------------------------- pills ---------------------------- */
.pill {
    display: inline-block;
    padding: .18rem .55rem;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid;
}
.pill-red    { color: var(--red);    background: #fdecea; border-color: #f6cfca; }
.pill-amber  { color: var(--amber);  background: #fdf3e3; border-color: #f2ddb8; }
.pill-blue   { color: var(--blue);   background: #e9f2f9; border-color: #c7ddec; }
.pill-green  { color: var(--green);  background: #e7f4ec; border-color: #c2e3d0; }
.pill-violet { color: var(--violet); background: #f1ebfa; border-color: #dccdf1; }
.pill-grey   { color: var(--grey);   background: #eef1f4; border-color: #d9e0e6; }

/* --------------------------- buttons --------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem .9rem;
    border-radius: 8px;
    border: 1px solid var(--brand);
    background: var(--brand);
    color: #fff;
    font: inherit;
    font-size: .88rem;
    font-weight: 560;
    text-decoration: none;
    cursor: pointer;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-sm { padding: .32rem .65rem; font-size: .82rem; }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-ghost:hover { background: var(--brand-tint); }
.btn-line { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-line:hover { background: #f3f6f8; border-color: #bdcbd6; }
.btn-danger { background: var(--red); border-color: var(--red); }
.btn-danger:hover { background: #8f2921; border-color: #8f2921; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* ---------------------------- forms ---------------------------- */
.field { margin-bottom: .9rem; }
.field label {
    display: block;
    margin-bottom: .3rem;
    font-size: .85rem;
    font-weight: 560;
    color: #33475a;
}
.field .hint { font-size: .78rem; color: var(--ink-soft); margin-top: .25rem; }
input[type=text], input[type=password], input[type=number], input[type=date],
input[type=email], input[type=search], select, textarea {
    width: 100%;
    padding: .5rem .65rem;
    border: 1px solid #c3d0da;
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-size: .9rem;
    color: var(--ink);
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus {
    border-color: var(--brand);
    outline: 3px solid #d6ecee;
    outline-offset: 0;
}
input[readonly] { background: #f2f5f7; color: var(--ink-soft); }
.row { display: grid; gap: .9rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.inline-form { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { margin-bottom: 0; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.check input { width: auto; }

/* --------------------------- alerts ---------------------------- */
.alert {
    padding: .7rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    border: 1px solid;
    font-size: .9rem;
}
.alert-success { background: #e7f4ec; border-color: #bfe0cd; color: #14563a; }
.alert-error   { background: #fdecea; border-color: #f3cbc6; color: #8f2921; }
.alert-info    { background: #e9f2f9; border-color: #c7ddec; color: #1c4a6d; }
.alert-warning { background: #fdf3e3; border-color: #f0dab4; color: #7d4e12; }

/* -------------------------- login page ------------------------- */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 1fr;
    background: var(--canvas);
}
.login-aside {
    background: linear-gradient(160deg, #10333c 0%, #0b2a31 60%, #123c3d 100%);
    color: #d7e5e8;
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.login-aside h2 { color: #fff; font-size: 1.9rem; max-width: 18ch; }
.login-aside ul { list-style: none; padding: 0; margin: 1.6rem 0 0; }
.login-aside li { padding: .45rem 0 .45rem 1.4rem; position: relative; font-size: .92rem; }
.login-aside li::before {
    content: ""; position: absolute; left: 0; top: 1.05rem;
    width: 8px; height: 2px; background: #d7453e;
}
.login-main { display: grid; place-items: center; padding: 2rem; }
.login-box { width: 100%; max-width: 370px; }
.login-box .card-body { padding: 1.6rem; }

/* ------------------------ result entry ------------------------- */
.result-row td { padding: .45rem .6rem; }
.result-row input[type=text] { padding: .35rem .5rem; }
.flag-high { color: var(--red); font-weight: 650; }
.flag-low  { color: var(--blue); font-weight: 650; }

.info-list { list-style: none; margin: 0; padding: 0; }
.info-list li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: .4rem 0;
    border-bottom: 1px dashed #e3e9ee;
    font-size: .88rem;
}
.info-list li:last-child { border-bottom: 0; }
.info-list span { color: var(--ink-soft); }

.timeline { list-style: none; margin: 0; padding: 0 0 0 1.1rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 1rem 1rem; font-size: .88rem; }
.timeline li::before {
    content: ""; position: absolute; left: -1.42rem; top: .45rem;
    width: 10px; height: 10px; border-radius: 50%;
    background: var(--surface); border: 2px solid var(--brand);
}
.timeline li.done::before { background: var(--brand); }

/* -------------------------- bed board -------------------------- */
.bed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: .7rem;
}
.bed {
    border: 1px solid var(--line);
    border-left: 4px solid var(--grey);
    border-radius: 8px;
    padding: .6rem .7rem;
    background: #fbfcfd;
    min-height: 88px;
}
.bed-no { font-family: var(--mono); font-weight: 700; font-size: .9rem; }
.bed-who { display: block; font-weight: 600; font-size: .9rem; margin-top: .2rem; color: var(--ink); text-decoration: none; }
.bed-who:hover { text-decoration: underline; }
.bed-meta { color: var(--ink-soft); font-size: .76rem; margin-top: .15rem; line-height: 1.35; }
.bed-admit { display: inline-block; margin-top: .35rem; font-size: .78rem; }
.bed-available   { border-left-color: var(--green); }
.bed-occupied    { border-left-color: var(--red); background: #fff; }
.bed-reserved    { border-left-color: var(--amber); }
.bed-maintenance { border-left-color: var(--grey); opacity: .7; }

/* --------------------------- branch ---------------------------- */
.brand-branch {
    display: inline-block;
    margin-left: .35rem;
    padding: .05rem .35rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, .14);
    font-size: .68rem;
    letter-spacing: .04em;
    vertical-align: middle;
}
.branch-switch select {
    width: auto;
    min-width: 150px;
    padding: .3rem .5rem;
    font-size: .84rem;
    border-color: var(--line);
}
.sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ------------------------- pagination -------------------------- */
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding: .75rem 1.1rem;
    border-top: 1px solid var(--line);
    background: #fbfcfd;
}
.pager-count { color: var(--ink-soft); font-size: .84rem; }
.pager-links { display: flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.pager-current { background: var(--brand); border-color: var(--brand); color: #fff; cursor: default; }
.pager-gap { color: var(--ink-soft); padding: 0 .2rem; }
.pager [aria-disabled="true"] { opacity: .45; pointer-events: none; }

/* -------------------------- responsive ------------------------- */
@media (max-width: 980px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-side { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 760px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
    .nav-toggle:checked ~ .sidebar { transform: translateX(0); box-shadow: 0 0 0 100vmax rgba(12, 32, 38, .45); }
    .shell { margin-left: 0; }
    .hamburger {
        display: block; width: 34px; height: 34px;
        border: 1px solid var(--line); border-radius: 8px;
        position: relative; cursor: pointer; flex: none;
    }
    .hamburger span, .hamburger span::before, .hamburger span::after {
        content: ""; position: absolute; left: 8px; width: 16px; height: 2px; background: var(--ink);
    }
    .hamburger span { top: 16px; }
    .hamburger span::before { top: -5px; left: 0; }
    .hamburger span::after  { top: 5px; left: 0; }
    .grid-2, .grid-3, .grid-4, .row, .row-3, .row-4 { grid-template-columns: minmax(0, 1fr); }
    .login-page { grid-template-columns: minmax(0, 1fr); }
    .login-aside { display: none; }
    .content { padding: 1rem; }
    .topbar { padding: .7rem 1rem; }
    .clock { display: none; }
    .pager { justify-content: center; }
    .pager-count { width: 100%; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; }
}

/* ---------------------------- print ---------------------------- */
@media print {
    .sidebar, .topbar, .foot, .no-print { display: none !important; }
    .shell { margin-left: 0; }
    body { background: #fff; }
    .card { box-shadow: none; border: 0; }
}
