/* The component layer, ported from aiReports.
 *
 * Each block here restates one PrimeVue component's look — Button, Tag, Badge,
 * InputText, Select, DataTable, Message, Skeleton, Toast, Drawer, Tooltip — plus
 * the three layout patterns aiReports built on top of them: the hover-expanding
 * sidebar rail, the `card-background` surface, and the page header.
 *
 * Class names are PrimeVue's (`p-button`, `p-tag p-tag-success`, `p-datatable`)
 * so the markup in app.js reads the same as the templates in that app. What is
 * NOT here is every variant PrimeVue ships: this file covers what the dashboard
 * actually renders, and stops. Adding a component means adding its block, not
 * pulling in a framework. The one exception is severity — success/info/warn/
 * danger/secondary are one axis of helpers that take it as an argument, so each
 * of those sets is complete even where a view has yet to ask for a colour.
 *
 * Everything draws from theme.css. No colour is written literally below except
 * where a shadow needs an alpha of its own.
 */

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

html {
  overflow-y: scroll;          /* aiReports: reserve the gutter so a short page
                                  and a long one do not shift by 8px */
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  /* aiReports' ground: a flat colour under a tiled topography texture, pinned
     with background-attachment so it stays put while the board scrolls over it.
     The tile is transparent PNG, so the same file works on #fafafa and on
     black — only the ground colour changes between themes. */
  background-color: var(--p-ground-background);
  background-image: url('/static/assets/topography.png');
  background-attachment: fixed;
  color: var(--p-text-color);
  font-family: var(--p-font-family);
  font-size: var(--p-font-size);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
p { margin: 0; }
a { color: var(--p-primary-color); text-decoration: none; }
a:hover { text-decoration: underline; }
.dark-mode a { color: var(--p-primary-300); }

code, pre { font-family: var(--p-font-mono); }
code {
  background: var(--p-surface-100);
  border: 1px solid var(--p-content-border-color);
  border-radius: var(--p-border-radius-sm);
  padding: 1px 5px;
  font-size: 0.85em;
}
.dark-mode code { background: rgba(255, 255, 255, 0.06); }

pre {
  background: var(--p-surface-50);
  border: 1px solid var(--p-content-border-color);
  border-radius: var(--p-border-radius);
  padding: 10px 12px;
  overflow: auto;
  font-size: 11.5px;
  max-height: 340px;
  margin: 0;
}
.dark-mode pre { background: rgba(0, 0, 0, 0.35); }

.hidden { display: none !important; }
/* `display: inline-flex` on .p-badge (and .p-tag, and every other component
   here) beats the UA's [hidden] rule, so el.hidden alone would leave a hidden
   badge on screen. Stated once, for everything. */
[hidden] { display: none !important; }
.muted { color: var(--p-text-muted-color); }
.dim { color: var(--p-text-dim-color); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.text-xs { font-size: 12px; }
.text-2xs { font-size: 11px; }

/* Scrollbars, as restyled in aiReports' primevue-custom.css. */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--p-surface-100); }
::-webkit-scrollbar-thumb { background: var(--p-surface-400); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--p-surface-500); }
.dark-mode ::-webkit-scrollbar-track { background: #18181b; }
.dark-mode ::-webkit-scrollbar-thumb { background: #3f3f46; }
.dark-mode ::-webkit-scrollbar-thumb:hover { background: #52525b; }

/* ── layout ──────────────────────────────────────────────────────────────── */
.layout-content-wrapper {
  margin-left: var(--rail-width);
  transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 0;
}

.layout-content {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 18px 20px 56px;
}

@media (max-width: 991px) {
  .layout-content-wrapper { margin-left: 0; }
  .layout-content { padding: 14px 12px 48px; }
}

.layout-footer {
  position: fixed;
  right: 0;
  bottom: 0;
  padding: 6px 12px;
  font-size: 11.5px;
  color: var(--p-text-dim-color);
  pointer-events: none;
}

/* ── sidebar rail ────────────────────────────────────────────────────────────
   aiReports' navigation: 70px of icons that widen to 250px on hover and float
   over the content rather than pushing it. On mobile it is off-canvas behind a
   hamburger, with a dimmed overlay. */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 999;
  height: 100vh;
  width: var(--rail-width);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--p-content-background);
  border-right: 1px solid var(--p-content-border-color);
  box-shadow: 0 3px 5px rgba(0, 0, 0, 0.02), 0 0 2px rgba(0, 0, 0, 0.05),
              0 1px 4px rgba(0, 0, 0, 0.08);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar:hover, .sidebar.is-open { width: var(--rail-width-open); }

.sidebar-logo {
  display: flex;
  width: 100%;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  align-items: center;
  gap: 10px;
  padding: 0 15px;
  min-height: 72px;
  border-bottom: 1px solid var(--p-content-border-color);
  flex-shrink: 0;
  cursor: pointer;
}

.sidebar-mark {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--p-primary-contrast-color);
  background: linear-gradient(135deg, var(--p-primary-400), var(--p-primary-600));
  font-size: 20px;
}

.sidebar-word {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}
.sidebar-word em { font-style: normal; color: var(--p-primary-500); }
.dark-mode .sidebar-word em { color: var(--p-primary-400); }
.sidebar:hover .sidebar-word, .sidebar.is-open .sidebar-word { opacity: 1; }

.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 13px 20px;
  border: 0;
  border-left: 4px solid transparent;
  margin-left: -4px;
  padding-left: 24px;
  background: none;
  color: var(--p-text-muted-color);
  font: inherit;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}
