/* ==========================================================================
   Component library — buttons, cards, forms, data display, feedback
   Every component documents its states: default / hover / active / focus /
   disabled / loading.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */

.btn {
  --btn-bg: var(--surface);
  --btn-ink: var(--text);
  --btn-border: var(--border);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;                      /* WCAG touch target */
  padding: 0 var(--s-5);
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-ink);
  border: 1px solid var(--btn-border);
  font-size: var(--fs-base);
  font-weight: var(--fw-semibold);
  letter-spacing: -.01em;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--t-fast) var(--ease),
              box-shadow var(--t-base) var(--ease),
              background-color var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              opacity var(--t-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.btn-primary {
  --btn-ink: #fff;
  --btn-border: transparent;
  background: var(--grad-primary);
  box-shadow: var(--e-brand);
}
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 10px 30px rgba(37,99,235,.36); }

.btn-accent {
  --btn-ink: #fff;
  --btn-border: transparent;
  background: var(--grad-accent);
  box-shadow: 0 8px 24px rgba(6,182,212,.28);
}
.btn-accent:hover { filter: brightness(1.06); }

.btn-secondary { --btn-bg: var(--surface); --btn-ink: var(--text); box-shadow: var(--e-1); }
.btn-secondary:hover { --btn-border: var(--brand-300); --btn-ink: var(--brand-700); box-shadow: var(--e-2); }

.btn-soft { --btn-bg: var(--brand-50); --btn-ink: var(--brand-700); --btn-border: transparent; }
.btn-soft:hover { --btn-bg: var(--brand-100); }

.btn-ghost { --btn-bg: transparent; --btn-ink: var(--text-2); --btn-border: transparent; }
.btn-ghost:hover { --btn-bg: var(--surface-3); --btn-ink: var(--text); }

.btn-danger { --btn-bg: var(--danger); --btn-ink: #fff; --btn-border: transparent; }
.btn-danger:hover { --btn-bg: #DC2626; }

.btn-sm  { min-height: 36px; padding: 0 var(--s-4); font-size: var(--fs-sm); border-radius: var(--r-sm); }
.btn-lg  { min-height: 54px; padding: 0 var(--s-7); font-size: var(--fs-lg); border-radius: var(--r-md); }
.btn-block { width: 100%; }

.btn-icon {
  min-height: 42px; width: 42px;
  padding: 0;
  border-radius: var(--r-md);
  --btn-bg: transparent; --btn-border: transparent; --btn-ink: var(--text-2);
}
.btn-icon:hover { --btn-bg: var(--surface-3); --btn-ink: var(--text); }
.btn-icon svg { width: 20px; height: 20px; }

/* Floating action button */
.fab {
  position: fixed;
  right: var(--s-6);
  bottom: var(--s-6);
  width: 60px; height: 60px;
  border-radius: var(--r-full);
  background: var(--grad-primary);
  color: #fff;
  box-shadow: var(--e-brand);
  z-index: var(--z-sticky);
  display: grid;
  place-items: center;
  transition: transform var(--t-base) var(--ease-spring), box-shadow var(--t-base) var(--ease);
}
.fab:hover { transform: scale(1.08) rotate(6deg); box-shadow: 0 14px 40px rgba(37,99,235,.45); }
.fab svg { width: 26px; height: 26px; }

/* Ripple — injected by ui.js on .btn press */
.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  background: currentColor;
  opacity: .28;
  pointer-events: none;
  animation: ripple var(--t-slower) var(--ease-out) forwards;
}
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }

/* Loading state */
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.btn-secondary.is-loading::after, .btn-ghost.is-loading::after {
  border-color: var(--border-2); border-top-color: var(--brand-primary);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Logo — shared by the app shell and the marketing site
   -------------------------------------------------------------------------- */

.logo {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--text);
  font-weight: var(--fw-bold);
  font-size: var(--fs-h4);
  letter-spacing: -.03em;
  white-space: nowrap;
}
.logo:hover { text-decoration: none; }

.logo-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  background: var(--grad-primary);
  display: grid;
  place-items: center;
  color: #fff;
  flex: none;
  box-shadow: var(--e-brand);
}
.logo-mark svg { width: 21px; height: 21px; }

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--e-1);
  padding: var(--s-5);
  transition: box-shadow var(--t-base) var(--ease),
              transform var(--t-base) var(--ease),
              border-color var(--t-base) var(--ease);
}
.card-hover:hover { box-shadow: var(--e-3); transform: translateY(-3px); border-color: var(--brand-200); }
.card-flush { padding: 0; overflow: hidden; }
.card-pad { padding: var(--s-5); }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--s-4);
  margin-bottom: var(--s-5);
}
.card-title { font-size: var(--fs-h4); font-weight: var(--fw-semibold); letter-spacing: -.015em; }
.card-sub { font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; }

