/* StreamDRM v3 Institutional Studio & Admin Portal Stylesheet
   Architectural Daylight Design System (TradersProxy v3 + Swiss Grid Standard).
   Strict CSP: style-src 'self'; zero inline styles; zero @keyframes animations. */

@font-face {
  font-family: "Archivo";
  src: url(/fonts/Archivo-Variable.woff2) format("woff2");
  font-weight: 100 900;
  font-stretch: 62% 125%;
  font-display: swap;
}

@font-face {
  font-family: "Martian Mono";
  src: url(/fonts/MartianMono-Variable.woff2) format("woff2");
  font-weight: 100 800;
  font-stretch: 75% 112.5%;
  font-display: swap;
}

:root {
  --paper: #F8FAFC;
  --sheet: #FFFFFF;
  --grid: #E2E8F0;
  --grid-strong: #CBD5E1;
  --rule: #94A3B8;
  --ink: #0F172A;
  --ink-2: #334155;
  --ink-3: #64748B;
  --trace: #1D4ED8;
  --trace-hover: #1E40AF;
  --trace-wash: #EFF6FF;
  --match: #B91C1C;
  --match-wash: #FEF2F2;
  --clear: #047857;
  --clear-wash: #ECFDF5;
  --hold: #B45309;
  --hold-wash: #FFFBEB;
  --plate: #0B1220;
  --plate-2: #0F172A;
  --plate-grid: #1E293B;
  --plate-ink: #F8FAFC;
  --plate-ink-2: #94A3B8;
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 72px;
  --r-1: 8px;
  --r-2: 12px;
  --pop: 0 1px 2px rgba(15, 23, 42, 0.05), 0 8px 24px -8px rgba(15, 23, 42, 0.12);
  --sans: "Archivo", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Martian Mono", ui-monospace, SFMono-Regular, monospace;
  --side: 256px;
  color-scheme: light;
}

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

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-color: var(--grid-strong) var(--paper);
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  font: 400 0.875rem/1.55 var(--sans);
  color: var(--ink);
  background-color: var(--paper);
  font-feature-settings: "tnum" 0;
}

::selection {
  background: var(--trace);
  color: var(--on-ink);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--paper);
}

::-webkit-scrollbar-thumb {
  background: var(--grid-strong);
  border: 2px solid var(--paper);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--rule);
}

:focus-visible {
  outline: 2px solid var(--trace);
  outline-offset: 2px;
}

a {
  color: var(--trace);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

a:hover {
  color: var(--trace-hover);
}

h1, h2, h3, p, dl, dd, ul, ol {
  margin: 0;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  caret-color: var(--trace);
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.noscript {
  padding: var(--s-6);
}

.mono {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}

.strong {
  font-weight: 650;
}

.dim {
  color: var(--ink-3);
}

.small {
  font-size: 0.8125rem;
}

.t-match {
  color: var(--match);
  font-weight: 600;
}

.t-hold {
  color: var(--hold);
}

.t-clear {
  color: var(--clear);
}

.warn-text {
  color: var(--hold);
}

.label {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-2);
}

kbd {
  font: 500 0.6875rem/1 var(--mono);
  color: var(--ink-3);
  border: 1px solid var(--grid-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 5px;
  background: var(--sheet);
}

.ico {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------- Swiss Architectural Logo ---------- */
.logo-mark {
  flex: none;
}

.lm-blade {
  fill: var(--ink);
}

.lm-reticle {
  fill: var(--trace);
}

.lm-bar {
  fill: var(--ink);
}

.lm-node {
  fill: var(--trace);
}

.wordmark {
  font-weight: 800;
  font-size: 1.0625rem;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.brand-stream {
  color: var(--ink);
}

.brand-drm {
  color: var(--trace);
}

/* ---------- Buttons & Inputs ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--grid-strong);
  border-radius: 6px;
  background: var(--sheet);
  color: var(--ink);
  font-weight: 600;
  font-size: 0.8125rem;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.btn:hover:not(:disabled) {
  background: var(--paper);
  border-color: var(--rule);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: #1E293B;
  border-color: #1E293B;
  color: var(--on-ink);
}

.btn-trace {
  background: var(--trace);
  border-color: var(--trace);
  color: var(--on-ink);
}

.btn-trace:hover:not(:disabled) {
  background: var(--trace-hover);
  border-color: var(--trace-hover);
  color: var(--on-ink);
}

.btn-secondary {
  background: var(--paper);
  border-color: var(--grid-strong);
  color: var(--ink);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--grid);
}

.btn-danger {
  color: var(--match);
  border-color: var(--grid-strong);
  background: transparent;
}

.btn-danger:hover:not(:disabled) {
  border-color: var(--match);
  background: var(--match-wash);
}

.btn-danger.armed {
  background: var(--match);
  border-color: var(--match);
  color: var(--on-ink);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--ink-2);
  padding: 0 10px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--grid);
  color: var(--ink);
}

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink-3);
  cursor: pointer;
  margin-left: auto;
}

.icon-btn:hover {
  background: var(--match-wash);
  color: var(--match);
}

.field {
  display: grid;
  gap: 6px;
  align-content: start;
  min-width: 0;
  width: 100%;
}

.field > label {
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--ink);
}

.hint {
  font-size: 0.75rem;
  color: var(--ink-3);
  line-height: 1.45;
  word-break: break-word;
}

.input {
  width: 100%;
  height: 38px;
  padding: 0 var(--s-3);
  background: var(--sheet);
  border: 1px solid var(--grid-strong);
  border-radius: 6px;
  transition: border-color 150ms ease;
  min-width: 0;
  box-sizing: border-box;
}

textarea.input {
  width: 100%;
  height: auto;
  min-height: 96px;
  padding: var(--s-2) var(--s-3);
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.5;
  resize: vertical;
  box-sizing: border-box;
  word-break: break-all;
}

.embed-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-4);
  padding: var(--s-4);
}

.embed-card {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--paper);
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
  align-content: start;
}

.input::placeholder {
  color: var(--ink-3);
}

.input:hover {
  border-color: var(--rule);
}

.input:focus {
  border-color: var(--trace);
  outline: 2px solid var(--trace);
  outline-offset: 0;
}

.input[aria-invalid="true"] {
  border-color: var(--match);
}

select.input {
  appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-2) 50%), linear-gradient(135deg, var(--ink-2) 50%, transparent 50%);
  background-position: calc(100% - 16px) 16px, calc(100% - 11px) 16px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.check {
  width: 16px;
  height: 16px;
  accent-color: var(--trace);
  margin: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: 0.8125rem;
  cursor: pointer;
  align-self: end;
  min-height: 36px;
}

.field-error {
  color: var(--match);
  font-size: 0.8125rem;
  min-height: 0;
}

.field-error:empty {
  display: none;
}

/* ---------- Badges & Chips ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border: 1px solid currentColor;
  border-radius: 6px;
  font: 600 0.6875rem/1 var(--mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.b-clear {
  color: var(--clear);
  background: var(--clear-wash);
}

.b-match {
  color: var(--match);
  background: var(--match-wash);
}

.b-hold {
  color: var(--hold);
  background: var(--hold-wash);
}

.b-plain {
  color: var(--ink-2);
  background: var(--paper);
}

.id-chip {
  border: 0;
  background: none;
  padding: 2px 5px;
  margin: -2px -5px;
  border-radius: 4px;
  color: var(--ink-2);
  cursor: copy;
}

.id-chip:hover {
  background: var(--trace-wash);
  color: var(--trace);
}

.chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1px solid var(--grid-strong);
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--paper);
}

/* ---------- Auth Gate ---------- */
body.is-gate {
  width: 100%;
  min-height: 100dvh;
  margin: 0;
  padding: var(--s-6) var(--s-4);
  box-sizing: border-box;
  display: grid;
  place-items: center;
  place-content: center;
  background-color: var(--paper);
}

.is-gate #app {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.is-gate .gate {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: var(--s-5);
  margin: 0 auto;
}

.gate-form {
  width: 100%;
  max-width: 480px;
  min-height: 440px;
  background: var(--sheet);
  border: 1px solid var(--grid-strong);
  border-radius: var(--r-2);
  box-shadow: var(--pop);
  padding: var(--s-6);
  display: grid;
  gap: var(--s-4);
  box-sizing: border-box;
  margin: 0 auto;
}

.gate-brand {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: var(--s-2);
  min-height: 32px;
}

.gate-brand-left {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.gate-brand .wordmark {
  font-size: 1.25rem;
}

.portal-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--paper);
  border: 1px solid var(--grid);
  border-radius: 8px;
  contain: layout;
}

.portal-tab {
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
}

.portal-tab.on {
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.gate-title {
  font-weight: 800;
  font-size: 2rem;
  line-height: 1.08;
  letter-spacing: -0.025em;
}

.gate-lede {
  color: var(--ink-2);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.gate-form .input {
  height: 42px;
  font-family: var(--mono);
  font-size: 0.8125rem;
}

.gate-form .btn {
  height: 42px;
}


.gate-notes {
  list-style: none;
  padding: var(--s-4) 0 0;
  border-top: 1px solid var(--grid);
  display: grid;
  gap: 6px;
  color: var(--ink-3);
  font-size: 0.8125rem;
}

.gate-notes li {
  padding-left: 14px;
  position: relative;
}

.gate-notes li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 6px;
  height: 1px;
  background: var(--rule);
}

.gate-foot {
  width: 100%;
  text-align: center;
  color: var(--ink-3);
  font-size: 0.8125rem;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin: 0 auto;
}

/* ---------- Shell & Sidebar ---------- */
.shell {
  display: grid;
  grid-template-columns: var(--side) minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-3);
  border-right: 1px solid var(--grid);
  background: var(--sheet);
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px;
  text-decoration: none;
  color: inherit;
}

.side-tag {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--trace-wash);
  color: var(--trace);
}

.tenant-card {
  padding: var(--s-3);
  background: var(--paper);
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
}

.tenant-name {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tenant-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  color: var(--ink-3);
  font-size: 0.75rem;
}

.tenant-meta .wm {
  color: var(--ink);
}

.nav {
  display: grid;
  gap: 2px;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--ink-2);
  text-decoration: none;
  font-weight: 500;
  transition: background-color 150ms ease, color 150ms ease;
}

