/* BioRambam Admin theme — palette derived from the sidebar (navy #052767 → plum #3a0647),
   with a single gold accent reserved for the "Manager" designation. Restrained, functional. */

:root {
    --br-navy: #052767;
    --br-plum: #3a0647;
    --br-grad: linear-gradient(135deg, #052767 0%, #3a0647 100%);
    --br-ink: #20233c;
    --br-muted: #6b7092;
    --br-surface: #f4f5fb;
    --br-border: #e7e8f2;
    --br-gold: #a9741f;
    --br-gold-bg: #f6ecd4;
    --br-gold-border: #e7d3a1;

    /* Bend Bootstrap toward the brand */
    --bs-primary: #1c2b6b;
    --bs-primary-rgb: 28, 43, 107;
    --bs-link-color: #23306e;
    --bs-link-hover-color: #3a0647;
}

/* Page surface */
main {
    background: var(--br-surface);
}

article.content {
    padding-top: 1.25rem;
}

body {
    color: var(--br-ink);
}

/* Buttons */
.btn-primary {
    background: var(--br-grad);
    border: 0;
}
.btn-primary:hover, .btn-primary:focus {
    filter: brightness(1.1);
    background: var(--br-grad);
}
.btn-outline-primary {
    color: var(--br-navy);
    border-color: #c9cde4;
}
.btn-outline-primary:hover {
    background: var(--br-navy);
    border-color: var(--br-navy);
    color: #fff;
}

/* Hero band — echoes the sidebar gradient, ties the page to the shell */
.admin-hero {
    background: var(--br-grad);
    color: #fff;
    border-radius: 0.9rem;
    padding: 1.4rem 1.6rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 14px 34px -16px rgba(5, 39, 103, 0.55);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.admin-hero h1 {
    font-size: 1.55rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    margin: 0;
}
.admin-hero p {
    margin: 0.35rem 0 0;
    color: rgba(255, 255, 255, 0.78);
    font-size: 0.95rem;
    max-width: 46ch;
}
.admin-hero .hero-back {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    font-size: 0.85rem;
}
.admin-hero .hero-back:hover { color: #fff; text-decoration: underline; }

/* Eyebrow label */
.admin-eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--br-plum);
    margin-bottom: 0.6rem;
}

/* Cards */
.admin-card {
    background: #fff;
    border: 1px solid var(--br-border);
    border-radius: 0.8rem;
    overflow: hidden; /* keep nested tables inside the rounded corners */
    box-shadow: 0 1px 2px rgba(5, 39, 103, 0.05), 0 16px 32px -24px rgba(5, 39, 103, 0.35);
}
.admin-card .card-body {
    padding: 1.25rem 1.4rem;
}
.admin-card .card-title {
    color: var(--br-ink);
    font-weight: 600;
}
/* A table placed directly in a card gets breathing room on the sides + bottom */
.admin-card > .admin-table {
    margin-bottom: 0;
}
.admin-card > .admin-table > thead > tr > th:first-child,
.admin-card > .admin-table > tbody > tr > td:first-child {
    padding-left: 1.4rem;
}
.admin-card > .admin-table > thead > tr > th:last-child,
.admin-card > .admin-table > tbody > tr > td:last-child {
    padding-right: 1.4rem;
}
.admin-card > .admin-table > thead > tr > th {
    padding-top: 1rem;
    padding-bottom: 0.6rem;
}
.admin-card > .admin-table > tbody > tr:last-child > td {
    padding-bottom: 1rem;
}

/* Tables */
.admin-table thead th {
    color: var(--br-navy);
    border-bottom: 2px solid var(--br-border);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.72rem;
    font-weight: 700;
}
.admin-table tbody tr:hover > * {
    background: #eef0f9;
}
.admin-table td { border-color: #eef0f6; }

/* Badges */
.badge-role {
    background: #edeffb;
    color: #2b356f;
    border: 1px solid #d8dcf3;
    font-weight: 600;
}
.badge-manager {
    background: var(--br-gold-bg);
    color: var(--br-gold);
    border: 1px solid var(--br-gold-border);
    font-weight: 700;
}

/* Join code */
.joincode {
    font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
    font-size: 1.5rem;
    letter-spacing: 0.14em;
    color: var(--br-navy);
    background: #eef1fb;
    border: 1px dashed #c3c9e6;
    border-radius: 0.5rem;
    padding: 0.4rem 0.85rem;
    display: inline-block;
}

/* Stat chip (center summary) */
.stat-chip {
    background: #fff;
    border: 1px solid var(--br-border);
    border-radius: 0.7rem;
    padding: 0.7rem 1rem;
    min-width: 7rem;
}
.stat-chip .num { font-size: 1.4rem; font-weight: 700; color: var(--br-navy); line-height: 1; }
.stat-chip .lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--br-muted); }