.nav-item:hover { background: var(--p-primary-50); }
/* The rail is all buttons, and a button whose focus you cannot see is a button
   you cannot use from the keyboard. Inset, because the item is flush to the
   edge and an outward ring would be clipped by the rail's own overflow. */
.nav-item:focus-visible, .sidebar-logo:focus-visible {
  outline: 2px solid var(--p-primary-500);
  outline-offset: -3px;
}
.dark-mode .nav-item:hover { background: rgba(var(--p-primary-rgb), 0.16); }

.nav-item.active {
  background: var(--p-primary-50);
  border-left-color: var(--p-primary-500);
  color: var(--p-primary-500);
  font-weight: 500;
}
.dark-mode .nav-item.active {
  background: rgba(var(--p-primary-rgb), 0.18);
  color: var(--p-primary-300);
  border-left-color: var(--p-primary-400);
}

.nav-item > i { font-size: 19px; min-width: 20px; text-align: center; flex-shrink: 0; }

.nav-label {
  flex: 1;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}
.sidebar:hover .nav-label, .sidebar.is-open .nav-label { opacity: 1; }

/* The count badge has to survive the collapsed rail, where there is no room
   beside the icon — so it parks on the icon's top-right corner instead. */
.nav-count {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
  flex-shrink: 0;
}
.sidebar:hover .nav-count, .sidebar.is-open .nav-count { opacity: 1; }

.nav-item { position: relative; }
.nav-dot {
  position: absolute;
  top: 9px;
  left: 34px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--p-danger-color);
  opacity: 0;
  transition: opacity 0.2s;
}
.nav-item.has-attention .nav-dot { opacity: 1; }
.sidebar:hover .nav-dot, .sidebar.is-open .nav-dot { opacity: 0 !important; }

.sidebar-foot {
  border-top: 1px solid var(--p-content-border-color);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.sidebar-toggle {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 997;
  display: none;
}
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); width: var(--rail-width-open); }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-word, .nav-label, .nav-count { opacity: 1 !important; }
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  z-index: 998;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}
.sidebar-overlay.is-open { opacity: 1; visibility: visible; }

/* ── topbar ──────────────────────────────────────────────────────────────────
   PrimeVue's Toolbar surface. Everything in it answers one question — is what
   I am looking at current — so it is sticky and never scrolls away. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  min-height: var(--topbar-height);
  padding: 8px 20px;
  background: var(--p-content-background);
  border-bottom: 1px solid var(--p-content-border-color);
}
@media (max-width: 991px) { .topbar { padding-left: 64px; } }

.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
/* When the bar wraps, the readings stay on the right rather than sliding under
   the board switcher — they are read by position as much as by colour. */
.topbar-right { margin-left: auto; }

/* The last poll's summary is the one piece of prose up here. It gets a ceiling
   so a chatty line cannot push the health pill onto its own row. */
#last-poll {
  max-width: 46ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── surfaces ────────────────────────────────────────────────────────────── */
.card-background {
  background: var(--p-content-background);
  border: 1px solid var(--p-content-border-color);
  border-radius: var(--p-border-radius);
}

.p-card {
  background: var(--p-content-background);
  border: 1px solid var(--p-content-border-color);
  border-radius: var(--p-border-radius-lg);
  box-shadow: var(--p-card-shadow);
  padding: 16px;
}
/* The 3px coloured stripe aiReports puts on every stat tile (top) and every
   report card (left). It is the one piece of ornament in that design, and it
   carries meaning: the stripe colour is the thing's own status colour. */
