:root {
  color-scheme: light;
  --ink: #132238;
  --ink-soft: #435269;
  --muted: #738198;
  --line: #e1e7ee;
  --canvas: #f3f6f9;
  --card: #ffffff;
  --nav: #101b2d;
  --nav-active: #20334c;
  --teal: #158b82;
  --teal-soft: #e8f5f2;
  --amber: #c98a29;
  --amber-soft: #fff4e3;
  --red: #d9525c;
  --red-soft: #fff0f0;
  --blue: #3e78b4;
  --shadow: 0 10px 32px rgba(24, 39, 59, .045);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--canvas); color: var(--ink); font: 14px/1.45 "Segoe UI", Inter, system-ui, sans-serif; }
button { font: inherit; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 238px; display: flex; flex-direction: column; padding: 29px 16px 22px; background: var(--nav); color: #edf5f8; z-index: 10; }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 11px 38px; color: inherit; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; border: 1px solid #64c7b8; border-radius: 10px; background: #164b51; display: flex; align-items: center; justify-content: center; gap: 3px; transform: rotate(-8deg); }
.brand-mark i { width: 4px; border-radius: 2px; background: #9ce7ce; }
.brand-mark i:nth-child(1) { height: 10px; }
.brand-mark i:nth-child(2) { height: 19px; }
.brand-mark i:nth-child(3) { height: 14px; }
.brand-copy { display: flex; flex-direction: column; line-height: 1.15; }
.brand-copy strong { font-size: 19px; letter-spacing: -.035em; }
.brand-copy small { margin-top: 5px; color: #83a4b4; font-size: 9px; font-weight: 700; letter-spacing: .19em; }
.nav-heading, .sidebar-foot-label { color: #718ca0; font-size: 10px; font-weight: 750; letter-spacing: .14em; }
.nav-heading { margin: 0 12px 12px; }
.sidebar nav { display: grid; gap: 5px; }
.nav-link { position: relative; min-height: 43px; display: flex; align-items: center; gap: 13px; padding: 10px 13px; border-radius: 9px; color: #a8b9ca; text-decoration: none; font-weight: 600; transition: background .15s, color .15s; }
.nav-link:hover, .nav-link.active { color: #fff; background: var(--nav-active); }
.nav-link.active::before { content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px; border-radius: 2px; background: #62d3b9; }
.nav-link svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sidebar-foot { margin-top: auto; padding: 18px 12px 0; border-top: 1px solid #2b3c51; display: grid; gap: 4px; }
.sidebar-foot strong { margin-top: 7px; font-size: 13px; letter-spacing: .02em; }
.sidebar-foot > span:last-child { color: #8ea2b5; font-size: 11px; }
.app-shell { margin-left: 238px; height: 100vh; height: 100dvh; display: flex; flex-direction: column; min-width: 0; }
.topbar { min-height: 107px; flex: 0 0 107px; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 18px 31px; border-bottom: 1px solid var(--line); background: #fff; }
.page-title { min-width: 0; }
.eyebrow { color: var(--teal); font-size: 10px; font-weight: 800; letter-spacing: .15em; }
h1 { margin: 3px 0 1px; font-size: clamp(21px, 2vw, 27px); letter-spacing: -.04em; line-height: 1.18; }
.topbar p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.connections { display: flex; align-items: center; gap: 8px; flex: none; }
.chip { display: inline-flex; align-items: center; gap: 7px; min-width: 104px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; background: #f8fafc; white-space: nowrap; color: var(--ink-soft); font-size: 11px; }
.chip b { font-weight: 700; }
.chip i { width: 7px; height: 7px; flex: none; border-radius: 50%; background: #9ba9b8; box-shadow: 0 0 0 3px #e7edf2; }
.chip::after { content: "Offline"; margin-left: auto; color: #8996a5; font-weight: 600; }
.chip.online { border-color: #cce7df; background: #f2fbf7; }
.chip.online i { background: #2ab889; box-shadow: 0 0 0 3px #d6f3e8; }
.chip.online::after { content: attr(data-online); color: #167e65; }
.page-content { flex: 1; min-height: 0; min-width: 0; overflow: hidden; display: flex; flex-direction: column; padding: 23px 30px 25px; gap: 18px; }
.card, .metric-card { min-width: 0; background: var(--card); border: 1px solid var(--line); border-radius: 13px; box-shadow: var(--shadow); }
.card { padding: 20px 22px; }
.card h2 { margin: 0; font-size: 16px; letter-spacing: -.025em; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; flex: none; }
.card-head p, .video-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; flex: none; }
.metric-card { position: relative; min-height: 117px; padding: 16px 19px 15px; overflow: hidden; }
.metric-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--blue); }
.metric-card.accent-green::before { background: var(--teal); }
.metric-card.accent-orange::before { background: var(--amber); }
.metric-card.accent-purple::before { background: #5a6b99; }
.metric-card > span, .security-stat > span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.metric-card strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin: 8px 0 2px; font-size: clamp(22px, 2.2vw, 29px); letter-spacing: -.045em; line-height: 1.1; }
.metric-card small, .security-stat small { color: var(--muted); font-size: 11px; }
.overview-layout { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(270px, .8fr); gap: 18px; flex: 1; min-height: 0; }
.chart-card { display: flex; flex-direction: column; min-height: 0; }
.chart-legend { display: flex; gap: 13px; white-space: nowrap; color: var(--ink-soft); font-size: 11px; }
.chart-legend span { display: flex; align-items: center; gap: 5px; }
.chart-legend i { width: 7px; height: 7px; border-radius: 50%; }
.normal { background: var(--teal); }.warning { background: var(--amber); }.danger { background: var(--red); }
#fatigue-chart { display: block; width: 100%; height: 100%; flex: 1; min-height: 0; margin-top: 14px; }
.risk-card { display: flex; flex-direction: column; align-items: center; min-height: 0; overflow: hidden; text-align: center; }
.risk-card h2 { align-self: stretch; text-align: left; }
.risk-qualifier { float: right; margin-top: 4px; color: var(--muted); font-size: 10px; font-weight: 500; letter-spacing: 0; }
.risk-ring { --risk: 0deg; --risk-color: var(--teal); position: relative; display: grid; place-items: center; width: clamp(116px, 11vw, 150px); aspect-ratio: 1; margin: 15px auto 9px; border-radius: 50%; background: conic-gradient(var(--risk-color) var(--risk), #e9eef2 0); }
.risk-ring::after { content: ""; position: absolute; inset: 14px; border-radius: 50%; background: #fff; }
.risk-ring > div { position: relative; z-index: 1; }
.risk-ring strong { font-size: clamp(31px, 3vw, 39px); line-height: 1; letter-spacing: -.06em; }
.risk-ring span { color: var(--muted); font-size: 13px; }
.risk-card h3 { margin: 0; font-size: 18px; letter-spacing: -.035em; }
.risk-card > p { min-height: 27px; max-width: 260px; margin: 5px 0 9px; color: var(--muted); font-size: 11px; }
.risk-facts { align-self: stretch; margin-top: auto; border-top: 1px solid var(--line); text-align: left; }
.risk-facts > div { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.risk-facts > div:last-child { border-bottom: 0; }
.risk-facts b { color: var(--ink); font-weight: 700; }
.live-layout { display: grid; grid-template-columns: minmax(0, 2.5fr) minmax(260px, .75fr); gap: 18px; flex: 1; min-height: 0; }
.video-card { display: flex; flex-direction: column; padding: 16px; min-height: 0; }
.video-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 1px 3px 14px; flex: none; }
.state-pill { display: inline-block; padding: 6px 10px; border-radius: 6px; background: #edf1f4; color: #677487; font-size: 11px; font-weight: 800; letter-spacing: .03em; white-space: nowrap; }
.state-pill.NORMAL { color: #157d67; background: var(--teal-soft); }.state-pill.WARNING { color: #a66e16; background: var(--amber-soft); }.state-pill.DROWSY, .state-pill.TAMPER { color: #ba404c; background: var(--red-soft); }
.video-frame { position: relative; flex: 1; min-height: 0; overflow: hidden; border-radius: 9px; background: #101c2b; }
.video-frame img { display: block; width: 100%; height: 100%; object-fit: cover; }
.video-empty { position: absolute; inset: 0; display: grid; place-content: center; gap: 6px; text-align: center; color: #fff; }
.video-empty b { font-size: 18px; }.video-empty span { color: #b5c2cf; font-size: 12px; }
.video-alert { position: absolute; left: 14px; right: 14px; bottom: 14px; padding: 10px 13px; border: 1px solid #385268; border-left: 3px solid #51cba3; border-radius: 6px; background: rgba(15, 29, 43, .88); color: #fff; font-size: 12px; font-weight: 650; backdrop-filter: blur(8px); }
.video-alert.WARNING { border-left-color: #e8ad4b; }.video-alert.DROWSY, .video-alert.TAMPER { border-left-color: #f07079; }
.live-metrics { display: grid; grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 12px; min-height: 0; }
.sensor-card { min-height: 0; padding: 14px 17px; overflow: hidden; }
.sensor-card > span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.sensor-card > strong { display: block; margin: 6px 0 10px; font-size: clamp(22px, 2.1vw, 29px); line-height: 1; letter-spacing: -.04em; }
.sensor-row { display: flex; justify-content: space-between; gap: 10px; padding-top: 7px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.sensor-row small { font-size: inherit; }.sensor-row b { color: var(--ink); }
.progress { height: 6px; overflow: hidden; border-radius: 4px; background: #ecf0f3; }
.progress i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--teal); transition: width .2s; }
.progress.warm i { background: var(--amber); }
.table-card { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.table-filter { display: flex; gap: 3px; padding: 3px; border: 1px solid var(--line); border-radius: 8px; background: #f3f6f8; }
.table-filter button { padding: 6px 11px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); font-size: 11px; cursor: pointer; }
.table-filter button:hover { color: var(--ink); }.table-filter button.active { color: var(--ink); background: #fff; box-shadow: 0 1px 5px #1a32421c; font-weight: 700; }
.table-scroll { flex: 1; min-height: 0; overflow: auto; margin-top: 16px; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
thead { position: sticky; top: 0; z-index: 1; background: #f7f9fb; }
th { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
th, td { min-width: 0; padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
td { color: var(--ink-soft); font-size: 12px; }
tbody tr:hover { background: #f7fafb; }
.events-table { display: grid; height: 100%; grid-template-rows: 39px minmax(0, 1fr); }
.events-table colgroup { display: none; }
.events-table thead { position: static; display: block; }
.events-table thead tr, .events-table tbody tr { display: grid; grid-template-columns: 1.25fr 1.15fr .9fr .9fr 1.8fr; }
.events-table thead tr { height: 39px; }
.events-table tbody { display: grid; grid-template-rows: repeat(7, minmax(0, 1fr)); min-height: 0; }
.events-table tbody tr:has(.empty-row) { grid-row: 1 / -1; }
.events-table th, .events-table td { display: flex; align-items: center; height: auto; overflow: hidden; }
.events-table td > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.events-card .table-scroll { overflow: hidden; }
.event-state { font-weight: 800; }.event-state.NORMAL, .ok { color: var(--teal); }.event-state.WARNING { color: var(--amber); }.event-state.DROWSY, .event-state.TAMPER, .bad { color: var(--red); }
.empty-row { grid-column: 1 / -1; display: flex; align-items: center; justify-content: center; color: var(--muted); text-align: center; }
.table-pagination { min-height: 50px; display: flex; align-items: center; justify-content: space-between; gap: 15px; padding-top: 10px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.pagination-controls, .page-numbers { display: flex; align-items: center; gap: 4px; }
.pagination-controls button { min-width: 31px; height: 31px; padding: 0 8px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink-soft); cursor: pointer; }
.pagination-controls button:hover:not(:disabled), .pagination-controls button.active { border-color: var(--teal); background: var(--teal); color: #fff; }
.pagination-controls button:disabled { opacity: .4; cursor: default; }
.security-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 15px; flex: none; }
.integrity-card { display: flex; align-items: center; gap: 15px; min-height: 125px; }
.shield { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border-radius: 11px; background: var(--teal-soft); color: var(--teal); font-size: 28px; }
.integrity-card span { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.integrity-card h2 { margin: 5px 0 2px; font-size: 20px; }.integrity-card p { margin: 0; color: var(--muted); font-size: 11px; }
.integrity-card.alert .shield { color: var(--red); background: var(--red-soft); }.integrity-card.alert h2 { color: var(--red); }
.security-stat { display: flex; flex-direction: column; justify-content: center; min-height: 125px; }
.security-stat strong { margin: 8px 0 3px; font-size: 19px; letter-spacing: -.03em; }
.security-grid + .table-card th { width: 33.333%; }
.security-grid + .table-card td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.security-grid + .table-card table:has(.empty-row) { height: 100%; }
.security-grid + .table-card td.empty-row { display: table-cell; text-align: center; vertical-align: middle; }
@media (max-width: 1180px) {
  .sidebar { width: 205px; }.app-shell { margin-left: 205px; }
  .topbar { padding-inline: 24px; }.page-content { padding-inline: 23px; }
  .connections { gap: 5px; }.chip { min-width: auto; }.chip::after { display: none; }
  .overview-layout { grid-template-columns: minmax(0, 1.7fr) minmax(250px, .8fr); }
}
@media (max-width: 900px) {
  html, body { height: auto; }
  .sidebar { position: static; width: auto; padding: 13px 18px; }.brand { padding: 0 0 12px; }.nav-heading, .sidebar-foot { display: none; }
  .sidebar nav { display: flex; overflow-x: auto; }.nav-link { white-space: nowrap; }
  .app-shell { margin-left: 0; height: auto; min-height: 100vh; }
  .topbar { flex-wrap: wrap; min-height: 0; flex-basis: auto; }
  .page-content { overflow: visible; min-height: 600px; }
  .overview-layout, .live-layout { min-height: 440px; }
}
@media (max-width: 650px) {
  .topbar, .page-content { padding-inline: 16px; }
  .connections { flex-wrap: wrap; }.metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-layout, .live-layout { grid-template-columns: 1fr; }.chart-card { min-height: 320px; }.risk-card { min-height: 300px; }
  .live-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(2, minmax(115px, auto)); }
  .video-card { min-height: 390px; }.security-grid { grid-template-columns: 1fr; }
  .table-card { min-height: 520px; }.table-scroll { overflow-x: auto; }.events-table { min-width: 760px; }
  .card-head { flex-wrap: wrap; }.table-pagination { flex-wrap: wrap; }
}
@media (max-height: 650px) and (min-width: 901px) {
  .topbar { min-height: 84px; flex-basis: 84px; }.page-content { padding-block: 13px; gap: 11px; }
  .metric-card { min-height: 96px; padding-block: 11px; }.card { padding-block: 13px; }
  .risk-ring { width: 95px; margin-block: 6px; }.risk-ring::after { inset: 11px; }
  .risk-card > p { margin-block: 3px; }.sensor-card { padding-block: 8px; }
}

/* The main screen keeps the camera and the actions that matter in one view. */
.sidebar { padding-top: 30px; }
.brand { padding-bottom: 35px; }
.topbar { min-height: 88px; flex-basis: 88px; }
.topbar h1 { font-size: 25px; }
.page-content:has(.monitor-layout) { padding-block: 20px; }
.monitor-layout { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(260px, .8fr); gap: 18px; flex: 1; min-height: 0; }
.monitor-layout .video-card { min-height: 0; padding: 15px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 2px 3px 13px; }
.section-head h2 { font-size: 17px; }
.monitor-layout .video-frame { flex: 1; min-height: 0; }
.monitor-side { display: grid; grid-template-rows: minmax(140px, .9fr) minmax(210px, 1.5fr) minmax(140px, .9fr); gap: 14px; min-height: 0; }
.monitor-side > .card { min-height: 0; overflow: hidden; }
.alert-card { display: flex; flex-direction: column; justify-content: center; border-left: 4px solid #9ba9b8; }
.alert-card.NORMAL { border-left-color: var(--teal); background: #f5fbf8; }
.alert-card.WARNING { border-left-color: var(--amber); background: #fffaf1; }
.alert-card.DROWSY, .alert-card.TAMPER { border-left-color: var(--red); background: #fff7f7; }
.card-label { color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.alert-card strong { display: block; margin: 8px 0 4px; font-size: clamp(18px, 1.8vw, 24px); line-height: 1.15; }
.alert-card p { margin: 0; color: var(--ink-soft); font-size: 12px; overflow-wrap: anywhere; }
.readings-card, .connection-card { display: flex; flex-direction: column; justify-content: center; }
.readings-card h2, .connection-card h2 { margin-bottom: 8px; }
.reading, .connection-card p { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0; padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--ink-soft); font-size: 14px; }
.reading:last-child, .connection-card p:last-child { border-bottom: 0; }
.reading strong, .connection-card strong { color: var(--ink); font-size: 14px; white-space: nowrap; }
.security-grid { display: block; margin-bottom: 0; }
.integrity-card { max-width: none; min-height: 100px; }
.security-grid + .table-card { min-height: 0; }
.events-table thead tr, .events-table tbody tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.events-table th, .events-table td, .security-grid + .table-card th, .security-grid + .table-card td { font-size: 13px; }
.security-grid + .table-card table { table-layout: fixed; }
@media (max-width: 1100px) {
  .monitor-layout { grid-template-columns: minmax(0, 1.7fr) minmax(240px, .8fr); }
}
@media (max-width: 900px) {
  .monitor-layout { min-height: 650px; }
}
@media (max-width: 700px) {
  .monitor-layout { display: flex; flex-direction: column; min-height: 0; }
  .monitor-layout .video-card { min-height: 360px; }
  .monitor-side { display: flex; flex-direction: column; }
  .monitor-side > .card { min-height: 0; }
  .events-table { min-width: 560px; }
}
@media (max-height: 720px) and (min-width: 901px) {
  .topbar { min-height: 72px; flex-basis: 72px; }
  .page-content:has(.monitor-layout) { padding-block: 12px; }
  .monitor-side { grid-template-rows: minmax(100px, .8fr) minmax(170px, 1.4fr) minmax(110px, .8fr); gap: 10px; }
  .monitor-side > .card { padding-block: 11px; }
  .reading, .connection-card p { padding-block: 5px; }
}

/* Dashboard summarizes the monitor without repeating its live camera view. */
.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; flex: none; }
.summary-card { min-height: 125px; padding: 18px 20px; border-top: 3px solid #b1bfca; }
.summary-card.status-NORMAL { border-top-color: var(--teal); }
.summary-card.status-WARNING { border-top-color: var(--amber); }
.summary-card.status-DROWSY, .summary-card.status-TAMPER { border-top-color: var(--red); }
.summary-card > span { color: var(--muted); font-size: 12px; font-weight: 700; }
.summary-card > strong { display: block; margin: 8px 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(22px, 2.3vw, 30px); line-height: 1.15; }
.summary-card > small { color: var(--muted); font-size: 12px; }
.dashboard-layout { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(300px, .8fr); gap: 18px; flex: 1; min-height: 0; }
.dashboard-chart-card { display: flex; flex-direction: column; min-height: 0; }
.chart-unit { color: var(--muted); font-size: 13px; }
#closure-chart { display: block; width: 100%; height: 100%; flex: 1; min-height: 0; margin-top: 12px; }
.recent-card { display: flex; flex-direction: column; min-height: 0; }
.recent-card .card-head { align-items: center; }
.recent-card .card-head a { color: var(--teal); font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.recent-card .card-head a:hover { text-decoration: underline; }
.recent-list { flex: 1; min-height: 0; overflow: hidden; margin-top: 12px; }
.recent-item { padding: 13px 0; border-bottom: 1px solid var(--line); }
.recent-item:last-child { border-bottom: 0; }
.recent-item > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.recent-item strong { font-size: 12px; }
.recent-item strong.WARNING { color: var(--amber); }
.recent-item strong.DROWSY, .recent-item strong.TAMPER { color: var(--red); }
.recent-item time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.recent-item p { margin: 5px 0 0; color: var(--ink-soft); font-size: 12px; overflow-wrap: anywhere; }
.empty-recent { margin: 0; padding: 40px 10px; text-align: center; color: var(--muted); }
@media (max-width: 1100px) { .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .dashboard-layout { min-height: 420px; } }
@media (max-width: 700px) {
  .dashboard-layout { display: flex; flex-direction: column; }
  .dashboard-chart-card { min-height: 330px; }
  .recent-card { min-height: 270px; }
}
@media (max-width: 430px) { .summary-grid { grid-template-columns: 1fr; } }
@media (max-height: 720px) and (min-width: 901px) {
  .summary-card { min-height: 100px; padding-block: 12px; }
  .recent-item { padding-block: 9px; }
}

/* Unified dark dashboard theme. */
:root {
  color-scheme: dark;
  --ink: #edf5fc;
  --ink-soft: #b8cadb;
  --muted: #91a6ba;
  --line: #284158;
  --canvas: #081827;
  --card: #10273b;
  --nav: #071321;
  --nav-active: #17354b;
  --teal: #56e1c1;
  --teal-soft: #123d3c;
  --amber: #ffca72;
  --amber-soft: #423423;
  --red: #ff7886;
  --red-soft: #492b36;
  --shadow: 0 16px 36px rgba(0, 9, 20, .16);
}
body { background: radial-gradient(circle at 82% 8%, #15324a 0, transparent 34%), var(--canvas); font-size: 15px; }
.sidebar { background: linear-gradient(180deg, #071321 0%, #0b1d2e 100%); border-right: 1px solid #1c3549; }
.brand { gap: 13px; padding-top: 2px; }
.brand-mark { width: 40px; height: 40px; border-color: #53cdb9; background: linear-gradient(145deg, #1e766d, #174d68); box-shadow: 0 8px 20px #030d1b80; }
.brand-copy strong { font-size: 20px; color: #f2fbff; }
.brand-copy small { color: #73bdb7; }
.sidebar nav { gap: 8px; }
.nav-link { min-height: 48px; color: #a8bbcd; font-size: 14px; }
.nav-link:hover { background: #122b40; }
.nav-link.active { background: linear-gradient(90deg, #1b4656, #17354b); box-shadow: inset 0 0 0 1px #32616b; }
.nav-link.active::before { background: #57e8c9; }
.topbar { background: rgba(9, 27, 43, .91); border-bottom-color: #264056; }
.topbar h1 { color: #f5fbff; font-size: 27px; }
.topbar p { color: #9cb1c5; font-size: 13px; }
.card, .metric-card { background: linear-gradient(155deg, #122b40, #0d2134); border-color: #2b465b; border-radius: 16px; box-shadow: var(--shadow); }
.card h2 { color: #eff8ff; font-size: 17px; }
.card-head p { color: #9cb1c5; font-size: 13px; }
.summary-grid { gap: 16px; }
.summary-card { position: relative; min-height: 133px; padding: 20px 22px; overflow: hidden; border-top-width: 0; }
.summary-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: #7a91aa; }
.summary-card:nth-child(2)::before { background: #55c7ee; }
.summary-card:nth-child(3)::before { background: var(--amber); }
.summary-card:nth-child(4)::before { background: #a4a4fa; }
.summary-card.status-NORMAL::before { background: var(--teal); }
.summary-card.status-WARNING::before { background: var(--amber); }
.summary-card.status-DROWSY::before, .summary-card.status-TAMPER::before { background: var(--red); }
.summary-card::after { content: ""; position: absolute; width: 125px; height: 125px; right: -52px; top: -64px; border-radius: 50%; background: rgba(91, 189, 204, .07); pointer-events: none; }
.summary-card > span { color: #a5bed1; font-size: 13px; }
.summary-card > strong { margin-top: 10px; font-size: clamp(24px, 2.5vw, 34px); color: #f7fbff; }
.summary-card:nth-child(2) > strong { color: #60d9f3; }
.summary-card:nth-child(3) > strong { color: var(--amber); }
.summary-card:nth-child(4) > strong { color: #b8bcff; }
.summary-card.status-NORMAL > strong { color: var(--teal); }
.summary-card.status-WARNING > strong { color: var(--amber); }
.summary-card.status-DROWSY > strong, .summary-card.status-TAMPER > strong { color: var(--red); }
.summary-card > small { color: #96aabd; font-size: 12px; }
.dashboard-layout { grid-template-columns: minmax(0, 1.45fr) minmax(340px, .9fr); gap: 16px; }
.dashboard-chart-card, .recent-card { padding: 23px 25px; }
.chart-unit { color: #a5bfd0; }
.recent-card .card-head a { color: var(--teal); font-size: 13px; }
.recent-list { margin-top: 17px; }
.recent-item { position: relative; padding: 11px 0 11px 16px; }
.recent-item::before { content: ""; position: absolute; top: 17px; left: 0; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 4px #50402966; }
.recent-item.status-DROWSY::before, .recent-item.status-TAMPER::before { background: var(--red); box-shadow: 0 0 0 4px #612d3c66; }
.recent-item strong { font-size: 13px; }
.recent-item time { color: #9ab0c4; font-size: 11px; }
.recent-item p { margin-top: 6px; color: #c9d8e6; font-size: 13px; }
.empty-recent { color: var(--muted); }
.monitor-layout .video-card { background: linear-gradient(145deg, #122b40, #0d2134); }
.monitor-layout .video-frame { border: 1px solid #315067; background: #071421; }
.state-pill { background: #263d52; color: #c5d5e5; font-size: 12px; }
.state-pill.NORMAL { background: var(--teal-soft); color: var(--teal); }
.state-pill.WARNING { background: var(--amber-soft); color: var(--amber); }
.state-pill.DROWSY, .state-pill.TAMPER { background: var(--red-soft); color: var(--red); }
.alert-card { background: linear-gradient(135deg, #142e43, #102638); }
.alert-card.NORMAL { background: linear-gradient(135deg, #143b3e, #102638); }
.alert-card.WARNING { background: linear-gradient(135deg, #453a27, #102638); }
.alert-card.DROWSY, .alert-card.TAMPER { background: linear-gradient(135deg, #492d39, #102638); }
.alert-card p { color: var(--ink-soft); font-size: 13px; }
.card-label { color: #a4bacd; font-size: 11px; }
.reading, .connection-card p { color: #b3c7d8; }
.reading strong, .connection-card strong { color: #f2f8fd; }
.table-filter { background: #0b2031; }
.table-filter button { color: #a6b9ca; font-size: 12px; }
.table-filter button.active { background: #235168; color: #effffb; box-shadow: none; }
thead { background: #173349; }
th { color: #a9c0d3; }
td { color: #d5e2ec; }
tbody tr:hover { background: #18344a; }
.events-table th, .events-table td, .security-grid + .table-card th, .security-grid + .table-card td { font-size: 14px; }
.pagination-controls button { background: #122d43; color: #d1e1ee; }
.pagination-controls button:hover:not(:disabled), .pagination-controls button.active { background: #2a766f; color: white; }
.integrity-card { background: linear-gradient(90deg, #143d43, #10273b); }
.integrity-card.alert { background: linear-gradient(90deg, #4a2d39, #10273b); }
.integrity-card h2 { color: #ecfcf6; }
.integrity-card p { color: #abc3d1; font-size: 13px; }
.shield { background: #1e5a57; color: var(--teal); }
@media (max-height: 720px) and (min-width: 901px) {
  .summary-card { min-height: 100px; padding-block: 12px; }
  .dashboard-chart-card, .recent-card { padding: 15px 18px; }
  .recent-item { padding-block: 8px; }
}

/* Keep the complete camera frame and its HUD visible at every viewport width. */
.monitor-layout { flex: none; min-height: 0; }
.monitor-layout .video-frame { flex: none; aspect-ratio: 4 / 3; }
.monitor-layout .video-frame img { object-fit: contain; }
@media (min-width: 901px) {
  .app-shell:has(.monitor-layout) { height: auto; min-height: 100vh; }
  .page-content:has(.monitor-layout) { flex: 1 0 auto; overflow: visible; }
}
@media (max-width: 1100px) {
  .monitor-layout { display: flex; flex-direction: column; }
  .monitor-layout .video-card { flex: none; }
  .monitor-side { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: none; min-height: 220px; }
}
@media (max-width: 700px) {
  .monitor-side { display: flex; min-height: 0; }
  .monitor-side > .card { min-height: 140px; }
}

.monitor-head { flex-wrap: wrap; }
.camera-controls { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.camera-button { border: 1px solid #426275; border-radius: 7px; padding: 7px 11px; background: #173247; color: #e9f4fb; font-size: 12px; font-weight: 700; cursor: pointer; }
.camera-button:hover:not(:disabled) { background: #26506a; }
.camera-button-primary { border-color: #52bcaa; background: #1c6d66; }
.camera-button-primary:hover:not(:disabled) { background: #258779; }
.camera-button:disabled { opacity: .5; cursor: default; }
.camera-action-message { margin: 0 3px 8px; min-height: 0; color: #b5cbd9; font-size: 12px; }
.camera-action-message:empty { display: none; }
.camera-action-message.error { color: #ff9da5; }
.video-frame [hidden] { display: none !important; }
.monitor-layout .video-frame video { display: block; width: 100%; height: 100%; object-fit: contain; }
.stream-mode { color: #9cc6d9; font-size: 11px; font-weight: 700; }
