/* Tessera Portal — Atelier layout & components.
   Tokens come from /static/tokens.css (generated from tessera-ui/tokens/*.json).
   Spec: docs/specs/shared/ux/design-system.adoc. */

/* ── Reset ─────────────────────────────────────────────────────────────────── */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--t-bg);
}

body {
  font-family: var(--t-font-body);
  font-size: var(--t-text-body);
  line-height: 1.55;
  color: var(--t-text);
  background: var(--t-bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: var(--t-signal); text-decoration: none; }
a:hover { color: var(--t-signal-hover); text-decoration: underline; text-underline-offset: 0.15em; }

h1, h2, h3, h4 { font-family: var(--t-font-display); font-weight: 400; color: var(--t-ink); line-height: 1.1; letter-spacing: -0.015em; }
h1 { font-size: var(--t-text-h1); }
h2 { font-size: var(--t-text-h2); letter-spacing: 0; }
h3 { font-size: var(--t-text-h3); font-family: var(--t-font-body); font-weight: 600; color: var(--t-text); }

code, pre, .mono { font-family: var(--t-font-mono); font-size: var(--t-text-small); }

:focus-visible { outline: none; box-shadow: var(--t-shadow-focus); outline-offset: 2px; border-radius: var(--t-radius-sm); }

/* ── Skip link ─────────────────────────────────────────────────────────────── */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: var(--t-space-2) var(--t-space-4);
  background: var(--t-ink);
  color: var(--t-text-on-ink);
  font-weight: 500;
  border-radius: 0 0 var(--t-radius-sm) 0;
}
.skip-link:focus { left: 0; text-decoration: none; color: var(--t-text-on-ink); }

/* ── Top nav ──────────────────────────────────────────────────────────────── */

.tp-topnav {
  height: 56px;
  border-bottom: 1px solid var(--t-hairline);
  background: var(--t-bg);
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}
.tp-topnav-inner {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--t-space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--t-space-4);
}
.tp-wordmark {
  font-family: var(--t-font-display);
  font-size: var(--t-text-h2);
  color: var(--t-ink);
  letter-spacing: -0.01em;
}
.tp-wordmark:hover { text-decoration: none; color: var(--t-ink); }
.tp-nav-links { display: flex; align-items: center; gap: var(--t-space-6); }
.tp-nav-links a {
  color: var(--t-text-secondary);
  font-size: var(--t-text-body);
  font-weight: 500;
}
.tp-nav-links a:hover { color: var(--t-text); text-decoration: none; }
.tp-nav-cta {
  color: var(--t-ink) !important;
  font-weight: 600;
}

.tp-account-menu {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--t-space-2);
}
.tp-account-menu summary {
  list-style: none;
  cursor: pointer;
  color: var(--t-text-secondary);
  display: inline-flex;
  align-items: center;
  gap: var(--t-space-2);
  padding: var(--t-space-1) var(--t-space-2);
  border-radius: var(--t-radius-sm);
}
.tp-account-menu summary::-webkit-details-marker { display: none; }
.tp-account-menu summary::marker { display: none; content: ''; }
.tp-account-menu summary:hover { background: var(--t-bg-sunken); color: var(--t-text); }
.tp-account-dot {
  width: 24px;
  height: 24px;
  border-radius: var(--t-radius-full);
  background: var(--t-signal-subtle);
  color: var(--t-signal);
  font-size: var(--t-text-small);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tp-account-menu[open] summary { background: var(--t-bg-sunken); }
.tp-account-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 200px;
  background: var(--t-bg-raised);
  border: 1px solid var(--t-hairline);
  border-radius: var(--t-radius);
  box-shadow: var(--t-shadow-pop);
  padding: var(--t-space-2);
  display: flex;
  flex-direction: column;
  gap: var(--t-space-1);
  z-index: 200;
}
.tp-account-dropdown a,
.tp-account-dropdown button {
  display: block;
  width: 100%;
  text-align: left;
  padding: var(--t-space-2) var(--t-space-3);
  border-radius: var(--t-radius-sm);
  color: var(--t-text);
  font: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
}
.tp-account-dropdown a:hover,
.tp-account-dropdown button:hover { background: var(--t-bg-sunken); text-decoration: none; color: var(--t-text); }

