/* ManualGen - RACV CES brand styling. */

:root {
  --racv-yellow: #F8DB00;
  --racv-navy: #001657;
  --racv-bright-blue: #0067F6;
  --racv-cyan: #43E6EB;
  --racv-stone: #F3F2EC;
  --racv-logo-blue: #1F5AA5;
  --racv-ink: #0E1430;
  --racv-grey-700: #3F4757;
  --racv-grey-500: #6E7689;
  --racv-grey-300: #C9CDD7;
  --racv-grey-200: #E6E8EE;
  --racv-grey-100: #F4F5F8;
  --racv-white: #FFFFFF;
  --racv-danger: #C2261A;
  --shadow-card: 0 1px 2px rgba(0, 22, 87, 0.06), 0 4px 16px rgba(0, 22, 87, 0.08);
}

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

html,
body {
  margin: 0;
  padding: 0;
  font-family: "Poppins", "Helvetica Neue", Arial, sans-serif;
  color: var(--racv-ink);
  background: var(--racv-stone);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--racv-bright-blue);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

.app-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Logged-out (auth) pages: paint the colour-mix gradient across the FULL
   viewport, not the 1200px content column. Previously the gradient lived on
   .auth-shell, which sits inside .app-main (max-width:1200px; margin:auto), so
   the mix was clipped to an arbitrary box behind the login card. Moving it to
   the body — and letting .app-main run full-width with no padding on auth
   pages — makes the mix follow the window width. */
.app-body--auth {
  background:
    radial-gradient(circle at top left, rgba(0, 103, 246, 0.10), transparent 55%),
    radial-gradient(circle at bottom right, rgba(67, 230, 235, 0.15), transparent 55%),
    var(--racv-stone);
}
.app-body--auth .app-main {
  max-width: none;
  width: 100%;
  padding: 0;
}

/* --- Header ------------------------------------------------------------- */
.app-header {
  background: var(--racv-navy);
  color: var(--racv-white);
  border-bottom: 4px solid var(--racv-yellow);
}
.app-header__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 64px;
}
.app-header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
}
.app-header__brand img {
  height: 32px;
  width: auto;
}
.app-header__title {
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.5px;
}
.app-header__nav {
  display: flex;
  gap: 8px;
  margin-left: 24px;
  flex: 1;
  justify-content: center;
}
.app-header__link {
  color: var(--racv-white);
  padding: 6px 12px;
  border-radius: 6px;
  font-weight: 500;
  font-size: 14px;
}
.app-header__link:hover {
  background: rgba(255, 255, 255, 0.08);
  text-decoration: none;
}
.app-header__link--muted {
  color: rgba(255, 255, 255, 0.55);
  cursor: not-allowed;
}
.app-header__user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}
.app-header__user-name { font-weight: 600; }
.app-header__user-role {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
}

/* --- Main / footer ------------------------------------------------------ */
.app-main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px;
}
.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--racv-grey-500);
  padding: 20px 24px 32px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 12px;
}
.app-footer a {
  color: var(--racv-bright-blue);
  font-weight: 600;
  text-decoration: none;
}
.app-footer a:hover { text-decoration: underline; }

/* --- Auth --------------------------------------------------------------- */
.auth-shell {
  /* Centres the login card. The colour-mix gradient now lives on
     .app-body--auth so it spans the full window width (see above). */
  min-height: calc(100vh - 80px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--racv-white);
  border-radius: 16px;
  padding: 40px 36px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-card);
  border-top: 6px solid var(--racv-yellow);
}
.auth-card__brand {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.auth-card__brand img {
  height: 72px;
  width: auto;
}
.auth-card__heading {
  text-align: center;
  font-size: 22px;
  font-weight: 600;
  color: var(--racv-navy);
  margin: 0 0 4px;
}
.auth-card__subheading {
  text-align: center;
  color: var(--racv-grey-500);
  margin: 0 0 24px;
  font-size: 14px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* --- Form fields -------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--racv-grey-700);
}
.field__input {
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--racv-grey-300);
  background: var(--racv-white);
  color: var(--racv-ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field__input:focus {
  outline: none;
  border-color: var(--racv-bright-blue);
  box-shadow: 0 0 0 3px rgba(0, 103, 246, 0.15);
}
.field__help {
  font-size: 12px;
  color: var(--racv-grey-500);
}

/* --- Buttons ------------------------------------------------------------ */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn--primary {
  background: var(--racv-yellow);
  color: var(--racv-navy);
}
.btn--primary:hover { background: #ffe632; }
.btn--ghost {
  background: transparent;
  color: var(--racv-white);
  border-color: rgba(255, 255, 255, 0.4);
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.08); }
.btn--block { display: block; width: 100%; }

/* --- Alerts ------------------------------------------------------------- */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 16px;
}
.alert--error {
  background: #FBEAE8;
  color: var(--racv-danger);
  border: 1px solid rgba(194, 38, 26, 0.25);
}