.nav-item:hover {
  color: var(--ink);
  background: var(--paper);
}

.nav-item.on {
  color: var(--trace);
  background: var(--trace-wash);
  border-color: #BFDBFE;
  font-weight: 650;
}

.nav-item.on .ico {
  color: var(--trace);
}

.nav-label {
  flex: 1;
}

.nav-item kbd {
  opacity: 0;
  transition: opacity 150ms ease;
}

.nav-item:hover kbd,
.nav-item.on kbd,
.nav:focus-within kbd {
  opacity: 1;
}

.side-foot {
  margin-top: auto;
  display: grid;
  gap: var(--s-2);
  padding-top: var(--s-3);
  border-top: 1px solid var(--grid);
}

.side-hint {
  color: var(--ink-3);
  font-size: 0.75rem;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
  border-radius: 6px;
}

.side-hint:hover {
  color: var(--ink);
  background: var(--paper);
}

.side-foot .btn {
  justify-content: flex-start;
}

/* ---------- Page Header & TradersProxy Status Line ---------- */
.page {
  min-width: 0;
  outline: none;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-6) 0 var(--s-5);
  border-bottom: 1px solid var(--grid-strong);
  margin: 0 var(--s-6);
}

.page-titles h1 {
  font-weight: 800;
  font-size: 1.875rem;
  line-height: 1.1;
  letter-spacing: -0.025em;
}

.lede {
  color: var(--ink-2);
  margin-top: var(--s-2);
  max-width: 72ch;
}

.page-actions {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  flex-wrap: wrap;
}

.page-body {
  padding: var(--s-5) var(--s-6) var(--s-7);
  display: grid;
  gap: var(--s-5);
  max-width: 1400px;
}

/* TradersProxy v3 Institutional Status Line */
.status-line {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  background: var(--grid);
  border: 1px solid var(--grid-strong);
  border-radius: var(--r-1);
  overflow: hidden;
}

.status-cell-box {
  background: var(--sheet);
  padding: 16px 18px;
  display: grid;
  gap: 4px;
  align-content: start;
}

.status-cell-box .k {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-3);
}

.status-cell-box .v {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.status-cell-box .sub {
  font-size: 0.75rem;
  color: var(--ink-2);
}

/* ---------- Panels & Grids ---------- */
.panel {
  background: var(--sheet);
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  min-height: 48px;
  padding: var(--s-2) var(--s-4);
  border-bottom: 1px solid var(--grid);
  background: #F8FAFC;
  border-top-left-radius: var(--r-1);
  border-top-right-radius: var(--r-1);
}

.panel-head h2 {
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink);
}

.panel-actions {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  flex-wrap: wrap;
}

.panel-actions .input {
  height: 32px;
  width: 220px;
}

.panel > .facts,
.panel > .count-slot,
.panel > div > .loading,
.panel > .form-grid,
.panel > .field-error,
.panel > .form-foot,
.panel > .small,
.panel > .thumbs,
.panel > .note,
.panel > form {
  margin: var(--s-4);
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s-5);
  align-items: start;
}

.grid-2.wide-left {
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-4);
  align-items: start;
}

.facts {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 10px var(--s-4);
  align-items: baseline;
}

.facts dt {
  color: var(--ink-3);
  font-size: 0.8125rem;
}

.facts dd {
  min-width: 0;
  overflow-wrap: anywhere;
}

.facts.compact {
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 6px var(--s-3);
}

.link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ---------- Ledger Tables ---------- */
.table-wrap {
  overflow-x: auto;
}

.ledger {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.ledger th {
  height: 36px;
  padding: 0 var(--s-4);
  text-align: left;
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-3);
  border-bottom: 1px solid var(--grid-strong);
  white-space: nowrap;
}

.ledger td {
  height: 44px;
  padding: 6px var(--s-4);
  border-bottom: 1px solid var(--grid);
  vertical-align: middle;
  white-space: nowrap;
}

.ledger tbody tr:last-child td {
  border-bottom: 0;
}

.ledger tbody tr {
  transition: background-color 150ms ease;
}

.ledger tbody tr:hover {
  background: var(--paper);
}

.ledger .num,
.ledger .r {
  text-align: right;
}

.ledger .actions-cell {
  width: 1%;
}

.row-actions {
  display: inline-flex;
  gap: 6px;
  justify-content: flex-end;
  align-items: center;
}

.row-actions .btn {
  height: 28px;
  padding: 0 10px;
  font-size: 0.75rem;
}

.row-dim td {
  color: var(--ink-3);
}

.row-failed td:first-child {
  box-shadow: inset 3px 0 0 var(--match);
}

.title-cell {
  display: grid;
  line-height: 1.3;
}

.kind {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--ink-2);
}

.status-cell {
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
}

.trunc {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.counts th {
  text-align: left;
  font: 500 0.875rem/1.4 var(--sans);
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-2);
  border-bottom: 1px solid var(--grid);
  padding: 0;
  height: 38px;
}

.counts td {
  height: 38px;
  padding: 0;
}

.counts td .mono {
  font-size: 0.875rem;
  font-weight: 600;
}

.counts tr:last-child th {
  border-bottom: 0;
}

.row-link {
  cursor: pointer;
}

.row-link:hover th {
  color: var(--trace);
}

.empty {
  padding: var(--s-6) var(--s-4);
  color: var(--ink-2);
  max-width: 64ch;
  display: grid;
  gap: var(--s-2);
}

.empty > div {
  display: grid;
  gap: var(--s-2);
  justify-items: start;
}

.empty .btn {
  margin-top: var(--s-2);
}

.empty-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}

.loading {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-4);
  color: var(--ink-3);
  font-size: 0.8125rem;
}

.loading-bar {
  display: block;
  height: 2px;
  background: var(--trace);
  max-width: 240px;
}

.error-box {
  margin: var(--s-4);
  padding: var(--s-4);
  border: 1px solid var(--match);
  border-radius: var(--r-1);
  background: var(--match-wash);
  display: grid;
  gap: var(--s-2);
  justify-items: start;
}

.error-title {
  font-weight: 700;
  color: var(--match);
}

/* ---------- Forms ---------- */
.form-panel .form-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-4);
}

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-foot {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  flex-wrap: wrap;
}

.inline-form {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-4);
  border-bottom: 1px solid var(--grid);
  background: var(--paper);
}

.inline-form .form-foot {
  justify-content: flex-start;
}

.add-row {
  display: flex;
  gap: var(--s-2);
  margin: 0 var(--s-4) var(--s-3);
}

.origin-list {
  list-style: none;
  padding: 0;
  margin: var(--s-3) var(--s-4);
  border-top: 1px solid var(--grid);
}

.origin-list li {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 40px;
  border-bottom: 1px solid var(--grid);
}

#keys-sheet dl,
.origins-slot {
  margin: 0;
}

.panel > .small.dim {
  margin-bottom: 0;
}

.secret {
  margin: var(--s-4);
  padding: var(--s-4);
  border: 1px solid var(--trace);
  background: var(--trace-wash);
  border-radius: var(--r-1);
  display: grid;
  gap: var(--s-3);
  justify-items: start;
}

.secret-row {
  display: flex;
  gap: var(--s-2);
  align-items: center;
  width: 100%;
}

.secret-val {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  background: var(--sheet);
  border: 1px solid var(--grid-strong);
  border-radius: 6px;
  overflow-wrap: anywhere;
  user-select: all;
}

pre.code {
  margin: 0;
  padding: var(--s-3);
  background: var(--paper);
  border: 1px solid var(--grid);
  border-radius: 6px;
  font: 0.6875rem/1.6 var(--mono);
  overflow: auto;
  max-height: 260px;
}

