/**
 * Design tokens + UI-kit styles, imported once by the host.
 *
 * Remotes build with `cssCodeSplit: false` and inherit these variables from the
 * host document, so a federated module can't ship a conflicting theme. Both
 * light and dark are defined; the host toggles `data-theme` on <html>.
 */

:root {
  --font-sans: 'Inter', ui-sans-serif, system-ui, 'Segoe UI', Roboto, 'Noto Sans Devanagari',
    sans-serif;
  --font-mono: ui-monospace, 'Cascadia Code', 'Source Code Pro', monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --sidebar-w: 248px;
  --topbar-h: 60px;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

:root,
:root[data-theme='light'] {
  color-scheme: light;

  --bg: #F5FAF5;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --surface-hover: #eceff3;
  --border: #e2e6ec;
  --border-strong: #cbd2dc;

  --text: #101828;
  --text-muted: #5b6472;
  --text-subtle: #8b95a5;

  /* Brand green. #12703a clears WCAG AA (>=4.5:1) as button text-on-fill,
     as body text on --surface, and as text on --accent-soft — see the
     contrast check in the PR description before touching these. */
  --accent: #12703a;
  --accent-hover: #0d5b2e;
  --accent-soft: #dcf5e3;
  --on-accent: #ffffff;

  --success: #17803d;
  --success-soft: #e3f5e9;
  --warning: #a4650a;
  --warning-soft: #fbf0d9;
  --danger: #bb2124;
  --danger-soft: #fbe6e6;
  --info: #1d54b0;
  --info-soft: #e3ecfb;
  --neutral-soft: #eceff3;

  --shadow-sm: 0 1px 2px rgb(16 24 40 / 6%);
  --shadow-md: 0 4px 12px rgb(16 24 40 / 8%);
  --shadow-lg: 0 12px 32px rgb(16 24 40 / 12%);

  /* Categorical series. Fixed order, assigned by entity — never cycled, never
     reassigned by rank. Validated for CVD separation against --surface. */
  --series-1: #3b5bdb;
  --series-2: #0f9b8e;
  --series-3: #c2410c;
  --series-4: #7c3aed;
  --series-5: #b0851d;

  --grid: #e2e6ec;
}

:root[data-theme='dark'] {
  color-scheme: dark;

  --bg: #0e1116;
  --surface: #161b23;
  --surface-2: #1d232d;
  --surface-hover: #232a35;
  --border: #2a323e;
  --border-strong: #3a4451;

  --text: #e9edf3;
  --text-muted: #9aa5b4;
  --text-subtle: #6f7b8b;

  /* Re-stepped for the dark surface, not a flip of light — re-validated below. */
  --accent: #3ddc78;
  --accent-hover: #5ee794;
  --accent-soft: #173821;
  --on-accent: #062e17;

  --success: #56c98a;
  --success-soft: #16281f;
  --warning: #e0b054;
  --warning-soft: #2a2216;
  --danger: #f08b8b;
  --danger-soft: #2c1a1c;
  --info: #83b1f2;
  --info-soft: #182338;
  --neutral-soft: #232a35;

  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-md: 0 4px 12px rgb(0 0 0 / 45%);
  --shadow-lg: 0 12px 32px rgb(0 0 0 / 55%);

  /* Dark steps are *selected*, not a flip of light: re-stepped into the dark
     lightness band (OKLCH L 0.48–0.67) and re-validated against --surface. */
  --series-1: #4e82e5;
  --series-2: #079b8b;
  --series-3: #d16022;
  --series-4: #9d69d2;
  --series-5: #9e840a;

  --grid: #2a323e;
}

/* ------------------------------------------------------------------ *
 * Base
 * ------------------------------------------------------------------ */

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

html,
body,
#root {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* Devanagari needs a touch more line height to avoid clipped matras. */
:root[lang='hi'] body {
  line-height: 1.65;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

button {
  font: inherit;
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------------------------ *
 * UI kit
 * ------------------------------------------------------------------ */

.ui-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.ui-card__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.ui-card__title {
  font-size: 14px;
  font-weight: 600;
}

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

.ui-card__body {
  padding: var(--space-5);
}

.ui-card__body--flush {
  padding: 0;
}

/* Badge */

.ui-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--neutral-soft);
  color: var(--text-muted);
}

.ui-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentcolor;
}

.ui-badge--success {
  background: var(--success-soft);
  color: var(--success);
}
.ui-badge--warning {
  background: var(--warning-soft);
  color: var(--warning);
}
.ui-badge--danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.ui-badge--accent {
  background: var(--accent-soft);
  color: var(--accent);
}
.ui-badge--info {
  background: var(--info-soft);
  color: var(--info);
}
.ui-badge--plain::before {
  display: none;
}

/* Buttons */

.ui-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.ui-btn:hover:not(:disabled) {
  background: var(--surface-hover);
}

