/* ==========================================================================
   User Panel — app.css
   Components only the user panel uses. Tokens and shared components
   (sections 01–18) live in public/template/core/assets/css/core.css, which
   every page loads before this file (decision D4), so the admin panel, the
   user panel and the portal look like one product.

   Sections
   19. User panel: organization switcher, status banner, usage meters,
       onboarding checklist, plans & checkout, bank transfer / VietQR,
       invoice document, receipt dropzone, settings layout, organizations,
       invitation
   20. Fleet: shell additions, freshness, severity, state bars, conditions,
       resource identity, operation lifecycle and results, previews, logs,
       panel keys, checks, filters, servers, search, cron, environment,
       wizard, step-up, assignment matrix, components page
   Responsive rules of 19 and 20 are together at the end of the file.
   ========================================================================== */

/* ==========================================================================
   19. User panel
   ========================================================================== */

/* Organization switcher (sidebar header) -------------------------------- */
.org-switcher {
  position: relative;
  flex: 1;
  min-width: 0;
}

.org-switcher-button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.org-switcher-button:hover,
.org-switcher.is-open .org-switcher-button {
  background: var(--color-surface-hover);
  border-color: var(--color-border);
}

.org-switcher-info {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.org-switcher-name {
  overflow: hidden;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.org-switcher-plan {
  font-size: 12px;
  color: var(--color-text-muted);
}

.org-switcher-chevron {
  color: var(--color-text-subtle);
}

.org-switcher-menu {
  left: 0;
  right: 0;
  min-width: 240px;
}

.org-switcher.is-open .org-switcher-menu {
  display: block;
}

.org-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.org-option:hover {
  background: var(--color-surface-hover);
  text-decoration: none;
}

.org-option-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.org-option-check {
  margin-left: auto;
  color: var(--color-primary-text);
}

.org-option-meta {
  font-size: 12px;
  color: var(--color-text-muted);
}

.dropdown-label {
  padding: 6px 8px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
}

/* Sidebar plan card (above the user block) */
.sidebar-plan {
  margin: 0 0 12px;
  padding: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
}

.sidebar-plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.sidebar-plan-title {
  font-weight: 600;
}

.sidebar-plan-text {
  margin: 6px 0 10px;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Status banner (trial, past due, suspended) ------------------------------ */
.app-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 24px;
  font-size: 13px;
}

.app-banner-text {
  flex: 1 1 280px;
}

.app-banner-info { background: var(--color-info-soft); color: var(--color-info); }
.app-banner-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.app-banner-danger { background: var(--color-danger-soft); color: var(--color-danger); }

.app-banner .btn {
  min-height: 32px;
  padding: 4px 12px;
  font-size: 13px;
}

/* Usage meters (seats) ---------------------------------------------------- */
.usage-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.usage-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.usage-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.usage-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

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

.usage-limit {
  color: var(--color-text-muted);
  font-weight: 400;
}

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

/* The other step classes (0, 10 … 100) are in core.css section 08. */
.progress-33 { width: 33%; }

.progress-bar-success { background: var(--color-success); }

/* Onboarding checklist ---------------------------------------------------- */
.checklist {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--color-border);
}

.checklist-item:last-child {
  border-bottom: 0;
}

.checklist-check {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border: 2px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  color: transparent;
}

.checklist-item.is-done .checklist-check {
  border-color: var(--color-success);
  background: var(--color-success);
  color: #ffffff;
}

[data-theme="dark"] .checklist-item.is-done .checklist-check {
  color: #0c0e13;
}

.checklist-body {
  flex: 1;
  min-width: 0;
}

.checklist-title {
  font-weight: 500;
}

.checklist-item.is-done .checklist-title {
  color: var(--color-text-muted);
  text-decoration: line-through;
}

.checklist-text {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Welcome card (dashboard hero) */
.welcome-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px;
}

.welcome-title {
  font-size: 20px;
  font-weight: 600;
}

.welcome-text {
  margin-top: 4px;
  color: var(--color-text-muted);
}

/* Quick actions grid */
.quick-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.quick-action {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}

/* An odd last action spans the row instead of leaving a gap. */
.quick-action:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.quick-action:hover {
  background: var(--color-surface-hover);
  text-decoration: none;
}

.quick-action .icon {
  color: var(--color-primary-text);
}

/* Steps (checkout progress) ----------------------------------------------- */
.steps {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.step {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-muted);
  font-weight: 500;
}

.step + .step::before {
  content: "";
  width: 24px;
  height: 1px;
  margin-right: 4px;
  background: var(--color-border-strong);
}

.step-number {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
}

.step.is-active {
  color: var(--color-text);
}

.step.is-active .step-number {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #ffffff;
}

.step.is-done .step-number {
  border-color: var(--color-success);
  background: var(--color-success-soft);
  color: var(--color-success);
}

[data-theme="dark"] .step.is-active .step-number {
  color: #0c0e13;
}

/* Plans catalogue --------------------------------------------------------- */
.billing-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.save-label {
  margin-left: 6px;
  color: var(--color-success);
  font-size: 12px;
  font-weight: 600;
}

.plan-grid {
  display: grid;
  /* As many columns as fit (one per plan up to four on desktop, two on tablet, one on phone). */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  gap: 16px;
}

.plan-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.plan-card.is-featured {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary), var(--shadow-md);
}

.plan-card.is-current {
  background: var(--color-surface-muted);
}

.plan-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.plan-name {
  font-size: 17px;
  font-weight: 600;
}

