/* Material Design 3 theme layer — local fonts, typography scale, and a
   bridge that maps the app's legacy palette variables onto M3 tokens so
   every existing page inherits the Material color system at once.
   Loaded after style.css; dark values ride the same data-bs-theme
   attribute the app already uses. */

/* ---- Local fonts (offline) ------------------------------------------- */
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/vendor/fonts/roboto-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA,
    U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193,
    U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Roboto';
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url('/vendor/fonts/roboto-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF,
    U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020,
    U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Material Symbols Rounded';
  font-style: normal;
  font-weight: 100 700;
  font-display: block;
  src: url('/vendor/fonts/material-symbols-rounded.woff2') format('woff2');
}
.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  direction: ltr;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

/* Material icons: point md-icon at the locally hosted Rounded font. */
md-icon {
  --md-icon-font: 'Material Symbols Rounded';
}

/* ---- Base typography (M3 type scale applied to the app) --------------- */
body {
  font-family: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
}
h1, .h1 { font-size: 2rem; font-weight: 400; letter-spacing: 0; }
h2, .h2 { font-size: 1.5rem; font-weight: 400; letter-spacing: 0; }
h3, .h3 { font-size: 1.25rem; font-weight: 500; letter-spacing: 0; }
h4, .h4 { font-size: 1rem; font-weight: 500; letter-spacing: .01em; }
h5, .h5 { font-size: .875rem; font-weight: 500; letter-spacing: .01em; }
h6, .h6 { font-size: .75rem; font-weight: 500; letter-spacing: .03em; text-transform: uppercase; }

/* ---- Bridge: legacy palette variables -> M3 tokens --------------------- */
:root {
  --bg: var(--md-sys-color-surface);
  --card: var(--md-sys-color-surface-container-lowest);
  --card-press: var(--md-sys-color-surface-container);
  --stroke: var(--md-sys-color-outline-variant);
  --text: var(--md-sys-color-on-surface);
  --dim: var(--md-sys-color-on-surface-variant);
  --heading: var(--md-sys-color-on-surface);
  --blue: var(--md-sys-color-primary);
  --navy: var(--md-sys-color-surface-container-high);
  --cat-engaged: #188038;
  --cat-stable: var(--md-sys-color-primary);
  --cat-atrisk: #e8710a;
  --cat-disengaged: #d93025;
  --cat-unknown: var(--md-sys-color-on-surface-variant);
}
html[data-bs-theme='dark'] {
  --heading: var(--md-sys-color-on-surface);
}
/* The dark block in style.css outranks :root, so the bridge needs the
   same specificity to win in dark mode. */
html[data-bs-theme='dark'] {
  --bg: var(--md-sys-color-surface);
  --card: var(--md-sys-color-surface-container-low);
  --card-press: var(--md-sys-color-surface-container);
  --stroke: var(--md-sys-color-outline-variant);
  --text: var(--md-sys-color-on-surface);
  --dim: var(--md-sys-color-on-surface-variant);
  --blue: var(--md-sys-color-primary);
  --navy: var(--md-sys-color-surface-container-high);
  --cat-stable: var(--md-sys-color-primary);
  --cat-unknown: var(--md-sys-color-on-surface-variant);
}

/* ---- App chrome (M3): topbar & sidebar --------------------------------- */
.topbar {
  background: var(--md-sys-color-surface-container);
  border-bottom-color: var(--md-sys-color-outline-variant);
}
.topbar .topbar-action {
  --md-outlined-button-container-height: 34px;
  --md-icon-button-icon-size: 20px;
  --md-icon-button-state-layer-height: 34px;
  --md-icon-button-state-layer-width: 34px;
  font-size: .82rem;
}
.sidebar {
  background: var(--md-sys-color-surface-container-low);
  color: var(--md-sys-color-on-surface-variant);
  border-right: 1px solid var(--md-sys-color-outline-variant);
}
.sidebar-brand {
  color: var(--md-sys-color-on-surface);
  border-bottom-color: var(--md-sys-color-outline-variant);
}
.sidebar-brand i { color: var(--md-sys-color-primary); }
.brand-sub { color: var(--md-sys-color-on-surface-variant); }
.sidebar-nav a {
  color: var(--md-sys-color-on-surface-variant);
  border-radius: 28px;
}
.sidebar-nav a i { color: var(--md-sys-color-on-surface-variant); }
.sidebar-nav a:hover {
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
}
.sidebar-nav a.active {
  background: var(--md-sys-color-secondary-container);
  color: var(--md-sys-color-on-secondary-container);
  font-weight: 600;
}
.sidebar-nav a.active i { color: var(--md-sys-color-on-secondary-container); }
.nav-group { color: var(--md-sys-color-outline); }
.nav-group:hover { color: var(--md-sys-color-on-surface); }