.cors {
  margin: 0 var(--s-4) var(--s-4);
}

.cors summary {
  cursor: pointer;
  font-weight: 600;
  padding: var(--s-2) 0;
}

.report {
  border-top: 1px solid var(--grid);
}

.report-title {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: var(--s-3) var(--s-4);
  flex-wrap: wrap;
}

.note {
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
  background: var(--sheet);
  color: var(--ink-2);
  font-size: 0.8125rem;
  display: grid;
  gap: var(--s-3);
  justify-items: start;
}

.note-warn {
  border-color: var(--hold);
  background: var(--hold-wash);
  color: var(--hold-ink);
}

/* ---------- Dropzone & Upload ---------- */
.dropzone {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px var(--s-3);
  align-items: start;
  padding: var(--s-5) var(--s-4);
  background: var(--paper);
  border: 1.5px dashed var(--grid-strong);
  border-radius: var(--r-1);
  cursor: pointer;
  overflow: hidden;
  transition: border-color 150ms ease, background-color 150ms ease;
}

.dropzone .ico {
  margin-top: 2px;
  color: var(--trace);
}

.dropzone:hover {
  border-color: var(--trace);
  background: var(--trace-wash);
}

.dropzone.over {
  border-style: solid;
  border-color: var(--trace);
  background: var(--trace-wash);
}

.dropzone.busy {
  cursor: progress;
  border-style: solid;
  border-color: var(--grid-strong);
}

.dz-text {
  display: grid;
  gap: 2px;
}

.dz-status {
  grid-column: 2;
  color: var(--ink);
}

.dz-status:empty {
  display: none;
}

.dz-meter {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--trace);
  transform-origin: left;
  transform: scaleX(var(--p, 0));
  transition: transform 200ms linear;
}

.dz-meter.pkg {
  background: var(--clear);
}

.upload-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: var(--s-5);
  padding: var(--s-4);
}

.upload-right {
  display: grid;
  gap: var(--s-4);
  align-content: start;
}

.upload-right > .btn {
  justify-self: start;
  height: 38px;
}

.upload-left {
  display: grid;
  gap: var(--s-4);
  align-content: start;
}

.steps {
  list-style: none;
  padding: 0;
  display: grid;
}

.steps:empty {
  display: none;
}

.steps li {
  display: grid;
  grid-template-columns: 16px 1fr auto;
  align-items: center;
  gap: var(--s-3);
  min-height: 36px;
  border-bottom: 1px solid var(--grid);
  color: var(--ink-3);
}

.steps li:last-child {
  border-bottom: 0;
}

.step-dot {
  width: 10px;
  height: 10px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.steps li.on {
  color: var(--ink);
  font-weight: 600;
}

.steps li.on .step-dot {
  border-color: var(--trace);
  background: var(--trace-wash);
}

.steps li.done {
  color: var(--ink-2);
}

.steps li.done .step-dot {
  background: var(--clear);
  border-color: var(--clear);
}

.steps li.fail {
  color: var(--match);
}

.steps li.fail .step-dot {
  background: var(--match);
  border-color: var(--match);
}

.step-note {
  font-weight: 400;
  color: var(--ink-2);
}

.job-line {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
}

.meter {
  display: inline-block;
  width: 72px;
  height: 4px;
  background: var(--grid);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.meter-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--trace);
  transition: opacity 250ms ease;
}

.w-0 { width: 0; } .w-5 { width: 5%; } .w-10 { width: 10%; } .w-15 { width: 15%; } .w-20 { width: 20%; } .w-25 { width: 25%; } .w-30 { width: 30%; }
.w-35 { width: 35%; } .w-40 { width: 40%; } .w-45 { width: 45%; } .w-50 { width: 50%; } .w-55 { width: 55%; } .w-60 { width: 60%; } .w-65 { width: 65%; }
.w-70 { width: 70%; } .w-75 { width: 75%; } .w-80 { width: 80%; } .w-85 { width: 85%; } .w-90 { width: 90%; } .w-95 { width: 95%; } .w-100 { width: 100%; }

/* ---------- Preview ---------- */
.preview-grid {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: var(--s-5);
  align-items: start;
}

.preview-side {
  display: grid;
  gap: var(--s-4);
}

.preview-form {
  display: grid;
  gap: var(--s-4);
}

.preview-form > .btn {
  height: 38px;
}

.ticket-meta:empty {
  display: none;
}

.ticket-meta {
  margin: 0 var(--s-4) var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--grid);
}

.stage {
  aspect-ratio: 16 / 9;
  background: var(--plate);
  border: 1px solid var(--plate);
  border-radius: var(--r-1);
  overflow: hidden;
  display: grid;
}

.stage-empty {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--s-3);
  color: var(--plate-ink-2);
  text-align: center;
  padding: var(--s-5);
}

.stage-empty .lm-blade {
  fill: #E2E8F0;
}

.stage-empty .lm-reticle {
  fill: #3B82F6;
}

.stage-empty .lm-bar {
  fill: #E2E8F0;
}

.stage-empty .lm-node {
  fill: #3B82F6;
}

.player-frame {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* ---------- Leak Scanner ---------- */
.leak-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--s-5);
  align-items: start;
}

.leak-grid > .panel > .dropzone {
  margin: var(--s-4);
}

.thumbs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.thumbs:empty {
  display: none;
}

.thumb {
  height: 56px;
  width: auto;
  border: 1px solid var(--grid-strong);
  border-radius: 6px;
}

.result-empty {
  padding: var(--s-5);
  border: 1px dashed var(--grid-strong);
  border-radius: var(--r-1);
  background: var(--sheet);
  color: var(--ink-2);
  display: grid;
  gap: var(--s-2);
}

.scan-progress {
  padding: var(--s-5);
  background: var(--sheet);
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
  display: grid;
  gap: var(--s-3);
  color: var(--ink-2);
}

.verdict {
  background: var(--sheet);
  border: 1px solid var(--grid-strong);
  border-radius: var(--r-1);
  padding: var(--s-5);
  display: grid;
  gap: var(--s-4);
}

.verdict.v-match {
  border-color: var(--match);
}

.verdict-head {
  display: flex;
  gap: var(--s-3);
  align-items: center;
}

.verdict-title {
  font-weight: 800;
  font-size: 2rem;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.v-match .verdict-title {
  color: var(--match);
}

.v-inconclusive .verdict-title {
  color: var(--hold);
}

.verdict-sub {
  font-size: 0.9375rem;
  color: var(--ink);
  margin-top: 4px;
}

.engine {
  padding: var(--s-2) 0;
  border-top: 1px solid var(--grid);
  border-bottom: 1px solid var(--grid);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.mark-card {
  display: grid;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--paper);
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
}

.mark-card .row-actions {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.checklist {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 6px;
}

.checklist li {
  display: flex;
  gap: var(--s-2);
  align-items: flex-start;
}

.checklist .ico {
  margin-top: 3px;
  color: var(--clear);
}

.trace-glyph {
  flex: none;
}

.tg-dot {
  fill: var(--match);
}

.tg-ring,
.tg-lead {
  fill: none;
  stroke: var(--match);
  stroke-width: 1.6;
}

/* ---------- Plans & Billing Grid ---------- */
.plan-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--s-4);
}

.plan-card {
  background: var(--sheet);
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.plan-card.active {
  border: 2px solid var(--trace);
  background: var(--trace-wash);
}

.plan-price-row {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.plan-price-row span {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink-3);
}

.plan-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 8px;
  font-size: 0.8125rem;
  color: var(--ink-2);
  margin-bottom: var(--s-3);
}