.plan-description {
  min-height: 42px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.plan-price {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}

.plan-price-amount {
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.plan-price-period {
  font-size: 13px;
  color: var(--color-text-muted);
}

.plan-price-note {
  font-size: 12px;
  color: var(--color-text-subtle);
}

.plan-feature-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 16px 0 0;
  border-top: 1px solid var(--color-border);
  list-style: none;
  font-size: 13px;
}

.plan-feature {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.plan-feature .icon {
  color: var(--color-success);
}

.plan-feature.is-excluded,
.plan-feature.is-excluded .icon {
  color: var(--color-text-subtle);
}

.plan-card-action {
  margin-top: auto;
}

/* Choice card: a radio or checkbox rendered as a selectable card */
.choice-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.choice-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.choice-card:hover {
  border-color: var(--color-text-subtle);
}

.choice-card:has(.choice-input:checked),
.choice-card.is-selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.choice-card:has(.choice-input:focus-visible) {
  box-shadow: var(--focus-ring);
}

.choice-input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex-shrink: 0;
  accent-color: var(--color-primary);
}

.choice-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.choice-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.choice-text {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Seat stepper */
.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.stepper-button {
  display: grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  border: 0;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}

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

.stepper-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stepper-input {
  width: 64px;
  border: 0;
  border-inline: 1px solid var(--color-border);
  background: none;
  color: var(--color-text);
  font: inherit;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}

.stepper-input::-webkit-outer-spin-button,
.stepper-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.stepper-input:focus {
  outline: none;
  background: var(--color-surface-muted);
}

/* Order summary */
.summary-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
}

.summary-row dt {
  color: var(--color-text-muted);
}

.summary-row dd {
  margin: 0;
  font-weight: 500;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.summary-total {
  padding-top: 12px;
  border-top: 1px solid var(--color-border);
  font-size: 15px;
}

.summary-total dt {
  color: var(--color-text);
  font-weight: 600;
}

.summary-total dd {
  font-size: 20px;
  font-weight: 600;
}

.checkout-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 380px);
  gap: 16px;
  align-items: start;
}

.secure-note {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Current subscription card */
.subscription-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.subscription-plan {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 600;
}

.subscription-price {
  margin-top: 4px;
  color: var(--color-text-muted);
}

.subscription-facts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
}

.subscription-fact dt {
  font-size: 12px;
  color: var(--color-text-muted);
}

.subscription-fact dd {
  margin: 4px 0 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Bank transfer / VietQR --------------------------------------------------- */
.payment-layout {
  display: grid;
  grid-template-columns: minmax(0, 340px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.qr-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface-muted);
  text-align: center;
}

.qr-frame {
  display: grid;
  place-items: center;
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1;
  padding: 14px;
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: var(--shadow-sm);
}

.qr-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Placeholder QR drawn with CSS, shown until the real VietQR image loads */
.qr-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 4px;
  background:
    linear-gradient(90deg, #111827 10%, transparent 10% 20%, #111827 20% 30%, transparent 30% 45%, #111827 45% 55%, transparent 55% 70%, #111827 70% 80%, transparent 80% 90%, #111827 90%) 0 0 / 100% 12.5%,
    linear-gradient(#111827 10%, transparent 10% 25%, #111827 25% 35%, transparent 35% 55%, #111827 55% 65%, transparent 65% 85%, #111827 85%) 0 0 / 12.5% 100%;
  opacity: 0.85;
}

.qr-caption {
  font-size: 13px;
  color: var(--color-text-muted);
}

.qr-bank {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.countdown {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-full);
  background: var(--color-warning-soft);
  color: var(--color-warning);
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.countdown.is-expired {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

/* Copyable value rows (bank details, reference code) */
.copy-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.copy-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 10px 14px;
  border-bottom: 1px solid var(--color-border);
}

.copy-row:last-child {
  border-bottom: 0;
}

.copy-row-body {
  flex: 1;
  min-width: 0;
}

.copy-row dt {
  font-size: 12px;
  color: var(--color-text-muted);
}

.copy-row dd {
  margin: 2px 0 0;
  overflow-wrap: anywhere;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.copy-row.is-highlight {
  background: var(--color-primary-soft);
}

.copy-row.is-highlight dd {
  color: var(--color-primary-text);
  font-family: var(--font-mono);
  font-size: 16px;
  letter-spacing: 0.04em;
}

.copy-button.is-copied {
  color: var(--color-success);
}

/* Instruction list (numbered how-to) */
.instruction-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: instruction;
  font-size: 13px;
}

.instruction-list li {
  display: flex;
  gap: 10px;
  counter-increment: instruction;
}

.instruction-list li::before {
  content: counter(instruction);
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--color-primary-soft);
  color: var(--color-primary-text);
  font-size: 12px;
  font-weight: 600;
}

/* Result page (checkout success / pending) */
.result-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 560px;
  margin: 24px auto;
  padding: 40px 32px;
  text-align: center;
}

.result-icon {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin-bottom: 8px;
  border-radius: var(--radius-full);
  background: var(--color-success-soft);
  color: var(--color-success);
}

.result-icon-warning {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.result-title {
  font-size: 22px;
  font-weight: 600;
}

.result-text {
  max-width: 420px;
  color: var(--color-text-muted);
}

.result-panel .summary-list {
  width: 100%;
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
  text-align: left;
}

/* Invoice document --------------------------------------------------------- */
.invoice-doc {
  padding: 40px;
}

.invoice-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

.invoice-number {
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--color-text-muted);
}

.invoice-parties {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  padding: 24px 0;
}

.invoice-party-label {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
}

.invoice-party {
  font-size: 13px;
  line-height: 1.6;
}

.invoice-totals {
  display: flex;
  justify-content: flex-end;
  padding-top: 20px;
}

.invoice-totals .summary-list {
  width: 100%;
  max-width: 320px;
}

.invoice-note {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  font-size: 12px;
  color: var(--color-text-muted);
}

/* Files & dropzone --------------------------------------------------------- */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 32px 24px;
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: var(--color-surface-muted);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}