/* ── Footer ────────────────────────────────────────────────────────────────── */

.tp-footer {
  border-top: 1px solid var(--t-hairline);
  background: var(--t-bg);
  padding: var(--t-space-8) 0;
  margin-top: auto;
}
.tp-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--t-space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--t-space-4);
  color: var(--t-text-tertiary);
  font-size: var(--t-text-small);
}
.tp-footer-links { display: flex; gap: var(--t-space-4); }
.tp-footer-links a { color: var(--t-text-tertiary); }
.tp-footer-links a:hover { color: var(--t-text); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.tp-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--t-space-2);
  height: 36px;
  padding: 0 var(--t-space-4);
  border-radius: var(--t-radius-sm);
  font-family: inherit;
  font-size: var(--t-text-body);
  font-weight: 500;
  line-height: 1;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color var(--t-duration-fast) var(--t-ease-standard),
              border-color var(--t-duration-fast) var(--t-ease-standard),
              color var(--t-duration-fast) var(--t-ease-standard);
}
.tp-btn-sm { height: 28px; padding: 0 var(--t-space-3); font-size: var(--t-text-small); }
.tp-btn-lg { height: 44px; padding: 0 var(--t-space-6); }

.tp-btn-primary { background: var(--t-signal); color: var(--t-signal-on); }
.tp-btn-primary:hover { background: var(--t-signal-hover); color: var(--t-signal-on); text-decoration: none; }

.tp-btn-secondary { background: transparent; color: var(--t-text); border-color: var(--t-hairline-strong); }
.tp-btn-secondary:hover { background: var(--t-bg-sunken); color: var(--t-text); text-decoration: none; }

.tp-btn-ghost { background: transparent; color: var(--t-text-secondary); }
.tp-btn-ghost:hover { color: var(--t-text); background: var(--t-bg-sunken); text-decoration: none; }

.tp-btn-inverted { background: var(--t-ink); color: var(--t-text-on-ink); }
.tp-btn-inverted:hover { background: var(--t-text); color: var(--t-text-on-ink); text-decoration: none; }

