/* 112 dispatch console — night control-room palette with ambulance livery accents */
:root {
    --bg: #0A1016;
    --panel: #0F171F;
    --panel-2: #142029;
    --line: #1F2C38;
    --line-strong: #2E3F50;
    --ink: #E2E8EE;
    --muted: #8A9BAD;
    --dim: #5C6E80;

    --livery-yellow: #FFD23F;   /* interactive accent, focus, primary action */
    --livery-green: #00A05A;    /* live call, routine */
    --urgent: #FF9F1C;
    --critical: #FF4545;

    /* Priorities, P1 most urgent */
    --p1: #FF4545;
    --p2: #FF8A1F;
    --p3: #F2C94C;
    --p4: #4CC38A;
    --p5: #6FA8DC;

    --font-display: 'Barlow Condensed', 'Arial Narrow', sans-serif;
    --font-body: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

    --radius: 4px;
    --gap: 16px;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 400 17px/1.45 var(--font-body);
    -webkit-font-smoothing: antialiased;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

button, input, textarea { font: inherit; color: inherit; }

:focus-visible {
    outline: 2px solid var(--livery-yellow);
    outline-offset: 2px;
}

[hidden], .is-hidden { display: none !important; }

/* ---------- Shell ---------- */

.console {
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100vh;
    height: 100dvh;
}

/* ---------- Top bar ---------- */

.topbar {
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.topbar-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 24px;
    padding: 10px 20px;
    min-height: 56px;
}

/* Support credit, centred in the top bar */
.support {
    margin: 0;
    font-size: 15px;
    color: var(--muted);
    text-align: center;
}
.support strong {
    font: 700 18px/1 var(--font-display);
    letter-spacing: .02em;
    color: var(--ink);
    margin-left: 2px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    text-decoration: none;
    min-width: 0;
}

.brand-mark {
    font: 700 22px/1 var(--font-display);
    color: var(--ink);
}

.brand-name {
    font-size: 16px;
    color: var(--muted);
    padding-left: 12px;
    border-left: 1px solid var(--line-strong);
}

.topbar-tools {
    display: flex;
    justify-self: end;
    align-items: center;
    gap: 16px;
}

.clock { color: var(--muted); font-size: 16px; }

/* Section links: Inicio · Demo */
.topnav { display: flex; gap: 4px; }
.topnav a {
    padding: 6px 10px;
    border-radius: var(--radius);
    color: var(--muted);
    text-decoration: none;
    font: 600 16px/1 var(--font-display);
}
.topnav a:hover { color: var(--ink); background: var(--panel-2); }
.topnav a.is-active { color: #111; background: var(--livery-yellow); }

/* ---------- Workspace ---------- */

.workspace {
    display: grid;
    grid-template-columns: minmax(250px, 290px) minmax(0, 1fr) minmax(330px, 400px);
    gap: 1px;
    background: var(--line);
    min-height: 0;
}

.panel {
    background: var(--panel);
    padding: 18px 20px 24px;
    overflow-y: auto;
    min-height: 0;
}
.panel-typing { background: var(--bg); }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}
.panel-head h2 {
    margin: 0;
    font: 700 20px/1 var(--font-display);
    letter-spacing: 0;
    color: var(--ink);
}
.classified-at { font-size: 15px; color: var(--muted); white-space: nowrap; }
.classified-at time { color: var(--ink); }

/* ---------- Fields ---------- */

.field { margin: 0 0 16px; padding: 0; border: 0; min-width: 0; }

.field-label {
    display: block;
    padding: 0;
    margin-bottom: 6px;
    font: 600 16px/1.1 var(--font-display);
    letter-spacing: 0;
    color: var(--muted);
}

input[type="number"], textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 10px 12px;
    transition: border-color .15s;
}
input[type="number"]:hover, textarea:hover { border-color: var(--dim); }
input[type="number"]:focus, textarea:focus {
    outline: none;
    border-color: var(--livery-yellow);
    box-shadow: 0 0 0 1px var(--livery-yellow);
}
textarea { resize: vertical; min-height: 80px; }
::placeholder { color: var(--dim); }

