/* ============================================================================
   AIRGRADIENT MONITORING — STYLESHEET (adapted from the eLibrary stylesheet)
   Component groups:
     1. Tokens & reset         7. Buttons                 14. Tables
     2. Typography             8. Forms & controls        15. Info grid & stats
     3. Layout                 9. Cards & sections        16. Pagination
     4. Site header & logo    10. Page header & actions   17. Login / error pages
     5. Side navigation       11. Search & results        18. Utilities
     6. Bottom navigation     13. Status & badges         21. Mobile side nav
                                                          22. Responsive

   Rules of thumb
   - Base styles live in their component section; every @media rule lives in
     section 22 so the cascade order stays predictable.
   - Colours, sizes and fixed heights that repeat are tokens in section 1.
   ============================================================================ */


/* 1. TOKENS & RESET ------------------------------------------------------- */
:root {
  /* brand */
  --header-color: #1555A1;
  --header-color-hover: #12498b;
  --header-color-dark: #0D3361;

  /* surfaces & text */
  --white: #ffffff;
  --background-color: #ffffff;
  --surface-muted: #f5f7fa;
  --text-color: #222222;
  --text-strong: #333333;
  --text-body: #444444;
  --text-muted: #666666;
  --text-subtle: #777777;

  /* borders */
  --border-color: #cccccc;
  --border-light: #dddddd;
  --border-row: #eeeeee;

  /* status colours */
  --danger: #c62828;
  --danger-hover: #a82121;
  --danger-bg: #fff4f4;
  --danger-border: #e0a0a0;
  --success: #2e7d4f;
  --success-bg: #eef7f1;
  --success-dot: #2e8b57;
  --info: #1565c0;
  --info-bg: #eef4fc;
  --info-border: #b3cdeb;
  --warning: #b45309;
  --dot-idle: #999999;

  /* side nav & bottom tabs */
  --side-nav-width: 190px;
  --side-nav-text: #333333;
  --side-nav-hover: #E8F1FB;
  --tab-color: #444444;
  --tab-hover-color: #666666;
  --tab-active-color: #222222;

  /* sizes */
  --header-height: 105px;
  --bottom-nav-height: 38px;
  --btn-uniform-width: 130px;
  --radius: 4px;
  --radius-lg: 6px;

  /* text size for every input / select / textarea (raised on touch devices) */
  --control-font-size: 10px;

  /* effects */
  --focus-ring: 0 0 0 2px rgba(21, 85, 161, 0.12);
  --animation-speed: 120ms;
}

/* set by script on phones / tablets: slightly larger control text */
:root.is-touch { --control-font-size: 12px; }

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; min-height: 100%; }

body {
  padding-bottom: var(--bottom-nav-height);
  background-color: var(--background-color);
  color: var(--text-color);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 11px;
}


/* 2. TYPOGRAPHY ----------------------------------------------------------- */
h1, h2, h3, h4, p { font-family: Arial, Helvetica, sans-serif; }
h1 { margin: 0 0 8px; font-size: 15px; line-height: 20px; }
h2 { margin: 0 0 8px; font-size: 14px; line-height: 18px; }
h3 { margin: 0 0 6px; font-size: 13px; line-height: 16px; }
h4 { margin: 0 0 5px; font-size: 12px; line-height: 15px; }
p  { margin: 0 0 8px; font-size: 11px; line-height: 15px; }
label { font-size: 11px; line-height: 14px; }
strong { color: var(--text-strong); }

/* form controls share one size token; buttons keep their own sizes */
input, select, textarea { font-family: inherit; font-size: var(--control-font-size); }
button { font-family: inherit; font-size: 10px; }

/* controls can shrink inside flex/grid containers instead of overflowing, and
   long placeholders / select values get an ellipsis instead of being clipped */
input, select, textarea { min-width: 0; max-width: 100%; }
input, input::placeholder, select { text-overflow: ellipsis; }

.page-title { margin: 0 0 5px; color: var(--header-color); font-size: 15px; font-weight: 600; line-height: 20px; }
.text-muted { color: var(--text-muted); }
.text-small { font-size: 10px; line-height: 13px; }
.text-italic { font-style: italic; }