.tp-btn-critical { background: var(--t-critical); color: #fff; }
.tp-btn-critical:hover { filter: brightness(1.1); color: #fff; text-decoration: none; }

.tp-btn-critical-ghost { background: transparent; color: var(--t-critical); border-color: var(--t-critical); }
.tp-btn-critical-ghost:hover { background: var(--t-critical-subtle); color: var(--t-critical); text-decoration: none; }

.tp-btn[disabled], .tp-btn:disabled { opacity: 0.6; cursor: not-allowed; }
.tp-btn-block { width: 100%; }

/* ── Links-as-buttons inherit alignment ─── */
a.tp-btn { display: inline-flex; }

/* ── Page container & hero ────────────────────────────────────────────────── */

.tp-page { max-width: 1280px; margin: 0 auto; padding: 0 var(--t-space-6); }
.tp-page-narrow { max-width: 720px; margin: 0 auto; padding: 0 var(--t-space-6); }

.tp-hero {
  padding: var(--t-space-24) 0 var(--t-space-16);
  max-width: 720px;
  margin: 0 auto;
}
.tp-hero-title {
  font-family: var(--t-font-display);
  font-size: var(--t-text-display);
  color: var(--t-ink);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0;
}
.tp-hero-title em,
.tp-hero-title i { font-style: italic; }
.tp-hero-rule {
  width: 64px;
  height: 1px;
  background: var(--t-hairline-strong);
  margin: var(--t-space-8) 0 var(--t-space-6);
  border: 0;
}
.tp-hero-body {
  color: var(--t-text-secondary);
  font-size: var(--t-text-body);
  max-width: 52ch;
  line-height: 1.6;
  margin-bottom: var(--t-space-8);
}
.tp-hero-cta-row {
  display: flex;
  align-items: center;
  gap: var(--t-space-4);
  flex-wrap: wrap;
}
.tp-hero-cta-secondary {
  color: var(--t-text-secondary);
  font-size: var(--t-text-body);
  font-weight: 500;
}
.tp-hero-cta-secondary:hover { color: var(--t-text); text-decoration: none; }

.tp-slot-strip {
  border-top: 1px solid var(--t-hairline);
  padding: var(--t-space-16) 0 var(--t-space-24);
  max-width: 1280px;
  margin: 0 auto;
}
.tp-slot-strip:empty { display: none; }

/* Subtle grain overlay on the index page only — avoids the
   flat-white look while staying inside the Atelier token budget. */
.tp-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.02;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

/* ── Pricing ──────────────────────────────────────────────────────────────── */

.tp-pricing-header { padding: var(--t-space-20) 0 var(--t-space-12); text-align: left; max-width: 720px; margin: 0 auto 0 0; }
.tp-pricing-subtitle { color: var(--t-text-secondary); font-size: var(--t-text-body); margin-top: var(--t-space-3); }
.tp-pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0;
  padding-bottom: var(--t-space-16);
  border-top: 1px solid var(--t-hairline);
}
@media (max-width: 960px) {
  .tp-pricing-grid { grid-template-columns: 1fr; }
}
.tp-pricing-col {
  padding: var(--t-space-8) var(--t-space-6);
  border-left: 1px solid var(--t-hairline);
  display: flex;
  flex-direction: column;
}
.tp-pricing-col:first-child { border-left: 0; }
@media (max-width: 960px) {
  .tp-pricing-col { border-left: 0; border-top: 1px solid var(--t-hairline); }
  .tp-pricing-col:first-child { border-top: 0; }
}
.tp-pricing-col-recommended {
  position: relative;
  border-top: 2px solid var(--t-signal);
  margin-top: -1px;
}
.tp-pricing-col-recommended::before {
  content: attr(data-recommended);
  position: absolute;
  top: -2px;
  left: var(--t-space-6);
  transform: translateY(-100%);
  font-size: var(--t-text-caption);
  color: var(--t-signal);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding-bottom: var(--t-space-2);
}
.tp-plan-name { font-family: var(--t-font-display); font-size: var(--t-text-h2); color: var(--t-ink); margin-bottom: var(--t-space-3); }
.tp-plan-price { font-family: var(--t-font-display); font-size: var(--t-text-kpi); color: var(--t-ink); line-height: 1; }
.tp-plan-price-unit { font-family: var(--t-font-body); font-size: var(--t-text-body); font-weight: 400; color: var(--t-text-tertiary); margin-left: 4px; }
.tp-plan-features { list-style: none; margin: var(--t-space-6) 0; padding: 0; flex: 1; }
.tp-plan-features li {
  padding: var(--t-space-2) 0 var(--t-space-2) var(--t-space-6);
  position: relative;
  color: var(--t-text);
  font-size: var(--t-text-body);
  line-height: 1.5;
}
.tp-plan-features li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 11px;
  width: 10px;
  height: 6px;
  border-left: 1.5px solid var(--t-signal);
  border-bottom: 1.5px solid var(--t-signal);
  transform: rotate(-45deg);
}

/* ── Cards / panels ───────────────────────────────────────────────────────── */

.tp-card {
  background: var(--t-bg-raised);
  border: 1px solid var(--t-hairline);
  border-radius: var(--t-radius);
  padding: var(--t-space-6);
}
.tp-card + .tp-card { margin-top: var(--t-space-8); }
.tp-card--centered { text-align: center; }

/* Section heading inside a card — matches h2 scale without requiring inline style. */
.tp-section-heading {
  font-size: var(--t-text-h2);
  margin-bottom: var(--t-space-4);
}

/* Secondary prose used inside cards (e.g. empty-state sentences). */
.tp-muted { color: var(--t-text-secondary); }

/* Card header row with title on left and an action button on right. */
.tp-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--t-space-4);
  gap: var(--t-space-4);
  flex-wrap: wrap;
}
.tp-card-meta {
  color: var(--t-text-secondary);
  font-size: var(--t-text-small);
}

/* ── Auth page ────────────────────────────────────────────────────────────── */

.tp-auth-page {
  min-height: calc(100vh - 56px - 72px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--t-space-12) var(--t-space-6);
}
.tp-auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--t-bg-raised);
  border: 1px solid var(--t-hairline);
  border-radius: var(--t-radius);
  padding: var(--t-space-8);
}
.tp-auth-title { font-family: var(--t-font-display); font-size: var(--t-text-h1); margin-bottom: var(--t-space-6); color: var(--t-ink); }
.tp-auth-link { text-align: center; margin-top: var(--t-space-4); font-size: var(--t-text-small); color: var(--t-text-secondary); }
.tp-auth-link a { text-decoration: underline; text-underline-offset: 0.15em; }