/* Glass card — light glassmorphism over gradient backdrops */
.card-glass {
  background: var(--glass-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--e-3);
}

/* Gradient stat card */
.card-grad {
  background: var(--grad-primary);
  border: none;
  color: #fff;
  position: relative;
  overflow: hidden;
}
.card-grad::after {
  content: "";
  position: absolute;
  width: 260px; height: 260px;
  right: -90px; top: -120px;
  border-radius: 50%;
  background: rgba(255,255,255,.14);
}
.card-grad .card-title, .card-grad .stat-value { color: #fff; }
.card-grad .card-sub, .card-grad .stat-label { color: rgba(255,255,255,.82); }

/* Icon tile */
.icon-tile {
  width: 44px; height: 44px;
  border-radius: var(--r-md);
  display: grid;
  place-items: center;
  background: var(--grad-primary);
  color: #fff;
  flex: none;
  box-shadow: var(--e-1);
}
.icon-tile svg { width: 22px; height: 22px; }
.icon-tile-lg { width: 56px; height: 56px; border-radius: var(--r-md); }
.icon-tile-lg svg { width: 28px; height: 28px; }
.icon-tile-soft { background: var(--brand-50); color: var(--brand-700); box-shadow: none; }
.icon-tile-success { background: var(--success-bg); color: var(--success-ink); box-shadow: none; }
.icon-tile-warning { background: var(--warning-bg); color: var(--warning-ink); box-shadow: none; }
.icon-tile-danger  { background: var(--danger-bg);  color: var(--danger-ink);  box-shadow: none; }
.icon-tile-info    { background: var(--info-bg);    color: var(--info-ink);    box-shadow: none; }
.icon-tile-accent  { background: var(--grad-accent); color: #fff; }

/* --------------------------------------------------------------------------
   Stat tile
   label · value · delta · trend   (contract from the dataviz spec)
   -------------------------------------------------------------------------- */

.stat-label {
  font-size: var(--fs-sm);
  color: var(--text-2);
  font-weight: var(--fw-medium);
}
.stat-value {
  font-size: 2rem;
  font-weight: var(--fw-bold);
  letter-spacing: -.03em;
  line-height: 1.1;
  margin-top: var(--s-2);
  /* proportional figures — tabular-nums is for columns, not display numbers */
}
.stat-unit { font-size: var(--fs-base); font-weight: var(--fw-medium); color: var(--text-2); margin-left: 2px; }

.delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  padding: 2px var(--s-2);
  border-radius: var(--r-full);
}
.delta svg { width: 14px; height: 14px; }
.delta-up   { color: var(--success-ink); background: var(--success-bg); }
.delta-down { color: var(--danger-ink);  background: var(--danger-bg); }
.delta-flat { color: var(--text-2);      background: var(--surface-3); }

/* --------------------------------------------------------------------------
   Badges & pills
   -------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 3px var(--s-3);
  border-radius: var(--r-full);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1.6;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge svg { width: 13px; height: 13px; flex: none; }
.badge-neutral { background: var(--surface-3); color: var(--text-2); }
.badge-brand   { background: var(--brand-50);  color: var(--brand-700); }
.badge-success { background: var(--success-bg); color: var(--success-ink); }
.badge-warning { background: var(--warning-bg); color: var(--warning-ink); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-ink); }
.badge-info    { background: var(--info-bg);    color: var(--info-ink); }
.badge-outline { background: transparent; border-color: var(--border-2); color: var(--text-2); }

.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--text-3);
}
.dot-success { background: var(--success); }
.dot-warning { background: var(--warning); }
.dot-danger  { background: var(--danger); }
.dot-brand   { background: var(--brand-primary); }
.dot-pulse { position: relative; }
.dot-pulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid currentColor;
  color: inherit;
  background: inherit;
  opacity: .5;
  animation: pulse-ring 2s var(--ease-out) infinite;
}
@keyframes pulse-ring {
  0%   { transform: scale(.7); opacity: .6; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: var(--s-2); }
.label { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--text); }
.hint  { font-size: var(--fs-xs); color: var(--text-2); }
.error-text { font-size: var(--fs-xs); color: var(--danger-ink); font-weight: var(--fw-medium); }

.input, .select, .textarea {
  width: 100%;
  min-height: 46px;
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  color: var(--text);
  font-size: var(--fs-base);
  transition: border-color var(--t-fast) var(--ease),
              box-shadow var(--t-fast) var(--ease),
              background-color var(--t-fast) var(--ease);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-2); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 4px var(--ring);
}
.input:disabled, .textarea:disabled { background: var(--surface-3); color: var(--text-3); cursor: not-allowed; }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus { box-shadow: 0 0 0 4px rgba(239,68,68,.22); }

.textarea { min-height: 132px; resize: vertical; line-height: 1.65; }

.select {
  appearance: none;
  padding-right: var(--s-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--s-4) center;
  cursor: pointer;
}

/* Input with a leading icon / trailing slot */
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: var(--s-9); }
.input-group > svg:first-child {
  position: absolute;
  left: var(--s-4);
  width: 18px; height: 18px;
  color: var(--text-3);
  pointer-events: none;
}
.input-group .input-actions {
  position: absolute;
  right: var(--s-2);
  display: flex;
  gap: var(--s-1);
}

