/* provman UI: no external assets. Light theme here; dark.css adds the dark theme
   (loaded with a media query from the viewer's choice: system / light / dark).
   Brand colour comes from the page (<style>:root{--brand;--brand-text}</style>, set by a
   superadmin under System → Branding); everything accent-coloured derives from it. */
:root {
  --brand: #635bff; --brand-text: #ffffff;
  --bg: #f6f8fc; --panel: #ffffff; --panel-2: #f6f8fb; --panel-3: #eef1f7;
  --text: #1a1f36; --text-2: #3c4257; --muted: #697386; --faint: #a3acb9;
  --border: #e3e8ef; --border-strong: #d5dbe5;
  --accent: var(--brand); --accent-text: var(--brand-text);
  --accent-ink: color-mix(in oklab, var(--brand) 82%, #000);
  --accent-soft: color-mix(in srgb, var(--brand) 9%, var(--panel));
  --accent-ring: color-mix(in srgb, var(--brand) 28%, transparent);
  --ok: #0e7a4a; --ok-bg: #dff6ea; --warn: #9a5800; --warn-bg: #fff1d6;
  --bad: #c0243c; --bad-bg: #ffe5e9; --neutral: #4f566b; --neutral-bg: #edf0f5;
  --shadow-sm: 0 1px 2px rgba(26, 31, 54, .05);
  --shadow: 0 1px 2px rgba(26, 31, 54, .04), 0 6px 20px -8px rgba(26, 31, 54, .10);
  --shadow-lg: 0 2px 4px rgba(26, 31, 54, .04), 0 18px 48px -12px rgba(26, 31, 54, .20);
  --radius: 16px; --radius-sm: 10px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --sidebar-w: 248px;
  /* Gradient partners for the brand colour: a hue shift where supported. */
  --brand-2: color-mix(in oklab, var(--brand) 60%, #ff7ab6);
  --brand-3: color-mix(in oklab, var(--brand) 55%, #7ae3ff);
  color-scheme: light;
}
.preview-frame {
  --brand-2: color-mix(in oklab, var(--brand) 60%, #ff7ab6);
  --brand-3: color-mix(in oklab, var(--brand) 55%, #7ae3ff);
}
@supports (color: oklch(from red l c h)) {
  :root, .preview-frame {
    --brand-2: oklch(from var(--brand) calc(l + .05) c calc(h + 40));
    --brand-3: oklch(from var(--brand) calc(l + .1) c calc(h - 35));
  }
}

/* ---------------------------------------------------------------- base */
* { box-sizing: border-box; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--sans);
  line-height: 1.55; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
code, .mono { font-family: var(--mono); font-size: .9em; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0; font-weight: 700; letter-spacing: -.022em; }
h2 { font-size: 1.08rem; margin: 0 0 .9rem; font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: .95rem; margin: 0 0 .5rem; font-weight: 650; }
p { margin: 0 0 .75rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
::selection { background: var(--accent-ring); }
.icon { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; }

/* ---------------------------------------------------------------- brand mark */
.brand { display: flex; align-items: center; gap: .65rem; color: var(--text); font-weight: 700;
  letter-spacing: -.01em; min-width: 0; }
.brand:hover { text-decoration: none; }
.brand img { display: block; max-height: 32px; max-width: 168px; object-fit: contain; }
.brand img.logo-dark { display: none; }  /* dark.css swaps in the dark-background logo */
.brand .mark { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  flex: none; color: var(--brand-text); font-weight: 750; font-size: .95rem;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--brand) 60%, transparent); }
.brand .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand small { display: block; color: var(--muted); font-weight: 500; font-size: .75rem;
  letter-spacing: 0; }

/* ---------------------------------------------------------------- admin shell */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--panel); border-right: 1px solid var(--border); padding: 1.1rem .85rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.sidebar > .brand { padding: .2rem .45rem 1.1rem; }
.sidebar > .brand img { max-height: 48px; max-width: 100%; }  /* wide logos are height-limited */
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: .7rem; padding: .5rem .7rem; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: .93rem; transition: background .12s, color .12s; }
.nav a .icon { color: var(--faint); transition: color .12s; }
.nav a:hover { background: var(--panel-2); color: var(--text); text-decoration: none; }
.nav a:hover .icon { color: var(--muted); }
.nav a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav a.active .icon { color: var(--accent); }
.nav .section { color: var(--faint); font-size: .7rem; font-weight: 650; text-transform: uppercase;
  letter-spacing: .08em; margin: 1.1rem .7rem .35rem; }
.userbox { margin-top: auto; padding: .75rem; border-radius: var(--radius-sm); background: var(--panel-2);
  display: flex; align-items: center; gap: .65rem; font-size: .85rem; }
.avatar { width: 34px; height: 34px; border-radius: 999px; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; font-size: .85rem; }
.userbox .who { min-width: 0; flex: 1; line-height: 1.3; }
.userbox .who strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { background: none; border: 0; padding: .4rem; border-radius: 8px; color: var(--muted);
  cursor: pointer; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--panel-3); color: var(--text); }

.main { padding: 2rem 2.5rem 4rem; width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem;
  margin-bottom: 1.6rem; flex-wrap: wrap; }
.topbar .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.topbar .muted { margin-top: .35rem; }
.crumbs { color: var(--muted); font-size: .84rem; margin-bottom: .4rem; font-weight: 500; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }

/* ---------------------------------------------------------------- panels */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.35rem 1.5rem; box-shadow: var(--shadow); margin-bottom: 1.5rem; }
.panel > h2:first-child, .panel-head h2 { margin-bottom: 1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  margin-bottom: 1rem; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.panel > .table-wrap:last-child, .panel > table:last-child { margin-bottom: -.35rem; }
a.panel { transition: box-shadow .15s, transform .15s, border-color .15s; }
a.panel:hover { box-shadow: var(--shadow-lg); border-color: var(--border-strong); transform: translateY(-1px); }
.grid { display: grid; gap: 1.5rem; }
.grid > .panel { margin-bottom: 0; }
.grid + .panel, .grid + .grid, .grid + p + .grid, .grid + p + .panel { margin-top: 1.5rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.small { gap: 1rem; }

.stat { position: relative; overflow: hidden; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem 1.4rem; box-shadow: var(--shadow); }
.stat .value { font-size: 2rem; font-weight: 700; letter-spacing: -.03em; line-height: 1.1;
  font-variant-numeric: tabular-nums; }
.stat .label { color: var(--muted); font-size: .86rem; margin-top: .3rem; font-weight: 500; }
.stat .stat-icon { position: absolute; top: 1.1rem; right: 1.1rem; width: 38px; height: 38px;
  border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.stat.hero { color: var(--brand-text); border-color: transparent;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  box-shadow: 0 12px 32px -12px color-mix(in srgb, var(--brand) 70%, transparent); }
.stat.hero .label { color: inherit; opacity: .85; }
.stat.hero .stat-icon { background: rgba(255, 255, 255, .18); color: inherit; }

dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: .55rem 1.5rem; margin: 0; }
dl.kv dt { color: var(--muted); font-size: .9rem; }
dl.kv dd { margin: 0; overflow-wrap: anywhere; font-weight: 500; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; margin: 0 -.5rem; padding: 0 .5rem; }
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .93rem; }
th, td { text-align: left; padding: .7rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .07em; background: var(--panel-2); border-bottom-color: var(--border); white-space: nowrap; }
th:first-child { border-top-left-radius: var(--radius-sm); border-bottom-left-radius: var(--radius-sm); }
th:last-child { border-top-right-radius: var(--radius-sm); border-bottom-right-radius: var(--radius-sm); }
tr:has(th) th { border-bottom: 0; }
tbody tr, table tr { transition: background .1s; }
tr:hover > td { background: color-mix(in srgb, var(--panel-2) 70%, transparent); }
tr:last-child td { border-bottom: 0; }
td a { font-weight: 550; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* Inline edit rows: an "Edit" link targets the row (#edit-…), no JS; saving redirects away. */
tr.edit-row { display: none; scroll-margin-top: 5rem; }
tr.edit-row:target { display: table-row; }
tr.edit-row > td, tr.edit-row:hover > td { background: var(--panel-2); }
.empty { color: var(--muted); padding: 2rem 0 !important; text-align: center; }
td.empty { background: none !important; }

/* ---------------------------------------------------------------- badges */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .12rem .6rem; border-radius: 999px;
  font-size: .76rem; font-weight: 600; background: var(--neutral-bg); color: var(--neutral);
  white-space: nowrap; line-height: 1.6; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 999px; background: currentColor; opacity: .75; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }

/* ---------------------------------------------------------------- forms */
form.inline { display: inline; }
.field { margin-bottom: 1rem; }
.field label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .35rem; color: var(--text-2); }
.field .hint { color: var(--muted); font-size: .8rem; margin-top: .3rem; }
.field .error { color: var(--bad); font-size: .82rem; margin-top: .3rem; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url],
input[type=date], input[type=datetime-local], input[type=search], input[type=file],
select, textarea {
  width: 100%; padding: .6rem .8rem; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--text); font: inherit; font-size: .93rem;
  box-shadow: var(--shadow-sm); transition: border-color .12s, box-shadow .12s;
}
input[type=file] { padding: .45rem .6rem; }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; font-size: .85rem; border: 0;
  border-radius: 8px; padding: .35rem .8rem; margin-right: .75rem; background: var(--panel-3);
  color: var(--text); cursor: pointer; }