.dropzone-compact {
  flex-direction: row;
  justify-content: center;
  padding: 16px;
  text-align: left;
}

.dropzone-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  color: var(--color-primary-text);
  box-shadow: var(--shadow-sm);
}

.dropzone-title {
  font-weight: 600;
}

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

.dropzone-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.upload-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.upload-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
}

.upload-item-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.upload-item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.upload-item.is-error {
  border-color: var(--color-danger);
}

.file-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
}

.file-icon-pdf { background: var(--color-danger-soft); color: var(--color-danger); }
.file-icon-image { background: var(--color-info-soft); color: var(--color-info); }
.file-icon-doc { background: var(--color-primary-soft); color: var(--color-primary-text); }
.file-icon-sheet { background: var(--color-success-soft); color: var(--color-success); }
.file-icon-archive { background: var(--color-warning-soft); color: var(--color-warning); }

/* Settings layout (sub navigation + content) ------------------------------- */
.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.settings-nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  font-weight: 500;
}

.settings-nav-link:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
  text-decoration: none;
}

.settings-nav-link.is-active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: inset 0 0 0 1px var(--color-border);
}

.settings-nav-title {
  padding: 12px 12px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-text-subtle);
}

/* Avatar / logo upload */
.avatar-upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.avatar-xl {
  width: 72px;
  height: 72px;
  font-size: 22px;
}

.avatar-upload-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Danger zone */
.card-danger {
  border-color: var(--color-danger);
}

.card-danger .card-header {
  border-bottom-color: var(--color-danger-soft);
}

.card-danger .card-title {
  color: var(--color-danger);
}

.danger-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.danger-row:last-child {
  border-bottom: 0;
}

.danger-row-title {
  font-weight: 600;
}

.danger-row-text {
  font-size: 13px;
  color: var(--color-text-muted);
}

/* Session / device list */
.session-list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}

.session-item:last-child {
  border-bottom: 0;
}

/* New API token, shown once (API tokens page): long secrets wrap anywhere. */
.token-reveal {
  min-width: 0;
}

.token-value {
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Two-factor recovery codes (My account) ------------------------------------ */
.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 16px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
  font-family: var(--font-mono);
  font-size: 13px;
  list-style: none;
}

/* Organizations ------------------------------------------------------------ */
.org-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.org-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
}

.org-card.is-current {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.org-card-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.org-card-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.org-card-new {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 180px;
  padding: 20px;
  border: 2px dashed var(--color-border-strong);
  border-radius: var(--radius-lg);
  background: transparent;
  color: var(--color-text-muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.org-card-new:hover {
  border-color: var(--color-primary);
  color: var(--color-primary-text);
  text-decoration: none;
}

/* Role legend (members page) */
.role-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.role-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
}

.role-item-text {
  color: var(--color-text-muted);
}

/* Invitation / centered auth card ------------------------------------------ */
.auth-center {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 32px 24px;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
}

.auth-center-content {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: 32px 0;
}

.auth-center-card {
  width: 100%;
  max-width: 440px;
  padding: 32px;
}

.invite-orgs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.invite-orgs-link {
  width: 32px;
  height: 2px;
  background: var(--color-border-strong);
}

.invite-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
  padding: 14px 16px;
  border-radius: var(--radius-md);
  background: var(--color-surface-muted);
  font-size: 13px;
}

/* Password strength meter */
.strength {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.strength-bar {
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--color-border);
}

.strength.is-weak .strength-bar:nth-child(-n+1) { background: var(--color-danger); }
.strength.is-fair .strength-bar:nth-child(-n+2) { background: var(--color-warning); }
.strength.is-good .strength-bar:nth-child(-n+3) { background: var(--color-success); }
.strength.is-strong .strength-bar { background: var(--color-success); }

/* One-time code input (email verification) */
.code-inputs {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.code-input {
  min-height: 52px;
  padding: 0;
  font-family: var(--font-mono);
  font-size: 22px;
  text-align: center;
}

/* Fieldset groups (plan, payment method radios) */
fieldset,
.fieldset {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

fieldset > legend,
.fieldset > legend {
  margin-bottom: 8px;
  padding: 0;
}

.copy-row-body {
  margin: 0;
}

/* Keep visually hidden labels inside scrolling tables from widening the page */
.table-wrapper {
  position: relative;
}

/* Let an open row menu escape the scrolling table box */
.table-wrapper:has(.dropdown.is-open) {
  overflow: visible;
}

/* Compact selects (role select in tables) keep room for the arrow */
.form-select.form-control-sm {
  padding-right: 30px;
  background-position: right 8px center;
}

.table .form-select {
  width: auto;
  min-width: 120px;
}

/* A light block nested in a dark page keeps light-theme text on filled controls */
[data-theme="light"] .btn-primary,
[data-theme="light"] .btn-danger,
[data-theme="light"] .page-link.is-active,
[data-theme="light"] .step.is-active .step-number,
[data-theme="light"] .checklist-item.is-done .checklist-check,
[data-theme="light"] .timeline-item.is-done .timeline-dot {
  color: #ffffff;
}

.chart-legend-swatch-muted {
  background: var(--color-border);
}

/* Focus ring for a hidden file input styled through its label button */
.visually-hidden:focus-visible + .btn,
.visually-hidden:focus-visible + label.btn {
  box-shadow: var(--focus-ring);
}

/* Colour variants for the centered status icon */
.result-icon-primary { background: var(--color-primary-soft); color: var(--color-primary-text); }
.result-icon-danger { background: var(--color-danger-soft); color: var(--color-danger); }

/* Organization suspended / blocked state */
.blocked-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 520px;
  margin: 48px auto;
  padding: 40px 32px;
  text-align: center;
}

/* ==========================================================================
   20. Fleet (member workspace)
   Components that the Fleet screens add on top of core.css (01–18) and the
   workspace's app.css (19). Tokens only: every color, radius and shadow is a
   variable from section 01, so light and dark mode follow automatically.
   ========================================================================== */

/* -- Small primitives ----------------------------------------------------- */
.text-2xs { font-size: 11px; }
.nowrap { white-space: nowrap; }
.min-w-0 { min-width: 0; }
.badge > .icon:not(.icon-sm), .chip > .icon, .source-tag > .icon, .freshness > .icon { width: 13px; height: 13px; }
.btn > .icon:not(.icon-sm):not(.icon-lg) { width: 16px; height: 16px; }
.btn-sm > .icon:not(.icon-sm):not(.icon-lg) { width: 14px; height: 14px; }
.icon-xs { width: 13px; height: 13px; }
.is-spinning { animation: fleet-spin 1s linear infinite; }
@keyframes fleet-spin { to { transform: rotate(360deg); } }
@keyframes fleet-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }

.badge-outline { background: transparent; box-shadow: inset 0 0 0 1px var(--color-border-strong); color: var(--color-text-muted); }
.badge-square { border-radius: var(--radius-sm); padding: 1px 8px; }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--color-text-subtle); flex-shrink: 0; }
.dot-success { background: var(--color-success); }
.dot-warning { background: var(--color-warning); }
.dot-danger { background: var(--color-danger); }
.dot-info { background: var(--color-info); }
.dot-live { animation: fleet-pulse 1.6s ease-in-out infinite; }