.ui-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ui-btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

.ui-btn--primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.ui-btn--ghost {
  border-color: transparent;
  background: transparent;
}

.ui-btn--icon {
  padding: 8px;
  min-width: 36px;
}

/* Inputs */

.ui-input,
.ui-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.ui-input:focus,
.ui-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.ui-input::placeholder {
  color: var(--text-subtle);
}

.ui-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

/* Table */

.ui-table-wrap {
  overflow-x: auto;
}

.ui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.ui-table th,
.ui-table td {
  padding: 12px var(--space-5);
  text-align: start;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.ui-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.ui-table tbody tr {
  transition: background 0.12s var(--ease);
}

.ui-table tbody tr:hover {
  background: var(--surface-hover);
}

.ui-table tbody tr:last-child td {
  border-bottom: none;
}

.ui-table td.is-numeric,
.ui-table th.is-numeric {
  text-align: end;
  font-variant-numeric: tabular-nums;
}

.ui-table__sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
}

.ui-table__sort:hover {
  color: var(--text);
}

.ui-table__sort-caret {
  opacity: 0.45;
  font-size: 9px;
}

.ui-table__sort[data-active='true'] .ui-table__sort-caret {
  opacity: 1;
  color: var(--accent);
}

/* States */

.ui-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-7) var(--space-5);
  text-align: center;
  color: var(--text-muted);
}

.ui-state__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.ui-state__hint {
  font-size: 13px;
  max-width: 42ch;
}

.ui-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: ui-spin 0.7s linear infinite;
}

@keyframes ui-spin {
  to {
    transform: rotate(360deg);
  }
}

.ui-skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-hover) 37%,
    var(--surface-2) 63%
  );
  background-size: 400% 100%;
  animation: ui-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
}

@keyframes ui-shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* Stat tile */

.ui-stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
}

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

.ui-stat__value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.ui-stat__delta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 12px;
  color: var(--text-muted);
}

.ui-stat__delta-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.ui-stat__delta--up .ui-stat__delta-value {
  color: var(--success);
}

.ui-stat__delta--down .ui-stat__delta-value {
  color: var(--danger);
}

/* ------------------------------------------------------------------ *
 * Charts
 * ------------------------------------------------------------------ */

.chart__tooltip {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  white-space: nowrap;
  z-index: 3;
}

.chart__tooltip-label {
  font-size: 11px;
  color: var(--text-muted);
}

.chart__tooltip-value {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.barlist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.barlist__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 6px;
}

.barlist__label {
  font-size: 13px;
  font-weight: 500;
}

.barlist__value {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.barlist__meta {
  color: var(--text-subtle);
}

.barlist__track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

.barlist__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--series-1);
  transition: width 0.4s var(--ease);
}
/* Shell chrome. Owned by the host — remotes never style outside their route. */

.shell {
  display: flex;
  min-height: 100%;
}

.shell__skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 500;
}

.shell__skip:focus {
  left: 8px;
}

.shell__main {
  flex: 1;
  min-width: 0; /* lets wide tables scroll instead of stretching the layout */
  display: flex;
  flex-direction: column;
}

.shell__content {
  flex: 1;
  padding: var(--space-5);
  max-width: 1440px;
  width: 100%;
}

.shell__content:focus {
  outline: none;
}

.shell__code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
}

.shell__scrim {
  display: none;
}

/* ------------------------------------------------------------------ *
 * Sidebar
 * ------------------------------------------------------------------ */

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  padding: var(--space-4);
  background: var(--bg);
  border-inline-end: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.22s var(--ease), padding 0.22s var(--ease);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
}

.sidebar__mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 16px;
}

.sidebar__brand-text {
  font-size: 17px;
  font-weight: 700;
}

.shell[data-sidebar-collapsed='true'] .sidebar {
  width: 48px;
  padding-inline: 6px;
}

.shell[data-sidebar-collapsed='true'] .sidebar__brand {
  justify-content: center;
  padding-inline: 0;
}

.shell[data-sidebar-collapsed='true'] .sidebar__brand-text,
.shell[data-sidebar-collapsed='true'] .sidebar__link-label,
.shell[data-sidebar-collapsed='true'] .sidebar__group-label,
.shell[data-sidebar-collapsed='true'] .sidebar__chevron,
.shell[data-sidebar-collapsed='true'] .sidebar__footer-text {
  display: none;
}

.shell[data-sidebar-collapsed='true'] .sidebar__group-toggle {
  display: none;
}

.shell[data-sidebar-collapsed='true'] .sidebar__link,
.shell[data-sidebar-collapsed='true'] .sidebar__group-toggle {
  position: relative;
  grid-template-columns: 1fr;
  justify-items: center;
  padding-inline: 0;
}