/* Search field, hero-sized */
.search-xl { position: relative; }
.search-xl .input {
  min-height: 64px;
  padding-left: 56px;
  padding-right: 148px;
  border-radius: var(--r-lg);
  font-size: var(--fs-lg);
  box-shadow: var(--e-2);
}
/* The icon may be the SVG itself or a wrapper span the icon was injected into. */
.search-xl > svg:first-child,
.search-xl > span:first-child {
  position: absolute;
  left: var(--s-5);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  color: var(--text-3);
  pointer-events: none;
}
.search-xl > svg:first-child,
.search-xl > span:first-child > svg { width: 22px; height: 22px; }
.search-xl .btn { position: absolute; right: var(--s-2); top: 50%; transform: translateY(-50%); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  width: 46px; height: 26px;
  border-radius: var(--r-full);
  background: var(--border-2);
  position: relative;
  transition: background-color var(--t-base) var(--ease);
  flex: none;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--e-1);
  transition: transform var(--t-base) var(--ease-spring);
}
.switch input:checked + .switch-track { background: var(--brand-primary); }
.switch input:checked + .switch-track::after { transform: translateX(20px); }
.switch input:focus-visible + .switch-track { box-shadow: 0 0 0 4px var(--ring); }

/* Checkbox / radio */
.check { display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; font-size: var(--fs-base); }
.check input { width: 20px; height: 20px; accent-color: var(--brand-primary); cursor: pointer; flex: none; }

/* Segmented control */
.segmented {
  display: inline-flex;
  padding: var(--s-1);
  background: var(--surface-3);
  border-radius: var(--r-md);
  gap: 2px;
}
/* A segmented control can't shrink below its buttons, so on narrow screens it
   scrolls rather than pushing the page wider. */
.segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }

.segmented button {
  padding: var(--s-2) var(--s-4);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: var(--fw-semibold);
  color: var(--text-2);
  min-height: 34px;
  flex: none;
  white-space: nowrap;
  transition: all var(--t-fast) var(--ease);
}
.segmented button:hover { color: var(--text); }
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--brand-700);
  box-shadow: var(--e-1);
}

/* Chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  min-height: 38px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-full);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--t-fast) var(--ease);
}
.chip:hover { border-color: var(--brand-300); color: var(--brand-700); background: var(--brand-50); transform: translateY(-1px); }
.chip[aria-pressed="true"] { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.chip svg { width: 15px; height: 15px; }

/* Dropzone */
.dropzone {
  border: 2px dashed var(--border-2);
  border-radius: var(--r-lg);
  padding: var(--s-7) var(--s-5);
  text-align: center;
  background: var(--surface-2);
  transition: all var(--t-base) var(--ease);
  cursor: pointer;
}
.dropzone:hover, .dropzone.is-over {
  border-color: var(--brand-primary);
  background: var(--brand-50);
  transform: scale(1.01);
}
.dropzone.is-over { box-shadow: 0 0 0 4px var(--ring); }

/* --------------------------------------------------------------------------
   Avatar
   -------------------------------------------------------------------------- */