select { appearance: none; padding-right: 2.2rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23697386' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center; }
td select, td input { padding-top: .35rem; padding-bottom: .35rem; width: auto; }
textarea { min-height: 6rem; font-family: var(--mono); font-size: .88rem; line-height: 1.5; }
textarea.prose { font-family: var(--sans); font-size: .93rem; }
input:hover, select:hover, textarea:hover { border-color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--panel-2); color: var(--muted); cursor: not-allowed; }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
input[type=color] { width: 44px; height: 40px; padding: 3px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); background: var(--panel); cursor: pointer; }
.checkbox { display: flex; gap: .55rem; align-items: center; font-weight: 500 !important; color: var(--text) !important; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: end; }
.row > .field { flex: 1 1 180px; }
.row.top { align-items: start; }
.form-actions { display: flex; gap: .6rem; margin-top: 1.25rem; flex-wrap: wrap; align-items: center; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .55rem 1.05rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--panel);
  color: var(--text); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow-sm); transition: background .12s, box-shadow .12s, filter .12s, transform .06s;
  white-space: nowrap;
}
button:hover, .button:hover { background: var(--panel-2); text-decoration: none; border-color: var(--faint); }
button:active, .button:active { transform: translateY(1px); }
button:focus-visible, .button:focus-visible, a:focus-visible { outline: none; box-shadow: 0 0 0 4px var(--accent-ring); }
.primary, button.primary, .button.primary { background: var(--accent); color: var(--accent-text);
  border-color: transparent; box-shadow: 0 1px 2px rgba(26, 31, 54, .12),
  0 4px 12px -4px color-mix(in srgb, var(--accent) 55%, transparent); }