.stripe-top, .stripe-left { position: relative; overflow: hidden; }
.stripe-top::before, .stripe-left::before {
  content: '';
  position: absolute;
  background: var(--stripe, var(--p-primary-500));
}
.stripe-top::before { top: 0; left: 0; right: 0; height: 3px; }
.stripe-left::before { top: 0; bottom: 0; left: 0; width: 3px; }

/* ── page header ─────────────────────────────────────────────────────────────
   `h1` plus a muted line on the left, actions on the right. Every aiReports
   view opens with this. */
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-head h1 { font-size: 22px; }
.page-head .page-sub { font-size: 13px; color: var(--p-text-dim-color); margin-top: 3px; }

/* ── Button ──────────────────────────────────────────────────────────────── */
.p-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: var(--p-button-padding);
  border: 1px solid var(--p-primary-color);
  border-radius: var(--p-border-radius);
  background: var(--p-primary-color);
  color: var(--p-primary-contrast-color);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s;
  white-space: nowrap;
}
.p-button:hover { background: var(--p-primary-hover-color); border-color: var(--p-primary-hover-color); }
.p-button:active { background: var(--p-primary-active-color); border-color: var(--p-primary-active-color); }
.p-button:focus-visible { outline: none; box-shadow: var(--p-focus-ring); }
.p-button:disabled { opacity: 0.6; cursor: not-allowed; }
.p-button > i { font-size: 13px; }

.p-button-secondary {
  background: var(--p-surface-100);
  border-color: var(--p-surface-200);
  color: var(--p-text-color);
}
.p-button-secondary:hover { background: var(--p-surface-200); border-color: var(--p-surface-300); }
.dark-mode .p-button-secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--p-content-border-color);
  color: var(--p-text-color);
}
.dark-mode .p-button-secondary:hover { background: rgba(255, 255, 255, 0.12); }

.p-button-outlined {
  background: transparent;
  color: var(--p-primary-color);
  border-color: var(--p-primary-color);
}
.p-button-outlined:hover { background: var(--p-primary-50); color: var(--p-primary-hover-color); }
.dark-mode .p-button-outlined { color: var(--p-primary-300); border-color: var(--p-primary-500); }
.dark-mode .p-button-outlined:hover { background: rgba(var(--p-primary-rgb), 0.2); }

.p-button-outlined.p-button-secondary {
  color: var(--p-text-muted-color);
  border-color: var(--p-content-border-color);
  background: transparent;
}
.p-button-outlined.p-button-secondary:hover { background: var(--p-content-hover-background); }

.p-button-text {
  background: transparent;
  border-color: transparent;
  color: var(--p-text-muted-color);
}
.p-button-text:hover { background: var(--p-content-hover-background); border-color: transparent; color: var(--p-text-color); }

.p-button-danger { background: var(--p-red-500); border-color: var(--p-red-500); }
.p-button-danger:hover { background: var(--p-red-700); border-color: var(--p-red-700); }
.p-button-outlined.p-button-danger {
  background: transparent;
  color: var(--p-danger-color);
  border-color: var(--p-red-500);
}
.p-button-outlined.p-button-danger:hover { background: var(--p-red-100); }


.p-button-sm { padding: 4px 9px; font-size: 12px; }

.p-button-icon-only { padding: 7px; width: 34px; height: 34px; }
.p-button-icon-only.p-button-sm { width: 28px; height: 28px; padding: 4px; }
.p-button-icon-only > i { font-size: 15px; }

/* ── Tag ─────────────────────────────────────────────────────────────────── */
.p-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 7px;
  border-radius: var(--p-border-radius-sm);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  background: var(--p-surface-100);
  color: var(--p-text-muted-color);
  white-space: nowrap;
}
.dark-mode .p-tag { background: rgba(255, 255, 255, 0.08); }
.p-tag > i { font-size: 10px; }

.p-tag-success { background: var(--p-green-100); color: var(--p-success-color); }
.p-tag-info    { background: var(--p-blue-100);  color: var(--p-info-color); }
.p-tag-warn    { background: var(--p-amber-100); color: var(--p-warn-color); }
.p-tag-danger  { background: var(--p-red-100);   color: var(--p-danger-color); }
.p-tag-primary { background: var(--p-primary-100); color: var(--p-primary-600); }
.dark-mode .p-tag-primary { background: rgba(var(--p-primary-rgb), 0.22); color: var(--p-primary-300); }