.avatar {
  width: 40px; height: 40px;
  border-radius: var(--r-full);
  background: var(--grad-primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  flex: none;
  overflow: hidden;
  user-select: none;
}
.avatar-sm { width: 32px; height: 32px; font-size: var(--fs-xs); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--fs-lg); }
.avatar-xl { width: 88px; height: 88px; font-size: var(--fs-h2); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -10px; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */

.tabs {
  display: flex;
  gap: var(--s-1);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--text-2);
  white-space: nowrap;
  min-height: 44px;
  transition: color var(--t-fast) var(--ease);
}
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { color: var(--brand-700); font-weight: var(--fw-semibold); }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: var(--s-3); right: var(--s-3); bottom: -1px;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--brand-primary);
  animation: tab-in var(--t-base) var(--ease-out);
}
@keyframes tab-in { from { transform: scaleX(.3); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }

/* --------------------------------------------------------------------------
   Table & data grid
   -------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; border-radius: var(--r-lg); }

.table { font-size: var(--fs-sm); }
.table th {
  text-align: left;
  padding: var(--s-3) var(--s-4);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-2);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.table td {
  padding: var(--s-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background-color var(--t-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Progress & meters
   -------------------------------------------------------------------------- */

.progress {
  height: 8px;
  border-radius: var(--r-full);
  background: var(--chart-track);   /* lighter step of the same ramp */
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  border-radius: var(--r-full);
  background: var(--grad-primary);
  transition: width var(--t-slower) var(--ease-out);
}
.progress-success > span { background: var(--success); }
.progress-warning > span { background: var(--warning); }
.progress-danger  > span { background: var(--danger); }
.progress-lg { height: 12px; }

/* Severity meter — fill carries severity, track is a lighter step */
.meter { height: 10px; border-radius: var(--r-full); background: var(--chart-track); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: var(--r-full); transition: width var(--t-slower) var(--ease-out); }

/* --------------------------------------------------------------------------
   Timeline
   -------------------------------------------------------------------------- */

.timeline { position: relative; padding-left: var(--s-7); }
.timeline::before {
  content: "";
  position: absolute;
  left: 15px; top: 6px; bottom: 6px;
  width: 2px;
  background: linear-gradient(180deg, var(--brand-200), var(--border) 80%);
  border-radius: 2px;
}
.timeline-item { position: relative; padding-bottom: var(--s-6); }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-node {
  position: absolute;
  left: calc(-1 * var(--s-7));
  top: 2px;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 2px solid var(--border);
  color: var(--text-2);
}
.timeline-node svg { width: 15px; height: 15px; }
.timeline-node.is-brand   { border-color: var(--brand-300); background: var(--brand-50); color: var(--brand-700); }
.timeline-node.is-success { border-color: #A7F3D0; background: var(--success-bg); color: var(--success-ink); }
.timeline-node.is-danger  { border-color: #FECACA; background: var(--danger-bg);  color: var(--danger-ink); }
.timeline-node.is-warning { border-color: #FDE68A; background: var(--warning-bg); color: var(--warning-ink); }

/* --------------------------------------------------------------------------
   Accordion
   -------------------------------------------------------------------------- */

.accordion { border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.accordion + .accordion { margin-top: var(--s-3); }
.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  min-height: 60px;
  text-align: left;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-base);
  transition: background-color var(--t-fast) var(--ease);
}
.accordion-trigger:hover { background: var(--surface-2); }
.accordion-trigger svg { width: 20px; height: 20px; color: var(--text-2); transition: transform var(--t-base) var(--ease); flex: none; }
.accordion-trigger[aria-expanded="true"] svg { transform: rotate(180deg); color: var(--brand-primary); }
.accordion-panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows var(--t-base) var(--ease);
}
.accordion-panel > div { overflow: hidden; }
.accordion-trigger[aria-expanded="true"] + .accordion-panel { grid-template-rows: 1fr; }
.accordion-body { padding: 0 var(--s-5) var(--s-5); color: var(--text-2); line-height: 1.7; }

/* --------------------------------------------------------------------------
   Dropdown / popover
   -------------------------------------------------------------------------- */

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + var(--s-2));
  min-width: 240px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  box-shadow: var(--e-4);
  padding: var(--s-2);
  z-index: var(--z-drawer);
  transform-origin: top right;
  animation: pop var(--t-base) var(--ease-out);
}
@keyframes pop { from { opacity: 0; transform: scale(.94) translateY(-6px); } to { opacity: 1; transform: none; } }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  color: var(--text);
  text-align: left;
  min-height: 42px;
  transition: background-color var(--t-fast) var(--ease);
}
.dropdown-item:hover { background: var(--surface-3); text-decoration: none; }
.dropdown-item svg { width: 17px; height: 17px; color: var(--text-2); flex: none; }
.dropdown-sep { height: 1px; background: var(--border); margin: var(--s-2) 0; }

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  backdrop-filter: blur(6px);
  z-index: var(--z-modal);
  display: grid;
  place-items: center;
  padding: var(--s-5);
  animation: fade var(--t-base) var(--ease);
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--e-4);
  padding: var(--s-6);
  animation: modal-in var(--t-slow) var(--ease-out);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-lg { width: min(760px, 100%); }