.shell[data-sidebar-collapsed='true'] .sidebar__subnav {
  display: flex;
  padding-top: 2px;
}

.shell[data-sidebar-collapsed='true'] .sidebar__link--sub {
  padding-inline-start: 0;
}

.shell[data-sidebar-collapsed='true'] .sidebar__link::after,
.shell[data-sidebar-collapsed='true'] .sidebar__group-toggle::after {
  content: attr(data-tooltip);
  position: absolute;
  inset-inline-start: calc(100% + 8px);
  top: 50%;
  z-index: 30;
  display: none;
  transform: translateY(-50%);
  padding: 7px 10px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--on-accent);
  box-shadow: var(--shadow-md);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
}

.shell[data-sidebar-collapsed='true'] .sidebar__link:hover::after,
.shell[data-sidebar-collapsed='true'] .sidebar__link:focus-visible::after,
.shell[data-sidebar-collapsed='true'] .sidebar__group-toggle:hover::after,
.shell[data-sidebar-collapsed='true'] .sidebar__group-toggle:focus-visible::after {
  display: block;
}

.shell[data-sidebar-collapsed='true'] .sidebar__icon {
  font-size: 18px;
}

.shell[data-sidebar-collapsed='true'] .sidebar__footer {
  grid-template-columns: 1fr;
  justify-items: center;
  padding-inline: 0;
}

.shell[data-sidebar-collapsed='true'] .sidebar__logout {
  display: none;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
}

.sidebar__link {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-weight: 500;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.sidebar__link:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar__link--active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.sidebar__link--sub {
  padding-inline-start: calc(var(--space-3) + 20px + var(--space-3));
  font-size: 13px;
}

.sidebar__icon {
  font-size: 14px;
  text-align: center;
  line-height: 1;
}

.sidebar__group-toggle {
  width: 100%;
  display: grid;
  grid-template-columns: 20px 1fr 14px;
  align-items: center;
  gap: var(--space-3);
  padding: 9px var(--space-3);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-muted);
  font-weight: 500;
  text-align: start;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.sidebar__group-toggle:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.sidebar__group-label {
  font-size: 14px;
}

.sidebar__chevron {
  font-size: 11px;
  color: var(--text-subtle);
  transition: transform 0.15s var(--ease);
}

.sidebar__chevron[data-open='true'] {
  transform: rotate(180deg);
}

.sidebar__subnav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: 2px;
}

.sidebar__footer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2);
  border-top: 1px solid var(--border);
  padding-top: var(--space-4);
}

.sidebar__avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}

.sidebar__footer-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.sidebar__footer-text strong {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__footer-text small {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar__logout {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-subtle);
  flex-shrink: 0;
}

.sidebar__logout:hover {
  background: var(--surface-hover);
  color: var(--text);
}

/* ------------------------------------------------------------------ *
 * Topbar
 * ------------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--topbar-h);
  padding-inline: var(--space-5);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar__title {
  font-size: 16px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.topbar__burger {
  display: inline-flex;
}

/* Language switcher */

.langswitch {
  display: inline-flex;
  padding: 2px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.langswitch__btn {
  padding: 5px 12px;
  border: none;
  border-radius: calc(var(--radius-md) - 3px);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.langswitch__btn:hover {
  color: var(--text);
}

.langswitch__btn--active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Wallet chip + avatar */

.topbar__wallet {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.topbar__wallet-icon {
  font-size: 12px;
}

.topbar__wallet-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.topbar__avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 12px;
}

@media (max-width: 640px) {
  .topbar__wallet-label {
    display: none;
  }
}

/* ------------------------------------------------------------------ *
 * Mobile: sidebar collapses to an overlay drawer
 * ------------------------------------------------------------------ */

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    inset-inline-start: 0;
    top: 0;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.22s var(--ease);
    box-shadow: var(--shadow-lg);
  }

  [dir='rtl'] .sidebar {
    transform: translateX(100%);
  }

  .shell[data-sidebar-open='true'] .sidebar {
    transform: translateX(0);
  }

  .shell[data-sidebar-open='true'] .shell__scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 10;
    border: none;
    background: rgb(0 0 0 / 45%);
  }

  .topbar__burger {
    display: inline-flex;
  }

  .shell[data-sidebar-collapsed='true'] .sidebar {
    width: var(--sidebar-w);
    padding: var(--space-4);
  }

  .shell[data-sidebar-collapsed='true'] .sidebar__brand {
    justify-content: flex-start;
    padding-inline: var(--space-2);
  }

  .shell[data-sidebar-collapsed='true'] .sidebar__brand-text,
  .shell[data-sidebar-collapsed='true'] .sidebar__link-label,
  .shell[data-sidebar-collapsed='true'] .sidebar__group-label,
  .shell[data-sidebar-collapsed='true'] .sidebar__chevron,
  .shell[data-sidebar-collapsed='true'] .sidebar__subnav,
  .shell[data-sidebar-collapsed='true'] .sidebar__footer-text {
    display: revert;
  }

  .shell[data-sidebar-collapsed='true'] .sidebar__link,
  .shell[data-sidebar-collapsed='true'] .sidebar__group-toggle {
    grid-template-columns: 20px 1fr 14px;
    justify-items: revert;
    padding-inline: var(--space-3);
  }

  .shell[data-sidebar-collapsed='true'] .sidebar__group-toggle {
    display: grid;
  }

  .shell[data-sidebar-collapsed='true'] .sidebar__icon {
    font-size: 14px;
  }

  .shell[data-sidebar-collapsed='true'] .sidebar__footer {
    grid-template-columns: auto 1fr auto;
    justify-items: revert;
    padding-inline: var(--space-2);
  }

  .shell[data-sidebar-collapsed='true'] .sidebar__logout {
    display: grid;
  }

  .shell__content {
    padding: var(--space-4);
  }
}

