/*
 * DocMaster operations — one stylesheet for the whole admin.
 *
 * The tokens are the customer web app's ("paper and ink"): a quiet paper page,
 * ink text, hairline rules, the brand blue for anything that acts and the
 * logo's red only for the logo and for danger. Keep them identical to
 * document-web/app/assets/css/tokens.css.
 *
 * Order: tokens · fonts · base · frame · components · screens · sign-in ·
 * small screens. Templates share these class names; a page adds layout only.
 */

/* ============================================================ tokens */

:root {
  --paper: #f5f7fa;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-sunken: #eef2f7;
  --hairline: #e3e8ef;
  --hairline-strong: #ccd4df;

  --ink: #0e1726;
  --text: #3b4859;
  --muted: #5b6779;

  --brand-blue: #0275fc;
  --brand-red: #fa3331;
  --blue-50: #edf4ff;
  --blue-100: #dcebff;
  --blue-200: #b9d6ff;
  --action: #0062d6;
  --action-hover: #0052b8;
  --on-action: #ffffff;
  --link: #0059c2;
  --focus: #0275fc;
  --glow: rgba(2, 117, 252, 0.07);

  --success-tint: #eaf6ef;
  --success-ink: #1c6b43;
  --success-border: #bfe1cc;
  --warning-tint: #fff5dd;
  --warning-ink: #7a4f00;
  --warning-border: #efd59a;
  --error-tint: #fff0f1;
  --error-ink: #a8202c;
  --error-border: #f3c4ca;
  --danger: #c8232f;
  --danger-hover: #ab1d28;
  --info-tint: var(--blue-50);
  --info-ink: var(--link);
  --info-border: var(--blue-200);

  --font-body: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-display: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-pill: 999px;
  --shadow-sm: 0 1px 2px rgba(14, 23, 38, 0.05);
  --shadow-md: 0 1px 2px rgba(14, 23, 38, 0.04), 0 6px 20px rgba(14, 23, 38, 0.06);
  --shadow-lg: 0 2px 6px rgba(14, 23, 38, 0.05), 0 18px 48px rgba(14, 23, 38, 0.14);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --duration: 180ms;

  --sidebar-width: 248px;
  --topbar-height: 64px;

  color-scheme: light;
}

:root[data-theme='dark'] {
  --paper: #0b111c;
  --surface: #121a27;
  --surface-raised: #18233a;
  --surface-sunken: #0e1522;
  --hairline: #233047;
  --hairline-strong: #33425c;

  --ink: #eef3fa;
  --text: #c2cddc;
  --muted: #93a2b7;

  --blue-50: #13233d;
  --blue-100: #1a2f52;
  --blue-200: #2b4a7a;
  --action: #6aa8ff;
  --action-hover: #8cbfff;
  --on-action: #0b111c;
  --link: #8cbfff;
  --focus: #8cbfff;
  --glow: rgba(106, 168, 255, 0.08);

  --success-tint: #15342a;
  --success-ink: #9fdcb8;
  --success-border: #2f5e48;
  --warning-tint: #372e1a;
  --warning-ink: #f0cf8a;
  --warning-border: #66522a;
  --error-tint: #3a2128;
  --error-ink: #ffb0b6;
  --error-border: #6b3a44;
  --danger: #c0303a;
  --danger-hover: #d8434d;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, 0.35), 0 20px 56px rgba(0, 0, 0, 0.45);

  color-scheme: dark;
}

/* ============================================================ fonts */

@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 100 1000;
  font-display: swap;
  src: url('fonts/dm-sans-variable.ttf') format('truetype');
}
@font-face {
  font-family: 'Manrope';
  font-style: normal;
  font-weight: 200 800;
  font-display: swap;
  src: url('fonts/manrope-variable.ttf') format('truetype');
}

/* ============================================================ base */

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  font-synthesis: none;
}
body {
  margin: 0;
  background:
    radial-gradient(1100px 420px at 20% -14%, var(--glow), transparent 70%),
    var(--paper);
  background-attachment: fixed;
  color: var(--text);
  font: 400 var(--text-base) / 1.55 var(--font-body);
  text-rendering: optimizeLegibility;
}
::selection {
  background: var(--blue-100);
  color: var(--ink);
}
h1,
h2,
h3,
p,
dl,
dd,
figure {
  margin: 0;
}
h1,
h2,
h3 {
  color: var(--ink);
  font-family: var(--font-display);
}
h1 {
  font-size: var(--text-2xl);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  text-wrap: balance;
}
h2 {
  font-size: var(--text-lg);
  font-weight: 750;
  letter-spacing: -0.015em;
  line-height: 1.35;
}
h3 {
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.4;
}
p {
  text-wrap: pretty;
}
a {
  color: inherit;
  text-decoration: none;
}
strong,
b {
  font-weight: 650;
}
small {
  font-size: var(--text-xs);
}
code,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
button:disabled {
  cursor: default;
}
img,
svg {
  display: block;
  max-width: 100%;
}
svg.icon {
  flex-shrink: 0;
}
:where(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}
.muted {
  color: var(--muted);
}
.tabular,
td,
.metric-card strong {
  font-variant-numeric: tabular-nums;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ============================================================ frame */

.skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip-link:focus {
  position: fixed;
  z-index: 200;
  left: var(--space-3);
  top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--action);
  color: var(--on-action);
  font-weight: 600;
  box-shadow: var(--shadow-md);
}
#main:focus {
  outline: none;
}

