/* ScanTrack — premium industrial enterprise UI */

:root {
  --navy-950: #02182b;
  --navy-900: #03233d;
  --navy-800: #073554;

  --blue-700: #005b9f;
  --blue-600: #0874bd;
  --blue-100: #eaf4fb;

  --page-bg: #f4f7fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;

  --border: #d7e0e9;
  --border-strong: #c4cfdb;

  --text-primary: #132238;
  --text-secondary: #526176;
  --text-muted: #7a8798;

  --success: #16834f;
  --success-bg: #e6f5ed;
  --warning: #e39712;
  --warning-bg: #fff4de;
  --danger: #d92d35;
  --danger-bg: #fdebec;
  --info: #0874bd;

  --radius-sm: 4px;
  --radius-md: 6px;

  --sidebar-width: 236px;
  --topbar-height: 48px;
  --shadow-soft: 0 1px 2px rgba(2, 24, 43, 0.06);
  --focus-ring: 0 0 0 3px rgba(8, 116, 189, 0.28);
}

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

html {
  font-size: 14px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text-primary);
  background: var(--page-bg);
  line-height: 1.45;
}

a {
  color: var(--blue-600);
  text-decoration: none;
}

a:hover,
a:focus {
  color: var(--blue-700);
  text-decoration: underline;
}

a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ===== App shell ===== */
.app-frame {
  display: flex;
  min-height: 100vh;
  align-items: stretch;
}

.app-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--page-bg);
}

/* Sidebar — deep navy */
.sidebar {
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  background: var(--navy-950);
  color: #d7e6f2;
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #fff;
}

.brand-sub {
  margin: 4px 0 0;
  font-size: 11px;
  color: #8fa6ba;
  letter-spacing: 0.02em;
}

.module {
  margin: 14px 10px 12px;
  background: transparent;
  border: none;
  border-radius: 0;
  overflow: visible;
}

.module-caption {
  margin: 0 8px 8px;
  padding: 0;
  background: transparent;
  color: #7f96ab;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

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

.module-list a {
  display: block;
  margin: 2px 0;
  padding: 9px 12px;
  color: #d5e4f0;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}

.module-list a:hover,
.module-list a:focus {
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
  text-decoration: none;
}

.module-list a.is-active {
  background: var(--blue-600);
  color: #fff;
  font-weight: 600;
}

/* Top bar */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: var(--topbar-height);
  padding: 0 20px;
  background: var(--navy-900);
  color: #fff;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.topbar-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  letter-spacing: 0.01em;
}

.user-tools {
  margin: 0;
  font-size: 12px;
  color: #c5d7e6;
  white-space: nowrap;
}

/* Breadcrumbs */
.breadcrumbs {
  padding: 8px 20px;
  background: var(--navy-800);
  color: #b7c9d8;
  font-size: 12px;
}

.breadcrumbs a {
  color: #cfe0ed;
}

.breadcrumbs a:hover,
.breadcrumbs a:focus {
  color: #fff;
}

.breadcrumbs .separator {
  margin: 0 0.4em;
  color: #7f96ab;
}

/* Content */
.content {
  flex: 1 1 auto;
  min-width: 0;
  padding: 16px 20px 28px;
  background: var(--page-bg);
}

.content h1 {
  margin: 0 0 14px;
  padding: 0 0 10px;
  font-size: 20px;
  font-weight: 650;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border);
}

.object-tools {
  margin: 0 0 12px;
  padding: 0;
  font-size: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.object-tools a {
  color: var(--blue-600);
}

/* Buttons */
.button-action,
.form-actions button,
.serial-search button {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--blue-600);
  border-radius: var(--radius-sm);
  background: var(--blue-600);
  color: #fff !important;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
  text-decoration: none !important;
  cursor: pointer;
}

.button-action:hover,
.button-action:focus,
.form-actions button:hover,
.serial-search button:hover {
  background: var(--blue-700);
  border-color: var(--blue-700);
  color: #fff !important;
}

.button-action:disabled,
.form-actions button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.button-secondary {
  display: inline-block;
  padding: 7px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary) !important;
  font-size: 12px;
  font-weight: 650;
  line-height: 1.3;
  text-decoration: none !important;
}