/* Row that spotlights a manager */
.member-manager > * { background: #fdfaf1; }

/* Removable role badge */
.badge .role-x {
    background: none;
    border: 0;
    color: inherit;
    font-weight: 700;
    line-height: 1;
    margin-left: 0.35rem;
    padding: 0;
    cursor: pointer;
    opacity: 0.6;
}
.badge .role-x:hover { opacity: 1; }

/* Inline "+ role" picker in the members table */
.role-add {
    display: inline-block;
    width: auto;
    vertical-align: middle;
    font-size: 0.75rem;
    padding: 0.1rem 1.4rem 0.1rem 0.5rem;
    color: var(--br-muted);
    border-style: dashed;
}

/* KPI tiles (dashboard) */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.kpi {
    background: #fff;
    border: 1px solid var(--br-border);
    border-radius: 0.8rem;
    padding: 1.1rem 1.25rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(5, 39, 103, 0.05), 0 16px 32px -26px rgba(5, 39, 103, 0.35);
}
.kpi::before {
    content: "";
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
    background: var(--br-grad);
}
.kpi .kpi-num { font-size: 1.9rem; font-weight: 700; color: var(--br-navy); line-height: 1; }
.kpi .kpi-lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--br-muted); margin-top: 0.4rem; }
.kpi.accent-green::before { background: #157347; }
.kpi.accent-amber::before { background: #a9741f; }
.kpi.accent-red::before   { background: #b02a37; }
.kpi.accent-gray::before  { background: #8a93a8; }

/* Status badges */
.st { font-weight: 600; }
.st-active      { background: #e6f4ec; color: #157347; border: 1px solid #bfe3cd; }
.st-inactive    { background: #eef0f5; color: #5c677d; border: 1px solid #d9dee8; }
.st-maintenance { background: #f6ecd4; color: #a9741f; border: 1px solid #e7d3a1; }
.st-retired     { background: #fbe9eb; color: #b02a37; border: 1px solid #f2c6cc; }

/* Role badge variants */
.badge-admin { background: #ece7f6; color: #3a0647; border: 1px solid #d6cbe9; font-weight: 600; }

/* Tints the shared clinical components (BioRambam.Ui) with the admin palette. Those components
   define every colour as var(--clinical-*, fallback), so this is the whole theming contract — the
   portal sets the same names to its own values. */
.clinical-scope {
    --clinical-accent: var(--br-navy);
    --clinical-ink: var(--br-ink);
    --clinical-muted: var(--br-muted);
    --clinical-border: var(--br-border);
    --clinical-surface: #fff;
    --clinical-hover: #eef0f9;
    --clinical-radius: 0.8rem;
}

/* ---- measurement drill-down ---- */

/* Seven readings per row means the numbers must line up vertically to be scannable. */
.measurement-grid .reading {
    font-variant-numeric: tabular-nums;
    font-size: 0.9rem;
}
/* Colour carries the same meaning as the counts to its right, so the eye can trace one to the
   other. Kept as tinted text rather than filled cells — a wall of colour blocks reads as an alarm. */
.measurement-grid .reading.is-low  { color: #b02a37; }
.measurement-grid .reading.is-high { color: #a9741f; }
.measurement-grid .reading.is-good { color: #157347; font-weight: 600; }

.measurement-grid tr.row-selected-good > * { background: #fdfaf1; }

/* Stacked bar: low | good | high across the seven readings. */
.dist {
    display: flex;
    height: 0.55rem;
    border-radius: 999px;
    overflow: hidden;
    background: #eef0f6;
}
.dist span { display: block; height: 100%; }
.dist-low  { background: #b02a37; }
.dist-good { background: #157347; }
.dist-high { background: #a9741f; }

.reading-chip {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border: 1px solid var(--br-border);
    border-radius: 0.5rem;
    background: #fff;
    font-variant-numeric: tabular-nums;
}
.reading-chip .rc-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--br-muted);
}

/* "What this screen can't do yet" — a collapsed note, not an alert. It must be findable without
   competing with the data the operator actually came for. */
.deferred-note {
    border-style: dashed;
    box-shadow: none;
}
.deferred-note > summary {
    cursor: pointer;
    list-style: none;
    color: var(--br-muted);
}
.deferred-note > summary::-webkit-details-marker { display: none; }
.deferred-note > summary strong { color: var(--br-ink); font-weight: 600; }
.deferred-note > summary:hover { background: #fafbff; }
.deferred-note > summary::after {
    content: "▾";
    float: right;
    opacity: 0.5;
}
.deferred-note[open] > summary::after { content: "▴"; }

/* Login */
.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--br-grad);
}
.login-card {
    width: 100%;
    max-width: 24rem;
    padding: 2rem 1.75rem;
    background: #fff;
}
.login-logo {
    height: 2.6rem;
    width: auto;
}