/* The light logo on paper; the icon and a wordmark on dark surfaces. */
.brand {
  display: inline-flex;
  align-items: center;
  color: var(--ink);
}
.brand-art {
  display: block;
  width: 148px;
  max-width: 100%;
}
.brand-logo {
  display: block;
  width: 100%;
  height: auto;
}
.brand-dark {
  display: none;
  align-items: center;
  gap: var(--space-2);
  color: var(--ink);
  font: 800 19px / 1 var(--font-display);
  letter-spacing: -0.03em;
  white-space: nowrap;
}
.brand-dark img {
  width: 30px;
  height: 30px;
}
:root[data-theme='dark'] .brand-logo {
  display: none;
}
:root[data-theme='dark'] .brand-dark {
  display: flex;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
}
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--hairline);
}
.sidebar-inner {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: var(--space-5) var(--space-3) var(--space-3);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3) var(--space-3);
}
.sidebar-brand small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.side-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  padding-bottom: var(--space-3);
}
.nav-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-group + .nav-group {
  margin-top: var(--space-4);
}
.nav-group > p {
  margin: 0 var(--space-3) var(--space-1);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 38px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--text-base);
  font-weight: 500;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}
.nav-link .icon {
  color: var(--muted);
  transition: color var(--duration) var(--ease);
}
.nav-link:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}
.nav-link.active {
  background: var(--blue-50);
  color: var(--link);
  font-weight: 650;
}
.nav-link.active .icon {
  color: var(--link);
}
/* Something is waiting for someone: a filled count beside the page. */
.nav-badge {
  margin-left: auto;
  min-width: 22px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
  background: var(--action);
  color: var(--on-action);
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.sidebar-profile {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-2) var(--space-1) var(--space-3);
  border-top: 1px solid var(--hairline);
}
.avatar {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--blue-100);
  color: var(--link);
  font: 750 14px / 1 var(--font-display);
}
.avatar.large {
  width: 52px;
  height: 52px;
  font-size: 20px;
}
.staff-name {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 650;
  line-height: 1.35;
}
.staff-name > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.staff-name small {
  color: var(--muted);
  font-weight: 450;
}
.signout {
  margin: 0;
}

.app-body {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-8);
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
}
.icon-button.menu-button,
.icon-button.menu-close,
.topbar-brand {
  display: none;
}
.topbar-search {
  position: relative;
  flex: 0 1 380px;
  min-width: 0;
}
.topbar-search .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.topbar-search input {
  width: 100%;
  min-height: 38px;
  padding-left: 38px;
  border-color: var(--hairline);
  background: var(--surface);
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-1);
}
.icon-button,
.theme-switch {
  min-width: 38px;
  min-height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted);
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}
.icon-button:hover,
.theme-switch:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}
.theme-switch .theme-dark,
:root[data-theme='dark'] .theme-switch .theme-light {
  display: none;
}
:root[data-theme='dark'] .theme-switch .theme-dark {
  display: block;
}
.language-menu {
  position: relative;
}
.language-menu summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 38px;
  padding: 0 var(--space-2) 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
.language-menu summary::-webkit-details-marker {
  display: none;
}
.language-menu summary:hover {
  background: var(--surface-sunken);
}
.language-menu > div {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 40;
  min-width: 160px;
  padding: var(--space-1);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.language-menu a {
  display: block;
  padding: var(--space-2) var(--space-3);
  border-radius: 6px;
  color: var(--text);
}
.language-menu a:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}
.language-menu a[aria-current] {
  color: var(--link);
  font-weight: 650;
}

main {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-8) var(--space-12);
}
.footer {
  display: flex;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: auto;
  padding: var(--space-5) var(--space-8);
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: var(--text-xs);
}
.nav-scrim {
  display: none;
}

/* ============================================================ components */

/* ---- page header */

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}
.page-heading > div:first-child {
  min-width: 0;
}
.page-heading-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.page-description {
  max-width: 72ch;
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: var(--text-base);
}
.eyebrow {
  margin-bottom: var(--space-2);
  color: var(--link);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
}
.back-link:hover {
  color: var(--link);
}
.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin: var(--space-8) 0 var(--space-3);
}
.section-title h2 {
  font-size: var(--text-md);
}