/* Chips: permission sets, groups, packages */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px; border-radius: var(--radius-sm);
  border: 1px solid var(--color-border); background: var(--color-surface);
  color: var(--color-text-muted); font-size: 12px; line-height: 20px; white-space: nowrap;
}
.chip-mono { font-family: var(--font-mono); font-size: 11.5px; }
.chip-primary { border-color: transparent; background: var(--color-primary-soft); color: var(--color-primary-text); }
.chip-warning { border-color: transparent; background: var(--color-warning-soft); color: var(--color-warning); }
.chip-danger { border-color: transparent; background: var(--color-danger-soft); color: var(--color-danger); }

/* Inline metadata line: a · b · c */
.meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; color: var(--color-text-muted); font-size: 13px; }
.meta-line > * { display: inline-flex; align-items: center; gap: 6px; }

/* -- Shell: Fleet additions to the sidebar and navbar ---------------------- */
.sidebar-beta {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 8px; padding: 12px;
  border: 1px dashed var(--color-border-strong); border-radius: var(--radius-md);
}
.sidebar-beta-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; }
.sidebar-beta-text { margin: 0; color: var(--color-text-muted); font-size: 12px; }

.navbar-chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 12px;
  border: 1px solid var(--color-border); border-radius: var(--radius-full);
  background: var(--color-surface); color: var(--color-text-muted); font-size: 13px; font-weight: 500; white-space: nowrap;
}
.navbar-chip:hover { background: var(--color-surface-hover); color: var(--color-text); text-decoration: none; }
.navbar-chip-count { min-width: 20px; padding: 0 6px; border-radius: var(--radius-full); background: var(--color-info-soft); color: var(--color-info); font-size: 12px; font-weight: 600; text-align: center; }
.navbar-chip.is-verified { color: var(--color-success); }
/* Phones hide the navbar search field; this link to the search page takes its place. */
.navbar-search-link { display: none; }

/* -- Page header extras ---------------------------------------------------- */
/* A section reached by its #id (section links, settings menu) lands below the sticky navbar. */
.page [id] { scroll-margin-top: calc(var(--navbar-height) + 16px); }
.page-eyebrow { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--color-text-muted); font-size: 13px; }
.page-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

/* -- Freshness: every observation shows when it was collected -------------- */
.freshness { display: inline-flex; align-items: center; gap: 5px; color: var(--color-text-subtle); font-size: 12px; white-space: nowrap; }
.freshness.is-stale { color: var(--color-warning); font-weight: 500; }
.freshness.is-failed { color: var(--color-danger); font-weight: 500; }
.value-unavailable { color: var(--color-text-subtle); font-style: italic; }

/* -- Severity marker (shape + color, never color alone) -------------------- */
.sev { display: grid; place-items: center; width: 32px; height: 32px; border-radius: var(--radius-md); flex-shrink: 0; }
.sev-critical { background: var(--color-danger-soft); color: var(--color-danger); }
.sev-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.sev-info { background: var(--color-info-soft); color: var(--color-info); }
.sev-sm { width: 24px; height: 24px; border-radius: var(--radius-sm); }

/* -- Estate state bar (stat cards) ----------------------------------------- */
.state-bar { display: flex; gap: 2px; height: 8px; overflow: hidden; border-radius: var(--radius-full); background: var(--color-surface-muted); }
.state-bar-seg { min-width: 4px; background: var(--color-text-subtle); }
.state-bar-seg.is-ok { background: var(--color-success); }
.state-bar-seg.is-warn { background: var(--color-warning); }
.state-bar-seg.is-fail { background: var(--color-danger); }
.state-bar-seg.is-off { background: var(--color-border-strong); }
.state-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 10px 0 0; padding: 0; list-style: none; color: var(--color-text-muted); font-size: 12px; }
.state-legend li { display: inline-flex; align-items: center; gap: 6px; }
.state-legend strong { color: var(--color-text); font-weight: 600; }