/* ---------- Toast & Keyboard Sheet ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: var(--s-5);
  transform: translate(-50%, 8px);
  opacity: 0;
  pointer-events: none;
  background: var(--ink);
  color: var(--on-ink);
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 0.8125rem;
  box-shadow: var(--pop);
  transition: opacity 150ms ease, transform 150ms ease;
  max-width: calc(100vw - 32px);
  z-index: 30;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.bad {
  background: var(--match);
}

.keys-sheet {
  position: fixed;
  right: var(--s-5);
  bottom: var(--s-5);
  background: var(--sheet);
  border: 1px solid var(--grid-strong);
  border-radius: var(--r-1);
  box-shadow: var(--pop);
  padding: var(--s-4);
  width: 280px;
  display: grid;
  gap: var(--s-3);
  z-index: 30;
}

.keys-sheet dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--s-2) var(--s-3);
  align-items: center;
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .grid-2,
  .grid-2.wide-left,
  .grid-3,
  .leak-grid,
  .embed-cards {
    grid-template-columns: minmax(0, 1fr);
  }
  .plan-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .status-line {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .form-panel .form-grid,
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .side {
    position: sticky;
    top: 0;
    z-index: 10;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    align-content: flex-start;
    gap: 0;
    padding: 0;
    border-right: 0;
    border-bottom: 1px solid var(--grid-strong);
  }
  .side-brand {
    order: 1;
    padding: 12px var(--s-4);
  }
  .side-tag {
    margin-left: 6px;
  }
  .tenant-card {
    order: 2;
    margin-left: auto;
    padding: 0 var(--s-4);
    background: none;
    border: 0;
    text-align: right;
  }
  .tenant-name {
    font-size: 0.75rem;
    max-width: 40vw;
  }
  .tenant-meta {
    display: none;
  }
  .nav {
    order: 3;
    flex: 1 0 100%;
    display: flex;
    gap: 0;
    overflow-x: auto;
    scrollbar-width: none;
    border-top: 1px solid var(--grid);
    padding: 0 var(--s-2);
    background: var(--sheet);
  }
  .nav::-webkit-scrollbar {
    display: none;
  }
  .nav-item {
    flex: none;
    height: 44px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 0 12px;
  }
  .nav-item.on {
    border: 0;
    border-bottom: 2px solid var(--trace);
    background: none;
  }
  .nav-item .ico,
  .nav-item kbd {
    display: none;
  }
  .side-foot {
    display: none;
  }
  .page-head {
    margin: 0 var(--s-4);
    padding: var(--s-5) 0 var(--s-4);
    flex-direction: column;
    align-items: flex-start;
    gap: var(--s-3);
  }
  .page-titles h1 {
    font-size: 1.625rem;
  }
  .page-body {
    padding: var(--s-4) var(--s-4) var(--s-7);
    gap: var(--s-4);
  }
  .preview-grid,
  .upload-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .c-opt {
    display: none;
  }
  .panel-actions .input {
    width: 100%;
  }
  .panel-head {
    flex-wrap: wrap;
  }
  .form-panel .form-grid,
  .form-grid,
  .form-grid.two,
  .inline-form {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .form-panel .form-grid,
  .form-grid,
  .form-grid.two,
  .plan-grid,
  .status-line {
    grid-template-columns: minmax(0, 1fr);
  }
  .facts {
    grid-template-columns: 96px minmax(0, 1fr);
  }
  .gate-form {
    padding: var(--s-5);
  }
  .gate-title {
    font-size: 1.75rem;
  }
  .ledger td,
  .ledger th {
    padding-left: var(--s-3);
    padding-right: var(--s-3);
  }
  .verdict-title {
    font-size: 1.625rem;
  }
}

/* ---------- 1-Click pCloud OAuth Connector Card ---------- */
.oauth-card {
  grid-column: 1 / -1;
  display: grid;
  gap: var(--s-3);
  padding: var(--s-4);
  border: 1px solid var(--grid-strong);
  border-radius: 8px;
  background: var(--paper);
}

.oauth-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
}

.oauth-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--ink);
}

.oauth-copy {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--ink-2);
  line-height: 1.5;
}

.oauth-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  font-size: 0.75rem;
  color: var(--ink-3);
}

/* ---------- Gate Sign-In Mode Tabs (API Key + Email OTP) ---------- */
.gate-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--paper);
  border: 1px solid var(--grid-strong);
  border-radius: var(--r-1);
}

.gate-tab {
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  text-align: center;
}

.gate-tab:hover {
  color: var(--ink);
}

.gate-tab.on {
  background: var(--sheet);
  color: var(--trace);
  border-color: var(--grid-strong);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.gate-step-box {
  display: grid;
  gap: var(--s-3);
}

/* ---------- Billing Usage Meters & Stripe Portal Banner ---------- */
.portal-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: var(--trace-wash);
  border: 1px solid #BFDBFE;
  border-radius: var(--r-1);
}

.portal-banner-copy {
  display: grid;
  gap: 4px;
}

.usage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--s-4);
}

.usage-card {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-4);
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
  background: var(--paper);
}

.usage-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
}

.usage-track {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--grid);
  overflow: hidden;
}

.usage-fill {
  height: 100%;
  background: var(--trace);
  border-radius: 999px;
}

.usage-fill.w-0 { width: 0%; }
.usage-fill.w-5 { width: 5%; }
.usage-fill.w-10 { width: 10%; }
.usage-fill.w-20 { width: 20%; }
.usage-fill.w-30 { width: 30%; }
.usage-fill.w-40 { width: 40%; }
.usage-fill.w-50 { width: 50%; }
.usage-fill.w-60 { width: 60%; }
.usage-fill.w-70 { width: 70%; }
.usage-fill.w-80 { width: 80%; background: var(--hold); }
.usage-fill.w-90 { width: 90%; background: var(--hold); }
.usage-fill.w-100 { width: 100%; background: var(--match); }
.usage-fill.unlimited { width: 100%; background: var(--clear); opacity: 0.45; }

.cadence-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-4);
  flex-wrap: wrap;
  gap: var(--s-3);
}

.cadence-toggle {
  display: inline-flex;
  gap: 6px;
}

.plan-cta-stack {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  width: 100%;
}

.btn-link-full {
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

/* ---------- CSP-Clean Utility Layouts (Admin & Studio) ---------- */
.admin-filter-bar {
  display: flex;
  gap: var(--s-2);
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: var(--s-4);
}

.admin-filter-search {
  flex: 1;
  min-width: 200px;
}

.admin-filter-sel {
  width: 190px;
}

.col-stack {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.inline-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.admin-plan-select {
  min-width: 124px;
  padding: 4px 8px;
  font-size: 0.75rem;
}

/* ==========================================================================
   PLAIN LOOK (2026-11-11), matching the marketing site (site.css "LOOK LAYER plain").
   One block; the rules above are unchanged. Delete this block to go back.
   Neutral greys and ink instead of the blue accent and blue-tinted slate, 6 px corners, no
   upper-case labels, no shadows. Status colours (match, clear, hold) are kept.
   ========================================================================== */
:root {
  --paper: #FAFAF8;
  --sheet: #FFFFFF;
  --grid: #E3E3DF;
  --grid-strong: #CECEC8;
  --rule: #8E8E87;
  --ink: #111110;
  --ink-2: #3F3F3B;
  --ink-3: #5E5E59;
  --trace: #111110;
  --trace-hover: #3F3F3B;
  --trace-wash: #F1F1EE;
  --plate: #121211;
  --plate-2: #1B1B1A;
  --plate-grid: #2C2C2A;
  --plate-ink: #F2F2EE;
  --plate-ink-2: #A3A39B;
  --r-1: 6px;
  --r-2: 8px;
  --pop: 0 0 0 1px rgba(17, 17, 16, 0.1);
}

.label,
.side-tag,
.status-cell-box .k,
.panel-head h2,
.ledger th {
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--sans);
}

.kind {
  letter-spacing: 0;
}

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

.portal-tab.on,
.gate-tab.on {
  box-shadow: none;
  color: var(--ink);
}

.nav-item.on {
  border-color: var(--grid-strong);
}

.panel-head {
  background: var(--paper);
}

.portal-banner {
  border-color: var(--grid-strong);
}

.logo-mark .lm-blade {
  fill: var(--ink);
}

.stage-empty .lm-blade {
  fill: var(--plate-ink);
}

/* ==========================================================================
   SIMPLE PORTAL (2026-11-12). Plain-language dashboard: setup checklist, provider tiles,
   step-by-step guides, fold-away advanced options, and the Help section.
   ========================================================================== */
.badge {
  font: 600 0.75rem/1 var(--sans);
  letter-spacing: 0;
  text-transform: none;
}

.help-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.8125rem;
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.help-link:hover {
  color: var(--ink);
}

.plain-lede {
  margin: 0;
  color: var(--ink-2);
  font-size: 0.875rem;
  line-height: 1.5;
  max-width: 68ch;
}

.panel > .plain-lede {
  padding: var(--s-4) var(--s-5) 0;
}

/* Setup checklist on Home. */
.guide {
  border: 1px solid var(--grid-strong);
  border-radius: var(--r-2);
  background: var(--sheet);
  padding: var(--s-5);
  display: grid;
  gap: var(--s-4);
}

.guide-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 650;
}

.guide-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--s-2);
}

.guide-step {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  gap: var(--s-3);
  align-items: center;
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
  background: var(--paper);
}

.guide-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--grid-strong);
  display: grid;
  place-items: center;
  font: 600 0.8125rem/1 var(--sans);
  color: var(--ink-2);
  background: var(--sheet);
}

.guide-step.done .guide-num {
  background: var(--clear);
  border-color: var(--clear);
  color: var(--on-ink);
}

.guide-step.done .guide-name {
  color: var(--ink-3);
}

.guide-step.next {
  border-color: var(--ink);
  background: var(--sheet);
}

.guide-name {
  margin: 0;
  font-weight: 600;
}

.guide-why {
  margin: 2px 0 0;
  font-size: 0.8125rem;
  color: var(--ink-3);
}

/* Provider tiles when connecting storage. */
.provider-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: var(--s-3);
}