/* ---- buttons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 40px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  transition:
    background var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}
.button.primary {
  background: var(--action);
  color: var(--on-action);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 1px 2px rgba(0, 61, 140, 0.24);
}
.button.primary:hover:not(:disabled) {
  background: var(--action-hover);
}
.button.secondary {
  background: var(--surface);
  border-color: var(--hairline-strong);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.button.secondary:hover:not(:disabled) {
  border-color: var(--action);
  color: var(--link);
}
.button.quiet {
  background: transparent;
  color: var(--link);
}
.button.quiet:hover:not(:disabled) {
  background: var(--blue-50);
}
.button.danger {
  background: var(--danger);
  color: #fff;
}
.button.danger:hover:not(:disabled) {
  background: var(--danger-hover);
}
.button.danger-outline {
  background: var(--surface);
  border-color: var(--error-border);
  color: var(--error-ink);
}
.button.danger-outline:hover:not(:disabled) {
  background: var(--error-tint);
}
.button.small {
  min-height: 34px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
}
.button.full {
  width: 100%;
}
.button:disabled {
  opacity: 0.5;
  box-shadow: none;
}
.text-link,
.table-link {
  color: var(--link);
  font-weight: 600;
  text-underline-offset: 3px;
}
.text-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  white-space: nowrap;
}
.text-link:hover,
.table-link:hover {
  text-decoration: underline;
}

/* ---- cards */

.panel {
  margin-bottom: var(--space-5);
  overflow: hidden;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.panel:last-child {
  margin-bottom: 0;
}
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6) var(--space-4);
}
.panel-heading h2 {
  font-size: var(--text-md);
}
.panel-heading p {
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--text-sm);
}
.info-panel {
  padding: var(--space-6);
}
.info-panel > h2 {
  margin-bottom: var(--space-3);
  font-size: var(--text-md);
}
.info-panel > h2 + p,
.info-panel > p {
  color: var(--muted);
}
.info-panel > p + p,
.info-panel > p + form,
.info-panel > form + p {
  margin-top: var(--space-3);
}
.info-panel .panel-heading {
  padding: 0 0 var(--space-3);
}
.panel > .table-region:first-child {
  border-top: 0;
}

/* ---- key facts */

dl {
  display: grid;
  grid-template-columns: minmax(120px, 200px) minmax(0, 1fr);
  gap: var(--space-3) var(--space-5);
  font-size: var(--text-base);
}
dt {
  color: var(--muted);
}
dd {
  min-width: 0;
  color: var(--ink);
  overflow-wrap: anywhere;
}

/* ---- stat tiles */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.metric-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
  padding: var(--space-5);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  transition:
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}
.metric-card > div,
.metric-card > span:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 550;
}
.metric-card strong {
  display: block;
  color: var(--ink);
  font: 800 var(--text-2xl) / 1.2 var(--font-display);
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}
.metric-card small {
  color: var(--muted);
}
a.metric-card:hover {
  border-color: var(--blue-200);
  box-shadow: var(--shadow-md);
}
.metric-arrow {
  color: var(--muted);
}
a.metric-card:hover .metric-arrow {
  color: var(--link);
}
.large-stat {
  display: block;
  margin: var(--space-3) 0;
  color: var(--ink);
  font: 800 40px / 1.1 var(--font-display);
  letter-spacing: -0.03em;
}

/* ---- badges */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
  color: var(--text);
  font-size: var(--text-xs);
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
  vertical-align: middle;
}
.badge.status-succeeded,
.badge.status-resolved,
.badge.status-approved,
.badge.status-ready,
.badge.status-sent,
.badge.status-delivered,
.badge.good {
  background: var(--success-tint);
  border-color: var(--success-border);
  color: var(--success-ink);
}
.badge.status-failed,
.badge.status-rejected,
.badge.status-blocked,
.badge.bad {
  background: var(--error-tint);
  border-color: var(--error-border);
  color: var(--error-ink);
}
.badge.status-running,
.badge.status-queued,
.badge.status-submitted,
.badge.status-open,
.badge.status-awaiting,
.badge.status-sending,
.badge.status-pending,
.badge.status-retrying,
.badge.attention {
  background: var(--warning-tint);
  border-color: var(--warning-border);
  color: var(--warning-ink);
}
.badge.status-no_op,
.badge.status-waiting_customer,
.badge.status-stopped,
.badge.status-skipped,
.badge.info {
  background: var(--info-tint);
  border-color: var(--info-border);
  color: var(--info-ink);
}
.badge.plan-plus {
  background: var(--blue-50);
  border-color: var(--blue-200);
  color: var(--link);
}
.badge.plan-premium {
  background: var(--action);
  border-color: var(--action);
  color: var(--on-action);
}
.status-dot,
.privacy-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--success-ink);
  vertical-align: middle;
}
.status-dot.bad {
  background: var(--danger);
}
.status-dot.attention {
  background: #d18b00;
}

/* ---- banners */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin: 0 0 var(--space-5);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--info-border);
  border-radius: var(--radius-md);
  background: var(--info-tint);
  color: var(--info-ink);
  font-size: var(--text-base);
  line-height: 1.55;
}
.alert .icon {
  margin-top: 2px;
}
.alert.warning {
  background: var(--warning-tint);
  border-color: var(--warning-border);
  color: var(--warning-ink);
}
.alert.error {
  background: var(--error-tint);
  border-color: var(--error-border);
  color: var(--error-ink);
}
.alert.success {
  background: var(--success-tint);
  border-color: var(--success-border);
  color: var(--success-ink);
}
.environment-note {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-5);
  color: var(--warning-ink);
  font-size: var(--text-sm);
  font-weight: 600;
}
.environment-note .status-dot {
  background: #d18b00;
}