.primary:hover, button.primary:hover, .button.primary:hover { background: var(--accent); filter: brightness(1.07);
  border-color: transparent; }
.danger, button.danger { color: var(--bad); }
button.danger:hover { background: var(--bad-bg); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.small-btn { padding: .3rem .7rem; font-size: .82rem; border-radius: 8px; }
.link-btn, button.link-btn { background: none; border: 0; color: var(--accent-ink); padding: 0; font-weight: 500;
  box-shadow: none; }
.link-btn:hover { background: none; text-decoration: underline; }

/* ---------------------------------------------------------------- disclosure */
details { margin-top: .75rem; }
details > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: .45rem;
  font-weight: 600; font-size: .9rem; color: var(--accent-ink); padding: .35rem 0; user-select: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: ""; width: 7px; height: 7px; border: solid currentColor; border-width: 0 2px 2px 0;
  transform: rotate(-45deg); transition: transform .15s; margin-right: .15rem; }
details[open] > summary::before { transform: rotate(45deg); }
details[open] > summary { margin-bottom: .75rem; }
td details { margin: 0; }
td details > summary { color: var(--text) !important; font-weight: 500; padding: 0; }
td details[open] > summary { margin-bottom: .5rem; }

/* ---------------------------------------------------------------- flash */
.flash { padding: .8rem 1rem .8rem 2.6rem; border-radius: var(--radius-sm); margin-bottom: 1.25rem; position: relative;
  border: 1px solid var(--border); background: var(--panel); font-weight: 500; font-size: .92rem; }
.flash::before { content: ""; position: absolute; left: 1rem; top: 1.05rem; width: 10px; height: 10px;
  border-radius: 999px; background: currentColor; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 18%, transparent); }
.flash.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 20%, transparent); }
.flash.bad { background: var(--bad-bg); color: var(--bad); border-color: color-mix(in srgb, var(--bad) 20%, transparent); }
.flash.warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 20%, transparent); }
.flash a { color: inherit; text-decoration: underline; }

/* ---------------------------------------------------------------- secrets */
.secret { font-family: var(--mono); background: var(--panel-2); border: 1px dashed var(--border-strong);
  padding: .65rem .85rem; border-radius: var(--radius-sm); display: flex; justify-content: space-between;
  gap: 1rem; align-items: center; overflow-wrap: anywhere; font-size: .9rem; color: var(--text); }