/* 3. LAYOUT --------------------------------------------------------------- */
.page-layout { display: flex; width: 100%; min-height: calc(100vh - var(--header-height)); }

.site-content {
  flex: 1;
  min-width: 0;
  min-height: calc(100vh - var(--header-height) - var(--bottom-nav-height));
  padding: 20px;
  font-size: 11px;
  line-height: 15px;
}

.page { width: 100%; max-width: 1100px; margin: 0 auto; }


/* 4. SITE HEADER & LOGO --------------------------------------------------- */
.site-header {
  width: 100%;
  height: var(--header-height);
  overflow: hidden;
  background-image: url("../images/header.png");
  background-repeat: no-repeat;
  background-position: left top;
  background-size: 100% 110px;
}

.header-inner { display: flex; align-items: center; width: 100%; height: var(--header-height); padding: 0 10px; }

.site-logo { display: flex; align-items: center; height: 100%; color: var(--white); text-decoration: none; }
.site-logo img { display: block; flex-shrink: 0; width: auto; max-width: 120px; height: 95px; }
.site-logo-text { display: flex; align-items: center; margin-left: 10px; color: var(--white); font-size: 35px; font-weight: 600; line-height: 1; }


/* 5. SIDE NAVIGATION -------------------------------------------- */
.side-nav {
  flex-shrink: 0;
  width: var(--side-nav-width);
  overflow-y: auto;
  background: var(--white);
  border-right: 1px solid var(--border-color);
  font-size: 11px;
}

.nav-section { margin-bottom: 7px; }
.nav-section-title { padding: 3px 7px; color: var(--header-color); font-size: 11px; font-weight: bold; line-height: 13px; }

.side-nav-item {
  display: block;
  width: 100%;
  padding: 5px 10px;
  color: var(--side-nav-text);
  font-size: 11px;
  line-height: 13px;
  text-decoration: none;
  border-left: 4px solid transparent;
  transition: background-color var(--animation-speed) ease, color var(--animation-speed) ease;
}
.side-nav-item:hover { background-color: var(--side-nav-hover); color: #000000; }
.side-nav-item.active,
.side-nav-item.active:hover {
  background-color: var(--header-color);
  color: var(--white);
  font-weight: bold;
  border-left-color: var(--header-color);
}

/* 6. BOTTOM NAVIGATION ---------------------------------------------------- */
.bottom-nav { position: fixed; left: 0; bottom: 0; z-index: 1000; width: 100%; pointer-events: none; }
.bottom-nav-inner { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 2px; width: 100%; padding: 0 4px; }

.bottom-tab {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 5px 9px;
  background: var(--tab-color);
  color: var(--white);
  font-size: 10px;
  font-weight: bold;
  line-height: 12px;
  text-decoration: underline;
  white-space: nowrap;
  border-radius: 5px 5px 0 0;
  pointer-events: auto;
  transition: transform var(--animation-speed) ease,
              background-color var(--animation-speed) ease,
              padding var(--animation-speed) ease;
}
.bottom-tab:hover { padding-left: 11px; padding-right: 11px; background: var(--tab-hover-color); transform: translateY(-5px); }
.bottom-tab:active { background: var(--tab-active-color); transform: translateY(-2px); }


/* 7. BUTTONS -------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 16px;
  font-size: 10px;
  font-weight: 600;
  line-height: 13px;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* colour variants */
.btn-primary { background: var(--header-color); border-color: var(--header-color); color: var(--white); }
.btn-primary:hover { background: var(--header-color-hover); border-color: var(--header-color-hover); }
.btn-secondary { background: var(--white); border-color: #bdbdbd; color: var(--text-body); }
.btn-secondary:hover { background: #f5f5f5; border-color: var(--dot-idle); color: var(--text-color); }
.btn-dark { background: var(--tab-color); border-color: var(--tab-color); color: var(--white); }
.btn-dark:hover { background: var(--text-color); border-color: var(--text-color); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--white); }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }

/* size variants (must follow .btn so they win at equal specificity) */
.btn-sm { min-height: 28px; padding: 0 12px; }
.btn-lg { min-height: 40px; padding: 0 20px; }
.btn-block { display: flex; width: 100%; }
.btn-uniform { width: var(--btn-uniform-width); min-height: 36px; padding: 0 8px; }


/* 8. FORMS & CONTROLS ----------------------------------------------------- */
.form-control,
.form-input,
.form-group :is(input, select, textarea):not([type="checkbox"], [type="radio"], [type="file"]) {
  display: block;
  width: 100%;
  height: 36px;
  padding: 0 11px;
  background: var(--white);
  color: var(--text-color);
  font-size: var(--control-font-size);
  line-height: 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
}
.form-control:focus,
.form-input:focus,
.form-group :is(input, select, textarea):focus {
  outline: none;
  border-color: var(--header-color);
  box-shadow: var(--focus-ring);
}
.form-control::placeholder { color: var(--dot-idle); }
select.form-control { cursor: pointer; }
textarea.form-control,
.form-group textarea { height: auto; min-height: 90px; padding: 10px 11px; resize: vertical; }
input[type="file"].form-control { height: auto; padding: 8px; }
.form-control--grow { flex: 1; width: auto; min-width: 0; }
.form-control--md { width: 280px; }

.form-label,
.form-group label { display: block; margin-bottom: 7px; color: var(--text-strong); font-size: 11px; font-weight: 600; line-height: 14px; }

.form-group { display: flex; flex-direction: column; margin-bottom: 0; }
.form-group-full { grid-column: 1 / -1; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.card > form > .form-group,
.card > .form-group { margin-bottom: 18px; }

.inline-form { display: flex; align-items: flex-end; gap: 10px; }
.inline-form--center { align-items: center; }
.inline-form .form-label { margin: 0; }
.card > .inline-form > .form-group { margin-bottom: 0; }

.form-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border-light);
}