/* ---- forms */

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 600;
}
input,
select,
textarea {
  min-height: 40px;
  max-width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-base);
  font-weight: 400;
  transition:
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}
textarea {
  line-height: 1.55;
  resize: vertical;
}
input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 1;
}
input:focus,
select:focus,
textarea:focus {
  border-color: var(--action);
  box-shadow: 0 0 0 3px var(--glow);
  outline: none;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}
input[type='checkbox'],
input[type='radio'] {
  width: 18px;
  height: 18px;
  min-height: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--action);
  box-shadow: none;
}
label:has(> input[type='checkbox']),
label:has(> input[type='radio']) {
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  font-weight: 500;
}
select {
  padding-right: var(--space-8);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235b6779' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-position: right 10px center;
  background-repeat: no-repeat;
}
fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
legend {
  margin-bottom: var(--space-2);
  padding: 0;
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 600;
}
.field-hint,
.integration-form small,
label small {
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 400;
}
.integration-form {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-4);
}
.integration-form input,
.integration-form select,
.integration-form textarea {
  width: 100%;
}
.integration-form input[type='checkbox'],
.integration-form input[type='radio'] {
  width: 18px;
}
.integration-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
/* Radio cards: one choice of a few, each a tappable box. */
.choice-group {
  display: grid;
  gap: var(--space-2);
}
.choice {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  font-weight: 500;
  cursor: pointer;
  transition:
    border-color var(--duration) var(--ease),
    background var(--duration) var(--ease);
}
.choice:hover {
  border-color: var(--action);
}
.choice:has(input:checked) {
  border-color: var(--action);
  background: var(--blue-50);
  box-shadow: inset 0 0 0 1px var(--action);
}

/* ---- filters */

.filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}
.segmented a,
.segmented button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  transition:
    background var(--duration) var(--ease),
    color var(--duration) var(--ease);
}
.segmented a:hover {
  color: var(--ink);
}
.segmented a[aria-current] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.segmented .count {
  color: var(--muted);
  font-weight: 500;
}
.more-filters {
  position: relative;
}
.more-filters > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 38px;
  padding: 0 var(--space-3);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}
.more-filters > summary::-webkit-details-marker {
  display: none;
}
.more-filters[open] > summary {
  border-color: var(--action);
}
.more-filters > form {
  position: absolute;
  left: 0;
  top: calc(100% + 6px);
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: var(--space-3);
  width: min(460px, calc(100vw - 32px));
  padding: var(--space-4);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.more-filters > form .button {
  grid-column: 1 / -1;
}
.filter-range {
  color: var(--muted);
  font-size: var(--text-sm);
}
.table-search {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--hairline);
}
.table-search input,
.table-search select {
  flex: 1 1 220px;
  min-width: 0;
}

/* ---- tables */

.table-region {
  max-width: 100%;
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th {
  padding: var(--space-2) var(--space-6);
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-sunken);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: inherit;
}
.sort-link:hover {
  color: var(--ink);
}
th[aria-sort] .sort-link {
  color: var(--ink);
}
.sort-link.up .icon {
  transform: rotate(180deg);
}
td {
  padding: var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--hairline);
  color: var(--text);
  font-size: var(--text-base);
  vertical-align: middle;
  white-space: nowrap;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr {
  transition: background var(--duration) var(--ease);
}
tbody tr:hover {
  background: color-mix(in srgb, var(--surface-sunken) 60%, transparent);
}
td small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}
td.wrap,
.request-cell {
  min-width: 260px;
  max-width: 520px;
  line-height: 1.5;
  white-space: normal;
}
td.actions {
  width: 1%;
  text-align: right;
}
.cell-person {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.cell-person .avatar {
  width: 30px;
  height: 30px;
  font-size: 12px;
}
.cell-person small {
  margin: 0;
}
.table-empty,
td.empty-state {
  padding: var(--space-8) var(--space-6);
  color: var(--muted);
  text-align: center;
  white-space: normal;
}
.tool-symbol {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-right: var(--space-2);
  border-radius: 7px;
  background: var(--blue-50);
  color: var(--link);
  vertical-align: middle;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-6);
  border-top: 1px solid var(--hairline);
  color: var(--muted);
  font-size: var(--text-sm);
}
.pagination > div {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.pagination a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 var(--space-3);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
}
.pagination a:hover {
  border-color: var(--action);
  color: var(--link);
}

/* ---- empty states */

.empty-state {
  padding: var(--space-10) var(--space-5);
  text-align: center;
  white-space: normal;
}
.empty-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  margin: 0 auto var(--space-3);
  border-radius: 12px;
  background: var(--blue-50);
  color: var(--link);
  font-size: 20px;
}
.empty-state h3 {
  font-size: var(--text-base);
}
.empty-state p {
  max-width: 44ch;
  margin: var(--space-1) auto 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

/* ---- dialogs */

.dialog {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop {
  background: rgba(8, 14, 26, 0.48);
  backdrop-filter: blur(3px);
}
.dialog[open] {
  animation: dialog-in 220ms var(--ease);
}
@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}
.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6) 0;
}
.dialog-head p {
  margin-top: var(--space-1);
  color: var(--muted);
  font-size: var(--text-sm);
}
.dialog-body {
  padding: var(--space-4) var(--space-6) var(--space-6);
}
.dialog-body .integration-form {
  margin-top: 0;
}
.dialog.wide {
  width: min(820px, calc(100vw - 32px));
}
.dialog > form {
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 48px);
}
.dialog > form > .dialog-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}
.dialog-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--hairline);
  background: var(--surface-sunken);
}
.dialog-foot .button.quiet {
  margin-right: auto;
}
.field-group + .field-group {
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--hairline);
}
.field-group > .field-hint {
  margin-bottom: var(--space-3);
}
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* ---- meters */