/* ── Form fields ──────────────────────────────────────────────────────────── */

.tp-field { display: flex; flex-direction: column; gap: var(--t-space-2); margin-bottom: var(--t-space-4); }
.tp-field label { font-size: var(--t-text-small); font-weight: 500; color: var(--t-text-secondary); }
.tp-field input,
.tp-field select,
.tp-field textarea {
  width: 100%;
  height: 36px;
  padding: 0 var(--t-space-3);
  background: var(--t-bg);
  border: 1px solid var(--t-hairline-strong);
  border-radius: var(--t-radius-sm);
  color: var(--t-text);
  font: inherit;
  font-size: var(--t-text-body);
  transition: border-color var(--t-duration-fast) var(--t-ease-standard),
              background-color var(--t-duration-fast) var(--t-ease-standard);
}
.tp-field textarea { height: auto; padding: var(--t-space-2) var(--t-space-3); }
.tp-field input:focus,
.tp-field select:focus,
.tp-field textarea:focus {
  outline: none;
  border-color: var(--t-signal);
  background: var(--t-signal-ghost);
  box-shadow: var(--t-shadow-focus);
}
.tp-field-hint { font-size: var(--t-text-caption); color: var(--t-text-tertiary); }
.tp-field-hint--block { display: block; margin-bottom: var(--t-space-6); }
.tp-field-error { font-size: var(--t-text-small); color: var(--t-critical); }
/* Inline checkbox + label (e.g. signup-trial opt-in). Horizontal row,
   cursor on the whole label, small gap between box and text. */
.tp-field-checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--t-space-2);
  cursor: pointer;
  font-size: var(--t-text-body);
  color: var(--t-text);
}
.tp-field-checkbox input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--t-signal);
  cursor: pointer;
}

/* ── Flash / alert banners ────────────────────────────────────────────────── */

.tp-alert {
  display: flex;
  gap: var(--t-space-3);
  padding: var(--t-space-3) var(--t-space-4);
  border-radius: var(--t-radius);
  border-left: 4px solid var(--t-hairline-strong);
  background: var(--t-bg-raised);
  font-size: var(--t-text-body);
  color: var(--t-text);
  margin-bottom: var(--t-space-4);
}
.tp-alert-success { border-left-color: var(--t-positive); background: var(--t-positive-subtle); }
.tp-alert-error { border-left-color: var(--t-critical); background: var(--t-critical-subtle); color: var(--t-critical); }
.tp-alert-warning { border-left-color: var(--t-warning); background: var(--t-warning-subtle); }
.tp-alert-signal { border-left-color: var(--t-signal); background: var(--t-signal-subtle); }

/* ── Badges ────────────────────────────────────────────────────────────────── */

.tp-badge {
  display: inline-block;
  padding: 2px var(--t-space-2);
  border-radius: var(--t-radius-full);
  font-size: var(--t-text-caption);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid var(--t-hairline);
  color: var(--t-text-secondary);
  background: var(--t-bg);
}
.tp-badge-positive { color: var(--t-positive); border-color: var(--t-positive); background: var(--t-positive-subtle); }
.tp-badge-critical { color: var(--t-critical); border-color: var(--t-critical); background: var(--t-critical-subtle); }
.tp-badge-warning { color: var(--t-warning); border-color: var(--t-warning); background: var(--t-warning-subtle); }
.tp-badge-signal { color: var(--t-signal); border-color: var(--t-signal); background: var(--t-signal-subtle); }

/* ── Data tables ──────────────────────────────────────────────────────────── */

