/* SRV Path Lab - modern admin theme (Bootstrap 5 based) */
:root {
    --brand: #0f766e;
    --brand-600: #0d9488;
    --brand-50: #f0fdfa;
    --side-bg: #0f172a;
    --side-fg: #cbd5e1;
    --side-muted: #64748b;
    --side-hover: #1e293b;
    --bg: #f1f5f9;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --radius: 12px;
    --side-w: 260px;
    --bs-primary: var(--brand);
    --bs-primary-rgb: 15, 118, 110;
    --bs-link-color: var(--brand);
}

html, body { height: 100%; }
body {
    background: var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
}

.app { display: flex; min-height: 100vh; }

/* ---------- sidebar ---------- */
.sidebar {
    width: var(--side-w);
    flex: 0 0 var(--side-w);
    background: var(--side-bg);
    color: var(--side-fg);
    position: sticky; top: 0; height: 100vh;
    overflow-y: auto;
    scrollbar-width: thin;
    z-index: 1040;
    transition: transform .2s ease;
}
.sidebar .brand { display: flex; align-items: center; justify-content: center; padding: 16px; background: #fff; border-bottom: 1px solid var(--border); }
.sidebar .brand img { max-height: 44px; max-width: 100%; }
.menu { padding: 10px 8px 40px; }
.menu-link {
    display: flex; align-items: center; gap: 10px; width: 100%;
    padding: 9px 12px; border: 0; border-radius: 8px;
    background: transparent; color: var(--side-fg); text-decoration: none; text-align: left;
    font-weight: 500; font-size: 14px;
}
.menu-link:hover { background: var(--side-hover); color: #fff; }
.menu-link.active { background: var(--brand); color: #fff; }
.menu-link .caret-icon { margin-left: auto; transition: transform .15s; color: var(--side-muted); }
.menu-group.open > .menu-toggle .caret-icon { transform: rotate(180deg); }
.submenu { display: none; padding: 2px 0 6px 14px; }
.menu-group.open > .submenu { display: block; }
.submenu-link {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 10px; margin: 1px 0; border-radius: 6px;
    color: #94a3b8; text-decoration: none; font-size: 13px;
}
.submenu-link:hover { color: #fff; background: var(--side-hover); }
.submenu-link.active { color: #fff; background: rgba(13,148,136,.35); }
.submenu-link.pending { opacity: .6; }
.submenu-link .dot { width: 6px; height: 6px; border-radius: 50%; background: #f59e0b; margin-left: auto; }

/* ---------- main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: 12px;
    height: 60px; padding: 0 20px;
    background: rgba(255,255,255,.92); backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
}
.btn-icon { border: 1px solid var(--border); background: #fff; width: 38px; height: 38px; border-radius: 8px; }
.marquee-wrap { flex: 1; min-width: 0; overflow: hidden; }
.marquee { white-space: nowrap; overflow: hidden; color: var(--brand); font-weight: 600; }
.marquee span { display: inline-block; padding-left: 100%; animation: marquee 22s linear infinite; }
@keyframes marquee { to { transform: translateX(-100%); } }
@media (prefers-reduced-motion: reduce) { .marquee span { animation: none; padding-left: 0; } }

.balance-chip {
    display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1;
    padding: 6px 12px; border-radius: 10px; background: var(--brand-50); border: 1px solid #99f6e4;
    text-decoration: none; color: var(--brand);
}
.balance-chip .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.balance-chip .value { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }
.user-btn { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; font-weight: 600; color: var(--text); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }

.content { padding: 22px 24px 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 22px; font-weight: 700; margin: 0; }
.page-head .crumb { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }

/* ---------- cards / tables / forms ---------- */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--border); font-weight: 600; padding: 14px 18px; border-radius: var(--radius) var(--radius) 0 0 !important; }
.card-body { padding: 18px; }
.form-label { font-weight: 600; font-size: 13px; color: #334155; margin-bottom: 4px; }
.form-control, .form-select { border-radius: 8px; border-color: #cbd5e1; font-size: 14px; }
.form-control:focus, .form-select:focus { border-color: var(--brand-600); box-shadow: 0 0 0 .2rem rgba(13,148,136,.15); }
.btn { border-radius: 8px; font-weight: 600; font-size: 14px; }
.btn-primary { background: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background: #115e59; border-color: #115e59; }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background: var(--brand); border-color: var(--brand); }

.table-modern { margin: 0; font-size: 13.5px; }
.table-modern thead th {
    position: sticky; top: 0; z-index: 1;
    background: #f8fafc; color: #475569; font-weight: 600; font-size: 12px;
    text-transform: uppercase; letter-spacing: .03em;
    border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table-modern td { vertical-align: middle; border-color: #f1f5f9; }
.table-modern tbody tr:hover { background: #f8fafc; }
.table-wrap { max-height: 65vh; overflow: auto; border-radius: 0 0 var(--radius) var(--radius); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions .btn { padding: 3px 9px; font-size: 12px; }
.table-search { max-width: 260px; }
.empty-state { padding: 40px; text-align: center; color: var(--muted); }

/* ---------- dashboard ---------- */
.stat {
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px 18px; display: flex; align-items: center; gap: 14px; height: 100%;
}
.stat .icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 20px; flex: 0 0 46px; }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat .value { font-size: 26px; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat .sub { font-size: 12px; color: var(--muted); }
.i-teal { background: #ccfbf1; color: #0f766e; }
.i-blue { background: #dbeafe; color: #1d4ed8; }
.i-amber { background: #fef3c7; color: #b45309; }
.i-green { background: #dcfce7; color: #15803d; }
.i-violet { background: #ede9fe; color: #6d28d9; }

/* ---------- login ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, #0f172a 0%, #0f766e 100%); padding: 16px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 32px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card img { max-height: 56px; display: block; margin: 0 auto 18px; }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; font-weight: 700; }
.login-card p.sub { text-align: center; color: var(--muted); margin-bottom: 22px; }

/* ---------- responsive ---------- */
@media (max-width: 991.98px) {
    .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); }
    .sidebar.show { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
    .content { padding: 16px; }
    .topbar { padding: 0 12px; }
    .balance-chip .label { display: none; }
}

@media print {
    .sidebar, .topbar, .page-head .btn, .no-print { display: none !important; }
    .content { padding: 0; }
    body { background: #fff; }
}

/* ---------- booking / result pages ---------- */
.amount-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.amount-grid span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
@media (max-width: 767.98px) { .amount-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.sticky-actions { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 16px; background: rgba(255,255,255,.95); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 -4px 14px rgba(15,23,42,.06); }
#itemsTable tr.row-group td { background: #f0f9ff; }
#itemsTable input[readonly] { background: #f8fafc; }
.patient-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 18px; }
.patient-strip span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
#resTable tr.res-head td { background: #eef2fb; font-weight: 700; }
#resTable input[readonly] { background: #f1f5f9; }
.tst { display: inline-block; margin: 1px 3px 1px 0; padding: 1px 7px; border-radius: 10px; font-size: 11.5px; font-weight: 600; }
.tst-done { background: #dcfce7; color: #166534; }
.tst-incomplete { background: #fee2e2; color: #991b1b; }
.tst-upload { background: #dbeafe; color: #1e40af; }
/* legacy row colours (rowdatabind) */
.legend { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; text-decoration: none; color: #0f172a; border: 1px solid rgba(0,0,0,.08); }
.st-notcollected, .legend.st-notcollected { background: #fde68a; }
.st-rejected, .legend.st-rejected { background: #fecaca; }
.st-done, .legend.st-done { background: #bbf7d0; }
.st-macdata, .legend.st-macdata { background: #e9d5ff; }
.st-rerun, .legend.st-rerun { background: #fed7aa; }
.st-hold, .legend.st-hold { background: #fef08a; }
.st-forward, .legend.st-forward { background: #bae6fd; }
.st-incomplete, .legend.st-incomplete { background: #fbcfe8; }
.st-resultdone, .legend.st-resultdone { background: #99f6e4; }
.st-dispatched, .legend.st-dispatched { background: #c7d2fe; }
.st-printed, .legend.st-printed { background: #d1d5db; }
.legend.st-approved { background: #86efac; }
.legend.st-received { background: #a7f3d0; }
.table-modern tbody tr[class^="st-"] td { background: transparent; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 12px; max-height: 420px; overflow: auto; padding: 8px; border: 1px solid var(--border); border-radius: 8px; }