.meter-list {
  display: grid;
  gap: var(--space-4);
}
.meter-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: 6px;
  font-size: var(--text-sm);
}
.meter-head span {
  color: var(--text);
  font-weight: 600;
}
.meter-head strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.meter-track {
  height: 6px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--surface-sunken);
}
.meter-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--action);
}
.meter-track i.low {
  background: #d18b00;
}
.meter-track i.empty {
  background: var(--danger);
}

/* ---- tabs inside a page */

.section-nav {
  position: sticky;
  top: var(--topbar-height);
  z-index: 10;
  display: flex;
  gap: var(--space-1);
  margin: 0 0 var(--space-5);
  padding: var(--space-2) 0;
  overflow-x: auto;
  background: var(--paper);
  border-bottom: 1px solid var(--hairline);
  scrollbar-width: none;
}
.section-nav a {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
}
.section-nav a:hover {
  background: var(--surface-sunken);
  color: var(--ink);
}
.section-nav a[aria-current] {
  background: var(--blue-50);
  color: var(--link);
}
.section-nav .count {
  color: var(--muted);
  font-weight: 500;
}
[id] {
  scroll-margin-top: calc(var(--topbar-height) + 64px);
}

/* ============================================================ screens */

/* ---- Today */

.today-date {
  color: var(--muted);
  font-size: var(--text-base);
}
.stat-delta {
  font-size: var(--text-xs);
}
.action-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.action-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-5);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  color: var(--text);
  transition:
    border-color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease);
}
.action-card:hover {
  border-color: var(--blue-200);
  box-shadow: var(--shadow-md);
}
.action-card .icon-tile {
  margin: 0;
}
.action-card > div {
  flex: 1;
  min-width: 0;
}
.action-card strong {
  display: block;
  color: var(--ink);
  font: 750 var(--text-md) / 1.35 var(--font-display);
}
.action-card small {
  color: var(--muted);
  font-size: var(--text-sm);
}
.action-card .action-count {
  color: var(--ink);
  font: 800 var(--text-2xl) / 1 var(--font-display);
  font-variant-numeric: tabular-nums;
}
.action-card.waiting {
  border-color: var(--blue-200);
  background: linear-gradient(135deg, var(--blue-50), var(--surface) 70%);
}
.action-card.calm .action-count {
  color: var(--muted);
}
.icon-tile {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  margin-bottom: var(--space-3);
  border-radius: 12px;
  background: var(--blue-50);
  color: var(--link);
}
.health-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-6);
  margin-bottom: var(--space-6);
  padding: var(--space-3) var(--space-5);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
}
.health-line > span {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.health-line strong {
  color: var(--ink);
}
.health-line .text-link {
  margin-left: auto;
}

/* ---- analytics */

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}
.dashboard-grid > .panel {
  margin-bottom: 0;
}
.chart-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: 0 var(--space-6);
}
.chart-head strong {
  color: var(--ink);
  font: 800 var(--text-2xl) / 1.1 var(--font-display);
  letter-spacing: -0.03em;
}
.chart-head span {
  color: var(--muted);
  font-size: var(--text-sm);
}
.bar-chart {
  display: flex;
  align-items: stretch;
  gap: 3px;
  height: 172px;
  margin: var(--space-5) var(--space-6) var(--space-3);
  background: repeating-linear-gradient(
    to top,
    transparent 0,
    transparent 36px,
    var(--hairline) 36px,
    var(--hairline) 37px
  );
}
.bar-column {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.bar-space {
  height: 146px;
  display: flex;
  align-items: flex-end;
  margin-bottom: 26px;
}
.bar-space i {
  display: block;
  width: 100%;
  max-width: 22px;
  margin: auto auto 0;
  border-radius: 4px 4px 0 0;
  background: var(--brand-blue);
  opacity: 0.85;
  transition: opacity var(--duration) var(--ease);
}
.bar-column:hover .bar-space i {
  opacity: 1;
}
.bar-column > span {
  position: absolute;
  bottom: 0;
  left: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 26px;
  white-space: nowrap;
}
.bar-column:last-child > span {
  left: auto;
  right: 0;
}
.chart-table {
  margin: 0 var(--space-6) var(--space-4);
}
.chart-table summary {
  min-height: 36px;
  display: flex;
  align-items: center;
  color: var(--link);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.chart-table .table-region {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
}
.chart-table th,
.chart-table td {
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}
.health-panel {
  padding: var(--space-6);
}
.health-panel > p {
  margin: var(--space-1) 0 var(--space-4);
  color: var(--muted);
  font-size: var(--text-sm);
}
.health-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--hairline);
  color: var(--text);
  font-size: var(--text-base);
}
.health-row:last-of-type {
  border-bottom: 0;
}
.health-row strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.health-foot {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  color: var(--muted);
  font-size: var(--text-xs);
}
.engagement-panel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-10);
  padding: var(--space-6);
}
.engagement-panel p {
  color: var(--muted);
  font-size: var(--text-sm);
}
.freshness {
  margin-top: var(--space-5);
  color: var(--muted);
  font-size: var(--text-xs);
  text-align: right;
}
.gate-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-12) var(--space-6);
  text-align: center;
}
.gate-panel .empty-icon {
  margin: 0;
}
.gate-panel p {
  max-width: 56ch;
  color: var(--muted);
}