.age-input {
    display: flex;
    align-items: baseline;
    gap: 10px;
}
.age-input input {
    width: 110px;
    font-size: 29px;
    font-weight: 600;
    padding: 6px 12px;
}
.age-input .unit { color: var(--muted); }

.segmented {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    overflow: hidden;
}
.segmented label { position: relative; cursor: pointer; }
.segmented label + label { border-left: 1px solid var(--line-strong); }
.segmented input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.segmented span {
    display: block;
    padding: 9px 6px;
    text-align: center;
    color: var(--muted);
    transition: background .15s, color .15s;
}
.segmented label:hover span { color: var(--ink); background: var(--panel-2); }
.segmented input:checked + span { background: var(--livery-yellow); color: #111; font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid var(--livery-yellow); outline-offset: -4px; }

/* ---------- People involved ---------- */

.persons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}
.person-tab, .person-add {
    border: 1px solid var(--line-strong);
    background: transparent;
    border-radius: var(--radius);
    padding: 6px 12px;
    cursor: pointer;
    color: var(--muted);
}
.person-tab:hover, .person-add:hover { color: var(--ink); border-color: var(--dim); }
.person-tab.is-active {
    color: #111;
    background: var(--livery-yellow);
    border-color: var(--livery-yellow);
    font-weight: 600;
}
.person-tab-wrap { display: inline-flex; }
.person-tab-wrap .person-tab:not(:only-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.person-remove {
    border: 1px solid var(--line-strong);
    border-left: 0;
    border-radius: 0 var(--radius) var(--radius) 0;
    background: transparent;
    color: var(--muted);
    padding: 0 9px;
    cursor: pointer;
    font-size: 19px;
    line-height: 1;
}
.person-remove:hover { color: var(--critical); border-color: var(--critical); }
.person-tab.has-empty::after {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    margin-left: 6px;
    border-radius: 50%;
    background: var(--urgent);
    vertical-align: middle;
}
.person-add {
    border-style: dashed;
    font: 600 15px/1.4 var(--font-display);
    letter-spacing: 0;
}

/* ---------- Clinical typing ---------- */

.hint { color: var(--muted); margin: 0 0 14px; }

.ghost {
    background: none;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 5px 10px;
    color: var(--muted);
    cursor: pointer;
    font: 600 15px/1.2 var(--font-display);
    letter-spacing: 0;
}
.ghost:hover { color: var(--ink); border-color: var(--dim); }

/* Beside the tree: the selected route, the call report and the actions */
.typing-side { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.call-report { margin-top: 18px; }
.sub-head {
    margin: 0 0 12px;
    font: 700 19px/1 var(--font-display);
    color: var(--ink);
}
.typing-side .actions { display: flex; gap: 10px; }
.typing-side .actions .btn { flex: 1; justify-content: center; }
.typing-side .actions .btn-primary { flex: 2; }

/* Missing person data, listed after a try to classify */
.empty-fields {
    margin: 0 0 12px;
    padding: 8px 12px;
    font-size: 17px;
    border: 1px solid color-mix(in srgb, var(--urgent) 60%, transparent);
    border-radius: var(--radius);
    color: var(--urgent);
}
[data-field].is-empty input[type="number"],
[data-field].is-empty textarea,
[data-field].is-empty .segmented { border-color: var(--urgent); border-style: dashed; }
[data-field].is-empty .field-label { color: var(--urgent); }
.empty-fields.is-blocking {
    border-color: color-mix(in srgb, var(--critical) 70%, transparent);
    color: var(--critical);
}

/* Selected sequence, numbered because order is the typing path */
.path {
    list-style: none;
    margin: 0 0 18px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.crumb {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 3px solid var(--livery-yellow);
    border-radius: var(--radius);
    padding: 7px 12px;
    min-height: 38px;
}
.crumb.is-negative { border-left-color: var(--dim); }
.crumb.is-empty { background: none; border-style: dashed; border-left: 3px solid var(--line-strong); color: var(--dim); }
.crumb-step {
    font-size: 14px;
    color: var(--muted);
    min-width: 1.5em;
}
.crumb-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Collapsible typing tree */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 13px; padding-left: 14px; border-left: 1px solid var(--line-strong); }
.tree-row { display: flex; align-items: stretch; gap: 2px; }

.tree-toggle {
    flex: none;
    width: 26px;
    background: none;
    border: 0;
    color: var(--muted);
    cursor: pointer;
    border-radius: var(--radius);
}
.tree-toggle::before {
    content: '';
    display: inline-block;
    border: 5px solid transparent;
    border-left: 7px solid currentColor;
    border-right: 0;
    transition: transform .15s;
}
.tree-item[aria-expanded="true"] > .tree-row > .tree-toggle::before { transform: rotate(90deg); }
.tree-toggle:hover { color: var(--ink); background: var(--panel-2); }
.tree-toggle:disabled { cursor: default; background: none; }
.tree-toggle:disabled::before {
    border: 0;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--dim);
}

.tree-select {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
    text-align: left;
    padding: 7px 10px;
    margin: 1px 0;
    background: none;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
}
.tree-select:hover { background: var(--panel-2); border-color: var(--line-strong); }
.tree-text { min-width: 0; line-height: 1.3; }

.is-on-path > .tree-row > .tree-select { background: var(--panel); }
.is-on-path > .tree-row > .tree-toggle { color: var(--livery-yellow); }
.is-selected > .tree-row > .tree-select {
    background: color-mix(in srgb, var(--livery-yellow) 10%, var(--panel));
    border-color: var(--livery-yellow);
}

/* Priority chips (P1-P5) */
.prio {
    --c: var(--dim);
    display: inline-flex;
    align-items: baseline;
    gap: 3px;
    font: 600 13px/1 var(--font-mono);
    padding: 3px 5px;
    border-radius: 3px;
    border: 1px solid color-mix(in srgb, var(--c) 55%, transparent);
    color: var(--c);
}
.prio.is-top { background: var(--c); border-color: var(--c); color: #111; }
.prio-p1 { --c: var(--p1); }
.prio-p2 { --c: var(--p2); }
.prio-p3 { --c: var(--p3); }
.prio-p4 { --c: var(--p4); }
.prio-p5 { --c: var(--p5); }
.prio.is-empty { border-style: dashed; color: var(--dim); }

/* Predicted priority with a P1-P5 scale as legend */
.priority-row { display: flex; align-items: center; gap: 18px; }
.priority-legend { flex: 1; min-width: 0; }
.priority-scale { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; }
.priority-scale .prio { flex: 1; justify-content: center; }
.priority-scale-caption {
    display: flex;
    justify-content: space-between;
    margin-top: 5px;
    font-size: 14px;
    color: var(--muted);
}
.no-priority { margin: 12px 0 0; font-size: 17px; line-height: 1.45; color: var(--ink); }
.no-priority strong { color: var(--urgent); }

.stale {
    margin: 0 0 14px;
    padding: 8px 12px;
    font-size: 16px;
    border: 1px solid color-mix(in srgb, var(--urgent) 60%, transparent);
    border-radius: var(--radius);
    color: var(--urgent);
}
body.is-stale .panel-triage .readout { opacity: .45; }

.prio-lg {
    font-size: 33px;
    padding: 6px 12px;
    background: var(--c);
    border-color: var(--c);
    color: #111;
}
.prio-lg.is-empty { background: none; border-color: var(--line-strong); color: var(--dim); min-width: 2.4em; justify-content: center; }


/* ---------- AI triage ---------- */

/* The tip spans the readout's own width, so it never leaves the panel */
.readout-label { position: relative; display: flex; align-items: center; gap: 8px; }
.help {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    font: 600 14px/1 var(--font-body);
    color: var(--muted);
    cursor: help;
}
.help:hover, .help:focus-visible { color: var(--ink); border-color: var(--dim); }
.help-tip {
    position: absolute;
    z-index: 5;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    padding: 10px 12px;
    background: var(--panel-2);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
    font: 400 16px/1.45 var(--font-body);
    color: var(--ink);
    text-align: left;
    visibility: hidden;
    opacity: 0;
    transition: opacity .12s;
}
.help:hover .help-tip, .help:focus .help-tip { visibility: visible; opacity: 1; }

.awaiting { margin: 0 0 16px; color: var(--muted); }

/* Empty readouts while the call is not classified */
.readout.is-idle .readout-verdict,
.readout.is-idle .readout-value,
.readout.is-idle .delay-row,
.readout.is-idle .reco p { color: var(--dim); }
.readout.is-idle .reco { border-left-color: var(--line-strong); }

.readout {
    padding: 14px 0 16px;
    border-bottom: 1px solid var(--line);
}
.readout:first-of-type { padding-top: 0; }
.readout:last-child { border-bottom: 0; }

.readout-label {
    font: 600 16px/1.1 var(--font-display);
    letter-spacing: 0;
    color: var(--muted);
    margin-bottom: 10px;
}

.readout-main {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.readout-verdict {
    font: 700 37px/1 var(--font-display);
    letter-spacing: .04em;
    color: var(--livery-green);
}
.readout-value { font-size: 33px; font-weight: 600; line-height: 1; }
.readout-value small { font-size: 18px; color: var(--muted); margin-left: 2px; }
.readout-binary.is-yes .readout-verdict { color: var(--critical); }

.meter, .delay-track {
    height: 8px;
    background: var(--line);
    border-radius: 2px;
    overflow: hidden;
}
.meter span, .delay-track span {
    display: block;
    height: 100%;
    width: calc(var(--v) * 1%);
    background: var(--livery-green);
    animation: grow .7s cubic-bezier(.2, .7, .2, 1) both;
    transform-origin: left;
}
.readout-binary.is-yes .meter span { background: var(--critical); }

.delay { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.delay-row {
    display: grid;
    grid-template-columns: minmax(11ch, auto) 1fr 6ch;
    align-items: center;
    gap: 10px;
    color: var(--muted);
}
.delay-name { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delay-value { font-size: 15px; text-align: right; }
.delay-track span { background: var(--dim); }
.delay-row.is-top { color: var(--ink); }
.delay-row.is-top .delay-name { font-weight: 600; }
.delay-undelayable.is-top .delay-track span { background: var(--critical); }
.delay-minutes.is-top .delay-track span { background: var(--urgent); }
.delay-hours.is-top .delay-track span,
.delay-days.is-top .delay-track span { background: var(--livery-green); }


.reco {
    padding: 12px 14px;
    background: var(--panel-2);
    border-left: 3px solid var(--livery-yellow);
    border-radius: var(--radius);
}
.reco p { margin: 0; font-size: 18px; line-height: 1.5; }
.reco-title {
    display: block;
    margin-bottom: 4px;
    font: 700 16px/1.2 var(--font-display);
    letter-spacing: 0;
    color: var(--urgent);
}
.readout-reco.is-warning .reco { border-left-color: var(--urgent); }
.reco .reco-reason {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line-strong);
    font-size: 16px;
    color: var(--ink);
}
.reco-reason strong { color: var(--urgent); margin-right: 4px; }

@keyframes grow { from { transform: scaleX(0); } }

/* ---------- Action bar ---------- */

.actionbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 10px 20px;
    background: var(--panel);
    border-top: 1px solid var(--line);
}

.disclaimer {
    margin: 0;
    font-size: 15px;
    color: var(--muted);
}
.badge {
    font: 700 13px/1 var(--font-display);
    letter-spacing: 0;
    padding: 3px 6px;
    border: 1px solid var(--urgent);
    color: var(--urgent);
    border-radius: 3px;
    margin-right: 6px;
}


.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    border-radius: var(--radius);
    font: 700 18px/1 var(--font-display);
    letter-spacing: 0;
    text-decoration: none;
    cursor: pointer;
    border: 1px solid transparent;
}
.btn-primary { background: var(--livery-yellow); color: #111; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .7; cursor: progress; }
.btn-secondary { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { border-color: var(--dim); background: var(--panel-2); }
.btn kbd {
    font: 500 13px/1 var(--font-mono);
    letter-spacing: 0;
    padding: 3px 5px;
    border-radius: 3px;
    background: rgba(0, 0, 0, .15);
}

body.is-busy .panel-triage { opacity: .5; transition: opacity .3s; }

/* ---------- Home: one vertical column — presentation, citations, logos ---------- */

.home { overflow-y: auto; min-height: 0; display: flex; }
.home-inner {
    width: 100%;
    max-width: 880px;
    margin: auto;
    padding: 40px 32px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "hero" "cite" "logos";
    gap: 36px;
}

.home-hero { grid-area: hero; display: flex; flex-direction: column; }
.home-hero .btn { align-self: center; }
.home-hero h1 {
    margin: 0;
    font: 700 42px/1.08 var(--font-display);
    color: var(--ink);
}
.home-lead { margin: 20px 0 24px; font-size: 17px; line-height: 1.6; color: var(--ink); }
.btn-lg { padding: 13px 24px; font-size: 20px; }

.home-section { grid-area: cite; }
.home-section h2 { margin: 0 0 14px; font: 700 21px/1 var(--font-display); color: var(--ink); }

.citations { margin: 0; padding-left: 20px; display: grid; gap: 10px; font-size: 15px; color: var(--muted); line-height: 1.45; }
.citations a { color: var(--ink); text-decoration-color: var(--livery-yellow); text-underline-offset: 3px; }
.citations a:hover { color: var(--livery-yellow); }
.citations i { color: var(--ink); }

/* The partner logos are dark artwork on transparency: rendered as white silhouettes on the page background */
.home-partners { grid-area: logos; }
.partners {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 16px 56px;
    padding: 16px 0;
}
.partners img { height: 64px; width: auto; max-width: 100%; filter: brightness(0) invert(1); }
/* The lab logo keeps its original colours */
.partners img.logo-original { filter: none; }

/* ---------- Responsive ---------- */

/* Wide screens: tree on the left; route, call report and actions on the right (sticky while the tree scrolls) */
@media (min-width: 1500px) {
    .panel-typing {
        display: grid;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
        grid-template-areas:
            "head head"
            "hint side"
            "tree side";
        grid-template-rows: auto auto 1fr;
        column-gap: 24px;
        align-content: start;
    }
    .panel-typing > .panel-head { grid-area: head; }
    .panel-typing > .hint { grid-area: hint; }
    .panel-typing > .tree { grid-area: tree; }
    .panel-typing > .typing-side {
        grid-area: side;
        align-self: start;
        position: sticky;
        top: 0;
        margin: 0;
        padding: 0;
        border: 0;
    }
    /* In the side column there is room for long names to wrap */
    .panel-typing .crumb-text { white-space: normal; }
}

@media (max-width: 1180px) {
    .workspace { grid-template-columns: minmax(240px, 280px) minmax(0, 1fr); }
    .panel-triage { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
    .console { height: auto; min-height: 100vh; }
    .workspace { grid-template-columns: minmax(0, 1fr); }
    .panel { overflow: visible; padding: 16px; }
    .panel-triage { order: 3; }
    .topbar-row { grid-template-columns: 1fr auto; gap: 8px 14px; padding: 10px 16px; }
    .support { grid-column: 1 / -1; order: 3; text-align: left; }
    .clock { display: none; }
    .home-inner { padding: 28px 16px 40px; }
    .home-hero h1 { font-size: 34px; }
    .partners img { height: 52px; }
    .actionbar { padding: 10px 16px; }
    .btn kbd { display: none; }
}

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