/* Heatmap header: --navy is a light container token now, so the hardcoded
   white header text pairs it with a readable M3 surface instead. */
table.heatmap thead th {
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
}
table.heatmap thead .id-col {
  background: var(--md-sys-color-surface-container-highest);
}

/* ---- Interim Bootstrap skin: components restyled with M3 tokens until
   each page is converted to native md-* components. Bootstrap 5.2+
   buttons/forms are driven by --bs-* variables, so overriding those is
   enough for rest, hover and focus states. ------------------------------- */
.btn {
  --bs-btn-border-radius: 20px;
  font-weight: 500;
  letter-spacing: .01em;
}
.btn-primary {
  --bs-btn-bg: var(--md-sys-color-primary);
  --bs-btn-border-color: var(--md-sys-color-primary);
  --bs-btn-color: var(--md-sys-color-on-primary);
  --bs-btn-hover-bg: var(--md-sys-color-primary);
  --bs-btn-hover-border-color: var(--md-sys-color-primary);
  --bs-btn-hover-color: var(--md-sys-color-on-primary);
  --bs-btn-active-bg: var(--md-sys-color-primary);
  --bs-btn-active-border-color: var(--md-sys-color-primary);
  --bs-btn-active-color: var(--md-sys-color-on-primary);
  --bs-btn-disabled-bg: var(--md-sys-color-primary);
  --bs-btn-disabled-border-color: var(--md-sys-color-primary);
  filter: brightness(1.1);
}
.btn-primary:hover { filter: brightness(1.16); box-shadow: 0 1px 3px 1px rgba(0, 0, 0, .15); }
.btn-primary:active { filter: brightness(.96); box-shadow: none; }
.btn-secondary {
  --bs-btn-bg: var(--md-sys-color-secondary);
  --bs-btn-border-color: var(--md-sys-color-secondary);
  --bs-btn-color: var(--md-sys-color-on-secondary);
  --bs-btn-hover-bg: var(--md-sys-color-secondary);
  --bs-btn-hover-border-color: var(--md-sys-color-secondary);
  --bs-btn-hover-color: var(--md-sys-color-on-secondary);
}
.btn-success {
  --bs-btn-bg: var(--cat-engaged);
  --bs-btn-border-color: var(--cat-engaged);
  --bs-btn-hover-bg: var(--cat-engaged);
  --bs-btn-hover-border-color: var(--cat-engaged);
}
.btn-danger {
  --bs-btn-bg: var(--md-sys-color-error);
  --bs-btn-border-color: var(--md-sys-color-error);
  --bs-btn-color: var(--md-sys-color-on-error);
  --bs-btn-hover-bg: var(--md-sys-color-error);
  --bs-btn-hover-border-color: var(--md-sys-color-error);
  --bs-btn-hover-color: var(--md-sys-color-on-error);
}
.btn-warning {
  --bs-btn-bg: var(--cat-atrisk);
  --bs-btn-border-color: var(--cat-atrisk);
  --bs-btn-color: #201a09;
  --bs-btn-hover-bg: var(--cat-atrisk);
  --bs-btn-hover-border-color: var(--cat-atrisk);
}
.btn-outline-secondary {
  --bs-btn-color: var(--md-sys-color-on-surface-variant);
  --bs-btn-border-color: var(--md-sys-color-outline);
  --bs-btn-hover-bg: var(--md-sys-color-surface-container);
  --bs-btn-hover-color: var(--md-sys-color-on-surface);
  --bs-btn-hover-border-color: var(--md-sys-color-outline);
  --bs-btn-active-bg: var(--md-sys-color-secondary-container);
  --bs-btn-active-color: var(--md-sys-color-on-secondary-container);
  --bs-btn-active-border-color: var(--md-sys-color-outline);
}
.btn-outline-primary {
  --bs-btn-color: var(--md-sys-color-primary);
  --bs-btn-border-color: var(--md-sys-color-primary);
  --bs-btn-hover-bg: var(--md-sys-color-primary-container);
  --bs-btn-hover-color: var(--md-sys-color-on-primary-container);
  --bs-btn-hover-border-color: var(--md-sys-color-primary);
}
.form-control, .form-select {
  border-color: var(--md-sys-color-outline-variant);
  border-radius: 8px;
  color: var(--md-sys-color-on-surface);
  background-color: var(--md-sys-color-surface-container-lowest);
}
.form-control:focus, .form-select:focus {
  border-color: var(--md-sys-color-primary);
  box-shadow: 0 0 0 .18rem color-mix(in srgb, var(--md-sys-color-primary) 22%, transparent);
}
.form-control::placeholder { color: var(--md-sys-color-on-surface-variant); opacity: .8; }
.form-label { color: var(--md-sys-color-on-surface-variant); font-weight: 500; }
.card {
  border-color: var(--md-sys-color-outline-variant);
  border-radius: 14px;
  background: var(--md-sys-color-surface-container-lowest);
  color: var(--md-sys-color-on-surface);
}
.card-header {
  background: var(--md-sys-color-surface-container);
  border-bottom-color: var(--md-sys-color-outline-variant);
  border-radius: 14px 14px 0 0 !important;
}
.badge.text-bg-primary { background-color: var(--md-sys-color-primary) !important; color: var(--md-sys-color-on-primary) !important; }
.modal-content {
  border-radius: 24px;
  border-color: var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}