/* ---- users */

.profile-head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-width: 0;
}
.profile-head h1 {
  overflow-wrap: anywhere;
}
.profile-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  margin-top: var(--space-1);
  color: var(--muted);
  font-size: var(--text-sm);
}
.overview-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: var(--space-5);
  margin-bottom: var(--space-5);
}
.overview-grid > .panel {
  margin-bottom: 0;
}
.plan-state {
  grid-template-columns: max-content 1fr;
  gap: var(--space-2) var(--space-5);
  margin-bottom: var(--space-4);
}
.plan-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-2);
}
.plan-choices .choice {
  justify-content: center;
}
.plan-limit-details {
  margin-top: var(--space-4);
}
.plan-limit-details summary {
  color: var(--link);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
}
.limit-grid {
  margin-top: var(--space-3);
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr) minmax(60px, auto));
  gap: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
}
.week-resets {
  margin-top: var(--space-3);
}

/* ---- payments */

.review-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.9fr);
  gap: var(--space-5);
  align-items: start;
}
.review-layout > div > .panel:last-child,
.review-layout > .panel {
  margin-bottom: 0;
}
.receipt-panel {
  position: sticky;
  top: calc(var(--topbar-height) + var(--space-5));
}
.receipt-frame {
  display: grid;
  place-items: center;
  min-height: 240px;
  margin-top: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-sunken);
}
.receipt-frame img {
  max-height: 72vh;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}
.decision-panel {
  display: grid;
  gap: var(--space-5);
}

/* ---- posts */

.post-title {
  overflow-wrap: anywhere;
}
.post-text {
  margin: var(--space-3) 0 0;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.post-image img {
  max-height: 360px;
}
.post-button-preview {
  margin: var(--space-3) 0 var(--space-4);
}
.post-audiences {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.post-progress {
  display: grid;
  gap: var(--space-2);
}
.post-tests {
  display: grid;
  gap: var(--space-2);
  margin: var(--space-4) 0 0;
  padding: 0;
  list-style: none;
}
.decision-approve .button {
  width: 100%;
}
.decision-reject {
  margin-top: 0;
  padding-top: var(--space-5);
  border-top: 1px solid var(--hairline);
}
.amount {
  color: var(--ink);
  font: 800 var(--text-xl) / 1.2 var(--font-display);
  letter-spacing: -0.02em;
}

/* ---- support */

.thread {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-6);
}
.message {
  max-width: min(640px, 88%);
  align-self: flex-start;
}
.message.staff {
  align-self: flex-end;
}
.message-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 var(--space-1) var(--space-1);
  color: var(--muted);
  font-size: var(--text-xs);
}
.message.staff .message-meta {
  justify-content: flex-end;
}
.message-meta strong {
  color: var(--ink);
  font-weight: 650;
}
.support-message {
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--hairline);
  border-radius: 4px var(--radius-lg) var(--radius-lg) var(--radius-lg);
  background: var(--surface-sunken);
  color: var(--ink);
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.message.staff .support-message {
  border-color: var(--blue-200);
  border-radius: var(--radius-lg) 4px var(--radius-lg) var(--radius-lg);
  background: var(--blue-50);
}
.support-action {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6);
  border-top: 1px solid var(--hairline);
  background: var(--surface);
}
.support-action textarea {
  width: 100%;
}
.support-action .form-actions {
  justify-content: space-between;
}

/* ---- plans */

.plans-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}
.plans-grid > .panel {
  margin-bottom: 0;
}
.plan-panel {
  padding: var(--space-6);
}
.plan-price {
  margin: var(--space-3) 0 var(--space-4);
  color: var(--ink);
  font: 800 var(--text-2xl) / 1.15 var(--font-display);
  letter-spacing: -0.03em;
}
.plan-price span {
  color: var(--muted);
  font: 500 var(--text-base) var(--font-body);
  letter-spacing: 0;
}
.limit-fields {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-4);
}
.limit-fields label {
  display: flex;
}
.plan-actions {
  margin-top: var(--space-5);
}

/* ---- integrations, staff */

.integration-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
  align-items: start;
}
.integration-grid > .panel,
.integration-grid > section > .panel {
  margin-bottom: 0;
}
.integration-grid > section > .panel + .panel {
  margin-top: var(--space-4);
}
.integration-grid > section > h2 {
  margin-bottom: var(--space-3);
}

