/* 112 Chemical Emergency Response Portal
   All styling lives here: the Content-Security-Policy forbids <style> blocks and style attributes. */

:root {
  --portal-navy: #14213d;
  --portal-navy-light: #1f2f55;
  --portal-accent: #e63946;
  --portal-bg: #f3f5f8;
  --portal-border: #d9dee6;
  --portal-muted: #5b6676;
  --sidebar-width: 15rem;
}

html {
  font-size: 14px;
}

body {
  background-color: var(--portal-bg);
  color: #1b2430;
}

/* ---------- Focus: always visible ---------- */

a:focus-visible,
button:focus-visible,
summary:focus-visible,
.btn:focus-visible,
.nav-link:focus-visible,
.page-link:focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 2px;
  box-shadow: none;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: #1d4ed8;
  box-shadow: 0 0 0 0.2rem rgba(29, 78, 216, 0.3);
}

.skip-link {
  position: absolute;
  top: 0.25rem;
  left: 0.25rem;
  z-index: 2000;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border-radius: 0.25rem;
}

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

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

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.app-content {
  flex: 1 1 auto;
  padding: 1rem;
}

/* ---------- Sidebar (Bootstrap offcanvas below lg, fixed column from lg up) ---------- */

.offcanvas.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--portal-navy);
  color: #dfe6f3;
  border-right: 0;
}

.app-sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.app-sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  text-decoration: none;
}

.app-sidebar-logo:hover {
  color: #fff;
}

.brand-112 {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  background-color: var(--portal-accent);
  color: #fff;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.03em;
  border-radius: 0.3rem;
  line-height: 1.3;
}

.brand-sub {
  font-size: 0.8rem;
  line-height: 1.25;
  font-weight: 600;
}

.app-nav {
  padding: 0.5rem 0;
  overflow-y: auto;
}

.app-nav .nav-link {
  padding: 0.6rem 1rem 0.6rem 0.85rem;
  color: #c9d3e6;
  border-left: 4px solid transparent;
}

.app-nav .nav-link:hover,
.app-nav .nav-link:focus {
  color: #fff;
  background-color: var(--portal-navy-light);
}

.app-nav .nav-link.active {
  color: #fff;
  font-weight: 600;
  background-color: var(--portal-navy-light);
  border-left-color: var(--portal-accent);
}

.app-nav-heading {
  padding: 1rem 1rem 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: #8f9cb8;
}

@media (min-width: 992px) {
  .offcanvas.app-sidebar {
    position: sticky;
    top: 0;
    flex: 0 0 var(--sidebar-width);
    height: 100vh;
    z-index: auto;
    visibility: visible !important;
    transform: none;
    transition: none;
  }
}

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

.app-topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.55rem 1rem;
  background-color: var(--portal-navy-light);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.app-product-name {
  flex: 1 1 auto;
  min-width: 0;
  font-weight: 600;
  font-size: 1.05rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  white-space: nowrap;
}

.app-username {
  font-weight: 600;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 575.98px) {
  .app-product-name {
    font-size: 0.9rem;
    white-space: normal;
    line-height: 1.2;
  }

  .app-username {
    display: none;
  }
}

/* ---------- Signed-out layout ---------- */

.auth-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background-color: var(--portal-navy);
  color: #fff;
}

.auth-main {
  max-width: 34rem;
  margin: 0 auto;
  padding: 2rem 1rem;
}

/* Sign-in page. Design: 112Portal-Login-Design.html (scene on the left, sign-in on the right; stacked on narrow screens).
   Everything is scoped to .login-page so nothing here touches another page. */
.auth-main-full {
  max-width: none;
  margin: 0;
  padding: 0;
}

.auth-main-full > .alert {
  margin: 0;
  border-radius: 0;
}