.modal-header, .modal-footer { border-color: var(--md-sys-color-outline-variant); }
.dropdown-menu {
  border-radius: 12px;
  border-color: var(--md-sys-color-outline-variant);
  background: var(--md-sys-color-surface-container);
  color: var(--md-sys-color-on-surface);
  box-shadow: 0 4px 12px 2px rgba(0, 0, 0, .12), 0 1px 4px rgba(0, 0, 0, .14);
}
.dropdown-item { color: var(--md-sys-color-on-surface); }
.dropdown-item:hover, .dropdown-item:focus {
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
}
.dropdown-divider { border-color: var(--md-sys-color-outline-variant); }
.nav-tabs {
  border-bottom-color: var(--md-sys-color-outline-variant);
}
.nav-tabs .nav-link {
  color: var(--md-sys-color-on-surface-variant);
  border-color: transparent;
}
.nav-tabs .nav-link:hover { color: var(--md-sys-color-on-surface); }
.nav-tabs .nav-link.active {
  color: var(--md-sys-color-primary);
  background: transparent;
  border-bottom: 3px solid var(--md-sys-color-primary);
}
.table { --bs-table-color: var(--md-sys-color-on-surface); }
.alert-danger {
  background: var(--md-sys-color-error-container);
  color: var(--md-sys-color-on-error-container);
  border-color: transparent;
}
.alert-success {
  background: color-mix(in srgb, var(--cat-engaged) 14%, var(--md-sys-color-surface));
  color: var(--cat-engaged);
  border-color: transparent;
}
.alert-info {
  background: var(--md-sys-color-primary-container);
  color: var(--md-sys-color-on-primary-container);
  border-color: transparent;
}
.alert-warning {
  background: color-mix(in srgb, var(--cat-atrisk) 14%, var(--md-sys-color-surface));
  color: var(--cat-atrisk);
  border-color: transparent;
}

/* ---- Material Web Components loading ---------------------------------- */
/* Avoid FOUC: register-hide until custom elements upgrade. */
md-filled-button:not(:defined),
md-filled-tonal-button:not(:defined),
md-outlined-button:not(:defined),
md-text-button:not(:defined),
md-elevated-button:not(:defined),
md-outlined-text-field:not(:defined),
md-filled-text-field:not(:defined),
md-select:not(:defined),
md-checkbox:not(:defined),
md-radio:not(:defined),
md-switch:not(:defined),
md-dialog:not(:defined),
md-icon:not(:defined),
md-list-item:not(:defined),
md-tabs:not(:defined),
md-secondary-tab:not(:defined),
md-linear-progress:not(:defined),
md-circular-progress:not(:defined),
md-divider:not(:defined),
md-fab:not(:defined) {
  visibility: hidden;
}