.tp-table { width: 100%; border-collapse: collapse; font-size: var(--t-text-small); }
.tp-table thead th {
  text-align: left;
  padding: var(--t-space-2) var(--t-space-3);
  background: var(--t-bg-sunken);
  border-bottom: 1px solid var(--t-hairline);
  font-size: var(--t-text-caption);
  font-weight: 600;
  color: var(--t-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.tp-table tbody td {
  padding: var(--t-space-3);
  border-bottom: 1px solid var(--t-hairline);
  color: var(--t-text);
  vertical-align: middle;
}
.tp-table tbody tr:last-child td { border-bottom: 0; }
.tp-table tbody tr:hover td { background: var(--t-bg-sunken); }

/* ── Dashboard shell ──────────────────────────────────────────────────────── */

.tp-dashboard {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  max-width: 1280px;
  margin: 0 auto;
  min-height: calc(100vh - 56px - 72px);
}
@media (max-width: 960px) {
  .tp-dashboard { grid-template-columns: 1fr; }
}
.tp-rail {
  border-right: 1px solid var(--t-hairline);
  padding: var(--t-space-8) var(--t-space-3);
  display: flex;
  flex-direction: column;
  gap: var(--t-space-6);
}
@media (max-width: 960px) {
  .tp-rail { border-right: 0; border-bottom: 1px solid var(--t-hairline); padding: var(--t-space-4) var(--t-space-6); }
}
.tp-rail-group { display: flex; flex-direction: column; gap: var(--t-space-1); }
.tp-rail-caption {
  font-size: var(--t-text-caption);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--t-text-tertiary);
  padding: 0 var(--t-space-3);
  margin-bottom: var(--t-space-1);
}
.tp-rail a,
.tp-rail .tp-rail-disabled {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--t-space-2) var(--t-space-3);
  border-radius: var(--t-radius-sm);
  color: var(--t-text-secondary);
  font-size: var(--t-text-body);
  font-weight: 500;
  text-decoration: none;
}
.tp-rail a:hover { background: var(--t-bg-sunken); color: var(--t-text); }
.tp-rail a.is-active { background: var(--t-signal-subtle); color: var(--t-signal); }
.tp-rail .tp-rail-disabled { color: var(--t-text-tertiary); cursor: default; }

.tp-soon {
  font-size: var(--t-text-caption);
  color: var(--t-text-tertiary);
  border: 1px solid var(--t-hairline);
  border-radius: var(--t-radius-xs);
  padding: 1px 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tp-canvas { padding: var(--t-space-8) var(--t-space-8); min-width: 0; }
@media (max-width: 960px) { .tp-canvas { padding: var(--t-space-6); } }

.tp-page-title { font-size: var(--t-text-h1); margin-bottom: var(--t-space-2); }
.tp-page-subtitle { color: var(--t-text-secondary); margin-bottom: var(--t-space-8); }

/* ── KPI strip ────────────────────────────────────────────────────────────── */

.tp-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--t-space-4);
  margin-bottom: var(--t-space-8);
}
.tp-kpi {
  background: var(--t-bg-raised);
  border: 1px solid var(--t-hairline);
  border-radius: var(--t-radius);
  padding: var(--t-space-6);
}
.tp-kpi-caption {
  font-size: var(--t-text-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--t-text-secondary);
  margin-bottom: var(--t-space-2);
}
.tp-kpi-value { font-family: var(--t-font-display); font-size: var(--t-text-kpi); line-height: 1; color: var(--t-ink); }
.tp-kpi-sub { font-size: var(--t-text-small); color: var(--t-text-secondary); margin-top: var(--t-space-2); }

/* ── Two-column info rows ─────────────────────────────────────────────────── */

.tp-info-list { list-style: none; padding: 0; margin: 0; }
.tp-info-list li { display: flex; gap: var(--t-space-4); padding: var(--t-space-3) 0; border-bottom: 1px solid var(--t-hairline); }
.tp-info-list li:last-child { border-bottom: 0; }
.tp-info-label { width: 160px; flex-shrink: 0; font-size: var(--t-text-small); color: var(--t-text-secondary); font-weight: 500; }
.tp-info-value { font-size: var(--t-text-body); color: var(--t-text); }

/* ── Device pairing input ─────────────────────────────────────────────────── */

.tp-code-input {
  font-family: var(--t-font-mono);
  font-size: var(--t-text-h2);
  letter-spacing: 0.2em;
  text-align: center;
  text-transform: uppercase;
}
/* Read-only code display (prefilled device pairing). Shares type treatment
   with the input so the two variants stay visually aligned. */
.tp-code-display {
  display: block;
  padding: var(--t-space-4) 0;
  text-align: center;
}