.login-page {
  --login-navy: #0b1d32;
  --login-text: #152a3e;
  --login-muted: #61758a;
  --login-line: #dce5ec;
  --login-focus: #007f8d;
  display: grid;
  grid-template-columns: minmax(0, 1.09fr) minmax(380px, 0.91fr);
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--login-text);
  background: #eff4f7;
}

.login-page *,
.login-page *::before {
  box-sizing: border-box;
}

.login-page .scene {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px clamp(32px, 5vw, 92px);
  overflow: hidden;
  color: #fff;
  background: radial-gradient(circle at 15% 15%, #234e65 0, transparent 36%), linear-gradient(140deg, #07192c 3%, #102e49 56%, #0b233b 100%);
}

.login-page .scene::before {
  content: "";
  pointer-events: none;
  position: absolute;
  inset: 0;
  opacity: 0.22;
  background-image: linear-gradient(#94e1e11b 1px, transparent 1px), linear-gradient(90deg, #94e1e11b 1px, transparent 1px);
  background-size: 36px 36px;
  -webkit-mask-image: linear-gradient(to bottom, transparent 8%, black 100%);
  mask-image: linear-gradient(to bottom, transparent 8%, black 100%);
}

.login-page .scene > * {
  position: relative;
  z-index: 1;
}

.login-page .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: 14px;
}

.login-page .brandmark {
  display: grid;
  place-items: center;
  width: 49px;
  height: 49px;
  border-radius: 13px;
  background: linear-gradient(140deg, #eb5250, #b91d31);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 9px 26px #0003;
}

.login-page .brand small {
  display: block;
  margin-top: 4px;
  color: #bed1de;
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.login-page .eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 11px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #a5f2e7;
  font-weight: 800;
}

.login-page .pulse {
  width: 8px;
  height: 8px;
  border-radius: 100%;
  background: #64dfca;
  box-shadow: 0 0 0 5px #64dfca1e;
}

.login-page .scene h1 {
  max-width: 640px;
  margin: 18px 0 20px;
  font-size: clamp(36px, 4vw, 65px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.045em;
}

.login-page .scene h1 em {
  font-style: normal;
  color: #77e3d7;
}

.login-page .intro {
  max-width: 550px;
  margin: 0;
  font-size: clamp(15px, 1.2vw, 18px);
  line-height: 1.8;
  color: #c2d3df;
}

.login-page .visual {
  max-width: 650px;
  margin: 28px 0 26px;
  padding: 18px 22px 12px;
  border: 1px solid #ffffff29;
  border-radius: 20px;
  background: #ffffff0c;
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.login-page .visual svg {
  display: block;
  width: 100%;
  height: auto;
}

.login-page .visual-caption {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
  color: #c0d8e2;
  letter-spacing: 0.03em;
}

.login-page .chiprow {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 13px 0 0;
  padding: 0;
  list-style: none;
}

.login-page .chip {
  padding: 9px 12px;
  border: 1px solid #ffffff2b;
  border-radius: 8px;
  background: #ffffff10;
  font-size: 11px;
  color: #d2e8ed;
}

.login-page .bottom {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  color: #9db6c9;
  font-size: 11px;
  line-height: 1.6;
}

.login-page .bottom strong {
  color: #e3eef6;
}

.login-page .login-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 55px clamp(24px, 5vw, 84px);
  background: linear-gradient(135deg, #f8fafc, #edf3f6);
}

.login-page .login-box {
  width: 100%;
  max-width: 430px;
}

.login-page .access {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid #cce4e2;
  border-radius: 30px;
  background: #e7f7f4;
  color: #0c6e70;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login-page .login-box h2 {
  margin: 23px 0 9px;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.05em;
  color: var(--login-navy);
}

.login-page .description {
  margin: 0 0 30px;
  color: var(--login-muted);
  font-size: 14px;
  line-height: 1.7;
}

.login-page .panel {
  padding: 32px;
  border: 1px solid var(--login-line);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 17px 50px #15304610;
}

.login-page label {
  display: block;
  margin-bottom: 9px;
  font-weight: 700;
  font-size: 12px;
  color: #263c4e;
}

.login-page .field {
  margin-bottom: 22px;
}

.login-page .inputwrap {
  position: relative;
}

.login-page .field input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid #cfdae4;
  border-radius: 10px;
  background: #f9fbfc;
  color: #142d42;
  font: inherit;
  font-size: 14px;
  transition: 0.16s ease;
}

.login-page .field input:focus {
  outline: 3px solid #4fb7c12e;
  border-color: var(--login-focus);
  background: #fff;
}

.login-page .field input.input-validation-error {
  border-color: #c0392b;
}

.login-page .field input::placeholder {
  color: #91a1b0;
}

.login-page .password input {
  padding-right: 75px;
}

.login-page .show {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  padding: 12px;
  border: 0;
  background: transparent;
  color: #0e7180;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

.login-page .field-error {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: #b3261e;
}

.login-page .login-errors {
  margin-bottom: 20px;
  font-size: 13px;
}

.login-page .submit {
  width: 100%;
  height: 52px;
  border: 0;
  border-radius: 10px;
  background: #086b82;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 9px 18px #086b8230;
}

.login-page .submit:hover {
  background: #07566b;
}

.login-page .submit:disabled {
  opacity: 0.75;
  cursor: progress;
}

.login-page .submit:focus-visible,
.login-page .show:focus-visible {
  outline: 3px solid #f0ae3d;
  outline-offset: 3px;
}

.login-page .note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 22px;
  padding: 14px;
  border: 1px solid #e2eaef;
  border-radius: 10px;
  background: #f8fafb;
  font-size: 12px;
  line-height: 1.6;
  color: #5c7181;
}

.login-page .note svg {
  flex: none;
  margin-top: 1px;
}

.login-page .login-footer {
  margin-top: 28px;
  font-size: 12px;
  line-height: 1.8;
  text-align: center;
  color: #75889a;
}

.login-page .login-footer b {
  color: #496076;
}

@media (max-width: 980px) {
  .login-page {
    grid-template-columns: 1fr;
  }

  /* On a phone the form comes first: signing in must never need scrolling past the picture. */
  .login-page .login-zone {
    order: -1;
    padding: 44px 25px 55px;
  }

  .login-page .scene {
    padding: 25px 30px 34px;
  }

  .login-page .scene-main {
    margin-top: 35px;
  }

  .login-page .scene h1 {
    font-size: 39px;
  }

  .login-page .visual {
    max-width: 700px;
  }

  .login-page .bottom {
    margin-top: 30px;
  }
}

@media (max-width: 560px) {
  .login-page .scene {
    padding: 22px;
  }

  .login-page .scene h1 {
    font-size: 32px;
  }

  .login-page .visual {
    padding: 10px;
  }

  .login-page .visual-caption {
    font-size: 9px;
  }

  .login-page .bottom {
    display: none;
  }

  .login-page .chiprow {
    gap: 6px;
  }

  .login-page .chip {
    font-size: 10px;
  }

  .login-page .login-box h2 {
    font-size: 28px;
  }

  .login-page .panel {
    padding: 23px;
  }

  .login-page .login-zone {
    padding: 35px 16px 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-page * {
    transition: none !important;
  }
}

.login-card,
.error-card {
  border-top: 4px solid var(--portal-accent);
}

.login-card .card-body,
.error-card .card-body {
  padding: 1.5rem;
}

.error-card {
  max-width: 40rem;
}

.error-code {
  margin-bottom: 0.25rem;
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--portal-accent);
}

/* ---------- Page furniture ---------- */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.page-title-group {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 1rem;
}

/* "Refresh in 10 seconds" beside the title of a list that reloads itself. */
.refresh-countdown {
  font-size: 0.875rem;
  font-weight: 600;
  color: #b02a37;
  background-color: #fdecee;
  border: 1px solid #f1aeb5;
  border-radius: 0.375rem;
  padding: 0.125rem 0.625rem;
  font-variant-numeric: tabular-nums;
}

/* The reload failed or has stopped: stronger than the ordinary countdown. */
.refresh-countdown.refresh-countdown-problem {
  color: #fff;
  background-color: #b02a37;
  border-color: #b02a37;
}

.card {
  border-color: var(--portal-border);
  box-shadow: 0 1px 2px rgba(20, 33, 61, 0.05);
}

.card-header {
  background-color: #fff;
  border-bottom-color: var(--portal-border);
  font-weight: 600;
}

.card-footer {
  background-color: #fff;
  border-top-color: var(--portal-border);
}

.card-attention {
  border-color: #dc3545;
  border-left-width: 4px;
}

.filter-card .form-label,
.form-label {
  margin-bottom: 0.2rem;
  font-weight: 600;
  font-size: 0.9rem;
}

.req {
  color: #b02a37;
  font-weight: 700;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 2rem;
}

.btn-xs {
  padding: 0.1rem 0.45rem;
  font-size: 0.8rem;
}

.notice-strong {
  border-left: 5px solid #cc9a06;
  font-size: 1rem;
}

.not-registered {
  display: inline-block;
  padding: 0.05rem 0.4rem;
  font-family: var(--bs-font-sans-serif);
  font-size: 0.8rem;
  font-weight: 600;
  color: #7a4b00;
  background-color: #fff3cd;
  border: 1px solid #e0b84a;
  border-radius: 0.25rem;
}

/* Validation: jQuery validation toggles these classes. */

.validation-summary-valid {
  display: none;
}

.validation-box ul {
  margin-bottom: 0;
  padding-left: 1.1rem;
}

.field-validation-error {
  display: block;
  color: #b02a37;
}

.input-validation-error {
  border-color: #dc3545;
}

/* ---------- Key / value lists ---------- */

.kv {
  display: grid;
  grid-template-columns: minmax(8rem, 38%) 1fr;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0;
}

.kv dt {
  font-weight: 600;
  color: var(--portal-muted);
}

.kv dd {
  margin-bottom: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.pre-wrap {
  white-space: pre-wrap;
}

.mono {
  font-family: var(--bs-font-monospace);
  font-size: 0.9em;
}

/* ---------- Ticket header: three separate status concepts ---------- */

.ticket-source .badge {
  font-size: 0.8rem;
  vertical-align: middle;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0;
}

.status-item {
  min-width: 8.5rem;
  padding: 0.4rem 0.7rem;
  background-color: #fff;
  border: 1px solid var(--portal-border);
  border-radius: 0.35rem;
}

.status-item dt {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--portal-muted);
}

.status-item dd {
  margin-bottom: 0;
}

.status-item .badge {
  font-size: 0.85rem;
}

/* ---------- Badges ---------- */

.badge {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.badge-erss {
  color: #14213d;
  background-color: #e3e9f6;
  border: 1px solid #14213d;
}

/* Uncertain must not be mistaken for an ordinary failure. */
.badge-uncertain {
  border: 2px dashed #fff;
  outline: 2px solid #dc3545;
  letter-spacing: 0.06em;
}

/* ---------- Dashboard ---------- */

.stat-card {
  border-left: 4px solid var(--portal-muted);
}

.stat-card .card-body {
  padding: 0.75rem 1rem;
}

.stat-label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--portal-muted);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.15;
}

.stat-total { border-left-color: var(--portal-navy); }
.stat-new { border-left-color: #0d6efd; }
.stat-open { border-left-color: #cc9a06; }
.stat-closed { border-left-color: #6c757d; }
.stat-today { border-left-color: #198754; }

.mini-stat {
  height: 100%;
  padding: 0.5rem 0.6rem;
  text-align: center;
  background-color: #f8f9fb;
  border: 1px solid var(--portal-border);
  border-radius: 0.35rem;
}

.mini-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.2;
}

.mini-stat-label {
  font-size: 0.78rem;
  color: var(--portal-muted);
}

.mini-stat-danger {
  background-color: #f8d7da;
  border-color: #dc3545;
  color: #842029;
}

.mini-stat-warning {
  background-color: #fff3cd;
  border-color: #cc9a06;
  color: #664d03;
}

.mini-stat-danger .mini-stat-label,
.mini-stat-warning .mini-stat-label {
  color: inherit;
  font-weight: 600;
}

/* ---------- Tables ---------- */

.table-dense {
  font-size: 0.92rem;
}

.table-dense > :not(caption) > * > * {
  padding: 0.4rem 0.6rem;
  vertical-align: top;
}

.table-dense thead th {
  background-color: #eef1f6;
  border-bottom: 1px solid var(--portal-border);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #3b4657;
  white-space: nowrap;
}

.cell-wrap {
  min-width: 10rem;
  max-width: 26rem;
  overflow-wrap: anywhere;
}

.cell-break {
  max-width: 14rem;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 1.5rem 0.75rem !important;
  text-align: center;
  color: var(--portal-muted);
  font-style: italic;
}

.row-attention > td:first-child {
  border-left: 4px solid #dc3545;
}

/* ---------- Pager ---------- */

.pager-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.pager-summary {
  color: var(--portal-muted);
}

/* ---------- Outbox & reconciliation ---------- */

.legend-list {
  display: grid;
  gap: 0.3rem;
}

.legend-list > div {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.5rem;
  align-items: baseline;
}

.legend-list dd {
  margin-bottom: 0;
}

.outbox-actions {
  min-width: 17rem;
  max-width: 24rem;
}

.requeue-form {
  margin-bottom: 0.5rem;
}

.duplicate-warning {
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.65rem;
  border-left: 5px solid #842029;
}

.reconcile > summary {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  color: #41464b;
  border: 1px solid #6c757d;
  border-radius: 0.2rem;
  cursor: pointer;
  list-style: none;
}

.reconcile > summary::-webkit-details-marker {
  display: none;
}

.reconcile[open] > summary {
  margin-bottom: 0.5rem;
  background-color: #e9ecef;
}

.resolve-form {
  padding: 0.6rem;
  background-color: #f8f9fb;
  border: 1px solid var(--portal-border);
  border-radius: 0.3rem;
}

/* ---------- Simulation banner: outbound traffic is not reaching 112 ---------- */

.simulation-banner {
  margin: -1rem -1rem 1rem;
  padding: 0.6rem 1rem;
  font-size: 1.05rem;
  font-weight: 600;
  text-align: center;
  color: #1b1300;
  background-color: #ffc107;
  background-image: repeating-linear-gradient(-45deg, transparent 0, transparent 14px, rgba(0, 0, 0, 0.13) 14px, rgba(0, 0, 0, 0.13) 28px);
  border-top: 3px solid #1b1300;
  border-bottom: 3px solid #1b1300;
  text-shadow: 0 0 3px #ffc107, 0 0 3px #ffc107;
}

.simulation-banner strong {
  letter-spacing: 0.08em;
}

/* ---------- Delivery to 112 ---------- */

.delivery-state {
  max-width: 100%;
  white-space: normal;
  text-align: left;
  line-height: 1.25;
}

.delivery-cell {
  min-width: 11rem;
}

/* The internal queue status, shown next to the operator-facing delivery state. */
.raw-status {
  display: block;
  margin-top: 0.2rem;
}

.raw-status .badge {
  padding: 0.1rem 0.35rem;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--portal-muted) !important;
  background-color: transparent !important;
  border: 1px solid var(--portal-border);
  outline: 0;
}

.delivery-summary {
  background-color: #f8f9fb;
  border-bottom: 1px solid var(--portal-border);
}

.delivery-summary-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
  margin-bottom: 0.3rem;
}

.delivery-summary-label {
  font-weight: 600;
}

.delivery-summary .delivery-state {
  font-size: 0.9rem;
}

.state-legend > summary {
  font-weight: 600;
  color: #1d4ed8;
  cursor: pointer;
}

.state-legend[open] > summary {
  margin-bottom: 0.5rem;
}

/* A part of the ticket page that most incidents do not need (the response vehicle): closed until asked for. */
.optional-block > summary {
  padding: 0.5rem 1rem;
  font-weight: 600;
  color: #1d4ed8;
  cursor: pointer;
}

.col-12 > .optional-block > summary {
  padding-left: 0;
}

.optional-block[open] > summary {
  margin-bottom: 0.5rem;
}

.legend-list-wide > div {
  grid-template-columns: minmax(9rem, 16rem) 1fr;
}

@media (max-width: 575.98px) {
  .legend-list-wide > div {
    grid-template-columns: 1fr;
    gap: 0.1rem;
  }
}

.legend-list .badge {
  white-space: normal;
  text-align: left;
}

/* ---------- Ticket details: classification group ---------- */

.kv-heading {
  margin-bottom: 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--portal-navy);
}

.kv-group {
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.65rem;
  background-color: #f8f9fb;
  border: 1px solid var(--portal-border);
  border-left: 4px solid var(--portal-accent);
  border-radius: 0.3rem;
}

/* ---------- Submitting state (set by site.js) ---------- */

form[data-submitting="true"] {
  cursor: progress;
}

@media print {
  .app-sidebar,
  .app-topbar,
  .filter-card,
  .pager-bar nav {
    display: none !important;
  }
}

/* ---------- Administration: users, roles, permissions ---------- */

.narrow-card {
  max-width: 34rem;
}

.role-list .form-check,
.permission-item {
  margin-bottom: 0.45rem;
}

.super-admin-choice {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--portal-border);
}

.permission-matrix {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(22rem, 1fr));
  gap: 0.75rem 1.5rem;
}