/* ---------------------------------------------------------------- auth pages */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); }
.auth-art { position: relative; overflow: hidden; color: var(--brand-text); padding: 2.5rem 3rem;
  display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(60% 55% at 15% 10%, var(--brand-3) 0%, transparent 70%),
    radial-gradient(55% 60% at 90% 25%, var(--brand-2) 0%, transparent 70%),
    radial-gradient(70% 60% at 50% 100%, color-mix(in oklab, var(--brand) 70%, #1a1f36) 0%, transparent 75%),
    var(--brand); }
.auth-art::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.07) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: linear-gradient(160deg, #000 20%, transparent 75%); }
.auth-art > * { position: relative; z-index: 1; }
.auth-art .brand { color: inherit; font-size: 1.4rem; gap: .8rem; }
.auth-art .brand .mark { background: rgba(255, 255, 255, .2); color: inherit; box-shadow: none;
  backdrop-filter: blur(6px); width: 48px; height: 48px; border-radius: 14px; font-size: 1.35rem; }
/* The sign-in panel is the logo's showcase: wide logos are height-limited, so allow more. */
.auth-art .brand img { max-height: 72px; max-width: min(340px, 100%); }
.auth-art h2 { font-size: 2.4rem; line-height: 1.12; letter-spacing: -.03em; font-weight: 750; margin: 0 0 1rem;
  max-width: 14em; }
.auth-art p { font-size: 1.05rem; opacity: .88; max-width: 30em; margin: 0; }
.auth-art .foot { font-size: .85rem; opacity: .75; }
.auth-form { display: grid; place-items: center; padding: 2.5rem 1.5rem; background: var(--panel); }
.auth .card { width: 100%; max-width: 400px; }
.auth h1 { margin-bottom: .4rem; font-size: 1.65rem; }
.auth .sub { color: var(--muted); margin-bottom: 1.75rem; }
.auth .card button, .auth .card .button { width: 100%; padding: .7rem 1rem; font-size: .95rem; }
.auth .card .secret button { width: auto; padding: .3rem .7rem; font-size: .82rem; }
.auth .card .field { margin-bottom: 1.1rem; }
.auth .help { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--border); }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--faint); font-size: .8rem;
  margin: 1.25rem 0; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
.divider::before, .divider::after { content: ""; height: 1px; flex: 1; background: var(--border); }
.qr { display: inline-block; padding: 12px; border-radius: var(--radius); background: #fff;
  border: 1px solid var(--border); box-shadow: var(--shadow); }
.qr svg { width: 180px; height: 180px; display: block; shape-rendering: crispEdges; }

/* ---------------------------------------------------------------- pagination */
.pager { display: flex; gap: .5rem; justify-content: flex-end; align-items: center; margin-top: 1rem;
  color: var(--muted); font-size: .85rem; }
.pager span { margin-right: .5rem; }

/* ---------------------------------------------------------------- portal */
.portal-nav { background: color-mix(in srgb, var(--panel) 85%, transparent); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10; backdrop-filter: saturate(1.6) blur(12px); }
.portal-nav .inner { max-width: 1120px; margin: 0 auto; display: flex; align-items: center; gap: .35rem;
  padding: .7rem 1.25rem; flex-wrap: wrap; }
.portal-nav .brand { margin-right: 1.5rem; }
.portal-nav .brand img { max-height: 40px; max-width: 220px; }
.portal-nav a.tab { color: var(--muted); padding: .45rem .85rem; border-radius: 999px; font-weight: 550;
  font-size: .92rem; display: inline-flex; align-items: center; gap: .45rem; }
.portal-nav a.tab:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.portal-nav a.tab.active { color: var(--accent-ink); background: var(--accent-soft); font-weight: 650; }
.portal-nav .spacer { flex: 1; }
.portal-hero { position: relative; overflow: hidden; border-bottom: 1px solid var(--border);
  background:
    radial-gradient(50% 120% at 0% 0%, color-mix(in srgb, var(--brand) 16%, transparent) 0%, transparent 70%),
    radial-gradient(40% 120% at 100% 0%, color-mix(in srgb, var(--brand) 10%, transparent) 0%, transparent 70%),
    var(--bg); }