.provider-tile {
  appearance: none;
  text-align: left;
  font: inherit;
  color: var(--ink);
  background: var(--sheet);
  border: 1px solid var(--grid-strong);
  border-radius: var(--r-1);
  padding: var(--s-3) var(--s-4);
  cursor: pointer;
  display: grid;
  gap: 4px;
  align-content: start;
  min-height: 76px;
}

.provider-tile:hover {
  border-color: var(--rule);
}

.provider-tile.on {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.provider-tile strong {
  font-size: 0.9375rem;
}

.provider-tile span {
  font-size: 0.8125rem;
  color: var(--ink-3);
  line-height: 1.35;
}

.form-body {
  display: grid;
  gap: var(--s-4);
  padding: var(--s-5);
}

.form-step {
  margin: 0;
  font-weight: 650;
  font-size: 0.9375rem;
}

.howto {
  margin: 0;
  padding: var(--s-3) var(--s-4) var(--s-3) calc(var(--s-4) + 1.2em);
  background: var(--paper);
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--ink-2);
  display: grid;
  gap: 4px;
}

.howto b {
  color: var(--ink);
  font-weight: 600;
}

/* Fold-away "more options" blocks. */
details.more {
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
  background: var(--sheet);
}

details.more > summary {
  cursor: pointer;
  padding: var(--s-3) var(--s-4);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--ink-2);
  list-style-position: inside;
}

details.more > summary:hover,
details.more[open] > summary {
  color: var(--ink);
}

details.more > .more-body {
  display: grid;
  gap: var(--s-4);
  padding: 0 var(--s-4) var(--s-4);
  min-width: 0;
}

details.more.flat {
  border: 0;
  background: transparent;
}

details.more.flat > summary {
  padding: 0;
}

details.more.flat > .more-body {
  padding: var(--s-3) 0 0;
}

.result-line {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  font-weight: 600;
}

.fix-list {
  margin: 0;
  padding-left: 1.2em;
  display: grid;
  gap: 6px;
  font-size: 0.875rem;
}

.share-way {
  margin: 0 0 2px;
  font-size: 0.75rem;
  color: var(--ink-3);
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2);
  align-items: center;
  min-width: 0;
}

.copy-row code {
  flex: 1 1 220px;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 8px 10px;
  background: var(--paper);
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
  font: 0.8125rem/1.4 var(--mono);
}

/* Help section. */
.help-search {
  max-width: 460px;
}

.help-group {
  display: grid;
  gap: var(--s-2);
}

.help-group > h2 {
  margin: var(--s-3) 0 0;
  font-size: 1rem;
  font-weight: 650;
}

details.help-item {
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
  background: var(--sheet);
}

details.help-item > summary {
  cursor: pointer;
  padding: var(--s-3) var(--s-4);
  font-weight: 600;
  list-style-position: inside;
}

details.help-item[open] > summary {
  border-bottom: 1px solid var(--grid);
}

.help-body {
  padding: var(--s-3) var(--s-4) var(--s-4);
  display: grid;
  gap: var(--s-3);
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--ink-2);
  max-width: 74ch;
  min-width: 0;
}

.help-body p,
.help-body ol,
.help-body ul {
  margin: 0;
}

.help-body ol,
.help-body ul {
  padding-left: 1.3em;
  display: grid;
  gap: 4px;
}

.help-body b {
  color: var(--ink);
  font-weight: 600;
}