/* --------------------------------------------------------------------------
   Toast
   -------------------------------------------------------------------------- */

.toast-region {
  position: fixed;
  right: var(--s-5);
  bottom: var(--s-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  min-width: 300px;
  max-width: 400px;
  padding: var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--brand-primary);
  border-radius: var(--r-md);
  box-shadow: var(--e-4);
  pointer-events: auto;
  animation: toast-in var(--t-slow) var(--ease-spring);
}
@keyframes toast-in { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
.toast.is-out { animation: toast-out var(--t-base) var(--ease) forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateX(40px); } }
.toast-success { border-left-color: var(--success); }
.toast-warning { border-left-color: var(--warning); }
.toast-danger  { border-left-color: var(--danger); }
.toast svg { width: 20px; height: 20px; flex: none; margin-top: 1px; }
.toast-success svg { color: var(--success-ink); }
.toast-warning svg { color: var(--warning-ink); }
.toast-danger svg  { color: var(--danger-ink); }
.toast-title { font-weight: var(--fw-semibold); font-size: var(--fs-sm); }
.toast-msg { font-size: var(--fs-sm); color: var(--text-2); margin-top: 2px; }

/* --------------------------------------------------------------------------
   Skeleton loaders
   -------------------------------------------------------------------------- */

.skeleton {
  border-radius: var(--r-sm);
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.skeleton-text { height: 12px; margin-bottom: var(--s-2); }
.skeleton-title { height: 20px; width: 45%; margin-bottom: var(--s-4); }
.skeleton-block { height: 180px; border-radius: var(--r-md); }

/* --------------------------------------------------------------------------
   Breadcrumbs & pagination
   -------------------------------------------------------------------------- */

.breadcrumb { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); color: var(--text-2); flex-wrap: wrap; }
.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--brand-primary); }
.breadcrumb svg { width: 15px; height: 15px; color: var(--text-3); }
.breadcrumb [aria-current] { color: var(--text); font-weight: var(--fw-semibold); }

.pagination { display: flex; align-items: center; gap: var(--s-1); }
.pagination button {
  min-width: 38px; height: 38px;
  border-radius: var(--r-sm);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--text-2);
  border: 1px solid transparent;
  transition: all var(--t-fast) var(--ease);
}
.pagination button:hover { background: var(--surface-3); color: var(--text); }
.pagination button[aria-current="page"] {
  background: var(--brand-600); color: #fff; border-color: var(--brand-600);
}
.pagination button:disabled { opacity: .4; pointer-events: none; }

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */

.stars { display: inline-flex; align-items: center; gap: 2px; }
.stars span { display: flex; }
.stars svg { width: 15px; height: 15px; }
/* a filled star must actually be filled — the icon set ships fill="none" */
.stars .is-full svg  { fill: var(--warning); color: var(--warning); }
.stars .is-empty svg { fill: none; color: var(--border-2); }

.divider { height: 1px; background: var(--border); }
.empty-state { text-align: center; padding: var(--s-9) var(--s-5); color: var(--text-2); }
.empty-state .icon-tile { margin: 0 auto var(--s-4); }

.tooltip-el {
  position: fixed;
  z-index: var(--z-toast);
  padding: var(--s-2) var(--s-3);
  background: #0F172A;
  color: #fff;
  border-radius: var(--r-xs);
  font-size: var(--fs-xs);
  pointer-events: none;
  box-shadow: var(--e-3);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--t-fast) var(--ease);
}
.tooltip-el.is-on { opacity: 1; }

/* Reveal-on-scroll (IntersectionObserver adds .is-in) */
.reveal { opacity: 0; transform: translateY(24px); transition: opacity var(--t-slow) var(--ease-out), transform var(--t-slow) var(--ease-out); }
.reveal.is-in { opacity: 1; transform: none; }