/* -- Condition list (incidents) -------------------------------------------- */
.condition-list { margin: 0; padding: 0; list-style: none; }
.condition-item { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--color-border); }
.condition-item:first-child { border-top: 0; }
.condition-item:hover { background: var(--color-surface-hover); }
.condition-main { flex: 1; min-width: 0; }
.condition-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--color-text); font-weight: 600; }
.condition-title a { color: inherit; }
.condition-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; margin-top: 3px; color: var(--color-text-muted); font-size: 12.5px; }
.condition-meta > span { display: inline-flex; align-items: center; gap: 5px; }
.condition-age { text-align: right; color: var(--color-text-subtle); font-size: 12px; white-space: nowrap; }
.condition-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* -- Resource identity: name + server + panel owner ------------------------ */
.res-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.res-id-icon { display: grid; place-items: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: var(--radius-md); background: var(--color-surface-muted); color: var(--color-text-muted); }
.res-id-body { min-width: 0; }
.res-id-name { display: block; color: var(--color-text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a.res-id-name:hover { color: var(--color-primary-text); }
.res-id-meta { display: flex; flex-wrap: wrap; gap: 0 8px; color: var(--color-text-subtle); font-size: 12px; }
.res-id-meta .font-mono { font-size: 11.5px; }
.res-id-host { display: block; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -- Preview source: panel dry run vs Fleet summary ------------------------ */
.source-tag { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: var(--radius-sm); font-size: 11.5px; font-weight: 600; line-height: 20px; white-space: nowrap; }
.source-tag-dryrun { background: var(--color-success-soft); color: var(--color-success); }
.source-tag-summary { border: 1px dashed var(--color-border-strong); color: var(--color-text-muted); }

/* -- Operation lifecycle (7 steps of the PRD) ------------------------------ */
.lifecycle { display: flex; margin: 0; padding: 0; list-style: none; counter-reset: lifecycle; }
.lifecycle-step { position: relative; flex: 1; min-width: 0; padding-top: 22px; color: var(--color-text-subtle); font-size: 12px; font-weight: 500; text-align: center; counter-increment: lifecycle; }
.lifecycle-step::before { content: counter(lifecycle); position: absolute; top: 0; left: 50%; z-index: 1; display: grid; place-items: center; width: 18px; height: 18px; margin-left: -9px; border-radius: var(--radius-full); background: var(--color-surface); box-shadow: inset 0 0 0 1.5px var(--color-border-strong); font-size: 10px; font-weight: 700; }
.lifecycle-step::after { content: ""; position: absolute; top: 8px; left: 50%; width: 100%; height: 2px; background: var(--color-border); }
.lifecycle-step:last-child::after { display: none; }
.lifecycle-step.is-done { color: var(--color-text-muted); }
.lifecycle-step.is-done::before { content: "✓"; background: var(--color-success); box-shadow: none; color: var(--color-text-inverse); }
.lifecycle-step.is-done::after { background: var(--color-success); }
.lifecycle-step.is-active { color: var(--color-primary-text); font-weight: 600; }
.lifecycle-step.is-active::before { background: var(--color-primary); box-shadow: 0 0 0 4px var(--color-primary-soft); color: var(--color-text-inverse); }
.lifecycle-step.is-failed { color: var(--color-danger); font-weight: 600; }
.lifecycle-step.is-failed::before { content: "✕"; background: var(--color-danger); box-shadow: 0 0 0 4px var(--color-danger-soft); color: var(--color-text-inverse); }
.lifecycle-step.is-warning { color: var(--color-warning); font-weight: 600; }
.lifecycle-step.is-warning::before { content: "!"; background: var(--color-warning); box-shadow: 0 0 0 4px var(--color-warning-soft); color: var(--color-text-inverse); }

/* -- Per-target facts: accepted / task / verified --------------------------- */
.facts { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.fact { display: inline-flex; align-items: center; gap: 5px; color: var(--color-text-muted); font-size: 12px; white-space: nowrap; }
.fact > .icon { width: 14px; height: 14px; }
.fact-ok > .icon { color: var(--color-success); }
.fact-fail > .icon { color: var(--color-danger); }
.fact-unknown > .icon { color: var(--color-warning); }
.fact-pending > .icon { color: var(--color-info); }
.fact-na { color: var(--color-text-subtle); }
.table tr.is-ineligible td { color: var(--color-text-subtle); background: var(--color-surface-muted); }
.table tr.is-attention td:first-child { box-shadow: inset 3px 0 0 var(--color-warning); }
/* Stacked table: on phones each row becomes a card and each cell shows its column name from data-label
   (cells without data-label, such as the identity or the checkbox, take the full row). */
.table-stack td[data-label]::before { content: none; }

/* -- Preview card: what will change ---------------------------------------- */
.preview-grid { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 10px 16px; margin: 0; font-size: 13.5px; }
.preview-grid dt { color: var(--color-text-muted); }
.preview-grid dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.diff { display: grid; gap: 4px; margin: 0; padding: 10px 12px; border-radius: var(--radius-md); background: var(--color-surface-muted); font-family: var(--font-mono); font-size: 12.5px; }
.diff-line { display: flex; gap: 10px; }
.diff-sign { width: 10px; flex-shrink: 0; color: var(--color-text-subtle); }
.diff-line.is-del { color: var(--color-danger); }
.diff-line.is-add { color: var(--color-success); }
.effect-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.effect-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.effect-list li > .icon { margin-top: 2px; color: var(--color-text-muted); }
.effect-list li.is-warning > .icon { color: var(--color-warning); }
.effect-list li.is-danger > .icon { color: var(--color-danger); }

/* Confirm bar: sticky footer of a preview */
.confirm-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; padding: 16px 20px; border-top: 1px solid var(--color-border); background: var(--color-surface-muted); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.confirm-bar-text { display: flex; align-items: center; gap: 10px; color: var(--color-text-muted); font-size: 13px; }

/* -- Log excerpt (fetched on demand, redacted, never stored) --------------- */
.log-view { overflow: hidden; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-muted); }
.log-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--color-border); color: var(--color-text-muted); font-size: 12px; }
.log-body { margin: 0; padding: 10px 0; overflow-x: auto; font-family: var(--font-mono); font-size: 12px; line-height: 1.65; }
.log-line { display: flex; gap: 14px; padding: 0 12px; white-space: pre; }
.log-ln { width: 24px; flex-shrink: 0; color: var(--color-text-subtle); text-align: right; user-select: none; }
.log-line.is-error { background: var(--color-danger-soft); color: var(--color-danger); }
.log-line.is-warn { color: var(--color-warning); }
.log-redacted { padding: 0 4px; border-radius: 3px; background: var(--color-border); color: var(--color-text-muted); }

/* -- Panel keys ------------------------------------------------------------- */
.key-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.key-card.is-warning { border-color: var(--color-warning); box-shadow: inset 3px 0 0 var(--color-warning); }
.key-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.key-purpose { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.key-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 16px; margin: 0; font-size: 13px; }
.key-facts dt { color: var(--color-text-subtle); font-size: 12px; }
.key-facts dd { margin: 0; }

/* -- Verification checklist (onboarding, post-action checks) --------------- */
.check-list { display: grid; margin: 0; padding: 0; list-style: none; }
.check-row { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--color-border); }
.check-row:first-child { border-top: 0; }
.check-row-icon { display: grid; place-items: center; width: 24px; height: 24px; flex-shrink: 0; border-radius: var(--radius-full); background: var(--color-surface-muted); color: var(--color-text-subtle); }
.check-row-icon > .icon { width: 14px; height: 14px; }
.check-row.is-pass .check-row-icon { background: var(--color-success-soft); color: var(--color-success); }
.check-row.is-warn .check-row-icon { background: var(--color-warning-soft); color: var(--color-warning); }
.check-row.is-fail .check-row-icon { background: var(--color-danger-soft); color: var(--color-danger); }
.check-row.is-pending .check-row-icon { background: var(--color-info-soft); color: var(--color-info); }
.check-row-body { flex: 1; min-width: 0; }
.check-row-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; }
.check-row-text { margin-top: 2px; color: var(--color-text-muted); font-size: 13px; }
.check-row-value { color: var(--color-text-muted); font-size: 12.5px; text-align: right; }