.help-body pre.code {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.help-body dl {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(90px, max-content) minmax(0, 1fr);
  gap: 6px var(--s-4);
}

.help-body dt {
  font-weight: 600;
  color: var(--ink);
}

.help-body dd {
  margin: 0;
}

.help-contact {
  padding: var(--s-4) var(--s-5);
  border: 1px solid var(--grid-strong);
  border-radius: var(--r-1);
  background: var(--paper);
}

.help-none {
  color: var(--ink-3);
}

@media (max-width: 560px) {
  .guide {
    padding: var(--s-4);
  }

  .guide-step {
    grid-template-columns: 28px minmax(0, 1fr);
  }

  .guide-step > .btn {
    grid-column: 2;
    justify-self: start;
  }

  .form-body {
    padding: var(--s-4);
  }

  .help-body dl {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .help-body dd {
    margin-bottom: 6px;
  }
}

/* ---- Simple portal, design round 2 (2026-11-12): one inset, readable headings, tables that fit ---- */
.status-line {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.panel-head {
  padding: var(--s-3) var(--s-4);
}

.panel-head h2 {
  font-size: 0.9375rem;
  font-weight: 650;
}

/* Everything inside a panel starts on the same left edge (16 px), wherever it is nested. */
.panel > .plain-lede,
.panel > div > .plain-lede {
  margin: var(--s-4) var(--s-4) 0;
  padding: 0;
}

.panel > div > .form-foot {
  margin: var(--s-3) var(--s-4) var(--s-4);
}

.panel > div > .field-error:not(:empty) {
  margin: 0 var(--s-4) var(--s-3);
}

.field-error:empty {
  display: none;
}

.form-body {
  padding: var(--s-4);
}

.form-body > .plain-lede,
.more-body > .plain-lede {
  margin: 0;
  padding: 0;
}

.form-body .form-grid,
.form-body .form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 0;
}

.more-body > .panel,
.more-body > .grid-2 {
  margin: 0;
}

details.more > summary {
  font-size: 0.9375rem;
}

.row-actions {
  flex-wrap: wrap;
  gap: 6px;
}

.row-actions .btn {
  font-size: 0.8125rem;
  min-height: 30px;
}

.ledger td.actions-cell {
  white-space: normal;
}

/* Extra columns (ids, codes, details) only where there is room for them. Rows keep one line now that
   less-used actions sit in the More menu, so the cut-off is lower than in round 2. */
@media (max-width: 1180px) {
  .ledger .c-opt {
    display: none;
  }
}

.file-name {
  font-weight: 600;
}

@media (max-width: 700px) {
  .form-body .form-grid,
  .form-body .form-grid.two {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ==========================================================================
   DESIGN ROUND 3 (2026-11-12). One spacing system for the whole dashboard and admin, replacing
   the per-element margins above (founder: "clunky, off-putting").
   - Page: every block, including the classless slots pages load into, sits 24 px from the next;
     an empty slot takes no space.
   - Panel: content is inset by --pad on all sides; the header and tables run edge to edge, and
     table text lines up with the panel text.
   - Tables: actions stay on one line; less-used actions live in the "More" menu (moreMenu()).
   ========================================================================== */
:root {
  --pad: 20px;
  --r-panel: 10px;
  --on-ink: #FFFFFF; /* text on an ink, red or green fill */
  --nav-on: #EDEDE9;
  --hold-ink: #78350F;
}

body {
  font-size: 0.875rem;
}

/* Page */
.page-head {
  max-width: calc(1320px - 2 * var(--s-6));
  padding: var(--s-6) 0 var(--s-5);
  border-bottom-color: var(--grid);
}

.page-titles h1 {
  font-size: 1.75rem;
}

.page-titles .lede {
  font-size: 0.9375rem;
  color: var(--ink-3);
  margin-top: 6px;
}

.page-body {
  max-width: 1320px;
  gap: var(--s-5);
  align-content: start;
}

.page-body > div:not([class]),
.stack {
  display: grid;
  gap: var(--s-5);
  min-width: 0;
  align-content: start;
}

.page-body > div:not([class]):empty,
.panel > div:not([class]):empty {
  display: none;
}

/* Sidebar */
.nav-item kbd,
.nav-item.on kbd,
.nav:focus-within kbd {
  display: none;
}

.nav-item {
  height: 38px;
  border: 0;
  font-weight: 500;
}

.nav-item.on {
  background: var(--nav-on);
  color: var(--ink);
  font-weight: 600;
  border: 0;
}

.nav-item.on .ico {
  color: var(--ink);
}

.tenant-card {
  background: var(--paper);
  border-color: var(--grid);
  padding: var(--s-3) 14px;
}

.tenant-name {
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.3;
}

.tenant-meta {
  margin-top: 6px;
}

/* Summary strip */
.status-line {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  border-color: var(--grid);
  border-radius: var(--r-panel);
}

.status-cell-box {
  padding: 18px var(--pad);
  gap: 2px;
}

.status-cell-box .k {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-3);
}

.status-cell-box .v {
  font-size: 1.375rem;
  font-weight: 700;
  margin-top: 2px;
}

.status-cell-box .sub {
  font-size: 0.8125rem;
  color: var(--ink-3);
}

/* Panel */
.panel {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  padding: 0 var(--pad) var(--pad);
  border-color: var(--grid);
  border-radius: var(--r-panel);
}

body .page .panel > * {
  margin: 0;
  min-width: 0;
}

body .page .panel > :first-child:not(.panel-head) {
  margin-top: var(--pad);
}

body .page .panel > .panel-head {
  margin: 0 calc(-1 * var(--pad));
  padding: 12px var(--pad);
  min-height: 56px;
  background: transparent;
  border-bottom: 1px solid var(--grid);
  border-radius: var(--r-panel) var(--r-panel) 0 0;
}

.panel-head h2 {
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.005em;
}

.panel > div:not([class]) {
  display: grid;
  gap: var(--s-4);
  min-width: 0;
}

body .page .panel > .table-wrap,
.panel > div:not([class]) > .table-wrap {
  margin-left: calc(-1 * var(--pad));
  margin-right: calc(-1 * var(--pad));
}

.panel:has(> .table-wrap:last-child),
.panel:has(> div:not([class]):last-child > .table-wrap:last-child) {
  padding-bottom: 0;
}

/* Everything that used to carry its own 16 px inset now relies on the panel's. */
.panel > .plain-lede,
.panel > div > .plain-lede,
.panel > div > .form-foot,
.panel > div > .field-error:not(:empty),
.panel > div > .loading,
.leak-grid > .panel > .dropzone,
.panel .add-row,
.panel .origin-list,
.panel .cors,
.panel .ticket-meta {
  margin: 0;
}

.panel .form-body,
.panel .embed-cards,
.panel .upload-grid,
.panel .usage-grid {
  padding: 0;
}

/* Forms sit on the panel itself: no grey band, no second box. Groups are labelled by the question
   they answer (fieldset + legend), separated by space. */
.inline-form,
body .page .panel > .inline-form,
.panel > div:not([class]) > .inline-form {
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  gap: var(--s-5);
}

.form-group {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
  display: grid;
  gap: var(--s-3);
}

.form-group > legend {
  padding: 0;
  margin-bottom: var(--s-3);
  font-size: 0.9375rem;
  font-weight: 650;
  color: var(--ink);
}

.form-group .check-row,
.inline-form > .check-row {
  align-self: start;
  min-height: 0;
  font-size: 0.875rem;
  align-items: flex-start;
}

.form-group .check-row .check {
  margin-top: 2px;
}

.inline-form > details.more {
  border-color: var(--grid);
}

.facts .hint {
  margin-top: 2px;
}

.error-box,
.secret {
  margin: 0;
}

.loading {
  padding: 4px 0;
}

.empty {
  padding: 4px 0;
  max-width: 68ch;
}

.plain-lede {
  color: var(--ink-3);
  max-width: 72ch;
}

/* Tables */
.ledger th {
  height: 40px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--ink-3);
  border-bottom-color: var(--grid);
  background: var(--paper);
}

.ledger td {
  height: 52px;
  padding-top: 8px;
  padding-bottom: 8px;
}

.ledger th:first-child,
.ledger td:first-child {
  padding-left: var(--pad);
}

.ledger th:last-child,
.ledger td:last-child {
  padding-right: var(--pad);
}

.ledger td.actions-cell {
  white-space: nowrap;
}

.row-actions {
  flex-wrap: nowrap;
  gap: 6px;
}

.row-actions .btn {
  height: 32px;
  min-height: 32px;
  font-size: 0.8125rem;
  padding: 0 12px;
}

/* "More" menu */
.menu {
  position: relative; /* keeps the hidden label inside the table's scroll box on phones */
  display: inline-flex;
}

.row-actions .menu-btn,
.menu-btn {
  width: 32px;
  padding: 0;
  color: var(--ink-2);
}

.menu-btn[aria-expanded="true"] {
  background: var(--grid);
  color: var(--ink);
}

.menu-list {
  position: fixed;
  z-index: 40;
  min-width: 190px;
  padding: 4px;
  display: grid;
  gap: 2px;
  background: var(--sheet);
  border: 1px solid var(--grid-strong);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(17, 17, 16, 0.06), 0 12px 28px -10px rgba(17, 17, 16, 0.22);
}

.row-actions .menu-list .btn,
.menu-list .btn {
  width: 100%;
  height: 36px;
  justify-content: flex-start;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--ink);
}

.menu-list .btn:hover:not(:disabled) {
  background: var(--paper);
}

.menu-list .btn-danger {
  color: var(--match);
}

.menu-list .btn-danger:hover:not(:disabled) {
  background: var(--match-wash);
}

.row-actions .menu-list .btn-danger.armed,
.menu-list .btn-danger.armed {
  background: var(--match);
  color: var(--on-ink);
}

/* Fold-away blocks and Help answers: one chevron instead of the browser's triangle. */
details.more > summary,
details.help-item > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

details.more > summary::-webkit-details-marker,
details.help-item > summary::-webkit-details-marker {
  display: none;
}

details.more > summary::after,
details.help-item > summary::after {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-right: 1.5px solid var(--ink-3);
  border-bottom: 1.5px solid var(--ink-3);
  transform: translateY(-2px) rotate(45deg);
}

details.more[open] > summary::after,
details.help-item[open] > summary::after {
  transform: translateY(2px) rotate(-135deg);
}

.page-body > details.more,
.page-body > div > details.more {
  border-color: var(--grid);
  border-radius: var(--r-panel);
}

.page-body > details.more > summary,
.page-body > div > details.more > summary {
  padding: 16px var(--pad);
  font-size: 1rem;
  font-weight: 650;
  color: var(--ink);
}

.page-body > details.more > .more-body,
.page-body > div > details.more > .more-body {
  padding: 0 var(--pad) var(--pad);
}

details.help-item {
  border-radius: 8px;
}

details.help-item > summary {
  padding: 14px var(--pad);
}

.help-body {
  padding: var(--s-4) var(--pad) var(--pad);
}

/* Billing */
.portal-banner {
  background: var(--sheet);
  border: 1px solid var(--grid);
  border-radius: var(--r-panel);
  padding: 16px var(--pad);
}

.portal-banner-copy strong {
  font-size: 0.9375rem;
}

.usage-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.usage-card {
  align-content: start;
  gap: 4px;
  padding: 16px;
  background: var(--paper);
  border-color: var(--grid);
  border-radius: 8px;
}

.usage-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--ink-2);
}

.usage-value {
  color: var(--ink-3);
  font-size: 0.8125rem;
}

.usage-value strong {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.usage-track {
  height: 6px;
  margin: 6px 0 4px;
}

.usage-fill {
  background: var(--ink);
}

.usage-card.near .usage-fill {
  background: var(--hold);
}

.usage-sub {
  font-size: 0.8125rem;
  color: var(--ink-3);
  line-height: 1.4;
}

.cadence-bar {
  margin: 0;
  align-items: center;
}

.cadence-bar .plain-lede {
  flex: 1 1 320px;
}

.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--paper);
  border: 1px solid var(--grid-strong);
  border-radius: 8px;
}

.seg-btn {
  appearance: none;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font: 600 0.8125rem/1 var(--sans);
  color: var(--ink-3);
  cursor: pointer;
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--ink);
}

.seg-btn.on {
  background: var(--sheet);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--grid-strong);
}

.plan-grid {
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: var(--s-4);
}

.plan-card {
  gap: 0;
  padding: var(--pad);
  background: var(--sheet);
  border: 1px solid var(--grid-strong);
  border-radius: var(--r-panel);
}

.plan-card.active {
  border: 1px solid var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
  background: var(--sheet);
}

.plan-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  min-height: 24px;
}

.plan-card__name {
  font-size: 1.0625rem;
  font-weight: 700;
}

.plan-card__desc {
  margin-top: 4px;
  min-height: 2.9em;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--ink-3);
}

.plan-card__price {
  margin-top: var(--s-4);
  font-size: 0.875rem;
  color: var(--ink-3);
}

.plan-card__price strong {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.plan-card__cad {
  margin-top: 2px;
  font-size: 0.8125rem;
  color: var(--ink-3);
}

.plan-card__list {
  list-style: none;
  margin: var(--s-4) 0 0;
  padding: var(--s-4) 0 0;
  border-top: 1px solid var(--grid);
  display: grid;
  gap: 8px;
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--ink-2);
}

.plan-card__list li {
  position: relative;
  padding-left: 22px;
}

.plan-card__list li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.38em;
  width: 10px;
  height: 5px;
  border-left: 1.5px solid var(--clear);
  border-bottom: 1.5px solid var(--clear);
  transform: rotate(-45deg);
}

.plan-card__foot {
  margin-top: auto;
  padding-top: var(--pad);
  display: flex;
}

.plan-card__foot > *,
.plan-card__foot .btn {
  width: 100%;
}

/* Cards inside panels (Share) */
.embed-card {
  border-radius: 8px;
  padding: var(--s-4);
}

@media (max-width: 900px) {
  :root {
    --pad: 16px;
  }

  .page-head {
    max-width: none;
  }
}
/* Half-width tables (Home) get tighter inner columns so they fit at 1280 px. */
.grid-2 .ledger th:not(:first-child):not(:last-child),
.grid-2 .ledger td:not(:first-child):not(:last-child) {
  padding-left: 12px;
  padding-right: 12px;
}
/* A table straight under the panel header joins it, with no gap. */
.panel > .panel-head + .table-wrap,
.panel > .panel-head + div:not([class]) > .table-wrap:first-child {
  margin-top: calc(-1 * var(--s-4));
}
/* The drop area is the main target of Add a file: as tall as the form beside it, content centred. */
.upload-left > .dropzone {
  min-height: 168px;
  align-content: center;
}
/* A section inside a panel (Subtitles, Marked PDF in a file's Settings): heading, one line of
   context, content. Separated from what comes before by a hairline; never a box in a box. */