/* --- Page chrome -------------------------------------------------------- */
.page-section { display: flex; flex-direction: column; gap: 24px; }
.page-section__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.page-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--racv-navy);
  margin: 0;
}
.page-subtitle {
  margin: 4px 0 0;
  color: var(--racv-grey-500);
  font-size: 14px;
}

/* --- Tiles -------------------------------------------------------------- */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.tile {
  background: var(--racv-white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: var(--shadow-card);
  border-left: 4px solid var(--racv-yellow);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tile__label {
  font-size: 13px;
  color: var(--racv-grey-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.tile__value {
  font-size: 32px;
  font-weight: 700;
  color: var(--racv-navy);
}

/* --- Cards / tables ----------------------------------------------------- */
.card {
  background: var(--racv-white);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.card__heading {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 600;
  color: var(--racv-navy);
}
.card__empty {
  color: var(--racv-grey-500);
  font-size: 14px;
  margin: 0;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--racv-grey-200);
}
.data-table th {
  color: var(--racv-grey-500);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.data-table tr:last-child td { border-bottom: none; }

.status {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.status--draft     { background: var(--racv-grey-200); color: var(--racv-grey-700); }
.status--queued    { background: #E8F0FE; color: var(--racv-bright-blue); }
.status--running   { background: #FFF6CC; color: #8A6C00; }
.status--completed { background: #E0F6E8; color: #1B7A3E; }
.status--failed    { background: #FBEAE8; color: var(--racv-danger); }
.status--expired   { background: var(--racv-grey-200); color: var(--racv-grey-500); }

/* --- Header link active state ------------------------------------------ */
.app-header__link.is-active {
  background: rgba(248, 219, 0, 0.18);
  color: var(--racv-yellow);
}

/* --- Header dropdown menus --------------------------------------------- */
/* Built on native <details>/<summary> for zero-framework keyboard support.
   The summary is styled to match .app-header__link; the panel sits
   absolutely below it. A small inline script in the layout closes the
   panel on outside clicks and after a child link is clicked. */
.app-header__menu {
  position: relative;
}
.app-header__menu > summary {
  list-style: none;          /* hide the default disclosure triangle */
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.app-header__menu > summary::-webkit-details-marker { display: none; }
.app-header__link--menu::after {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 4px solid currentColor;
  margin-left: 4px;
  opacity: 0.75;
  transition: transform 0.15s ease;
}
.app-header__menu[open] .app-header__link--menu::after {
  transform: rotate(180deg);
}
.app-header__menu.is-active > summary {
  background: rgba(248, 219, 0, 0.18);
  color: var(--racv-yellow);
}
.app-header__menu[open] > summary {
  background: rgba(255, 255, 255, 0.12);
}
.app-header__menu__panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 200px;
  background: var(--racv-white);
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 100;
  border: 1px solid var(--racv-grey-200);
}
.app-header__menu__panel a {
  display: block;
  padding: 8px 14px;
  border-radius: 6px;
  color: var(--racv-navy);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
}
.app-header__menu__panel a:hover {
  background: var(--racv-grey-100);
  color: var(--racv-bright-blue);
  text-decoration: none;
}
.app-header__menu__panel a.is-active {
  background: rgba(0, 103, 246, 0.10);
  color: var(--racv-bright-blue);
}

/* --- Flash banners ------------------------------------------------------ */
.flash-stack { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 14px;
  border: 1px solid transparent;
}
.flash--success { background: #E0F6E8; color: #1B7A3E; border-color: rgba(27, 122, 62, 0.2); }
.flash--error   { background: #FBEAE8; color: var(--racv-danger); border-color: rgba(194, 38, 26, 0.25); }
.flash--info    { background: #E8F0FE; color: var(--racv-bright-blue); border-color: rgba(0, 103, 246, 0.2); }
.flash--warning { background: #FFF6CC; color: #8A6C00; border-color: rgba(138, 108, 0, 0.25); }

/* High-visibility alert: a selected inverter has no startup/shutdown procedure
   on file, so that section will be missing from the generated manual. */
.proc-warning {
  border: 2px solid var(--racv-danger);
  background: #FBEAE8;
  color: var(--racv-danger);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 0 0 16px;
}
.proc-warning__title {
  font-weight: 700;
  font-size: 14px;
  margin: 0 0 4px;
  display: flex; align-items: center; gap: 8px;
}
.proc-warning p { margin: 0; font-size: 13px; color: #7A1A12; }
.proc-warning strong { color: var(--racv-danger); }

/* --- Breadcrumbs / action bars ----------------------------------------- */
.breadcrumbs {
  font-size: 13px;
  color: var(--racv-grey-500);
  margin: 0 0 4px;
}
.breadcrumbs a { color: var(--racv-grey-500); }
.breadcrumbs a:hover { color: var(--racv-bright-blue); }
.breadcrumbs__sep { margin: 0 6px; color: var(--racv-grey-300); }

.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.action-bar__actions { display: flex; gap: 8px; }

/* --- Filter row -------------------------------------------------------- */
.filter-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
  background: var(--racv-white);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
}
.filter-row .field { min-width: 180px; }
.filter-row select,
.filter-row input {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--racv-grey-300);
  border-radius: 8px;
  background: var(--racv-white);
}

/* --- Buttons (extras) -------------------------------------------------- */
.btn--secondary {
  background: var(--racv-white);
  color: var(--racv-navy);
  border-color: var(--racv-grey-300);
}
.btn--secondary:hover { border-color: var(--racv-navy); }
.btn--danger {
  background: var(--racv-white);
  color: var(--racv-danger);
  border-color: rgba(194, 38, 26, 0.4);
}
.btn--danger:hover { background: #FBEAE8; }
.btn--sm { padding: 6px 12px; font-size: 13px; }
.btn--link {
  background: transparent;
  border: none;
  color: var(--racv-bright-blue);
  padding: 0;
  font-weight: 500;
}
.btn--link:hover { text-decoration: underline; }

/* --- Badges / pills ---------------------------------------------------- */
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--racv-grey-200);
  color: var(--racv-grey-700);
}
.pill--ok       { background: #E0F6E8; color: #1B7A3E; }
.pill--off      { background: var(--racv-grey-200); color: var(--racv-grey-500); }
.pill--category { background: rgba(0, 103, 246, 0.10); color: var(--racv-bright-blue); }
.pill--role     { background: rgba(0, 22, 87, 0.08); color: var(--racv-navy); }

/* --- File pills (uploaded doc indicators) ------------------------------ */
.file-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 12px;
  border: 1px solid var(--racv-grey-200);
  background: var(--racv-grey-100);
  color: var(--racv-grey-700);
  text-decoration: none;
}
.file-pill:hover { background: var(--racv-white); border-color: var(--racv-bright-blue); text-decoration: none; }
.file-pill--empty { color: var(--racv-grey-500); font-style: italic; }
.file-pill__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--racv-bright-blue);
}

/* --- Site-document upload (dropzone + file rows + modal) --------------- */
.doc-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.doc-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 10px;
  border: 1px solid var(--racv-grey-200);
  border-radius: 8px;
  background: var(--racv-white);
}
.doc-row--pending { background: var(--racv-grey-100); border-style: dashed; }
.doc-row__name {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--racv-grey-700);
  word-break: break-all; min-width: 0;
}
.doc-row__actions { display: flex; gap: 6px; flex-shrink: 0; }

.dropzone {
  border: 1.5px dashed var(--racv-grey-300);
  border-radius: 10px;
  padding: 14px;
  background: var(--racv-grey-100);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.dropzone.is-drag {
  border-color: var(--racv-bright-blue);
  background: #EAF1FE;
}
.dropzone__prompt { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dropzone__hint { font-size: 12px; color: var(--racv-grey-500); }
.dropzone .doc-list--pending { margin-top: 10px; margin-bottom: 0; }

/* In-page confirm modal */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal__backdrop { position: absolute; inset: 0; background: rgba(14, 20, 48, 0.45); }
.modal__panel {
  position: relative;
  background: var(--racv-white);
  border-radius: 12px;
  padding: 20px 22px;
  max-width: 420px; width: calc(100% - 40px);
  box-shadow: var(--shadow-card);
}
.modal__message { margin: 0 0 18px; font-size: 14px; color: var(--racv-ink); }
.modal__actions { display: flex; justify-content: flex-end; gap: 8px; }

/* Customer download links - persistent list, full-width copyable URL */
.dl-links { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.dl-link {
  border: 1px solid var(--racv-grey-200);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--racv-white);
}
.dl-link--expired, .dl-link--revoked { background: var(--racv-grey-100); opacity: 0.85; }
.dl-link__row { display: flex; gap: 8px; align-items: center; }
.dl-link__url {
  flex: 1 1 auto; min-width: 0; width: 100%;
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: 13px; background: var(--racv-grey-100);
}
.dl-link__copy { flex: 0 0 auto; }
.dl-link__meta {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-top: 10px; font-size: 12.5px; color: var(--racv-grey-500);
}
.dl-link__pw-label {
  flex: 0 0 auto; font-size: 12px; font-weight: 600; color: var(--racv-grey-700);
  min-width: 64px;
}
/* Ready-to-send customer email: give it room so it isn't a long thin strip. */
.dl-blurb__field { margin-top: 10px; }
.dl-blurb__field .dl-link__pw-label { display: block; margin-bottom: 4px; min-width: 0; }
.dl-blurb__text {
  margin-top: 10px;
  width: 100%;
  min-height: 320px;
  font-size: 13px;
  line-height: 1.5;
  font-family: inherit;
}

/* --- Forms (admin pages) ---------------------------------------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
}
.form-grid .field--full { grid-column: 1 / -1; }
.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 24px;
}
.form-section {
  border-top: 1px solid var(--racv-grey-200);
  margin-top: 24px;
  padding-top: 16px;
}
.form-section__heading {
  font-size: 14px;
  font-weight: 600;
  color: var(--racv-navy);
  margin: 0 0 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

textarea.field__input { font-family: inherit; min-height: 80px; resize: vertical; }
select.field__input { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8'><path fill='%236E7689' d='M0 0l6 8 6-8z'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.field__input--file {
  padding: 8px;
  background: var(--racv-grey-100);
}

.field__hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* --- Table action column ---------------------------------------------- */
.data-table td.actions,
.data-table th.actions {
  text-align: right;
  white-space: nowrap;
}
.data-table td.actions form { display: inline; }
.data-table .col-thin { width: 1%; white-space: nowrap; }

.empty-state {
  padding: 32px;
  text-align: center;
  color: var(--racv-grey-500);
  font-size: 14px;
}

/* --- Errors ------------------------------------------------------------- */
.error-shell {
  min-height: 60vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.error-card {
  text-align: center;
  background: var(--racv-white);
  padding: 48px;
  border-radius: 16px;
  box-shadow: var(--shadow-card);
}
.error-card__code {
  font-size: 64px;
  font-weight: 700;
  color: var(--racv-navy);
  margin: 0;
}
.error-card__detail {
  color: var(--racv-grey-500);
  margin: 8px 0 24px;
}

/* --- Phase 3: generation form + history helpers --- */
.field__help--error { color: var(--racv-danger); }
.text-muted { color: var(--racv-grey-500); font-size: 12px; }
.page-section__actions { margin-left: auto; }
.tile--link { text-decoration: none; color: inherit; transition: box-shadow .15s ease; }
.tile--link:hover { box-shadow: 0 6px 18px rgba(0,30,80,.08); }
.data-table__actions { display: flex; gap: 6px; justify-content: flex-end; white-space: nowrap; }
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card--table { overflow: hidden; }
.card--table .data-table { min-width: 760px; }
/* The action cell stays a real table-cell so its bottom border lines up with
   every other cell in the row. Making the <td> itself `display:flex` pulled it
   out of the table-row box, so its bottom border misaligned and the row changed
   height (the "row line stops at Actions" bug). Buttons are laid out either by
   an inner .row-actions flex wrapper, or - for cells we don't wrap - by a small
   left-margin on the direct children so they never touch. */
.data-table td.actions,
.data-table td.data-table__actions {
  display: table-cell;
  text-align: right;
  vertical-align: middle;
  white-space: nowrap;
}
.data-table td.actions > *,
.data-table td.data-table__actions > * { margin-left: 6px; }
.data-table td.actions > *:first-child,
.data-table td.data-table__actions > *:first-child { margin-left: 0; }
.data-table td.actions form,
.data-table td.data-table__actions form { display: inline-flex; margin-top: 0; margin-bottom: 0; }
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
}
/* When the buttons are wrapped in .row-actions the wrapper owns the spacing. */
.data-table td.actions .row-actions > *,
.data-table td.data-table__actions .row-actions > * { margin-left: 0; }
.data-table--lines td { vertical-align: top; }
.data-table--lines .field__input { width: 100%; }

/* --- Collapsible per-company user groups (super-admin) ----------------- */
.company-group { margin-bottom: 14px; }
.company-group__summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--racv-stone);
  border-radius: 10px;
  font-weight: 600;
  color: var(--racv-navy);
}
.company-group__summary::-webkit-details-marker { display: none; }
.company-group__summary::before {
  content: "";
  width: 0; height: 0;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  transition: transform 0.15s ease;
}
.company-group[open] .company-group__summary::before { transform: rotate(90deg); }
.company-group__count { margin-left: auto; font-weight: 500; font-size: 12px; color: var(--racv-grey-500); }
.product-combobox {
  position: relative;
}
.product-combobox__input { padding-right: 32px; }
.product-combobox::after {
  content: '';
  position: absolute;
  right: 12px;
  top: 18px;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--racv-grey-500);
  pointer-events: none;
}
.product-combobox__menu {
  display: none;
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 260px;
  overflow-y: auto;
  background: var(--racv-white);
  border: 1px solid var(--racv-grey-300);
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0, 21, 58, 0.16);
  padding: 6px;
}
.product-combobox.is-open .product-combobox__menu { display: block; }
.product-combobox__option {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--racv-ink);
  text-align: left;
  font: inherit;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.product-combobox__option:hover,
.product-combobox__option.is-selected {
  background: var(--racv-grey-100);
  color: var(--racv-navy);
}
.product-combobox__empty {
  padding: 10px;
  color: var(--racv-grey-500);
  font-size: 13px;
}
.kv-grid {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 8px 16px;
  margin: 8px 0 0;
  font-size: 14px;
}
.kv-grid dt { color: var(--racv-grey-500); font-weight: 500; }
.kv-grid dd { margin: 0; color: var(--racv-grey-900); }
.error-box {
  background: #FBEAE8;
  color: var(--racv-danger);
  border-radius: 8px;
  padding: 12px 16px;
  margin: 8px 0 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre-wrap;
}

/* --- Phase 5: analytics dashboard --- */
.tile--cta .tile__value { color: var(--racv-bright-blue); font-size: 22px; }
.chart-grid {
  display: grid;
  gap: 24px;
  margin-top: 12px;
}
.chart-grid--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 880px) {
  .chart-grid--two { grid-template-columns: 1fr; }
}
.chart-block {
  background: var(--racv-grey-100);
  border-radius: 10px;
  padding: 16px;
  min-height: 220px;
}
.chart-block__title {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--racv-grey-700);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.chart-block canvas { max-width: 100%; }

/* --- Phase 5: history filter bar --- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 12px 0 16px;
}
.filter-bar__input {
  flex: 1 1 280px;
  min-width: 220px;
  padding: 8px 12px;
  border: 1px solid var(--racv-grey-300);
  border-radius: 8px;
  font: inherit;
  background: var(--racv-white);
}
.filter-bar__input:focus,
.filter-bar__select:focus { outline: 2px solid var(--racv-bright-blue); outline-offset: 1px; }
.filter-bar__select {
  padding: 8px 12px;
  border: 1px solid var(--racv-grey-300);
  border-radius: 8px;
  font: inherit;
  background: var(--racv-white);
}

/* --- Narrow viewports (~960 px and below) ------------------------------ */
/* The header used to need a separate tablet rule because there were ~10
   nav items; now there's only Generate + three dropdowns, so the nav
   fits cleanly at desktop widths. Below 960 px we wrap the nav onto a
   second row, and we deliberately avoid ``overflow-x: auto`` because it
   would clip the absolutely-positioned dropdown panels. */
@media (max-width: 960px) {
  .app-header__inner {
    height: auto;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px 20px;
  }
  .app-header__nav {
    order: 3;
    flex: 1 0 100%;
    margin-left: 0;
    flex-wrap: wrap;
    justify-content: center;
  }
  .app-header__link {
    white-space: nowrap;
  }
  .app-header__user {
    margin-left: auto;
  }
}

/* --- Mobile (~720 px and below) ---------------------------------------- */
/* Phone-friendly sweep across the admin surface. The header nav still
   wraps; on top of that we shrink the logo, hide the role pill, and
   reflow data tables / forms into single columns. */
@media (max-width: 720px) {
  .app-header__inner {
    padding: 10px 14px;
    gap: 8px;
  }
  .app-header__brand img { height: 26px; }
  .app-header__link {
    padding: 6px 10px;
    font-size: 13px;
  }
  .app-header__user {
    margin-left: auto;
    gap: 8px;
    font-size: 13px;
  }
  .app-header__user-role { display: none; }
  /* Right-aligned dropdown panels would otherwise bleed off the right
     edge on a phone; keep them flush-left under their summary. */
  .app-header__menu__panel { left: 0; right: auto; min-width: 180px; }

  .app-main { padding: 16px 12px; }

  .page-title { font-size: 20px; }
  .page-subtitle { font-size: 14px; }

  .card { padding: 16px; }
  .tile { padding: 16px; }
  .tile__value { font-size: 24px; }
  .tile--cta .tile__value { font-size: 18px; }

  /* Horizontal scroll for tables that don't collapse cleanly. Cards
     containing data tables get an inner scroll so the table itself
     keeps its column layout instead of squishing illegibly. */
  .card > .data-table,
  .card > .table-wrap > .data-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }
  .data-table th,
  .data-table td { padding: 10px 12px; }

  /* Equipment-picker rows are too wide to scroll horizontally on a
     phone - let each cell wrap so qty + warranty inputs stack. */
  .data-table--lines,
  .data-table--lines thead,
  .data-table--lines tbody,
  .data-table--lines tr,
  .data-table--lines th,
  .data-table--lines td {
    display: block;
    width: 100%;
  }
  .data-table--lines thead { display: none; }
  .data-table--lines tr {
    border-bottom: 1px solid var(--racv-grey-200);
    padding: 8px 0;
  }
  .data-table--lines td {
    padding: 4px 0;
    border: none;
  }

  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .form-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .form-actions .btn { width: 100%; justify-content: center; }

  .kv-grid { grid-template-columns: 1fr; gap: 4px 0; }
  .kv-grid dt { margin-top: 8px; }

  .action-bar { gap: 8px; }
  .action-bar__actions { width: 100%; }

  .filter-bar { gap: 6px; }
  .filter-bar__input,
  .filter-bar__select {
    flex: 1 1 100%;
    min-width: 0;
  }

  .breadcrumbs { font-size: 12px; }
}

/* --- Feedback modal (in-page, no navigation) --------------------------- */
.feedback-dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  width: min(560px, 92vw);
  background: var(--racv-white);
  color: var(--racv-ink);
  box-shadow: 0 24px 60px rgba(0, 22, 87, 0.30);
}
.feedback-dialog::backdrop {
  background: rgba(0, 22, 87, 0.45);
}
.feedback-dialog__form { padding: 22px 24px 20px; }
.feedback-dialog__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.feedback-dialog__title { margin: 0; font-size: 1.2rem; color: var(--racv-navy); }
.feedback-dialog__sub {
  margin: 6px 0 14px;
  color: var(--racv-grey-500);
  font-size: 0.9rem;
}
.feedback-dialog__close {
  border: none;
  background: transparent;
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  color: var(--racv-grey-500);
  padding: 0 4px;
}
.feedback-dialog__close:hover { color: var(--racv-navy); }
.feedback-dialog__status { margin: 12px 0 0; font-size: 0.9rem; }
.feedback-dialog__status.is-ok { color: #2E7D32; }
.feedback-dialog__status.is-err { color: var(--racv-danger); }