/* ── Badge ───────────────────────────────────────────────────────────────── */
.p-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--p-surface-200);
  color: var(--p-text-muted-color);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.dark-mode .p-badge { background: rgba(255, 255, 255, 0.1); }
.p-badge-success { background: var(--p-primary-500); color: #fff; }
.p-badge-warn    { background: var(--p-amber-500); color: #fff; }
.p-badge-danger  { background: var(--p-red-500); color: #fff; }
.p-badge-info    { background: var(--p-blue-500); color: #fff; }

/* Status pills in the topbar: a Tag with a dot, sized for a strip of live
   readings rather than a table cell. */
.p-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--p-content-border-color);
  border-radius: 999px;
  background: var(--p-content-background);
  font-size: 12px;
  font-weight: 500;
  color: var(--p-text-muted-color);
  white-space: nowrap;
}
.p-pill-success { border-color: var(--p-green-500); color: var(--p-success-color); }
.p-pill-warn    { border-color: var(--p-amber-500); color: var(--p-warn-color); }
.p-pill-danger  { border-color: var(--p-red-500); color: var(--p-danger-color); font-weight: 600; }

.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--p-surface-400); flex-shrink: 0; }
.status-dot.on   { background: var(--p-green-500); box-shadow: 0 0 6px var(--p-green-500); }
.status-dot.bad  { background: var(--p-red-500);   box-shadow: 0 0 6px var(--p-red-500); }

/* ── inputs ──────────────────────────────────────────────────────────────── */
.p-inputtext, .p-select {
  padding: var(--p-inputtext-padding);
  border: 1px solid var(--p-content-border-color);
  border-radius: var(--p-border-radius);
  background: var(--p-content-background);
  color: var(--p-text-color);
  font: inherit;
  font-size: 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 0;
}
.p-inputtext::placeholder { color: var(--p-text-dim-color); }
.p-inputtext:hover, .p-select:hover { border-color: var(--p-surface-400); }
.p-inputtext:focus, .p-select:focus {
  outline: none;
  border-color: var(--p-primary-color);
  box-shadow: var(--p-focus-ring);
}
.p-select {
  appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%2394a3b8'%3E%3Cpath d='M8 11 3.5 6h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 14px;
  cursor: pointer;
}

/* IconField: a search icon inside the left edge of the input. */
.p-iconfield { position: relative; display: flex; align-items: center; }
.p-iconfield > i {
  position: absolute;
  left: 10px;
  font-size: 13px;
  color: var(--p-text-dim-color);
  pointer-events: none;
}
.p-iconfield > .p-inputtext { padding-left: 30px; width: 100%; }

.p-field { display: flex; flex-direction: column; gap: 4px; }
.p-field > label { font-size: 12px; color: var(--p-text-muted-color); }

/* ── DataTable ───────────────────────────────────────────────────────────── */
.p-datatable {
  background: var(--p-content-background);
  border: 1px solid var(--p-content-border-color);
  border-radius: var(--p-border-radius-lg);
  overflow: hidden;
}
/* Wide tables scroll inside their own card — the page body never scrolls
   sideways. That wrapper is also what the sticky header sticks to, which is why
   long tables get a height here: a `position: sticky` header is scoped to its
   nearest scroll container, so without one it would pin to a box that never
   scrolls and never move. `is-tall` is for the lists worth scrolling (the board,
   the activity feed); a truckload's eight legs do not need it. */
.p-datatable-scroll { overflow-x: auto; }
.p-datatable-scroll.is-tall {
  overflow-y: auto;
  /* The slack has to be at least the page's own bottom padding. Below that, the
     last scroll of the page carries the table's top — and its pinned header —
     up behind the sticky topbar, and the headings you scrolled to keep are the
     thing that disappears. (Worked through: at maximum page scroll the wrapper
     sits at topbar + slack − page-padding.) */
  max-height: calc(100vh - var(--topbar-height) - 72px);
}
/* On a phone the topbar wraps to two or three rows, so its height is no longer
   a constant to subtract — and a scroll region inside a scrolling page is a bad
   trade on a small screen anyway. The table goes back to scrolling with the
   page; the header stops sticking, which is the right thing to lose. */
@media (max-width: 991px) {
  .p-datatable-scroll.is-tall { overflow-y: visible; max-height: none; }
}
.p-datatable table { width: 100%; border-collapse: collapse; }