/* ── HTMX indicator ───────────────────────────────────────────────────────── */

.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-block; color: var(--t-text-secondary); }
.htmx-request .tp-btn-primary { opacity: 0.7; pointer-events: none; }

/* ── SSO ──────────────────────────────────────────────────────────────────── */

.tp-sso-divider {
  text-align: center;
  margin: var(--t-space-6) 0;
  position: relative;
  font-size: var(--t-text-small);
  color: var(--t-text-tertiary);
}
.tp-sso-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  border-top: 1px solid var(--t-hairline);
  z-index: 0;
}
.tp-sso-divider span {
  background: var(--t-bg-raised);
  position: relative;
  padding: 0 var(--t-space-3);
  z-index: 1;
}
.tp-sso-buttons { display: flex; flex-direction: column; gap: var(--t-space-2); }
.tp-sso-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border-radius: var(--t-radius-sm);
  background: var(--t-signal-ghost);
  color: var(--t-text);
  font-size: var(--t-text-body);
  font-weight: 500;
  border: 1px solid var(--t-hairline);
  text-decoration: none;
  transition: background-color var(--t-duration-fast) var(--t-ease-standard);
}
.tp-sso-btn:hover { background: var(--t-signal-subtle); color: var(--t-text); text-decoration: none; }

/* ── Motion reset ─────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* ── Admin surface (merged from upstream plan-catalog PR) ─────────────── */
/* Uses only Atelier tokens from tokens.css. Tokens from upstream's inline
   :root block were mapped to their Atelier equivalents:
   --t-bg-overlay → --t-bg-sunken
   --t-border-light → --t-hairline
   --t-border → --t-hairline-strong
   --t-error → --t-critical
   --t-space-{xs,sm,md,lg} → --t-space-{1,3,4,6}
   --t-text-sm → --t-text-small */

/* Admin dashboard layout — reuses non-prefixed classes referenced by
   admin/layout.html; distinct from the tp-* dashboard layout in base. */
/* ── Dashboard ──────────────────────────────────────────────────────────────── */

.dashboard-layout {
    display: flex;
    min-height: calc(100vh - 120px); /* nav + footer */
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}
.dashboard-layout {
    display: flex;
    min-height: calc(100vh - 120px); /* nav + footer */
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.dashboard-sidebar {
    width: 220px;
    flex-shrink: 0;
    background-color: var(--t-bg-raised);
    border-right: 1px solid var(--t-hairline-strong);
    padding: var(--t-space-8) 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: var(--t-space-1);
    padding: 0 var(--t-space-3);
}

.sidebar-link {
    display: block;
    padding: var(--t-space-3) var(--t-space-4);
    border-radius: var(--t-radius-sm);
    color: var(--t-text-secondary);
    font-size: var(--t-text-small);
    font-weight: 500;
    transition: background-color 0.15s ease, color 0.15s ease;
    cursor: pointer;
    text-decoration: none;
}

.sidebar-link:hover:not(.disabled) {
    background-color: var(--t-bg-sunken);
    color: var(--t-text);
}

.sidebar-link.active {
    background-color: var(--t-signal-subtle);
    color: var(--t-signal);
}

.sidebar-link.disabled {
    /* secondary, not tertiary: tertiary fails AA (3.53:1) on --t-bg-raised. */
    color: var(--t-text-secondary);
    cursor: default;
    display: flex;
    align-items: center;
    gap: var(--t-space-3);
}

.coming-soon {
    font-size: 10px;
    background-color: var(--t-bg-sunken);
    border: 1px solid var(--t-hairline-strong);
    border-radius: 4px;
    padding: 1px 5px;
    /* secondary, not tertiary: tertiary fails AA (3.17:1) on --t-bg-overlay. */
    color: var(--t-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.dashboard-content {
    flex: 1;
    padding: var(--t-space-8) var(--t-space-12);
    min-width: 0;
}

.dashboard-heading {
    font-size: var(--t-text-h1);
    margin-bottom: var(--t-space-8);
    color: var(--t-text);
}

/* ── Cards ───────────────────────────────────────────────────────────────────── */

.card {
    background-color: var(--t-bg-raised);
    border: 1px solid var(--t-hairline-strong);
    border-radius: var(--t-radius-lg);
    padding: var(--t-space-8);
    margin-bottom: var(--t-space-6);
}

.card-title {
    font-size: var(--t-text-h3);
    color: var(--t-text);
    margin-bottom: var(--t-space-6);
    font-family: 'Bricolage Grotesque', sans-serif;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--t-space-6);
}

.card-header .card-title {
    margin-bottom: 0;
}

.info-row {
    display: flex;
    align-items: center;
    gap: var(--t-space-6);
    padding: var(--t-space-3) 0;
    border-bottom: 1px solid var(--t-hairline);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    width: 140px;
    flex-shrink: 0;
    font-size: var(--t-text-small);
    color: var(--t-text-secondary);
    font-weight: 500;
}

.info-value {
    color: var(--t-text);
    font-size: var(--t-text-small);
}

.mono {
    font-family: 'JetBrains Mono', monospace;
    font-size: var(--t-text-small);
}

.license-key-row {
    display: flex;
    align-items: center;
    gap: var(--t-space-3);
}

/* ── Badges ──────────────────────────────────────────────────────────────────── */

.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: var(--t-text-small);
    font-weight: 600;
}

.badge-active {
    background-color: rgba(61, 139, 94, 0.15);
    color: #5ec28a;
    border: 1px solid rgba(61, 139, 94, 0.3);
}

.badge-inactive {
    background-color: var(--t-bg-sunken);
    color: var(--t-text-tertiary);
    border: 1px solid var(--t-hairline-strong);
}


.machines-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--t-text-small);
}