/* ------------------------------------------------------------------ *
 * Sign-in (spec 014)
 * ------------------------------------------------------------------ */

.login {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-7) var(--space-4);
  background: var(--bg);
  position: relative;
}

.login__tools {
  position: absolute;
  top: var(--space-4);
  inset-inline-end: var(--space-4);
  display: flex;
  gap: var(--space-2);
}

.login__column {
  width: 100%;
  max-width: 404px;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.login__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 18px;
  color: var(--text);
}

.login__mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 14px;
}

.login__card {
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
}

.login__title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.login__subtitle {
  margin: var(--space-1) 0 var(--space-5);
  color: var(--text-muted);
  font-size: 13.5px;
}

.login__form {
  display: flex;
  flex-direction: column;
}

.login__label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.login__input {
  width: 100%;
  height: 34px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  margin-bottom: var(--space-4);
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.login__input::placeholder {
  color: var(--text-subtle);
}

.login__input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.login__password {
  position: relative;
}

.login__password .login__input {
  padding-inline-end: 40px;
}

.login__reveal {
  position: absolute;
  top: 0;
  inset-inline-end: 4px;
  height: 34px;
  width: 32px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.login__reveal:hover {
  color: var(--text);
}

.login__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  font-size: 13px;
}

.login__remember {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text);
  cursor: pointer;
}

.login__remember input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.login__link {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.login__link:hover:not(:disabled) {
  color: var(--accent);
}

.login__link:disabled {
  color: var(--text-subtle);
  cursor: not-allowed;
}

.login__hint {
  margin: 0 0 var(--space-4);
  color: var(--text-muted);
  font-size: 13px;
}

.login__alert,
.login__notice {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.login__alert {
  background: var(--danger-soft);
  color: var(--danger);
}

.login__notice {
  background: var(--info-soft);
  color: var(--info);
}

.login__submit {
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.login__submit:hover:not(:disabled) {
  background: var(--accent-hover);
}

.login__submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login__demo {
  margin-top: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--accent-soft) 35%, var(--surface-2));
  font-size: 12px;
}

.login__demo-title {
  margin: 0 0 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

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

.login__demo-account {
  border: none;
  background: none;
  padding: 1px 0;
  font: inherit;
  color: var(--text-muted);
  text-align: start;
  cursor: pointer;
}

.login__demo-account:hover {
  color: var(--accent);
}

.login__footer {
  margin: 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--text-muted);
}

.auth-gate {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-5);
}

/* ------------------------------------------------------------------ *
 * Admin console chrome (spec 014)
 * ------------------------------------------------------------------ */

.admin-shell {
  min-height: 100vh;
  background: var(--bg);
}

.admin-shell__header {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 22%, var(--border));
}

.admin-shell__inner,
.admin-shell__content {
  max-width: 1128px;
  margin: 0 auto;
  padding-inline: var(--space-4);
}

.admin-shell__inner {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding-block: var(--space-2);
}

.admin-shell__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text);
  text-decoration: none;
}

.admin-shell__mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 18px;
}

.admin-shell__brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.admin-shell__brand-text strong {
  font-size: 14.5px;
}

.admin-shell__brand-text small {
  font-size: 11.5px;
  color: var(--text-muted);
}

.admin-shell__actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.admin-shell__email {
  font-size: 13px;
  color: var(--text-muted);
  margin-inline: var(--space-2);
}

.admin-shell__switch,
.admin-shell__logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.admin-shell__switch:hover,
.admin-shell__logout:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.admin-shell__content {
  padding-block: var(--space-5);
}

.admin-shell__content:focus {
  outline: none;
}

.sidebar__link--admin {
  margin-top: var(--space-3);
  border-top: 1px solid var(--border);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding-top: var(--space-3);
}

@media (max-width: 640px) {
  .admin-shell__email {
    display: none;
  }
}