.portal-hero .inner { max-width: 1120px; margin: 0 auto; padding: 2.25rem 1.25rem 2rem; }
.portal-hero h1 { font-size: 2rem; }
.portal-hero p { color: var(--text-2); margin: .5rem 0 0; max-width: 46em; white-space: pre-line; }
.portal-main { max-width: 1120px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.license-card .panel-head h2 { font-size: 1.15rem; }
.license-card .grid { gap: 1rem; }
.license-card .metric { background: var(--panel-2); border-radius: var(--radius-sm); padding: .75rem .9rem; }
.license-card .metric strong { font-size: 1.02rem; }

/* ---------------------------------------------------------------- branding page */
.swatch-row { display: flex; gap: .6rem; align-items: center; }
.swatch-row input[type=text] { max-width: 9rem; font-family: var(--mono); }
.asset-tile { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; background: var(--panel-2); }
.asset-tile .preview { height: 72px; border-radius: 8px; display: grid; place-items: center; margin-bottom: .75rem;
  background: var(--panel); border: 1px solid var(--border);
  background-image: linear-gradient(45deg, var(--panel-3) 25%, transparent 25%), linear-gradient(-45deg, var(--panel-3) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--panel-3) 75%), linear-gradient(-45deg, transparent 75%, var(--panel-3) 75%);
  background-size: 14px 14px; background-position: 0 0, 0 7px, 7px -7px, -7px 0; }
.asset-tile .preview.dark { background-color: #0a0e1a; border-color: #222b40;
  background-image: linear-gradient(45deg, #151c2e 25%, transparent 25%), linear-gradient(-45deg, #151c2e 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #151c2e 75%), linear-gradient(-45deg, transparent 75%, #151c2e 75%); }
.asset-tile .preview.dark .muted { color: #8b93a7; }
.asset-tile input[type=file] { font-size: .8rem; }
.asset-tile .preview img { max-height: 52px; max-width: 85%; object-fit: contain; }
.preview-frame { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.preview-frame .pv-bar { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; background: var(--panel);
  border-bottom: 1px solid var(--border); }
.preview-frame .pv-body { padding: 1rem; background: var(--bg); display: grid; gap: .75rem; }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--border);
    padding: .75rem 1rem; flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; }
  .sidebar > .brand { padding: 0; margin-right: auto; }
  .sidebar > .brand img { max-height: 36px; }
  .nav { flex-direction: row; overflow-x: auto; width: 100%; order: 3; gap: .25rem; padding-bottom: .25rem; }
  .nav a { white-space: nowrap; padding: .4rem .65rem; }
  .nav .section { display: none; }
  .userbox { margin: 0; padding: .35rem .5rem; background: none; }
  .userbox .who { display: none; }
  .main { padding: 1.25rem 1rem 3rem; }
  .grid-2, .grid-3, .grid-4, .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  [style*="position:sticky"] { position: static !important; }
  .auth { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }  /* header hugs the logo */
  .auth-art { padding: 1.5rem; min-height: 0; }
  .auth-art h2, .auth-art p, .auth-art .foot { display: none; }
  .auth-art .brand img { max-height: 48px; max-width: min(240px, 100%); }
  h1 { font-size: 1.45rem; }
  .stat .value { font-size: 1.6rem; }
}
@media (max-width: 700px) {
  .hide-sm { display: none; }
  /* Two rows: brand + account on top, the section tabs below. */
  .portal-nav .inner { gap: .15rem; padding: .6rem .75rem .5rem; }
  .portal-nav .brand { margin-right: 0; }
  .portal-nav a.tab { padding: .4rem .6rem; font-size: .88rem; white-space: nowrap; }
  .portal-nav a.tab:not([title]) { order: 1; }
  .portal-nav .spacer { order: 0; }
  .portal-nav .inner::after { content: ""; order: 0; flex-basis: 100%; height: .35rem; }
  .portal-hero .inner { padding: 1.5rem 1rem 1.25rem; }
  .portal-hero h1 { font-size: 1.6rem; }
  .portal-main { padding: 1.25rem 1rem 3rem; }
}
/* ---------------------------------------------------------------- theme switch */
.theme-switch { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--border); }
.theme-switch button { background: none; border: 0; box-shadow: none; padding: .3rem;
  border-radius: 999px; color: var(--muted); line-height: 0; }
.theme-switch button:hover { background: var(--panel-3); color: var(--text); }
.theme-switch button[aria-pressed="true"] { background: var(--panel); color: var(--accent-ink);
  box-shadow: var(--shadow-sm); }
.theme-switch .icon { width: 16px; height: 16px; }
.sidebar > .theme-switch { margin: auto .45rem .6rem; align-self: flex-start; }
.sidebar > .theme-switch + .userbox { margin-top: 0; }
.auth-form { position: relative; }
.auth-form > .theme-switch { position: absolute; right: 1.25rem; bottom: 1.25rem; }

[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; }

/* Page swaps (app.js): a thin bar at the top while the next page loads. */
html.is-loading::before { content: ""; position: fixed; z-index: 1000; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--brand-2)); transform-origin: left;
  animation: page-loading 1.4s ease-out forwards; }
@keyframes page-loading { from { transform: scaleX(.05); } to { transform: scaleX(.9); } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