.section-flow {
  display: grid;
  gap: var(--s-4);
  min-width: 0;
}

.panel > div:not([class]) > .section-flow {
  padding-top: var(--s-5);
  border-top: 1px solid var(--grid);
}

.section-title {
  font-size: 1rem;
  font-weight: 650;
}

.section-flow .table-wrap {
  border: 1px solid var(--grid);
  border-radius: 8px;
}

.section-flow .ledger th:first-child,
.section-flow .ledger td:first-child {
  padding-left: var(--s-4);
}

.section-flow .ledger th:last-child,
.section-flow .ledger td:last-child {
  padding-right: var(--s-4);
}

.two-ways {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--s-4);
}

.way {
  display: grid;
  gap: var(--s-2);
  align-content: start;
  justify-items: start;
  padding: var(--s-4);
  border: 1px solid var(--grid);
  border-radius: 8px;
}

.way > .dropzone {
  justify-self: stretch;
}

.way-title {
  font-weight: 600;
}
/* Provider tiles: three across, so six tiles make two even rows instead of five and an orphan. */
.provider-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (max-width: 700px) {
  .provider-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
/* Share: the three ways to share are equal choices, so their buttons share one style and sit on
   one line at the bottom of each card. Code wraps instead of scrolling sideways. */
.embed-card {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.embed-card > .form-foot {
  margin-top: auto;
}

.embed-card .code {
  white-space: pre-wrap;
  word-break: break-all;
  overflow-x: hidden;
  max-height: 8.5em;
  font-size: 0.75rem;
}
/* Developer detail columns (viewing IDs, networks) only on wide screens. */
@media (max-width: 1599px) {
  .ledger .c-wide {
    display: none;
  }
}
.origin-remove {
  margin-left: auto;
}

.origin-remove .btn {
  height: 30px;
  font-size: 0.8125rem;
}
/* Sign-in: an email is read as text, not code; the 6-digit code is large and spaced for typing. */
.gate-form input[type="email"] {
  font-family: var(--sans);
  font-size: 0.9375rem;
}

#gate-otp {
  font-size: 1.25rem;
  letter-spacing: 0.3em;
  text-align: center;
}

/* Quality floor: motion only answers an action, and is dropped for people who ask for less. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   DARK MODE (2026-11-12). Follows the marketing site: theme.js sets <html data-theme> from the
   saved choice ("sdrm-theme", shared with streamdrm.com) or the system setting, before first
   paint. Same token names, so every rule above works in both themes. Values are the site's dark
   plain look; status colours lightened for dark backgrounds. Contrast measured 2026-11-12:
   ink 15.5:1, ink-2 9.9:1, ink-3 6.3:1 on panels; red 7.0, green 8.0, amber 8.3 on their
   washes; button text on ink 16.8:1 (AA needs 4.5).
   ========================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;
  --paper: #111110;
  --sheet: #1A1A19;
  --grid: #2A2A28;
  --grid-strong: #3A3A37;
  --rule: #77776F;
  --ink: #F2F2EE;
  --ink-2: #C4C4BD;
  --ink-3: #9C9C94;
  --trace: #F2F2EE;
  --trace-hover: #C4C4BD;
  --trace-wash: #232322;
  --match: #F28B82;
  --match-wash: #2C1817;
  --clear: #6CCB8F;
  --clear-wash: #14261B;
  --hold: #E6B35A;
  --hold-wash: #2A2112;
  --on-ink: #111110;
  --nav-on: #262624;
  --hold-ink: #E6B35A;
  --pop: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

:root[data-theme="dark"] .menu-list {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 12px 28px -10px rgba(0, 0, 0, 0.7);
}

:root[data-theme="dark"] .seg-btn.on {
  background: var(--grid);
}

:root[data-theme="dark"] .gate-form {
  box-shadow: none;
}

/* The switch in the sidebar footer. */
.theme-switch .ico {
  color: var(--ink-3);
}
/* ==========================================================================
   THREE LAYOUTS (2026-11-12). Founder: "make PC, tablet and mobile fully responsive and
   independent, not one concept forced on all 3", and nothing left in a box on the left.
   - All sizes: text fills the box it is in. No character caps inside the dashboard.
   - Desktop, 1180 px and up: sidebar; content fills the window and is centred only past 1760 px;
     form groups are settings rows (heading left, fields right).
   - Tablet, 768 to 1179 px: top bar (brand, account, theme, sign out) over a section bar that
     wraps so every section stays visible; content full width; grids in twos with no orphans.
   - Phone, below 768 px: top bar with a Menu button that opens the section list and footer;
     tables become cards ("Label  value" per line); page buttons share the full width.
   The older 1180 and 900 px rules above are overridden here, property by property.
   ========================================================================== */

/* ---- All sizes ---- */
.lede,
.page-titles .lede,
.plain-lede,
.empty,
.help-body,
.help-search {
  max-width: none;
}

.page-titles {
  flex: 1 1 auto;
  min-width: 0;
}

.side-menu-btn {
  display: none;
}

.page-head {
  max-width: none;
  margin: 0 max(var(--s-6), calc((100% - 1760px) / 2));
}

.page-body {
  max-width: none;
  padding-left: max(var(--s-6), calc((100% - 1760px) / 2));
  padding-right: max(var(--s-6), calc((100% - 1760px) / 2));
}

/* ---- Desktop ---- */
@media (min-width: 1180px) {
  /* Settings rows: the group's heading on the left, its fields across the rest. A floated
     legend is laid out as a normal grid item, so it can take the first column. */
  .form-group {
    grid-template-columns: 220px minmax(0, 1fr);
    column-gap: var(--s-6);
    align-items: start;
  }

  .form-group > legend {
    float: left;
    grid-column: 1;
    grid-row: 1;
    margin: 0;
    padding-top: 2px;
  }

  .form-group > :not(legend) {
    grid-column: 2;
  }

  .inline-form > details.more,
  .inline-form > .form-foot,
  .inline-form > .field-error:not(:empty) {
    margin-left: calc(220px + var(--s-6));
  }
}

/* ---- Tablet and phone: the sidebar becomes a top bar ---- */
@media (max-width: 1179px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .side {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "brand tenant foot" "nav nav nav";
    align-items: center;
    gap: 0 var(--s-4);
    padding: 10px var(--s-6) 0;
    border-right: 0;
    border-bottom: 1px solid var(--grid);
  }

  .side-brand {
    grid-area: brand;
    padding: 4px 0;
  }

  .side-tag {
    margin-left: 8px;
  }

  .tenant-card {
    grid-area: tenant;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    margin: 0;
    padding: 0 0 0 var(--s-4);
    border: 0;
    border-left: 1px solid var(--grid);
    border-radius: 0;
    background: none;
    text-align: left;
  }

  .tenant-name {
    max-width: none;
    font-size: 0.875rem;
    -webkit-line-clamp: 1;
  }

  .tenant-meta {
    display: flex;
    margin: 0;
    white-space: nowrap;
  }

  .side-foot {
    grid-area: foot;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    margin: 0;
    padding: 0;
    border: 0;
  }

  .side-foot .side-hint:not(.theme-switch) {
    display: none;
  }

  .nav {
    grid-area: nav;
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    overflow: visible;
    margin: 8px 0 0;
    padding: 0 0 10px;
    border-top: 0;
    background: none;
  }

  .nav-item {
    flex: none;
    height: 36px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
  }

  .nav-item .ico {
    display: inline-block;
  }

  .nav-item.on {
    border: 0;
    background: var(--nav-on);
  }

  .page-head {
    margin: 0 var(--s-6);
    padding: var(--s-5) 0 var(--s-4);
    flex-direction: row;
    align-items: flex-end;
  }

  .page-body {
    padding: var(--s-5) var(--s-6) var(--s-7);
  }

  .status-line {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .usage-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .usage-grid > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }
}

/* ---- Phone ---- */
@media (max-width: 767px) {
  :root {
    --pad: 16px;
  }

  .side {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "brand tenant menu" "nav nav nav" "foot foot foot";
    padding: 8px var(--s-4);
  }

  .side-menu-btn {
    grid-area: menu;
    display: inline-flex;
    padding: 0 10px;
  }

  .tenant-card {
    padding-left: var(--s-3);
  }

  .tenant-meta,
  .side-tag {
    display: none;
  }

  .nav,
  .side-foot {
    display: none;
  }

  .shell.nav-open .nav {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
    margin: 8px 0 0;
    padding: 8px 0 0;
    border-top: 1px solid var(--grid);
  }

  .shell.nav-open .nav-item {
    height: 44px;
  }

  .shell.nav-open .side-foot {
    display: flex;
    justify-content: space-between;
    padding: 8px 0 4px;
    border-top: 1px solid var(--grid);
    margin-top: 8px;
  }

  .page-head {
    margin: 0 var(--s-4);
    padding: var(--s-5) 0 var(--s-4);
    flex-direction: column;
    align-items: stretch;
    gap: var(--s-3);
  }

  .page-actions .btn {
    flex: 1 1 auto;
  }

  .page-body {
    padding: var(--s-4) var(--s-4) var(--s-7);
    gap: var(--s-4);
  }

  .usage-grid,
  .plan-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Tables become cards: the first cell is the card title, then one "Label  value" line per
     column, then the actions. */
  .ledger thead {
    display: none;
  }

  .ledger,
  .ledger tbody {
    display: block;
  }

  .ledger tbody tr {
    display: grid;
    gap: 6px;
    padding: 14px var(--pad);
    border-bottom: 1px solid var(--grid);
  }

  .ledger tbody tr:last-child {
    border-bottom: 0;
  }

  .ledger tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-3);
    height: auto;
    padding: 0 !important;
    border: 0;
    white-space: normal;
    text-align: right;
    min-width: 0;
  }

  .ledger tbody td::before {
    content: attr(data-label);
    flex: none;
    color: var(--ink-3);
    font-size: 0.8125rem;
    text-align: left;
  }

  .ledger tbody td:first-child {
    justify-content: flex-start;
    text-align: left;
    font-size: 0.9375rem;
  }

  .ledger tbody td:first-child::before,
  .ledger tbody td:not([data-label])::before {
    display: none;
  }

  .ledger tbody td.actions-cell {
    justify-content: flex-start;
    width: auto;
    padding-top: 6px !important;
  }

  .ledger tbody td:empty {
    display: none;
  }

  .row-failed td:first-child {
    box-shadow: none;
  }

  .ledger tbody tr.row-failed {
    box-shadow: inset 3px 0 0 var(--match);
  }

  .row-actions {
    flex-wrap: wrap;
  }
}
/* A form row with a single field uses the whole row instead of half of it. */
.form-grid > .field:only-child {
  grid-column: 1 / -1;
}
/* Desktop: the five usage cards always share one row (they wrapped 4 + 1 at 1280 px). */
@media (min-width: 1180px) {
  .usage-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}