.integration-list {
  display: grid;
  gap: var(--space-3);
}
.integration-list > .panel {
  margin: 0;
}
.integration-card > summary {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  list-style: none;
  cursor: pointer;
  transition: background var(--duration) var(--ease);
}
.integration-card > summary::-webkit-details-marker {
  display: none;
}
.integration-card > summary:hover {
  background: color-mix(in srgb, var(--surface-sunken) 55%, transparent);
}
.integration-card .icon-tile {
  margin: 0;
}
.integration-title {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.integration-title strong {
  color: var(--ink);
  font: 750 var(--text-md) / 1.35 var(--font-display);
}
.integration-title small {
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.integration-toggle {
  color: var(--muted);
  transition: transform var(--duration) var(--ease);
}
.integration-card[open] .integration-toggle {
  transform: rotate(180deg);
}
.integration-card[open] > summary {
  border-bottom: 1px solid var(--hairline);
}
.integration-body {
  max-width: 760px;
  padding: var(--space-5) var(--space-6) var(--space-6) calc(var(--space-5) + 42px + var(--space-4));
}
.integration-body > p {
  color: var(--muted);
}
.integration-body > p + p,
.integration-body > * + form,
.integration-body > form + * {
  margin-top: var(--space-3);
}
.integration-body ul {
  margin: var(--space-2) 0;
  padding-left: var(--space-5);
}

/* ---- AI requests */

.generation-filters input,
.generation-filters select {
  flex: 1 1 200px;
}
.request-text {
  color: var(--ink);
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}
.generation-request h3,
.generation-outline h3 {
  margin-top: var(--space-4);
}
.generation-outline ol {
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding-left: 22px;
}
.page-viewer img {
  max-height: 900px;
  margin: 0 auto var(--space-3);
  border: 1px solid var(--hairline);
  background: #fff;
  box-shadow: var(--shadow-md);
}
.page-viewer .pagination {
  border-top: 0;
  padding: 0;
}

/* ---- audit */

.change-list {
  display: grid;
  gap: 2px;
  font-size: var(--text-sm);
}
.change-list span {
  color: var(--muted);
}
.change-list del {
  color: var(--error-ink);
  text-decoration-thickness: 1px;
}
.change-list ins {
  color: var(--success-ink);
  text-decoration: none;
}

/* ============================================================ sign-in */

.login-page {
  min-height: 100vh;
  display: flex;
}
.login-story {
  position: relative;
  width: 46%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: var(--space-10) var(--space-12);
  overflow: hidden;
  border-right: 1px solid var(--hairline);
  background: linear-gradient(150deg, var(--surface), var(--blue-50));
}
.login-story::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, var(--brand-red) 0 30%, var(--brand-blue) 30% 100%);
}
.login-story .brand-art {
  width: 196px;
}
.login-story > div {
  max-width: 440px;
  margin: var(--space-10) auto;
}
.login-story h1 {
  margin: var(--space-4) 0;
  font-size: 40px;
  line-height: 1.12;
}
.login-story p {
  color: var(--muted);
  font-size: var(--text-md);
}
.login-story > small {
  color: var(--muted);
}
.login-form-panel {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-8) var(--space-12);
}
.login-tools {
  position: absolute;
  top: var(--space-6);
  right: var(--space-10);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.login-languages {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  color: var(--muted);
  font-size: var(--text-sm);
}
.login-languages a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
}
.login-languages [aria-current] {
  color: var(--link);
  font-weight: 700;
}
.login-mobile-brand {
  display: none;
}
.login-card {
  width: 100%;
  max-width: 380px;
  margin: var(--space-12) auto;
}
.login-card h2 {
  margin: var(--space-2) 0;
  font-size: var(--text-2xl);
  letter-spacing: -0.03em;
}
.login-card > p {
  margin-bottom: var(--space-6);
  color: var(--muted);
}
.login-card form {
  display: grid;
  gap: var(--space-4);
}
.login-card input {
  min-height: 46px;
  width: 100%;
}
.login-card .button {
  min-height: 46px;
  margin-top: var(--space-2);
}
.dev-login {
  margin-top: var(--space-8);
  padding-top: var(--space-5);
  border-top: 1px solid var(--hairline);
}
.dev-login p {
  margin-bottom: var(--space-3);
  color: var(--muted);
  font-size: var(--text-sm);
}
.document-art {
  position: relative;
  width: 230px;
  height: 250px;
  margin: var(--space-10) auto var(--space-4);
}
.art-page {
  position: absolute;
  left: 21px;
  top: 15px;
  width: 156px;
  height: 202px;
  padding: 17px 20px 20px;
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 18px 35px rgba(2, 46, 99, 0.1);
  transform: rotate(-7deg);
}
.art-back {
  left: 51px;
  top: 19px;
  border: 1px solid var(--hairline-strong);
  background: var(--blue-50);
  transform: rotate(10deg);
}
.art-mark {
  width: 34px;
  height: 34px;
  margin: 0 0 9px;
}
.art-page i {
  display: block;
  height: 5px;
  margin: 8px 0;
  border-radius: 3px;
  background: var(--hairline);
}
.art-page i.short {
  width: 65%;
}
.art-chart {
  display: flex;
  align-items: end;
  gap: 6px;
  height: 47px;
  margin: 11px 0;
}
.art-chart b {
  display: block;
  width: 20%;
  height: 45%;
  border-radius: 3px 3px 0 0;
  background: var(--blue-200);
}
.art-chart b:nth-child(2) {
  height: 70%;
  background: #68a9ff;
}
.art-chart b:nth-child(3) {
  height: 58%;
  background: var(--brand-red);
}
.art-chart b:nth-child(4) {
  height: 100%;
  background: var(--brand-blue);
}
.art-seal {
  position: absolute;
  right: 6px;
  bottom: 2px;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 4px solid var(--blue-50);
  border-radius: 50%;
  background: var(--action);
  color: var(--on-action);
  font-size: 22px;
  box-shadow: 0 10px 20px rgba(2, 46, 99, 0.12);
}