.machines-table th {
    text-align: left;
    padding: var(--t-space-3) var(--t-space-4);
    color: var(--t-text-tertiary);
    font-weight: 500;
    font-size: var(--t-text-small);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--t-hairline-strong);
}

.machines-table td {
    padding: var(--t-space-3) var(--t-space-4);
    color: var(--t-text);
    border-bottom: 1px solid var(--t-hairline);
}

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

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--t-space-6);
}

.feature-card {
    background-color: var(--t-bg-raised);
    border: 1px solid var(--t-hairline-strong);
    border-radius: var(--t-radius-lg);
    padding: var(--t-space-8);
}

.feature-card h3 {
    font-size: var(--t-text-h2);
    color: var(--t-signal);
    margin-bottom: var(--t-space-3);
}

.feature-card p {
    color: var(--t-text-secondary);
    line-height: 1.6;
}


.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--t-text-small);
}

.admin-table th {
    text-align: left;
    padding: var(--t-space-3) var(--t-space-4);
    color: var(--t-text-tertiary);
    font-weight: 500;
    font-size: var(--t-text-xs, 0.75rem);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    border-bottom: 1px solid var(--t-hairline-strong);
}

.admin-table td {
    padding: var(--t-space-3) var(--t-space-4);
    color: var(--t-text);
    border-bottom: 1px solid var(--t-hairline);
    vertical-align: top;
}

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

.admin-lede {
    color: var(--t-text-secondary);
    font-size: var(--t-text-small);
    margin: 0 0 var(--t-space-6) 0;
    max-width: 56ch;
}

.admin-row-sub {
    color: var(--t-text-tertiary);
    font-size: var(--t-text-xs, 0.75rem);
    display: block;
    margin-top: 2px;
}

.admin-row-link {
    color: var(--t-text);
    text-decoration: none;
    font-weight: 600;
}

.admin-row-link:hover {
    color: var(--t-signal);
    text-decoration: underline;
}

.admin-breadcrumb {
    margin: 0 0 var(--t-space-3) 0;
    font-size: var(--t-text-small);
}

.admin-breadcrumb a {
    color: var(--t-text-secondary);
    text-decoration: none;
}

.admin-breadcrumb a:hover {
    color: var(--t-text);
}

.admin-banner {
    padding: var(--t-space-3) var(--t-space-4);
    border-radius: var(--t-radius-sm, 4px);
    margin-bottom: var(--t-space-4);
    font-size: var(--t-text-small);
}