.p-datatable th {
  padding: var(--p-datatable-header-cell-padding);
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--p-text-dim-color);
  background: var(--p-content-background);
  border-bottom: 1px solid var(--p-content-border-color);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 5;
}
.p-datatable th.num { text-align: right; }

.p-datatable td {
  padding: var(--p-datatable-body-cell-padding);
  border-bottom: 1px solid var(--p-content-border-color);
  font-size: 13px;
  vertical-align: top;
}
.p-datatable tbody tr:last-child td { border-bottom: 0; }
.p-datatable tbody tr { transition: background-color 0.15s ease; }
.p-datatable tbody tr:hover { background: var(--p-datatable-row-hover-background); }
.p-datatable-selectable tbody tr { cursor: pointer; }

/* ── Message (inline, non-dismissing) ────────────────────────────────────── */
.p-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--p-content-border-color);
  border-left: 5px solid var(--p-surface-400);
  border-radius: var(--p-border-radius);
  background: var(--p-content-background);
  font-size: 13px;
}
.p-message > i { font-size: 15px; margin-top: 1px; flex-shrink: 0; }
.p-message-info    { border-left-color: var(--p-blue-500);  background: var(--p-blue-100); }
.p-message-success { border-left-color: var(--p-green-500); background: var(--p-green-100); }
.p-message-warn    { border-left-color: var(--p-amber-500); background: var(--p-amber-100); }
.p-message-error   { border-left-color: var(--p-red-500);   background: var(--p-red-100); }
.p-message-info > i    { color: var(--p-info-color); }
.p-message-success > i { color: var(--p-success-color); }
.p-message-warn > i    { color: var(--p-warn-color); }
.p-message-error > i   { color: var(--p-danger-color); }
.p-message ul { margin: 6px 0 0; padding-left: 18px; }
.p-message li { margin: 2px 0; }

/* ── Skeleton ────────────────────────────────────────────────────────────── */
.p-skeleton {
  background: var(--p-surface-200);
  border-radius: var(--p-border-radius-lg);
  overflow: hidden;
  position: relative;
}
.dark-mode .p-skeleton { background: rgba(255, 255, 255, 0.08); }
.p-skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.35), transparent);
  animation: p-skeleton-shine 1.2s infinite;
}
.dark-mode .p-skeleton::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
}
@keyframes p-skeleton-shine { 100% { transform: translateX(100%); } }

/* Everything that moves here is decoration — a rail widening, a drawer sliding,
   a skeleton shimmering. None of it carries meaning, so all of it goes when the
   system asks for less motion. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .p-skeleton::after { animation: none; }
}

.p-skeleton-stack { display: flex; flex-direction: column; gap: 12px; }

/* ── Toast ───────────────────────────────────────────────────────────────────
   Transient confirmations, where the old UI printed a line into the card and
   left it there. Bottom-right rather than PrimeVue's top-right: the top right
   of this screen is the live status strip, and a toast landing on it would
   cover the one thing that must never be hidden. */
.p-toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 32px));
}

.p-toast-message {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--p-content-border-color);
  border-left: 5px solid var(--p-surface-400);
  border-radius: var(--p-border-radius);
  background: var(--p-overlay-background);
  box-shadow: var(--p-overlay-shadow);
  animation: p-toast-in 0.22s ease-out;
}
.p-toast-message.is-leaving { animation: p-toast-out 0.2s ease-in forwards; }
.p-toast-message > i { font-size: 16px; margin-top: 1px; }
.p-toast-success { border-left-color: var(--p-green-500); }
.p-toast-success > i { color: var(--p-success-color); }
.p-toast-error { border-left-color: var(--p-red-500); }
.p-toast-error > i { color: var(--p-danger-color); }
.p-toast-warn { border-left-color: var(--p-amber-500); }
.p-toast-warn > i { color: var(--p-warn-color); }
.p-toast-info { border-left-color: var(--p-blue-500); }
.p-toast-info > i { color: var(--p-info-color); }
.p-toast-body { min-width: 0; flex: 1; }
.p-toast-summary { font-weight: 600; font-size: 13px; }
.p-toast-detail { font-size: 12.5px; color: var(--p-text-muted-color); margin-top: 2px; word-break: break-word; }

@keyframes p-toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes p-toast-out { to { opacity: 0; transform: translateY(10px); } }