.permission-group {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.permission-group legend {
  float: none;
  width: auto;
}

.admin-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(16rem, 1fr));
  gap: 1rem 1.5rem;
}

.admin-action .btn {
  min-width: 12rem;
}

.temporary-password {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  font-size: 1.35rem;
  letter-spacing: 0.08em;
  color: #111;
  background-color: #fff8e1;
  border: 1px solid #e0c36a;
  border-radius: 0.3rem;
  user-select: all;
}

/* ---------- Stage E: ticket list (sorting, advanced filters), timeline, vehicles ---------- */
.sort-link {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.sort-link:hover,
.sort-link:focus {
  text-decoration: underline;
}

.sort-link-sub {
  display: block;
  font-weight: 400;
  font-size: 0.8em;
  color: #5a6570;
}

.sort-mark {
  display: inline-block;
  min-width: 0.9em;
  margin-left: 0.2em;
  font-size: 0.75em;
}

.advanced-filters > summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: #33475b;
}

.advanced-filters[open] > summary {
  margin-bottom: 0.25rem;
}

.filter-check {
  padding-bottom: 0.2rem;
  font-size: 0.875rem;
}

.row-attention > td:first-child {
  box-shadow: inset 3px 0 0 #b02a37;
}

.attention-flag {
  font-weight: 600;
}