.button-secondary:hover,
.button-secondary:focus {
  background: var(--blue-100);
  border-color: #9fc4df;
  color: var(--blue-700) !important;
}

/* Messages */
.messages {
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.message {
  margin: 0 0 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
}

.message-success {
  background: var(--success-bg);
  border-color: #b5dfc6;
  color: var(--success);
}

.message-error {
  background: var(--danger-bg);
  border-color: #f0b7bb;
  color: var(--danger);
}

.message-warning {
  background: var(--warning-bg);
  border-color: #f0d39a;
  color: #9a6808;
}

.message-info {
  background: var(--blue-100);
  border-color: #b7d7ee;
  color: var(--blue-700);
}

/* Forms */
.form-intro {
  margin: 0 0 12px;
  color: var(--text-secondary);
  font-size: 13px;
}

.portal-form {
  max-width: 560px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.form-row {
  margin: 0 0 12px;
}

.form-row label {
  display: block;
  margin-bottom: 4px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.form-control,
.portal-form input[type="text"],
.portal-form input[type="date"],
.portal-form input[type="file"],
.portal-form select,
.portal-form textarea,
.compliance-filters select,
.compliance-filters input[type="text"],
.compliance-filters input[type="file"],
.serial-search input[type="text"] {
  width: 100%;
  box-sizing: border-box;
  min-height: 34px;
  padding: 7px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  font: inherit;
  font-size: 13px;
}

.portal-form textarea {
  min-height: 88px;
  resize: vertical;
}

.form-help {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 12px;
}

.form-errors {
  margin-top: 4px;
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
}

.form-errors ul {
  margin: 0;
  padding-left: 18px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

/* Tables */
.results-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.results {
  width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
}

.results thead th {
  padding: 8px 10px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border-strong);
  white-space: nowrap;
}

.results tbody td {
  padding: 7px 10px;
  font-size: 13px;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  color: var(--text-primary);
}

.results tbody tr:nth-child(even) {
  background: #fbfcfe;
}

.results tbody tr:hover {
  background: #f1f7fc;
}

.detail-table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.detail-table th,
.detail-table td {
  padding: 8px 10px;
  font-size: 13px;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.detail-table th {
  width: 200px;
  background: var(--surface-muted);
  color: var(--text-secondary);
  font-weight: 650;
  white-space: nowrap;
}

.detail-table tr:last-child th,
.detail-table tr:last-child td {
  border-bottom: none;
}

.empty {
  padding: 22px 16px;
  text-align: center;
  color: var(--text-secondary);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.empty strong {
  display: block;
  margin-bottom: 4px;
  color: var(--text-primary);
  font-size: 14px;
}

/* Dashboard tabs */
.dash-tabs {
  display: flex;
  gap: 0;
  margin: 0 0 12px;
  border-bottom: 1px solid var(--border-strong);
}

.dash-tab {
  display: inline-block;
  padding: 7px 14px;
  margin-bottom: -1px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-secondary);
  background: var(--surface-muted);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.dash-tab.is-active {
  color: var(--blue-700);
  background: var(--surface);
  border-bottom: 1px solid var(--surface);
}

.dash-tab.is-disabled {
  color: var(--text-muted);
  background: var(--surface-muted);
  cursor: not-allowed;
  opacity: 0.75;
}

/* Equipment matrix */
.matrix-wrap {
  width: 100%;
  max-height: calc(100vh - 260px);
  overflow: auto;
  margin-bottom: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.matrix {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
}

.matrix th,
.matrix td {
  padding: 10px 12px;
  font-size: 12px;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid #edf2f7;
  white-space: nowrap;
  background-clip: padding-box;
}

.matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #e8eef5;
  color: var(--text-secondary);
  font-weight: 700;
  border-bottom: 1px solid var(--border-strong);
  box-shadow: 0 1px 0 var(--border-strong);
}

.matrix tbody th,
.matrix .matrix-corner {
  position: sticky;
  left: 0;
  z-index: 2;
  text-align: left;
  background: var(--surface-muted);
  color: var(--text-primary);
  font-weight: 600;
  border-right: 1px solid var(--border-strong);
  min-width: 140px;
}

.matrix thead .matrix-corner {
  z-index: 4;
  background: #e8eef5;
}

.matrix-empty {
  text-align: left !important;
  color: var(--text-secondary);
  background: var(--surface-muted);
}

.overall-row th,
.overall-row td {
  background: #e7eef6;
  font-weight: 700;
  border-top: 2px solid #9eb3c2;
  border-bottom: 2px solid #9eb3c2;
}

.overall-row th {
  background: #dfe8ef;
  z-index: 2;
}

.project-row th,
.project-row td {
  background: #eaf3f8;
  border-top: 2px solid #9db8c9;
}

.project-row th {
  background: #dceaf2;
  font-weight: 700;
}

.project-row[aria-expanded="true"] th,
.project-row[aria-expanded="true"] td {
  background: #d7e8f2;
}

.project-row[aria-expanded="true"] th {
  background: #c9deeb;
}

.matrix-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.matrix-toggle:hover .matrix-project-label,
.matrix-toggle:focus .matrix-project-label {
  text-decoration: underline;
}

.matrix-toggle-icon {
  display: inline-block;
  width: 1em;
  color: var(--blue-600);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}

.matrix-project-label {
  font-weight: 700;
}

.location-row th,
.location-row td {
  background: #fff;
  font-weight: 400;
  font-size: 12px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.location-row.is-alt th,
.location-row.is-alt td {
  background: #f7f9fb;
}

.location-row:hover th,
.location-row:hover td {
  background: #eaf4fb;
}

.location-row th {
  font-weight: 400;
}

.location-row.is-last-location th,
.location-row.is-last-location td {
  border-bottom: 10px solid var(--page-bg);
}

.matrix-location-label {
  position: relative;
  display: inline-block;
  padding-left: 28px;
  color: var(--blue-600);
  font-weight: 400;
  text-decoration: none;
}

.matrix-location-label:hover,
.matrix-location-label:focus {
  color: var(--blue-700);
  text-decoration: underline;
}

.matrix-location-label::before {
  content: "";
  position: absolute;
  left: 10px;
  top: -8px;
  bottom: -8px;
  width: 2px;
  background: #b7c5d0;
  border-radius: 1px;
}

.matrix-location-label::after {
  content: "";
  position: absolute;
  left: 10px;
  top: 50%;
  width: 10px;
  height: 2px;
  background: #b7c5d0;
}

.location-row[hidden] {
  display: none;
}

/* A location's comment, e.g. the well a BARS stands at; long ones are cut. */
.matrix-location-comment {
  display: inline-block;
  max-width: 16ch;
  margin-left: 6px;
  overflow: hidden;
  color: var(--text-secondary);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}

.location-comment-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: -6px 0 16px;
  font-size: 13px;
}

.location-comment-form input {
  flex: 1 1 220px;
  max-width: 360px;
}

.location-project-meta {
  margin: -4px 0 16px;
  color: var(--text-secondary);
  font-size: 13px;
}

.section-title {
  margin: 18px 0 10px;
  padding: 0;
  font-size: 15px;
  font-weight: 650;
  color: var(--text-primary);
}

.location-summary-wrap {
  width: 100%;
  overflow-x: auto;
  margin-bottom: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.location-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0;
}

.location-category-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 78px;
  padding: 12px 10px;
  border-right: 1px solid #edf1f4;
  border-bottom: 1px solid #edf1f4;
  background: var(--surface-muted);
  color: var(--text-secondary);
  text-decoration: none;
  text-align: center;
  cursor: pointer;
}

.location-category-card:hover,
.location-category-card:focus {
  background: var(--blue-100);
  color: var(--text-primary);
  text-decoration: none;
}

.location-category-card.is-selected {
  background: #d8ebf8;
  box-shadow: inset 0 0 0 2px var(--blue-600);
  color: var(--text-primary);
  font-weight: 600;
}

.location-category-name {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
}

.pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 12px;
}

.pagination-status {
  color: var(--text-secondary);
}

/* Panels / KPI */
.dashboard-alerts-panel,
.equipment-tests-panel,
.compliance-filters,
.compliance-chart-card,
.compliance-card,
.history-panel,
.serial-search {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}

.bars-transfer-actions {
  margin: 0 0 16px;
  gap: 10px;
}

.bars-transfer-actions .bars-transfer-action {
  min-height: 44px;
  padding: 12px 18px;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 900px) {
  .bars-transfer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .bars-transfer-actions .bars-transfer-action {
    width: 100%;
    text-align: center;
  }
}

.dashboard-alerts-panel {
  margin: 0 0 16px;
  padding: 12px 14px;
}

.dashboard-alerts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.dashboard-alerts-header .section-title {
  margin: 0;
}

/* Home dashboard Compliance and Status donuts (inventory/_donut.html). Each
   panel lays itself out by its own width: side by side when there is room,
   a smaller ring in a narrow panel. Every figure is also in the legend. */
.home-charts {
  container-type: inline-size;
  margin: 0 0 16px;
}

.home-charts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

@container (min-width: 760px) {
  .home-charts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.home-charts .chart-panel {
  margin: 0;
  display: flex;
  flex-direction: column;
  container-type: inline-size;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 10px;
  margin-bottom: 10px;
}

.chart-head h2 {
  margin: 0;
  font-size: 16px;
}

.chart-total {
  margin-left: 8px;
  color: #5b6573;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
}

.chart-head a {
  font-size: 12px;
}

.donut-body {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.donut-ring {
  position: relative;
  flex: none;
  width: 132px;
  height: 132px;
}

/* The ring starts at twelve o'clock and runs clockwise. */
.donut-ring svg {
  display: block;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-ring circle {
  fill: none;
  stroke-width: 7;
}

.donut-track {
  stroke: #e9edf1;
}

.donut-slice {
  stroke: var(--slice);
}

.donut-total {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  line-height: 1.15;
  pointer-events: none;
}

.donut-total strong {
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.donut-total span {
  color: #5b6573;
  font-size: 11px;
}

.donut-legend {
  flex: 0 1 300px;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.donut-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) 3em 3.6em;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
  color: inherit;
  font-size: 13px;
  white-space: nowrap;
  text-decoration: none;
}

a.donut-row:hover {
  background: var(--surface-muted);
  text-decoration: none;
}

a.donut-row:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.donut-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--slice);
}

.donut-name {
  min-width: 0;
}

.donut-count,
.donut-percent {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.donut-count {
  font-weight: 700;
}

.donut-percent {
  color: #5b6573;
}

.donut-row.is-zero,
.donut-row.is-zero .donut-count,
.donut-row.is-zero .donut-percent {
  color: #9aa3ad;
  font-weight: 400;
}

/* A phone-sized panel: a smaller ring beside the legend. */
@container (max-width: 420px) {
  .donut-ring {
    width: 96px;
    height: 96px;
  }

  .donut-body {
    gap: 12px;
  }

  .donut-total strong {
    font-size: 17px;
  }

  /* The figures take only the width they need, and a name that still does
     not fit takes a second line: it is never cut. */
  .donut-row {
    grid-template-columns: 10px minmax(0, 1fr) auto 3.3em;
    gap: 6px;
    white-space: normal;
  }
}

/* Slice colours, checked for normal vision and colour blindness. */
.donut-overdue { --slice: #9e1f1f; }
.donut-due_today { --slice: #e56a2c; }
.donut-due_soon { --slice: #f7c948; }
.donut-missing { --slice: #aab2bb; }
.donut-compliant { --slice: #0ca30c; }
.donut-in_use { --slice: #008300; }
.donut-reserve { --slice: #2a78d6; }
.donut-under_repair { --slice: #eb6834; }
.donut-in_transit { --slice: #6250d6; }
.donut-rented { --slice: #1baf7a; }
.donut-written_off { --slice: #aab2bb; }

.equipment-tests-panel {
  margin: 18px 0 20px;
  padding: 12px 14px;
}

.equipment-tests-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.equipment-tests-header .section-title {
  margin: 0;
}

.equipment-tests-meta {
  margin: 0;
}

.alert-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.alert-summary-grid-compact {
  margin-bottom: 0;
}

.ba-alerts-section {
  margin-top: 28px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.ba-alerts-title {
  margin-top: 12px;
}

.ba-alerts-subtitle {
  margin-top: 22px;
}

.compliance-lead {
  margin: 0 0 14px;
  color: var(--text-secondary);
}

.compliance-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 16px;
}

.compliance-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin: 0 0 16px;
  padding: 12px;
}

.compliance-filter-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 180px;
  flex: 1 1 180px;
}

.compliance-filter-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.compliance-filter-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

/* Text boxes and dropdowns line up at exactly the same height. */
.compliance-filters select,
.compliance-filters input[type="text"] {
  height: 35px;
}

/* Equipment list: the filters in even columns, then one row with Apply,
   Reset and a compact Sort by beside them. */
#equipment-filters {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

#equipment-filters .compliance-filter-field {
  min-width: 0;
}

#equipment-filters .compliance-filter-actions {
  grid-column: 1 / -1;
}

.equipment-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 8px;
}

.compliance-filters .equipment-sort select {
  width: auto;
}

.results-count {
  margin: 0 0 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Equipment list: the working status as a coloured label (Write off keeps
   the grey default), centered in its column. */
.results .status-cell {
  text-align: center;
}

.status-label {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #eef1f4;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-in_use { background: var(--success-bg); color: var(--success); }
.status-reserve { background: var(--blue-100); color: var(--blue-600); }
.status-under_repair { background: #f1ebf8; color: #6b3fa0; }
.status-rented { background: #e2f4f2; color: #0f766e; }
.status-in_transit { background: #eaedf8; color: #3f51b5; }

/* Equipment list rows with a compliance problem get a soft warm tint: rose
   when overdue or failed, amber when due within 30 days. The reason is the
   row's title. */
.results tbody tr.compliance-overdue { background: #fdf0ee; }
.results tbody tr.compliance-overdue:hover { background: #fae2de; }
.results tbody tr.compliance-due-soon { background: #fff6e5; }
.results tbody tr.compliance-due-soon:hover { background: #ffedcc; }

@media (max-width: 1280px) {
  #equipment-filters {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  #equipment-filters {
    grid-template-columns: minmax(0, 1fr);
  }
}

.compliance-tab {
  display: inline-block;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.compliance-tab:hover {
  background: var(--blue-100);
  text-decoration: none;
}

.compliance-tab.is-active {
  background: var(--blue-600);
  border-color: var(--blue-600);
  color: #fff;
}

.compliance-analytics {
  margin-bottom: 18px;
}

.compliance-charts {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.compliance-chart-card {
  padding: 12px;
}

.compliance-chart-card .section-title {
  margin: 0 0 8px;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 11px;
  color: var(--text-secondary);
}

.chart-legend-item::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: -1px;
  background: currentColor;
}

.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  min-height: 140px;
}

.bar-chart-group {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.bar-chart-bars {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  width: 100%;
  height: 110px;
}

.bar-chart-bar {
  flex: 1 1 0;
  min-width: 8px;
  max-width: 28px;
  height: calc(var(--bar-value, 0) * 1%);
  min-height: 2px;
  border-radius: 3px 3px 0 0;
  position: relative;
  background: #9db8c9;
}

.bar-chart-value {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: var(--text-secondary);
}

.bar-chart-label {
  font-size: 10px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.2;
}

.chart-series-inspection,
.chart-series-inspection::before {
  color: var(--blue-700);
  background: var(--blue-600);
}

.chart-series-hydrotest,
.chart-series-hydrotest::before {
  color: #b35c00;
  background: var(--warning);
}

.chart-series-posicheck,
.chart-series-posicheck::before {
  color: var(--blue-700);
  background: #5ea0c8;
}

.chart-series-service,
.chart-series-service::before {
  color: #2f6b5f;
  background: #4f9d8f;
}

.chart-status-compliant { background: #5fad7f; }
.chart-status-due_soon { background: var(--warning); }
.chart-status-overdue { background: #e07278; }
.chart-status-missing { background: #a0aab6; }

.compliance-cell-critical {
  color: var(--danger);
  font-weight: 700;
}

.compliance-cell-urgent {
  color: #b35c00;
  font-weight: 700;
}

.compliance-cell-soon {
  color: #8a6d1d;
  font-weight: 600;
}

.compliance-cell-ok {
  color: var(--success);
}

.alert-pill.compliance-level-missing,
.alert-pill.compliance-level-failed,
.alert-pill.compliance-level-overdue {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-pill.compliance-level-due_today {
  background: #ffe0c2;
  color: #b35c00;
}

.alert-pill.compliance-level-due_soon {
  background: var(--warning-bg);
  color: #8a6d1d;
}

.alert-pill.compliance-level-compliant {
  background: var(--success-bg);
  color: var(--success);
}

.muted {
  color: var(--text-muted);
  font-size: 12px;
}

.alert-summary-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.alert-summary-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.alert-summary-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text-primary);
}

.alert-summary-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.alert-critical {
  background: var(--danger-bg);
  border-color: #f0b7bb;
}

.alert-critical .alert-summary-value {
  color: var(--danger);
}

.alert-due-7 {
  background: #ffeee0;
  border-color: #f0b27a;
}

.alert-due-7 .alert-summary-value {
  color: #b35c00;
}

.alert-due-14 {
  background: var(--warning-bg);
  border-color: #e6c86a;
}

.alert-due-14 .alert-summary-value {
  color: #8a6d1d;
}

.alert-due-30 {
  background: var(--blue-100);
  border-color: #9db8c9;
}

.alert-due-30 .alert-summary-value {
  color: var(--blue-700);
}

/* No record entered yet: needs doing, but not alarming like Overdue. */
.alert-missing {
  background: var(--surface-muted);
  border-color: var(--border-strong);
}

.alert-missing .alert-summary-value {
  color: var(--text-secondary);
}

/* A card that filters the list below it. */
a.alert-summary-link {
  color: inherit;
  text-decoration: none;
}

a.alert-summary-link:hover {
  border-color: var(--blue-600);
}

a.alert-summary-link:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

a.alert-summary-link.is-active {
  border-color: var(--navy-800);
  box-shadow: inset 0 0 0 1px var(--navy-800);
}

.compliance-summary-wrap {
  margin-bottom: 16px;
}

.compliance-summary th[scope="row"] {
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.compliance-summary thead th:not(:first-child),
.compliance-summary td {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.compliance-summary tfoot th,
.compliance-summary tfoot td {
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
  background: var(--surface-muted);
}

.compliance-level-note {
  margin: 0 0 10px;
  color: var(--text-secondary);
}

/* On a phone the whole summary fits without scrolling sideways, and the
   four cards sit two by two. */
@media (max-width: 600px) {
  .compliance-summary thead th {
    white-space: normal;
    vertical-align: bottom;
  }

  .compliance-summary thead th,
  .compliance-summary th[scope="row"],
  .compliance-summary tbody td,
  .compliance-summary tfoot td {
    padding: 6px 4px;
    font-size: 12px;
  }

  .compliance-summary thead th {
    font-size: 10px;
    letter-spacing: 0;
  }

  .compliance-summary th[scope="row"] {
    white-space: normal;
  }

  .compliance-analytics .alert-summary-grid,
  .dashboard-alerts-panel .alert-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.alert-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.alert-level-missing,
.alert-level-failed,
.alert-level-overdue,
.alert-level-due_today {
  background: var(--danger-bg);
  color: var(--danger);
}

.alert-level-due_7 {
  background: #ffe0c2;
  color: #b35c00;
}

.alert-level-due_14 {
  background: var(--warning-bg);
  color: #8a6d1d;
}

.alert-level-due_30 {
  background: var(--blue-100);
  color: var(--blue-700);
}

.alerts-table td,
.alerts-table th {
  white-space: nowrap;
}

.equipment-hero {
  margin-bottom: 8px;
}

.equipment-summary {
  margin-bottom: 8px;
}

.qr-identification-panel {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface, #fff);
}

.qr-identification-grid {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 16px;
  align-items: start;
}

.qr-identification-image img {
  display: block;
  width: 180px;
  height: 180px;
  border: 1px solid var(--border);
  background: #fff;
}

.qr-payload-code {
  font-size: 12px;
  word-break: break-all;
}

.qr-identification-actions {
  margin-top: 10px;
}

.send-scan-panel,
.send-equipment-list-panel {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface, #fff);
}

.qr-reader {
  max-width: 420px;
  margin: 10px 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #000;
}

.manual-qr-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.manual-qr-row .form-control {
  flex: 1 1 240px;
}

.send-equipment-table {
  width: 100%;
}

/* .portal-form is 560px, which suits the single-column forms that share the
   class but is tight for this table's four columns. Widened only on the
   pages that actually contain the table, so login and the other portal
   forms keep their width. Browsers without :has() simply keep 560px. */
.portal-form:has(.send-equipment-table) {
  max-width: 900px;
}

/* .alerts-table sets no padding, so these cells fell back to the browser
   default and columns ran into each other. */
.send-equipment-table th,
.send-equipment-table td {
  padding: 8px 12px;
}

/* Overrides the blanket nowrap .alerts-table sets: these rows carry long
   category/model and location strings that pushed the row past the 560px
   .portal-form and out through the panel border. Same specificity as the
   .alerts-table rule, so this must stay below it to win.
   break-word rather than anywhere: anywhere also shrinks the column's
   intrinsic minimum, which let the browser split serials and headings
   mid-word. */
.send-equipment-table td {
  white-space: normal;
  overflow-wrap: break-word;
}

/* Column headings and the action button are short labels that read badly
   when split, so they keep their line and the button column sizes to fit. */
.send-equipment-table th,
.send-equipment-table td:last-child {
  white-space: nowrap;
}

.send-equipment-table td:last-child {
  width: 1%;
}

.send-equipment-table td {
  vertical-align: middle;
}

.receive-scan-counter {
  margin: 0 0 14px;
  font-size: 14px;
}

@media (max-width: 900px) {
  .qr-identification-grid {
    grid-template-columns: 1fr;
  }
}

/* Status badges */
.status-pill {
  display: inline-block;
  min-width: 4.5em;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.status-working {
  background: var(--blue-100);
  color: var(--blue-700);
}

.status-present,
.status-valid,
.status-green {
  background: var(--success-bg);
  color: var(--success);
}

.status-due_soon,
.status-yellow {
  background: var(--warning-bg);
  color: #9a6808;
}

.status-missing,
.status-expired,
.status-failed,
.status-red {
  background: var(--danger-bg);
  color: var(--danger);
}

.status-not_required,
.status-gray {
  background: #eceff1;
  color: #607078;
}

.compliance-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.compliance-grid-ba {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compliance-card {
  overflow: hidden;
}

.compliance-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--blue-100);
  border-bottom: 1px solid var(--border);
}

.compliance-card-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy-800);
}

.compliance-meta {
  margin: 0;
  padding: 10px 12px 12px;
}

.compliance-meta > div {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid #f0f3f5;
  font-size: 13px;
}

.compliance-meta > div:last-child {
  border-bottom: none;
}

.compliance-meta dt {
  margin: 0;
  color: var(--text-muted);
  font-weight: 600;
}

.compliance-meta dd {
  margin: 0;
  color: var(--text-primary);
}

.text-missing {
  color: var(--danger);
  font-weight: 700;
}

.history-panel {
  margin: 0 0 14px;
}

.history-panel > summary {
  cursor: pointer;
  padding: 10px 12px;
  background: var(--blue-100);
  color: var(--navy-800);
  font-size: 14px;
  font-weight: 700;
  list-style: none;
}

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

.history-panel > summary::before {
  content: "▶";
  display: inline-block;
  width: 1.2em;
  margin-right: 6px;
  color: var(--blue-600);
  font-size: 10px;
}

.history-panel[open] > summary::before {
  content: "▼";
}

.manage-block {
  max-width: 560px;
}

.manage-block > .portal-form > .form-help:first-child {
  margin-bottom: 12px;
}

.manage-block > .portal-form {
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}

.history-panel .results,
.history-panel .empty {
  margin: 0;
  border: none;
  border-top: 1px solid var(--border);
  border-radius: 0;
  box-shadow: none;
}

.count-badge {
  display: inline-block;
  min-width: 1.75em;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: var(--success);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
}

.zero-count {
  display: inline-block;
  min-width: 1.75em;
  color: #9aa4ad;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
}

.serial-search {
  max-width: 480px;
  padding: 12px;
}

/* Send/Receive on the left, Find equipment on the right. */
.dashboard-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
}

.dashboard-toolbar .bars-transfer-actions {
  margin: 0;
}

.dashboard-toolbar .serial-search {
  flex: 1 1 360px;
  margin-left: auto;
}

.serial-search-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-secondary);
}

.serial-search-row {
  display: flex;
  gap: 8px;
}

/* Wraps the input so the suggestions can sit right under it. */
.serial-search-field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.serial-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 320px;
  overflow-y: auto;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: 0 6px 16px rgba(2, 24, 43, 0.12);
}

.serial-suggestion,
.serial-suggestion-empty {
  display: flex;
  flex-direction: column;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text-secondary);
}

.serial-suggestion {
  cursor: pointer;
}

.serial-suggestion.is-active,
.serial-suggestion:hover {
  background: var(--blue-100);
}

.serial-suggestion-serial {
  font-size: 14px;
  font-weight: 650;
  color: var(--text-primary);
}

.serial-search-error {
  margin: 8px 0 0;
  color: var(--danger);
  font-size: 12px;
  font-weight: 600;
}

/* Keep legacy .app-shell if referenced */
.app-shell {
  display: contents;
}

/* Responsive */
@media (max-width: 900px) {
  .app-frame {
    flex-direction: column;
  }

  .sidebar {
    flex: none;
    width: 100%;
    border-right: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .sidebar-brand {
    padding: 14px 16px 10px;
  }

  .module {
    margin: 8px 8px 12px;
  }

  .module-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .module-list li {
    flex: 1 1 auto;
  }

  .module-list a {
    text-align: center;
  }

  .content {
    padding: 14px 14px 24px;
  }

  .results,
  .alerts-table,
  .detail-table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
  }

  .compliance-charts {
    grid-template-columns: 1fr;
  }

  .compliance-grid,
  .compliance-grid-ba {
    grid-template-columns: 1fr;
  }

  .compliance-meta > div {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .alert-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-table th {
    width: 140px;
  }
}

.badge-exception {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 600;
  color: #7a3b00;
  background: #ffe8cc;
  border: 1px solid #e0a85c;
  border-radius: 3px;
  vertical-align: middle;
}

@media (max-width: 600px) {
  .header {
    flex-wrap: wrap;
    padding: 10px 12px;
    min-height: auto;
  }

  .breadcrumbs {
    padding: 8px 12px;
  }

  .brand {
    font-size: 15px;
  }

  .content h1 {
    font-size: 18px;
  }

  .alert-summary-grid {
    grid-template-columns: 1fr;
  }
}

.posicheck-drop {
  flex: 2 1 240px;
  padding: 10px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.posicheck-drop.is-over {
  border-color: var(--blue-600);
  background: var(--blue-100);
}

.posicheck-drop.is-disabled {
  opacity: 0.6;
}

.posicheck-remove {
  padding: 0 6px;
  border: 0;
  background: none;
  color: var(--danger);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.posicheck-remove:disabled {
  opacity: 0.4;
  cursor: default;
}

.form-warning {
  margin: 6px 0 0;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--warning-bg);
  color: #7a4d00;
  font-size: 13px;
}

/* A POST form on its way (submit_once.js): its buttons look busy. */
form.is-submitting button[type="submit"],
form.is-submitting input[type="submit"] {
  opacity: 0.6;
  cursor: progress;
}