/* ── Drawer ──────────────────────────────────────────────────────────────── */
.p-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1050;
  width: min(560px, 94vw);
  display: flex;
  flex-direction: column;
  background: var(--p-overlay-background);
  border-left: 1px solid var(--p-content-border-color);
  box-shadow: var(--p-overlay-shadow);
  transform: translateX(0);
  visibility: visible;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.25s;
}
/* Kept in the layout so it can animate out, but `visibility: hidden` takes it
   out of the tab order and the accessibility tree — a closed panel whose close
   button still answers Tab is a trap for anyone not using a mouse. */
.p-drawer.hidden {
  display: flex !important;
  transform: translateX(102%);
  visibility: hidden;
  pointer-events: none;
}

.p-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--p-content-border-color);
  flex-shrink: 0;
}
.p-drawer-title { font-size: 15px; font-weight: 600; }
.p-drawer-content { padding: 16px; overflow-y: auto; flex: 1; }
.p-drawer-content h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--p-text-dim-color);
  margin: 18px 0 6px;
}

/* ── key/value rows ──────────────────────────────────────────────────────── */
.kv {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 5px 0;
  border-bottom: 1px solid var(--p-content-border-color);
  font-size: 13px;
}
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--p-text-dim-color); flex-shrink: 0; }
.kv > span:last-child { text-align: right; word-break: break-word; }
.kv-good > span:last-child { color: var(--p-success-color); }
.kv-bad > span:last-child { color: var(--p-danger-color); }
.kv-warn > span:last-child { color: var(--p-warn-color); }

/* ── empty state ─────────────────────────────────────────────────────────────
   The big muted icon, a heading, one explaining line and at most one call to
   action — aiReports' pattern for "nothing here, and here is why". */
.p-empty { text-align: center; padding: 56px 24px; }
.p-empty > i { font-size: 46px; color: var(--p-surface-300); }
.dark-mode .p-empty > i { color: var(--p-surface-700); }
.p-empty h2 { font-size: 17px; margin: 14px 0 0; }
.p-empty p {
  font-size: 13px;
  color: var(--p-text-dim-color);
  margin: 8px auto 0;
  max-width: 560px;
  line-height: 1.6;
}
.p-empty .p-empty-actions { margin-top: 18px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* ── stat tiles ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  border: 1px solid var(--p-content-border-color);
  border-radius: var(--p-border-radius-lg);
  background: var(--p-content-background);
  box-shadow: var(--p-card-shadow);
  font: inherit;
  color: inherit;
  transition: box-shadow 0.2s;
}
/* A tile that does something gets a pointer and lifts on hover; a tile that is
   only a reading does neither, because a card that invites a click and then
   ignores it is worse than a flat one. */
button.stat-card, a.stat-card { cursor: pointer; }
button.stat-card:hover, a.stat-card:hover { box-shadow: var(--p-card-shadow-hover); }
.stat-card.is-emphasised { box-shadow: 0 0 0 1px rgba(var(--p-primary-rgb), 0.4), var(--p-card-shadow); }
.stat-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-top: 4px; }
.stat-value { font-size: 23px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 12px; color: var(--p-text-dim-color); margin-top: 7px; }
.stat-card > .stat-row > i { font-size: 19px; opacity: 0.75; }

/* ── tooltip ─────────────────────────────────────────────────────────────────
   PrimeVue's tooltip is a directive with a JS overlay. Here it is one attribute
   and two pseudo-elements: `data-tip="..."` on anything focusable or hoverable.
   Native `title` is still used where the text is long or the element is inside a
   table row, because a CSS tooltip cannot escape an overflow container. */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) scale(0.96);
  transform-origin: bottom center;
  padding: 6px 10px;
  border-radius: var(--p-border-radius);
  background: var(--p-surface-800);
  color: #fff;
  font-size: 12px;
  font-weight: 400;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease-out 0.35s, visibility 0.15s ease-out 0.35s, transform 0.15s ease-out 0.35s;
  z-index: 1200;
  pointer-events: none;
  box-shadow: var(--p-overlay-shadow);
}
[data-tip]:hover::after, [data-tip]:focus-visible::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) scale(1);
}
[data-tip-pos="right"]::after {
  left: calc(100% + 10px);
  bottom: auto;
  top: 50%;
  transform: translateY(-50%) scale(0.96);
  transform-origin: left center;
}
[data-tip-pos="right"]:hover::after, [data-tip-pos="right"]:focus-visible::after {
  transform: translateY(-50%) scale(1);
}