.help-text { margin-bottom: 8px; font-size: 10px; line-height: 14px; }
.checkbox-row { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.checkbox-row input { width: 14px; height: 14px; margin: 0; }
.checkbox-row label { display: inline; margin: 0; font-size: 10px; font-weight: normal; }

.field-error,
.errorlist { margin: 5px 0 0; padding: 0; color: var(--danger); font-size: 10px; line-height: 13px; list-style: none; }

.alert { margin-bottom: 18px; padding: 10px 12px; font-size: 10px; line-height: 14px; border: 1px solid; border-radius: var(--radius); }
.alert--error { background: var(--danger-bg); border-color: var(--danger-border); color: #8a2020; }
.alert--info { background: var(--info-bg); border-color: var(--info-border); color: #0d47a1; }
.alert--success { background: var(--success-bg); border-color: #a5d6a7; color: var(--success); }
.alert--warning { background: #fff8e1; border-color: #f0d28a; color: var(--warning); }
.alert--spaced { margin: 15px 0 0; }
.alert .errorlist { margin: 0; color: inherit; }


/* 9. CARDS & SECTIONS ----------------------------------------------------- */
.card {
  width: 100%;
  margin-bottom: 20px;
  padding: 25px;
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}
.card:last-child { margin-bottom: 0; }
.card--compact { padding: 18px 20px; }
.card--split { display: grid; grid-template-columns: 1fr 220px; gap: 30px; }
.card--active { background: #f8fbff; border-color: #c9dcef; }
.card-side { display: flex; align-items: flex-start; justify-content: center; }

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-light);
}
.card-header-actions { display: flex; align-items: center; flex-shrink: 0; gap: 8px; }
.card-title { margin: 0 0 4px; color: var(--text-strong); font-size: 14px; font-weight: 600; line-height: 18px; }
.card-header .text-muted { margin: 0; font-size: 10px; line-height: 14px; }

.section { margin-bottom: 25px; }
.section:last-child { margin-bottom: 0; }
.section-title {
  margin: 0 0 12px;
  padding-bottom: 8px;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 600;
  line-height: 16px;
  border-bottom: 1px solid var(--border-light);
}
.section-title--plain { padding-bottom: 0; font-size: 14px; line-height: 18px; border-bottom: 0; }

.detail-list p { margin: 0 0 10px; color: var(--text-body); font-size: 11px; line-height: 15px; }
.detail-list p:last-child { margin-bottom: 0; }


/* 10. PAGE HEADER & ACTIONS ----------------------------------------------- */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.page-header .page-subtitle { margin: 0; color: var(--text-muted); font-size: 11px; line-height: 15px; }
.page-header-actions { display: flex; align-items: center; flex-shrink: 0; gap: 8px; }
.page-header-actions form { margin: 0; }

/* bottom-of-page row: safe action on the left, destructive action on the right */
.page-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 14px; }
.page-actions > :last-child { margin-left: auto; }   /* stays right even if the left button is hidden */

.action-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px; }


/* 11. SEARCH & RESULTS ---------------------------------------------------- */
.search-form { margin-bottom: 30px; }
.results-header { margin-bottom: 15px; }
.results-header h2 { margin: 0 0 5px; }
.results-header p { margin: 0; color: var(--text-muted); }
.result-count { margin-bottom: 12px; color: var(--text-muted); font-size: 10px; line-height: 14px; }

.result-list { display: flex; flex-direction: column; gap: 10px; }
.result-item {
  display: block;
  padding: 15px;
  background: var(--white);
  color: inherit;
  text-decoration: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.result-item:hover { border-color: var(--header-color); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08); }
.result-info { min-width: 0; }
.result-info h3 { margin: 0 0 8px; color: var(--text-color); font-size: 12px; font-weight: 600; line-height: 15px; }
.result-info .text-muted.text-italic { margin: -3px 0 8px; }
.result-info .detail-list p { margin: 3px 0; font-size: 10px; line-height: 14px; }

.empty-state {
  padding: 30px 20px;
  background: var(--white);
  text-align: center;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}
.empty-state h3 { margin: 0 0 6px; color: var(--text-strong); }
.empty-state p { margin: 0; color: var(--text-muted); }
.card .empty-state { border: 0; }


/* 13. STATUS & BADGES ----------------------------------------------------- */
.status-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 78px; }
.status { display: flex; align-items: center; gap: 14px; }
.status-indicator { flex: 0 0 10px; width: 10px; height: 10px; border-radius: 50%; background: var(--dot-idle); }
.status-indicator--active { background: var(--success-dot); }
.status-title { display: block; margin-bottom: 4px; color: var(--text-strong); font-size: 12px; font-weight: 600; }
.status-text { display: block; color: var(--text-subtle); font-size: 11px; }
.status-text + .status-text { margin-top: 3px; }

.badge { display: inline-block; padding: 4px 9px; font-size: 10px; font-weight: 600; border-radius: var(--radius); }
.badge--success { background: var(--success-bg); color: var(--success); }
.badge--muted { background: var(--surface-muted); color: var(--text-muted); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }


/* 14. TABLES -------------------------------------------------------------- */
.table-wrapper {
  width: 100%;
  margin: 16px 0;
  overflow-x: auto;
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
}
.card .table-wrapper { margin: 0; border: 0; border-radius: 0; }

/* scrollable body with a sticky header row */
.table-wrapper--scroll { max-height: 60vh; overflow-y: auto; }
.table-wrapper--scroll thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-muted); }
.table-wrapper--scroll tbody tr { scroll-margin-top: 2.5rem; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  padding: 10px 12px;
  background: var(--surface-muted);
  color: #555555;
  font-size: 10px;
  font-weight: 600;
  line-height: 13px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-light);
}
.data-table td {
  padding: 10px 12px;
  color: var(--text-body);
  font-size: 11px;
  line-height: 14px;
  vertical-align: top;
  white-space: nowrap;
  border-bottom: 1px solid var(--border-row);
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fafafa; }
.data-table tbody tr[data-href] { cursor: pointer; }
.data-table tbody tr[data-href]:focus-visible { outline: 2px solid var(--header-color); outline-offset: -2px; }
.data-table .cell-fit { width: 1%; }
.data-table .cell-mono { color: #555555; font-family: monospace; font-size: 10px; }
.data-table .cell-wrap { min-width: 220px; max-width: 350px; white-space: normal; overflow-wrap: break-word; }

.change-list { margin: 0; padding: 0 0 0 16px; white-space: normal; }
.change-list li { margin: 4px 0; font-size: 10px; line-height: 13px; }


/* 15. INFO GRID & STATS --------------------------------------------------- */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 20px; }
.info-grid--panel { margin-bottom: 24px; padding: 16px; background: #f8f9fa; border: 1px solid var(--border-light); border-radius: var(--radius); }
.info-item { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.info-label { color: var(--text-subtle); font-size: 10px; font-weight: 600; line-height: 13px; }
.info-value { color: var(--text-strong); font-size: 12px; font-weight: 500; line-height: 16px; overflow-wrap: break-word; }
.info-value--lg { color: var(--header-color); font-size: 18px; font-weight: 700; line-height: 22px; }

/* stats on the left, one action button on the right */
.info-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.info-row .info-grid { flex: 1; min-width: 0; }
.info-row .btn { flex-shrink: 0; }


/* 16. PAGINATION ---------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--border-light);
}
.pagination-info,
.pagination-page { color: var(--text-muted); font-size: 10px; line-height: 14px; }
.pagination-page { white-space: nowrap; }
.pagination-actions { display: flex; align-items: center; gap: 8px; }

.pagination-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 65px;
  padding: 7px 12px;
  background: var(--header-color);
  color: var(--white);
  font-size: 10px;
  line-height: 13px;
  text-decoration: none;
  border: 1px solid var(--header-color);
  border-radius: var(--radius);
}
.pagination-button:hover { background: var(--header-color-hover); border-color: var(--header-color-hover); }
.pagination-button--disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

/* "Page [ 3 ] of 25": type a page number and press Enter to jump there.
   Must follow .form-control (section 8) so the compact sizing wins. */
.pagination-jump { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.pagination-input {
  width: 56px;
  height: 28px;
  padding: 0 6px;
  text-align: center;
  -moz-appearance: textfield;
  appearance: textfield;
}
.pagination-input::-webkit-outer-spin-button,
.pagination-input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; }


/* 17. LOGIN --------------------------------------------------------------- */
.login-page { display: flex; align-items: center; justify-content: center; min-height: calc(100vh - var(--header-height)); padding: 30px 20px; }
.login-card { max-width: 380px; margin-bottom: 0; padding: 30px; }
.login-card .page-title { margin-bottom: 25px; text-align: center; }
.login-card .form-group { margin-bottom: 18px; }

/* 17a. ERROR PAGES (400 / 403 / 404 / 500) -------------------------------- */
.error-page { max-width: 560px; margin: 30px auto; text-align: center; }
.error-page .detail-list { margin-bottom: 18px; text-align: left; }
.error-page .alert { margin-bottom: 0; text-align: left; }
.error-code { margin-bottom: 8px; color: var(--header-color); font-size: 48px; font-weight: 700; line-height: 1; }


/* 18. UTILITIES ----------------------------------------------------------- */
/* keep the hidden attribute working on elements that set their own display */
[hidden] { display: none !important; }


/* 19. CHARTS (graphs.html, device.html) ----------------------------------- */
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 20px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; touch-action: pan-y; }
.chart-axis { fill: var(--text-subtle); font-size: 10px; }
.chart-gridline { stroke: var(--border-row); stroke-width: 1; }
.chart-cross { stroke: var(--dot-idle); stroke-dasharray: 3 3; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 6px; color: var(--text-muted); font-size: 10px; line-height: 13px; }
.chart-swatch { display: inline-block; width: 10px; height: 10px; margin-right: 5px; border-radius: 2px; vertical-align: -1px; }
.checkbox-row .chart-swatch { margin-right: 0; }
.device-picker { display: flex; flex-wrap: wrap; gap: 0 18px; margin-bottom: 10px; }

.chart-tip {
  position: absolute;
  z-index: 2;
  padding: 6px 8px;
  background: var(--white);
  color: var(--text-body);
  font-size: 10px;
  line-height: 14px;
  white-space: nowrap;
  pointer-events: none;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}


/* 21. MOBILE SIDE NAV TOGGLE (base; the drawer behaviour is in section 22) */
.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin-right: 8px;
  padding: 0;
  background: rgba(0, 0, 0, 0.15);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--radius);
  cursor: pointer;
}
.nav-toggle:hover { background: rgba(0, 0, 0, 0.3); }
.nav-backdrop { display: none; }