/* Tablet only: tables wrap their cells instead of scrolling sideways, and each plan is one
   full-width card in two halves (name, price and button left; what it includes right). */
@media (min-width: 768px) and (max-width: 1179px) {
  .ledger td {
    white-space: normal;
  }

  .ledger td.actions-cell {
    white-space: nowrap;
  }

  .plan-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .plan-card {
    display: grid;
    grid-template-columns: minmax(200px, 1fr) minmax(0, 1.4fr);
    grid-template-rows: auto auto auto auto 1fr;
    column-gap: var(--s-6);
  }

  .plan-card > :not(.plan-card__list) {
    grid-column: 1;
  }

  .plan-card__list {
    grid-column: 2;
    grid-row: 1 / -1;
    margin: 0;
    padding: 0 0 0 var(--s-6);
    border-top: 0;
    border-left: 1px solid var(--grid);
    align-content: start;
  }

  .plan-card__desc {
    min-height: 0;
  }

  .plan-card__foot {
    align-self: end;
  }
}
/* Portrait tablets (768 to 899 px) get the card form of tables too, with two label/value columns
   per card: a row of seven columns does not fit there without scrolling sideways. */
@media (min-width: 768px) and (max-width: 899px) {
  .ledger thead {
    display: none;
  }

  .ledger,
  .ledger tbody {
    display: block;
  }

  .ledger tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px var(--s-6);
    padding: 16px var(--pad);
    border-bottom: 1px solid var(--grid);
  }

  .ledger tbody tr:last-child {
    border-bottom: 0;
  }

  .ledger tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--s-3);
    height: auto;
    padding: 0 !important;
    border: 0;
    white-space: normal;
    text-align: right;
    min-width: 0;
  }

  .ledger tbody td::before {
    content: attr(data-label);
    flex: none;
    color: var(--ink-3);
    font-size: 0.8125rem;
    text-align: left;
  }

  .ledger tbody td:first-child,
  .ledger tbody td.actions-cell {
    grid-column: 1 / -1;
    justify-content: flex-start;
    text-align: left;
  }

  .ledger tbody td:first-child {
    font-size: 0.9375rem;
  }

  .ledger tbody td:first-child::before,
  .ledger tbody td:not([data-label])::before {
    display: none;
  }

  .ledger tbody td:empty {
    display: none;
  }

  .row-failed td:first-child {
    box-shadow: none;
  }

  .ledger tbody tr.row-failed {
    box-shadow: inset 3px 0 0 var(--match);
  }
}
/* Tablet: title and intro use the full width, the page's buttons sit on their own row below. */
@media (min-width: 768px) and (max-width: 1179px) {
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: var(--s-3);
  }
}
/* Phone: the account name lives in the Menu sheet (it was cut to a few letters beside the logo). */
@media (max-width: 767px) {
  .side {
    grid-template-areas: "brand brand menu" "tenant tenant tenant" "nav nav nav" "foot foot foot";
  }

  .tenant-card {
    display: none;
  }

  .shell.nav-open .tenant-card {
    display: flex;
    margin-top: 8px;
    padding: 10px 12px 0;
    border-left: 0;
    border-top: 1px solid var(--grid);
  }

  .shell.nav-open .tenant-meta {
    display: flex;
  }

  .shell.nav-open .nav {
    border-top: 0;
    margin-top: 4px;
  }
}
/* Small desktops (1180 to 1439 px): table cells wrap rather than scroll; actions stay on one line. */
@media (min-width: 1180px) and (max-width: 1439px) {
  .ledger td {
    white-space: normal;
  }

  .ledger td.actions-cell {
    white-space: nowrap;
  }
}
/* FOLDER BROWSER (2026-11-13): choose a pCloud or Publitio folder in Connect storage and in a
   storage's Settings. One list, one row per folder; the same at every width (rows wrap). */
.folder-browser {
  display: grid;
  gap: var(--s-3);
  min-width: 0;
}

.folder-bar,
.folder-new {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.folder-bar {
  justify-content: space-between;
}

.folder-where {
  margin: 0;
  min-width: 0;
  font-size: 0.875rem;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.folder-where b {
  color: var(--ink);
  font-weight: 600;
}

.folder-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
  background: var(--sheet);
  border: 1px solid var(--grid);
  border-radius: var(--r-1);
}

.folder-list[hidden] {
  display: none;
}

.folder-list > li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  min-height: 48px;
  padding: 6px var(--s-3);
  border-top: 1px solid var(--grid);
}

.folder-list > li:first-child {
  border-top: 0;
}

.folder-list > li.on {
  box-shadow: inset 3px 0 0 var(--ink);
}

.folder-list > li.folder-here {
  background: var(--paper);
}

.folder-list > li.folder-here .folder-open {
  font-weight: 600;
}

.folder-open {
  flex: 1 1 8rem;
  min-width: 0;
  padding: 6px 0;
  font: inherit;
  font-size: 0.875rem;
  text-align: left;
  color: var(--ink);
  overflow-wrap: anywhere;
}

button.folder-open {
  appearance: none;
  background: none;
  border: 0;
  cursor: pointer;
}

button.folder-open:hover {
  text-decoration: underline;
}

.folder-list > li.folder-empty {
  color: var(--ink-3);
  font-size: 0.875rem;
}

.folder-new .input {
  flex: 1 1 14rem;
  min-width: 0;
}
.form-grid > .folder-browser,
.form-grid > .field-wide {
  grid-column: 1 / -1;
}

.menu-sep {
  height: 1px;
  margin: 4px 2px;
  background: var(--grid);
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.toast.show {
  pointer-events: auto;
}

.toast-close {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.keys-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}

.keys-sheet-head .label {
  margin: 0;
}

.check-grid {
  display: grid;
  gap: 8px;
}

.usage-card.over .usage-fill {
  background: var(--match);
}

/* ASK SAM SUPPORT CHAT (2026-11-20) */
.sam-chat { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 18px 20px; margin-bottom: 22px; }
.sam-chat__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.sam-chat__head h2 { margin: 0; font-size: 16px; }
.sam-chat__log { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); margin-bottom: 12px; }
.sam-chat__empty { margin: 4px 0; font-size: 13.5px; }
.sam-chat__msg { display: flex; flex-direction: column; gap: 3px; }
.sam-chat__who { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.sam-chat__msg--sam .sam-chat__who { color: var(--accent, var(--ink)); }
.sam-chat__text { white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.sam-chat__status { margin: 0 0 10px; font-size: 13px; }
.sam-chat__row { display: flex; gap: 10px; align-items: center; }
.sam-chat__input { flex: 1; min-width: 0; }