.timeline {
  list-style: none;
  margin: 0;
  padding: 0;
}

.timeline-day {
  margin: 0.75rem 0 0.35rem;
  padding-bottom: 0.2rem;
  border-bottom: 1px solid #dee2e6;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #5a6570;
}

.timeline-day:first-child {
  margin-top: 0;
}

.timeline-item {
  display: flex;
  gap: 0.75rem;
  padding: 0.45rem 0 0.45rem 0.75rem;
  border-left: 4px solid #adb5bd;
}

.timeline-item + .timeline-item {
  border-top: 1px dashed #e3e6ea;
}

.timeline-time {
  flex: 0 0 4.6rem;
  font-size: 0.85rem;
  color: #495057;
}

.timeline-body {
  flex: 1 1 auto;
  min-width: 0;
}

.timeline-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem;
}

.timeline-text {
  margin-top: 0.15rem;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.timeline-badge {
  background-color: #6c757d;
  color: #fff;
}

.timeline-agency {
  border-left-color: #0d6efd;
}

.timeline-agency .timeline-badge {
  background-color: #0d6efd;
}

.timeline-erss {
  border-left-color: #212529;
}

.timeline-erss .timeline-badge {
  background-color: #212529;
}

.timeline-integration {
  border-left-color: #b8860b;
}

.timeline-integration .timeline-badge {
  background-color: #8a6d0b;
}

.timeline-filter .nav-link {
  padding: 0.2rem 0.7rem;
  font-size: 0.85rem;
}

@media (max-width: 575.98px) {
  .timeline-item {
    flex-direction: column;
    gap: 0.1rem;
  }

  .timeline-time {
    flex-basis: auto;
  }
}

/* ---------- Stage G/H: dashboard links, integration environment indicator, reports, administration ---------- */

/* A counter that leads to the list behind it. Without an address (the reader may not open the list) it is plain text. */
a.stat-link { display: block; color: inherit; text-decoration: none; }
a.stat-link[href]:hover, a.stat-link[href]:focus { background-color: rgba(13, 110, 253, 0.06); }
a.stat-link[href]:focus-visible { outline: 2px solid #0d6efd; outline-offset: -2px; }
.stat-note { display: block; font-size: 0.7rem; font-weight: 400; text-transform: none; letter-spacing: 0; color: #6c757d; }
.stat-active { border-left: 4px solid #fd7e14; }
.mini-stat-sub { font-size: 0.9rem; font-weight: 400; color: #6c757d; }
.registration-states .registration-state { font-size: 0.8rem; font-weight: 500; text-decoration: none; }

/* Where outbound messages go. LIVE is loud on purpose; OFF and SIMULATION must never look like it. */
.integration-mode { flex: 0 0 auto; padding: 0.15rem 0.6rem; border-radius: 0.25rem; font-size: 0.8rem; white-space: nowrap; border: 2px solid transparent; }
.integration-mode-live, .integration-mode-badge.integration-mode-live { background-color: #b02a37; color: #fff; border-color: #fff; text-transform: uppercase; letter-spacing: 0.04em; }
.integration-mode-simulation, .integration-mode-badge.integration-mode-simulation { background-color: #ffc107; color: #212529; border-color: #212529; }
.integration-mode-off, .integration-mode-badge.integration-mode-off { background-color: #6c757d; color: #fff; border-color: #adb5bd; }
.integration-mode-misconfigured, .integration-mode-badge.integration-mode-misconfigured { background-color: #212529; color: #ffc107; border-color: #ffc107; }
.integration-banner { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; align-items: baseline; padding: 0.6rem 0.9rem; margin-bottom: 1rem; border-radius: 0.375rem; border: 2px solid; }
.integration-banner-mode { font-size: 1rem; }
.integration-banner-live { background-color: #f8d7da; border-color: #b02a37; color: #58151c; }
.integration-banner-live .integration-banner-mode strong { background-color: #b02a37; color: #fff; padding: 0.05rem 0.5rem; border-radius: 0.25rem; letter-spacing: 0.05em; }
.integration-banner-simulation { background-color: #fff3cd; border-color: #997404; color: #664d03; border-style: dashed; }
.integration-banner-off { background-color: #e9ecef; border-color: #6c757d; color: #343a40; border-style: dotted; }
.integration-banner-misconfigured { background-color: #212529; border-color: #ffc107; color: #fff; }
.integration-banner-host { margin-left: auto; }

/* Reports */
.report-card h2 a { text-decoration: none; }
.report-card:hover { border-color: #0d6efd; }
.report-notes summary { cursor: pointer; color: #495057; font-size: 0.875rem; }
.report-table th { white-space: normal; vertical-align: bottom; }
.report-table td.cell-wrap { min-width: 6rem; }
.report-totals th, .report-totals td { border-top: 2px solid #495057; font-weight: 600; background-color: #f8f9fa; }

/* Administration */
.settings-table td { vertical-align: top; }
.setting-number { width: 7rem; }
.status-edit > summary { cursor: pointer; list-style: revert; }
.confirm-cdac { padding: 0.5rem 0.75rem 0.5rem 2.25rem; border: 1px solid #f1aeb5; border-radius: 0.375rem; background-color: #f8d7da; }
.transition-matrix th, .transition-matrix td { font-size: 0.8rem; vertical-align: top; }
.transition-matrix .transition-cell { min-width: 7.5rem; }
.transition-matrix .transition-allowed { background-color: #e8f5e9; }
.transition-matrix .form-check { min-height: 1.1rem; margin-bottom: 0.1rem; }

/* ---------- Alerts ---------- */

/* The indicator of the top bar: on every page, for users who may see an alert kind (wwwroot/js/alerts.js keeps it current). */
.alert-indicator { flex: 0 0 auto; padding: 0.15rem 0.6rem; border-radius: 0.25rem; font-size: 0.85rem; white-space: nowrap; border: 2px solid transparent; text-decoration: none; }
.alert-indicator:hover, .alert-indicator:focus { text-decoration: underline; }
.alert-indicator-clear { background-color: #198754; color: #fff; border-color: #198754; }
.alert-indicator-open { background-color: #b02a37; color: #fff; border-color: #fff; font-weight: 600; animation: alert-indicator-pulse 1.6s ease-in-out infinite; }
.alert-indicator-acknowledged { background-color: #ffc107; color: #212529; border-color: #212529; }
.alert-indicator-unknown { background-color: #212529; color: #ffc107; border-color: #ffc107; font-weight: 600; }
/* No emergency is open, but notifications fail or the worker does not run: a colour of its own - neither the red of an
   emergency (people would get used to it) nor the green of "all clear". */
.alert-indicator-system { background-color: #6f42c1; color: #fff; border-color: #ffc107; font-weight: 600; }
.alert-indicator-system:hover { color: #fff; }
.surge-notice { padding: 0.4rem 0.6rem; border: 2px dashed currentColor; border-radius: 0.25rem; }
.alert-indicator-open:hover, .alert-indicator-clear:hover { color: #fff; }
.alert-indicator-acknowledged:hover { color: #212529; }
.alert-indicator-unknown:hover { color: #ffc107; }

@keyframes alert-indicator-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.75); }
  50% { box-shadow: 0 0 0 0.3rem rgba(255, 255, 255, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .alert-indicator-open { animation: none; }
}

/* The alarm panels at the top of the dashboard: deliberately unlike the ordinary notices of the page. */
.alarm-panel { margin-bottom: 1rem; border-radius: 0.375rem; color: #fff; border: 3px solid #212529; box-shadow: 0 0.25rem 0.6rem rgba(0, 0, 0, 0.25); }
.alarm-panel-open { background-color: #b02a37; }
.alarm-panel-acknowledged { background-color: #7a4b00; }
.alarm-panel-system { background-color: #212529; border-color: #ffc107; }
.alarm-panel-title { padding: 0.35rem 1rem; font-weight: 700; letter-spacing: 0.06em; font-size: 0.95rem; background-color: rgba(0, 0, 0, 0.25); }
.alarm-panel-body { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; font-size: 1.05rem; }
.alarm-panel-count { font-size: 2.2rem; font-weight: 700; line-height: 1; }

.delivery-content { white-space: pre-wrap; word-break: break-word; max-height: 18rem; overflow: auto; background-color: #f8f9fa; padding: 0.5rem; border: 1px solid #dee2e6; }