/* 22. RESPONSIVE ---------------------------------------------------------- */
/* Order matters: wider breakpoints first, narrower ones later so they win. */

/* ---- up to 700px: tablets / phones ---- */
@media (max-width: 700px) {

  /* layout & components */
  .form-grid,
  .info-grid { grid-template-columns: 1fr; }
  .form-group-full { grid-column: auto; }
  .page { max-width: none; }
  .card { padding: 20px 15px; }
  .card--split { grid-template-columns: 1fr; }
  .card--split .card-side { order: -1; }
  .card-header { flex-direction: column; }
  .card-header-actions { width: 100%; }
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-header-actions { flex-wrap: wrap; justify-content: flex-start; }
  .info-row { flex-direction: column; align-items: stretch; }
  .status-card { flex-direction: column; align-items: flex-start; }
  .status-card .btn { width: 100%; }
  .data-table th, .data-table td { padding: 8px 10px; }

  /* forms & buttons */
  .inline-form { flex-direction: column; align-items: stretch; }
  .form-control--md { width: 100%; }
  .btn-block-mobile,
  .inline-form .btn,
  .form-actions .btn { width: 100%; }
  .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .card-header-actions .btn-uniform,
  .page-actions .btn-uniform { flex: 1; width: auto; }

  /* pagination (the page-jump form must not inherit the stacked inline-form rules) */
  .pagination { flex-direction: column; align-items: stretch; gap: 10px; }
  .pagination-actions { justify-content: space-between; }
  .pagination-button { flex: 1; }
  .pagination-jump { flex: 0 0 auto; }

  /* side nav becomes an off-canvas drawer between the header and bottom tabs */
  .nav-toggle { display: inline-flex; }
  .side-nav {
    position: fixed;
    top: var(--header-height);
    bottom: var(--bottom-nav-height);
    left: 0;
    z-index: 900;
    width: min(240px, 80vw);
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
    transform: translateX(-100%);
    transition: transform 200ms ease;
  }
  body.nav-open .side-nav { transform: translateX(0); }

  .nav-backdrop {
    position: fixed;
    inset: var(--header-height) 0 0 0;
    z-index: 800;
    display: block;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms ease;
  }
  body.nav-open .nav-backdrop { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }

}