/* ============================================================ arrival */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}
main > * {
  animation: rise 320ms var(--ease) both;
}
main > *:nth-child(2) {
  animation-delay: 30ms;
}
main > *:nth-child(3) {
  animation-delay: 60ms;
}
main > *:nth-child(n + 4) {
  animation-delay: 90ms;
}

/* ============================================================ smaller screens */

@media (max-width: 1200px) {
  main {
    padding: var(--space-6) var(--space-6) var(--space-10);
  }
  .topbar {
    padding: 0 var(--space-6);
  }
  .dashboard-grid,
  .overview-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .review-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .receipt-panel {
    position: static;
    order: -1;
  }
}

/* The sidebar becomes a drawer behind the menu button. */
@media (max-width: 960px) {
  .app-shell {
    display: block;
  }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 60;
    width: min(300px, 86vw);
    border-right: 1px solid var(--hairline);
    box-shadow: var(--shadow-lg);
    transform: translateX(-104%);
    visibility: hidden;
    transition:
      transform 240ms var(--ease),
      visibility 0s linear 240ms;
  }
  .nav-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 240ms var(--ease);
  }
  .nav-open .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(8, 14, 26, 0.42);
  }
  .icon-button.menu-close {
    display: inline-grid;
  }
  .icon-button.menu-button {
    display: inline-grid;
    margin-left: calc(var(--space-2) * -1);
  }
  .topbar-brand {
    display: inline-flex;
  }
  .topbar-brand img {
    width: 30px;
    height: 30px;
  }
  .topbar-search {
    flex: 1 1 auto;
  }
  .integration-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  :root {
    --topbar-height: 58px;
  }
  .topbar {
    gap: var(--space-2);
    padding: 0 var(--space-4);
  }
  .topbar-search input {
    font-size: 16px;
  }
  .topbar-actions .language-menu summary span {
    display: none;
  }
  main {
    padding: var(--space-5) var(--space-4) var(--space-10);
  }
  h1 {
    font-size: 24px;
  }
  .page-heading {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
  }
  .metrics-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
  }
  .metric-card {
    padding: var(--space-4);
  }
  .metric-card strong {
    font-size: var(--text-xl);
  }
  .panel-heading,
  .info-panel,
  .health-panel,
  .thread {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
  .info-panel .panel-heading {
    padding-left: 0;
    padding-right: 0;
  }
  th,
  td {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
  .table-search,
  .pagination,
  .support-action {
    padding-left: var(--space-4);
    padding-right: var(--space-4);
  }
  .chart-head {
    padding: 0 var(--space-4);
  }
  .bar-chart {
    margin-left: var(--space-4);
    margin-right: var(--space-4);
    gap: 2px;
  }
  .bar-column:not(:first-child):not(:last-child) > span {
    display: none;
  }
  .chart-table {
    margin-left: var(--space-4);
    margin-right: var(--space-4);
  }
  dl {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }
  dd {
    margin-bottom: var(--space-2);
  }
  .plan-state {
    grid-template-columns: minmax(0, 1fr);
  }
  .engagement-panel {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-6);
  }
  .integration-card > summary {
    flex-wrap: wrap;
    padding: var(--space-4);
  }
  .integration-card .integration-title {
    flex-basis: calc(100% - 42px - var(--space-4) - 40px);
  }
  .integration-card > summary .badge {
    margin-left: calc(42px + var(--space-4));
  }
  .integration-body {
    padding: var(--space-4);
  }
  .message {
    max-width: 94%;
  }
  .more-filters > form {
    position: fixed;
    left: var(--space-4);
    right: var(--space-4);
    top: auto;
    bottom: var(--space-4);
    width: auto;
    grid-template-columns: minmax(0, 1fr);
  }
  .health-line .text-link {
    margin-left: 0;
  }
  .footer {
    flex-direction: column;
    padding: var(--space-5) var(--space-4);
  }
  .freshness {
    text-align: left;
  }
  .login-page {
    display: block;
  }
  .login-story {
    display: none;
  }
  .login-form-panel {
    min-height: 100vh;
    padding: var(--space-8) var(--space-5);
  }
  .login-tools {
    top: var(--space-4);
    left: var(--space-5);
    right: var(--space-5);
    justify-content: space-between;
  }
  .login-card {
    margin: 80px auto var(--space-6);
  }
  .login-mobile-brand {
    display: flex;
    margin-bottom: var(--space-8);
  }
  .login-mobile-brand .brand-art {
    width: 180px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