/* -- Filter bar ------------------------------------------------------------- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
/* Native selects in a filter bar size to their options instead of taking a full line each */
.filter-bar .form-select { flex: 0 1 auto; width: auto; min-width: 150px; max-width: 240px; }
.filter-select { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 6px 10px 6px 12px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-text); font: inherit; font-size: 13px; cursor: pointer; }
.filter-select:hover { background: var(--color-surface-hover); }
.filter-select-label { color: var(--color-text-subtle); }
.filter-select.is-set { border-color: var(--color-primary); background: var(--color-primary-soft); color: var(--color-primary-text); }
.filter-select.is-set .filter-select-label { color: var(--color-primary-text); opacity: .75; }
.filter-count { color: var(--color-text-subtle); font-size: 13px; }

/* -- Server header and metrics --------------------------------------------- */
.entity-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; }
.entity-icon { display: grid; place-items: center; width: 48px; height: 48px; flex-shrink: 0; border-radius: var(--radius-lg); background: var(--color-primary-soft); color: var(--color-primary-text); }
.entity-icon > .icon { width: 24px; height: 24px; }
.entity-body { flex: 1; min-width: 0; }
.entity-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.metric-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.metric { padding: 16px 20px; border-left: 1px solid var(--color-border); }
.metric:first-child { border-left: 0; }
.metric:nth-child(4n+1) { border-left: 0; }
.metric:nth-child(n+5) { border-top: 1px solid var(--color-border); }
/* Five metrics share one row; six or nine fill rows of three (no metric alone on the last row). */
@media (min-width: 1201px) {
  .metric-list:has(> .metric:nth-child(5):last-child) { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .metric-list:has(> .metric:nth-child(5):last-child) > .metric:nth-child(5) { border-top: 0; border-left: 1px solid var(--color-border); }
  .metric-list:is(:has(> .metric:nth-child(6):last-child), :has(> .metric:nth-child(9):last-child)) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .metric-list:is(:has(> .metric:nth-child(6):last-child), :has(> .metric:nth-child(9):last-child)) > .metric { border-top: 0; border-left: 1px solid var(--color-border); }
  .metric-list:is(:has(> .metric:nth-child(6):last-child), :has(> .metric:nth-child(9):last-child)) > .metric:nth-child(3n+1) { border-left: 0; }
  .metric-list:is(:has(> .metric:nth-child(6):last-child), :has(> .metric:nth-child(9):last-child)) > .metric:nth-child(n+4) { border-top: 1px solid var(--color-border); }
}
.metric-label { display: flex; align-items: center; gap: 6px; color: var(--color-text-muted); font-size: 12.5px; }
.metric-value { margin: 6px 0 8px; font-size: 22px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.metric-value small { color: var(--color-text-subtle); font-size: 13px; font-weight: 500; }

/* -- Fleet-wide search results --------------------------------------------- */
.search-hero { display: flex; align-items: center; gap: 12px; padding: 4px 16px; border: 1px solid var(--color-border-strong); border-radius: var(--radius-lg); background: var(--color-surface); box-shadow: var(--shadow-sm); }
.search-hero:focus-within { border-color: var(--color-primary); box-shadow: var(--focus-ring); }
.search-hero input { flex: 1; min-width: 0; min-height: 48px; border: 0; outline: 0; background: transparent; color: var(--color-text); font: inherit; font-size: 16px; }
.search-group-title { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 20px 8px; color: var(--color-text-muted); font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; }
mark.hit { padding: 0 1px; border-radius: 3px; background: var(--color-warning-soft); color: inherit; }

/* -- Cron schedule ---------------------------------------------------------- */
.cron-fields { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.cron-field { display: block; padding: 8px; border: 1px solid var(--color-border); border-radius: var(--radius-md); text-align: center; cursor: text; }
.cron-field:focus-within { border-color: var(--color-primary); box-shadow: var(--focus-ring); }
.cron-field-value { display: block; width: 100%; padding: 0; border: 0; background: transparent; color: var(--color-text); font-family: var(--font-mono); font-size: 16px; font-weight: 600; text-align: center; }
.cron-field-value:focus { outline: none; }
.cron-field-label { display: block; color: var(--color-text-subtle); font-size: 11px; }
.cron-fields.is-invalid .cron-field { border-color: var(--color-danger); }
.code-block { margin: 0; padding: 10px 12px; overflow-x: auto; border-radius: var(--radius-md); background: var(--color-surface-muted); font-family: var(--font-mono); font-size: 12.5px; white-space: pre; }

/* -- Environment variables (values never shown back) ----------------------- */
.env-list { display: grid; margin: 0; padding: 0; list-style: none; }
.env-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--color-border); }
.env-row:first-child { border-top: 0; }
.env-key { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; overflow-wrap: anywhere; }
.env-value { color: var(--color-text-subtle); font-family: var(--font-mono); font-size: 12.5px; letter-spacing: .1em; }

/* -- Wizard (connect a server) --------------------------------------------- */
.wizard { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
.vsteps { display: grid; gap: 4px; margin: 0; padding: 0; list-style: none; }
.vstep { display: flex; gap: 12px; padding: 10px 12px; border-radius: var(--radius-md); color: var(--color-text-muted); }
.vstep-num { display: grid; place-items: center; width: 24px; height: 24px; flex-shrink: 0; border-radius: var(--radius-full); box-shadow: inset 0 0 0 1.5px var(--color-border-strong); font-size: 12px; font-weight: 600; }
.vstep-title { color: inherit; font-weight: 600; font-size: 13.5px; }
.vstep-text { font-size: 12px; color: var(--color-text-subtle); }
.vstep.is-done .vstep-num { background: var(--color-success); box-shadow: none; color: var(--color-text-inverse); }
.vstep.is-active { background: var(--color-primary-soft); color: var(--color-primary-text); }
.vstep.is-active .vstep-num { background: var(--color-primary); box-shadow: none; color: var(--color-text-inverse); }

/* -- Step-up and typed confirmation ---------------------------------------- */
.stepup { display: flex; gap: 14px; padding: 14px 16px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface-muted); }
.stepup-icon { display: grid; place-items: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: var(--radius-full); background: var(--color-primary-soft); color: var(--color-primary-text); }
.typed-confirm { font-family: var(--font-mono); }

/* -- Assignment matrix (members × server groups) --------------------------- */
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix-mark { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: var(--radius-sm); background: var(--color-primary-soft); color: var(--color-primary-text); }
.matrix-mark.is-empty { background: transparent; box-shadow: inset 0 0 0 1px var(--color-border); }
.matrix-mark.is-implied { background: var(--color-surface-muted); color: var(--color-text-subtle); }

/* -- Components page -------------------------------------------------------- */
.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.spec-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spec-label { margin: 0 0 8px; color: var(--color-text-subtle); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.spec-cell { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-md); }
.spec-cell-note { color: var(--color-text-subtle); font-size: 12px; }

/* -- Replacements for the canvas's inline styles ---------------------------- */
/* State bar segments: share of the bar in 5% steps. Blade rounds count / total
   to the nearest step (at least seg-5), the same rule as progress-25/60. */
.state-bar-seg.is-info { background: var(--color-info); }
.state-bar-compact { width: 120px; }
.seg-5 { flex: 5 1 0; } .seg-10 { flex: 10 1 0; } .seg-15 { flex: 15 1 0; } .seg-20 { flex: 20 1 0; }
.seg-25 { flex: 25 1 0; } .seg-30 { flex: 30 1 0; } .seg-35 { flex: 35 1 0; } .seg-40 { flex: 40 1 0; }
.seg-45 { flex: 45 1 0; } .seg-50 { flex: 50 1 0; } .seg-55 { flex: 55 1 0; } .seg-60 { flex: 60 1 0; }
.seg-65 { flex: 65 1 0; } .seg-70 { flex: 70 1 0; } .seg-75 { flex: 75 1 0; } .seg-80 { flex: 80 1 0; }
.seg-85 { flex: 85 1 0; } .seg-90 { flex: 90 1 0; } .seg-95 { flex: 95 1 0; } .seg-100 { flex: 100 1 0; }
.sev-lg { width: 48px; height: 48px; border-radius: var(--radius-lg); }
.table-col-wide { width: 40%; }
.cell-truncate { display: block; max-width: 300px; }
.cron-field.is-selected { border-color: var(--color-primary); }
.stepup-compact { padding: 10px 14px; background: var(--color-surface); }
.preview-grid-compact { grid-template-columns: 110px minmax(0, 1fr); }
.auth-card-wide { max-width: 520px; }
.items-center { align-items: center; }
.qr-frame-square { display: grid; place-items: center; aspect-ratio: 1; }
.hosting-tabs { overflow-x: auto; }

/* Responsive (user panel and Fleet) ------------------------------------------ */
@media (max-width: 1200px) {
  .checkout-layout { grid-template-columns: minmax(0, 1fr); }
  .org-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Fleet (section 20) */
  .metric-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(odd) { border-left: 0; }
  .metric:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .metric:nth-child(n+3) { border-top: 1px solid var(--color-border); }
  .wizard { grid-template-columns: minmax(0, 1fr); }
  .vsteps { grid-auto-flow: column; overflow-x: auto; }
  .vstep-text { display: none; }
}

@media (max-width: 1024px) {
  .payment-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-layout { grid-template-columns: minmax(0, 1fr); }
  .settings-nav { flex-direction: row; overflow-x: auto; }
  .settings-nav-title { display: none; }
  .settings-nav-link { white-space: nowrap; }
  .invoice-parties { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .app-banner { padding: 10px 16px; }
  /* A long freshness line (last check, next check, state) wraps instead of widening the page */
  .freshness { white-space: normal; flex-wrap: wrap; }

  /* Steps stay on one line: only the current step keeps its label visible */
  .steps { flex-wrap: nowrap; gap: 8px; }
  .step + .step::before { width: 16px; margin-right: 0; }
  .step:not(.is-active) .step-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .choice-group,
  .quick-actions,
  .org-grid,
  .subscription-facts,
  .invoice-parties { grid-template-columns: minmax(0, 1fr); }
  .welcome-card { padding: 20px 16px; }
  .welcome-card .btn { flex: 1; }
  .invoice-doc { padding: 20px 16px; }
  .invoice-totals .summary-list { max-width: none; }
  .checklist-item { padding: 12px 16px; }
  .danger-row { padding: 16px; }
  .danger-row .btn { width: 100%; }
  .auth-center { padding: 24px 16px; }
  .auth-center-card { padding: 24px 20px; }
  .result-panel { padding: 32px 20px; }
  .code-input { font-size: 18px; }

  /* Fleet (section 20) */
  .navbar-chip-label { display: none; }
  .navbar-search-link { display: inline-grid; }
  /* Age and action share the last row: the age stays next to the button it explains */
  .condition-item { flex-wrap: wrap; align-items: flex-start; padding: 14px 16px; }
  .condition-age { order: 3; padding-left: 46px; text-align: left; }
  .condition-actions { order: 4; flex: 1; }
  .condition-actions .btn { flex: 1; justify-content: center; }
  .preview-grid,
  .preview-grid-compact { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .preview-grid dd { margin-bottom: 10px; }
  .metric-list { grid-template-columns: minmax(0, 1fr); }
  .metric { border-left: 0; border-top: 1px solid var(--color-border); }
  .metric:first-child { border-top: 0; }
  .entity-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .entity-actions > .btn,
  .entity-actions > form,
  .entity-actions > form > .btn { width: 100%; }
  .entity-actions > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .key-facts { grid-template-columns: minmax(0, 1fr); }
  .lifecycle-step { font-size: 0; }
  .lifecycle-step.is-active, .lifecycle-step.is-failed, .lifecycle-step.is-warning { font-size: 11px; }
  .env-row { grid-template-columns: minmax(0, 1fr) auto; }
  .env-value { grid-column: 1 / -1; grid-row: 2; }
  .cron-fields { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 4px; }
  .confirm-bar .btn { flex: 1; justify-content: center; }
  .cell-truncate { max-width: 200px; }
  .state-bar-compact { width: 80px; }
  .page .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .page .segmented-item { flex-shrink: 0; }
  .table-wrapper:has(> .table-stack) { overflow-x: visible; }
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); }
  .table-stack tbody tr { display: grid; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--color-border); }
  .table-stack tbody tr:last-child { border-bottom: 0; }
  .table-stack tbody td,
  .table-stack tbody td:first-child,
  .table-stack tbody td:last-child { display: block; padding: 0; border-bottom: 0; background: transparent; }
  .table-stack tbody td[data-label] { display: grid; grid-template-columns: 96px minmax(0, 1fr); column-gap: 12px; align-items: start; }
  .table-stack tbody td[data-label] > * { grid-column: 2; justify-self: start; max-width: 100%; }
  .table-stack td[data-label]::before { content: attr(data-label); grid-column: 1; grid-row: 1 / span 4; color: var(--color-text-subtle); font-size: 12px; font-weight: 500; line-height: 20px; }
  .table-stack tr.is-ineligible { background: var(--color-surface-muted); }
  .table-stack tr.is-attention { box-shadow: inset 3px 0 0 var(--color-warning); }
  .table-stack tr.is-attention td:first-child { box-shadow: none; }
  .table-stack .table-col-check { width: auto; }
  .filter-bar .form-select { flex: 1 1 140px; max-width: none; }
  /* A row with a checkbox keeps it beside the identity cell; labelled cells take the full width below */
  .table-stack tbody tr:has(> .table-col-check) { grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 12px; }
  .table-stack tbody tr:has(> .table-col-check) > td[data-label] { grid-column: 1 / -1; }
}

/* Laptops: the chips keep their icon and count so the search field keeps room for its text and Ctrl K.
   The label stays readable by screen readers; the chip's title gives the full text on hover. */
@media (max-width: 1280px) {
  .navbar-search { min-width: 200px; }
  .navbar-chip { padding: 6px 10px; }
  .navbar-chip-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
  }
}

/* Short screens: the beta card keeps its title and button so the menu has more room. */
@media (max-height: 820px) {
  .sidebar-beta-text { display: none; }
}

/* Touch screens have no Ctrl K: hide the shortcut hints. */
@media (hover: none) {
  .navbar-search-shortcut,
  .btn .kbd { display: none; }
}