/* ---- up to 600px: phones ---- */
@media (max-width: 600px) {
  :root { --header-height: 60px; --side-nav-width: 170px; }

  .site-header { position: sticky; top: 0; z-index: 1000; }
  .header-inner { height: 60px; padding: 0 8px; }
  .site-logo img { max-width: 75px; height: 52px; }
  .site-logo-text { margin-left: 6px; font-size: 24px; }

  .side-nav, .side-nav-item { font-size: 10px; }
  .nav-section-title { padding: 3px 6px; font-size: 10px; line-height: 12px; }
  .side-nav-item { padding: 5px 7px; line-height: 12px; }

  .site-content { padding: 15px; font-size: 10px; line-height: 14px; }
  .site-content p, .site-content label { font-size: 10px; line-height: 14px; }
  .login-page { min-height: calc(100vh - 60px); padding: 20px 15px; }
  .login-card { padding: 25px 20px; }

  .bottom-tab { min-height: 24px; padding: 4px 7px; line-height: 11px; }
  .bottom-tab:hover { padding-left: 8px; padding-right: 8px; }

  .card--compact { padding: 15px; }
  .data-table th, .data-table td { padding: 6px 8px; }
  .data-table .cell-wrap { min-width: 150px; }
  .info-value--lg { font-size: 16px; }
}