.admin-banner-success {
    background: var(--t-positive-subtle, #e8f5e9);
    color: var(--t-positive, #2e7d32);
    border: 1px solid var(--t-positive, #2e7d32);
}

.admin-banner-error {
    background: var(--t-critical-subtle, #fdecea);
    color: var(--t-critical, #c62828);
    border: 1px solid var(--t-critical, #c62828);
}

.admin-form .admin-field {
    display: block;
    margin-bottom: var(--t-space-4);
}

.admin-field-label {
    display: block;
    font-size: var(--t-text-xs, 0.75rem);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--t-text-tertiary);
    margin-bottom: 4px;
}

.admin-form input[type="text"],
.admin-form input[type="number"],
.admin-form textarea {
    width: 100%;
    max-width: 480px;
    padding: 6px 8px;
    border: 1px solid var(--t-hairline-strong);
    border-radius: var(--t-radius-sm, 3px);
    font: inherit;
    font-size: var(--t-text-small);
}

.admin-field-row {
    display: flex;
    gap: var(--t-space-4);
    flex-wrap: wrap;
    align-items: flex-end;
}

.admin-field-inline {
    display: flex;
    flex-direction: column;
    font-size: var(--t-text-xs, 0.75rem);
    color: var(--t-text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.admin-field-inline input {
    width: 110px;
}

.admin-checkbox {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    font-size: var(--t-text-small);
    color: var(--t-text);
    margin-right: var(--t-space-4);
}

.admin-field-readonly {
    display: flex;
    gap: var(--t-space-4);
    align-items: baseline;
    margin-top: var(--t-space-3);
    font-size: var(--t-text-small);
}

.admin-input-num {
    width: 90px;
}

.admin-input-text {
    width: 140px;
}

.admin-form-footer {
    display: flex;
    gap: var(--t-space-3);
    margin-top: var(--t-space-6);
}

.machine-count {
    font-size: var(--t-text-small);
    color: var(--t-text-secondary);
}

.empty-state {
    color: var(--t-text-secondary);
    font-size: var(--t-text-small);
    padding: var(--t-space-6) 0;
}

/* ── Dashboard Buttons ───────────────────────────────────────────────────────── */

.btn-sm {
    padding: var(--t-space-3) var(--t-space-4);
    font-size: var(--t-text-small);
    border-radius: var(--t-radius-sm);
}

.btn-danger {
    display: inline-block;
    background-color: transparent;
    color: var(--t-critical);
    padding: var(--t-space-1) var(--t-space-3);
    border-radius: var(--t-radius-sm);
    font-size: var(--t-text-small);
    font-weight: 500;
    border: 1px solid var(--t-critical);
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.15s ease;
}

.btn-danger:hover {
    background-color: rgba(196, 82, 74, 0.1);
}

.btn-copy {
    display: inline-block;
    background-color: transparent;
    color: var(--t-text-secondary);
    padding: 2px var(--t-space-3);
    border-radius: var(--t-radius-sm);
    font-size: var(--t-text-small);
    font-weight: 500;
    border: 1px solid var(--t-hairline-strong);
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-copy:hover {
    background-color: var(--t-bg-sunken);
    color: var(--t-text);
}


/* ── Admin-template button/field aliases ─────────────────────────────────
   Admin templates inherited from the upstream plan-catalog PR use
   non-prefixed button classes. Alias them to the Atelier tp-btn styles
   so both surfaces share a single visual language; the admin i18n sweep
   (deferred S32) will rename the classes to tp-* later. */

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--t-space-2);
  font-family: var(--t-font-body);
  font-size: var(--t-text-body);
  font-weight: 500;
  padding: var(--t-space-2) var(--t-space-4);
  border-radius: var(--t-radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--t-duration-fast) var(--t-ease-standard),
              color var(--t-duration-fast) var(--t-ease-standard);
  text-decoration: none;
}

.btn-primary {
  background: var(--t-signal);
  color: var(--t-signal-on);
}
.btn-primary:hover {
  background: var(--t-signal-hover);
  color: var(--t-signal-on);
  text-decoration: none;
}

.btn-secondary {
  background: transparent;
  color: var(--t-text);
  border-color: var(--t-hairline-strong);
}
.btn-secondary:hover {
  background: var(--t-bg-sunken);
  color: var(--t-text);
  text-decoration: none;
}

/* Read-only value cell on admin detail pages (admin-field-value was
   referenced in templates but never defined in the upstream stylesheet). */
.admin-field-value {
  color: var(--t-text);
  font-size: var(--t-text-body);
}
