:root,
html[data-theme="dark"] {
  --bg: #0D131A;
  --surface: #131C26;
  --surface-2: #182330;
  --stage-bg: #090E14;
  --ink: #F4F1EA;
  --ink-2: #D4CFC4;
  --muted: #98A3B0;
  --line: #233040;
  --line-strong: #324357;
  --sidebar: #090E14;
  --sidebar-2: #131C26;
  --sidebar-ink: #EAE6DF;
  --sidebar-muted: #8E9AA8;
  --sidebar-line: #1E2A38;
  --stone: #C8A97E;
  --stone-hover: #D7BC96;
  --stone-ink: #0D131A;
  --focus: #D7BC96;
  --emerald: #C8A97E;
  --emerald-700: #D7BC96;
  --emerald-50: rgba(200, 169, 126, 0.12);
  --emerald-100: rgba(200, 169, 126, 0.28);
  --ok: #38B27B;
  --ok-bg: rgba(56, 178, 123, 0.14);
  --ok-border: rgba(56, 178, 123, 0.36);
  --ok-ink: #7CE0B1;
  --amber: #E0A445;
  --amber-50: rgba(224, 164, 69, 0.14);
  --amber-border: rgba(224, 164, 69, 0.36);
  --amber-ink: #F5C97B;
  --red: #E05A52;
  --red-50: rgba(224, 90, 82, 0.14);
  --red-border: rgba(224, 90, 82, 0.38);
  --red-ink: #F79892;
  --violet: #B396E8;
  --violet-50: rgba(179, 150, 232, 0.14);
  --violet-border: rgba(179, 150, 232, 0.36);
  --violet-ink: #D4C2F5;
  --blue: #6BA8E5;
  --blue-50: rgba(107, 168, 229, 0.14);
  --blue-border: rgba(107, 168, 229, 0.36);
  --blue-ink: #A3CBF2;
  --input-bg: #0F1720;
  --item-hover: #1A2634;
  --track-bg: #0A0F15;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 6px rgba(0, 0, 0, 0.28), 0 14px 32px rgba(0, 0, 0, 0.32);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "SFMono-Regular", Menlo, monospace;
}

html[data-theme="light"] {
  --bg: #F5F1E8;
  --surface: #FCFBF7;
  --surface-2: #EFEAE0;
  --stage-bg: #E9E2D4;
  --ink: #0D131A;
  --ink-2: #243140;
  --muted: #566270;
  --line: #DED7C8;
  --line-strong: #C5BBA7;
  --sidebar: #0D131A;
  --sidebar-2: #16202C;
  --sidebar-ink: #F4F1EA;
  --sidebar-muted: #98A3B0;
  --sidebar-line: #212E3D;
  --stone: #C8A97E;
  --stone-hover: #B39062;
  --stone-ink: #0D131A;
  --focus: #7A5B32;
  --emerald: #7A5B32;
  --emerald-700: #5E4422;
  --emerald-50: #F4EDE1;
  --emerald-100: #E2D2BA;
  --ok: #156C47;
  --ok-bg: #E6F4EC;
  --ok-border: #B9E0CB;
  --ok-ink: #0E5235;
  --amber: #8F5B0D;
  --amber-50: #FDF3DF;
  --amber-border: #EBD09E;
  --amber-ink: #6E4506;
  --red: #A8241C;
  --red-50: #FCECEB;
  --red-border: #EBB8B3;
  --red-ink: #7F1812;
  --violet: #5B389E;
  --violet-50: #F1ECFA;
  --violet-border: #D5C6F0;
  --violet-ink: #46287D;
  --blue: #1D558F;
  --blue-50: #E8F1FA;
  --blue-border: #BFD6EE;
  --blue-ink: #15406E;
  --input-bg: #FFFFFF;
  --item-hover: #F7F4EC;
  --track-bg: #E4DDD0;
  --shadow: 0 1px 3px rgba(13, 19, 26, 0.06), 0 8px 24px rgba(13, 19, 26, 0.06);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  color-scheme: dark light;
}

html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

body {
  margin: 0;
  font: 15px/1.55 var(--font);
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.22;
  color: var(--ink);
}

h1,
h2 {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.015em;
}

h1 {
  font-size: 1.75rem;
}

h2 {
  font-size: 1.32rem;
}

h3 {
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}

h4 {
  font-family: var(--font);
  font-size: 0.92rem;
  font-weight: 600;
}

p {
  margin: 0;
}

a {
  color: var(--emerald-700);
  text-underline-offset: 3px;
}

img {
  max-width: 100%;
  display: block;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  background: var(--stone);
  color: var(--stone-ink);
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

.muted {
  color: var(--muted);
}

.fineprint {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
}

.mono {
  font-family: var(--mono);
  font-size: 0.86rem;
}

.stack {
  display: grid;
  gap: 22px;
}

.stack-sm {
  display: grid;
  gap: 8px;
}

.boot {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  background: var(--bg);
}

.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  padding: 12px 0;
}

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--emerald-100);
  border-top-color: var(--stone);
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--stone), #9E7B4F);
  color: var(--stone-ink);
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 430px);
  grid-template-rows: auto 1fr;
  gap: 24px 48px;
  align-items: center;
  justify-content: center;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 32px 40px;
  background:
    radial-gradient(circle at 12% 16%, rgba(200, 169, 126, 0.1), transparent 42%),
    radial-gradient(circle at 88% 85%, rgba(107, 168, 229, 0.06), transparent 45%),
    var(--bg);
}

.auth-toolbar {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.theme-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.theme-switch button:hover {
  color: var(--ink);
}

.theme-switch button[aria-pressed="true"] {
  background: var(--stone);
  color: var(--stone-ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.auth-intro {
  display: grid;
  gap: 18px;
  padding: 12px 0;
  max-width: 540px;
}

.eyebrow {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--stone);
}

html[data-theme="light"] .eyebrow {
  color: var(--emerald);
}

.auth-intro h2 {
  font-size: clamp(1.85rem, 3.2vw, 2.5rem);
  line-height: 1.14;
  letter-spacing: -0.02em;
}

.auth-intro > p {
  color: var(--ink-2);
  font-size: 1.02rem;
  line-height: 1.6;
}

.auth-drawing {
  position: relative;
  height: 168px;
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, rgba(200, 169, 126, 0.06), transparent),
    var(--surface);
  border: 1px solid var(--line);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.8fr;
  gap: 14px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.auth-drawing::before {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px dashed var(--line-strong);
  border-radius: calc(var(--radius) - 4px);
  pointer-events: none;
  opacity: 0.55;
}

.auth-drawing span {
  position: relative;
  display: block;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: linear-gradient(145deg, rgba(200, 169, 126, 0.14), rgba(19, 28, 38, 0.04));
}

.auth-drawing span:nth-child(1) {
  border-color: var(--stone);
  background:
    linear-gradient(160deg, rgba(200, 169, 126, 0.22) 0%, transparent 72%),
    var(--surface-2);
}

.auth-drawing span:nth-child(2) {
  margin-top: 18px;
  background:
    linear-gradient(180deg, rgba(107, 168, 229, 0.12), transparent),
    var(--surface-2);
}

.auth-drawing span:nth-child(3) {
  margin-bottom: 22px;
  border-style: solid;
  background: var(--surface-2);
}

.auth-intro-note {
  font-size: 0.84rem;
  color: var(--muted) !important;
  border-left: 2px solid var(--stone);
  padding-left: 12px;
}

/* The general portal has its own illustration; office portfolios stay scoped. */
.auth-drawing {
  display: block;
  height: auto;
  padding: 0;
  margin: 0;
  background: #14232e;
}
.auth-drawing::before { display: none; }
.auth-drawing svg { display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; }
.auth-drawing figcaption {
  padding: 10px 16px;
  color: #ded5c4;
  font-size: .8rem;
  border-top: 1px solid rgba(229, 217, 194, .14);
}
.auth-office-directory { display: grid; gap: 10px; margin: 22px 0; }
.auth-office-directory h2 { font-size: 1rem; }
.auth-office-list { display: grid; gap: 10px; }
.auth-office-link {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
  transition: border-color .15s ease, background-color .15s ease;
}
.auth-office-link:hover { border-color: var(--stone); background: var(--surface); }
.auth-office-link img { width: 64px; height: 46px; object-fit: contain; flex: 0 0 64px; }
.auth-office-link > span { display: grid; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.auth-office-link .auth-office-arrow { margin-left: auto; color: var(--stone); font-size: 1.3rem; }

.auth-card {
  width: 100%;
  max-width: 430px;
  justify-self: end;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-brand .brand-mark {
  width: 44px;
  height: 44px;
  font-size: 1.3rem;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 4px;
}

.tab {
  border: 0;
  background: transparent;
  padding: 8px 10px;
  border-radius: 7px;
  font: inherit;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

.form {
  display: grid;
  gap: 14px;
}

.form-row {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
}

.form-inline {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.field-label {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink-2);
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--input-bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  min-height: 40px;
}

input[type="file"] {
  font: inherit;
  width: 100%;
  padding: 8px;
  color: var(--ink-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  border-color: var(--stone);
  outline-offset: 0;
}

input[readonly] {
  background: var(--surface-2);
  color: var(--ink-2);
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--stone);
  width: 18px;
  height: 18px;
  margin: 2px 0 0;
  flex: none;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

legend {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--ink-2);
  margin-bottom: 8px;
  padding: 0;
}

.check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  cursor: pointer;
}

.providers {
  display: grid;
  gap: 10px;
}

.provider-option {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.provider-option > span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.provider-option:has(input:checked) {
  border-color: var(--stone);
  background: var(--emerald-50);
}

.provider-option.is-disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.gemini-block {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--amber-border);
  background: var(--amber-50);
  color: var(--ink);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.2;
  padding: 10px 16px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.is-busy {
  cursor: progress;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 6px 10px;
  min-height: 32px;
  font-size: 0.84rem;
}

.btn-primary {
  background: var(--stone);
  color: var(--stone-ink);
  border-color: var(--stone);
}

.btn-primary:hover:not(:disabled) {
  background: var(--stone-hover);
  border-color: var(--stone-hover);
}

.btn-warn {
  background: var(--amber);
  color: #0D131A;
}

html[data-theme="light"] .btn-warn {
  color: #FFFFFF;
}

.btn-warn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--stone);
  color: var(--emerald-700);
}

html[data-theme="light"] .btn-secondary:hover:not(:disabled) {
  color: var(--ink);
}

.btn-danger {
  background: var(--red);
  color: #FFFFFF;
}

html[data-theme="dark"] .btn-danger { color: #0D131A; }

.btn-danger-ghost {
  background: transparent;
  color: var(--red-ink);
  border-color: var(--red-border);
}

.btn-danger-ghost:hover:not(:disabled) {
  background: var(--red-50);
}

.btn-link {
  background: none;
  border: 0;
  padding: 4px 6px;
  min-height: 0;
  color: var(--emerald-700);
  text-decoration: underline;
}

html[data-theme="light"] .btn-link {
  color: var(--emerald);
}

.btn-sidebar {
  width: 100%;
  background: transparent;
  color: var(--sidebar-ink);
  border-color: var(--sidebar-line);
}

.btn-sidebar:hover {
  background: var(--sidebar-2);
  border-color: var(--stone);
}

.notice {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid;
  font-size: 0.92rem;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
}

.notice.stack-sm {
  display: grid;
  align-items: start;
}

.notice-info {
  background: var(--blue-50);
  border-color: var(--blue-border);
  color: var(--blue-ink);
}

.notice-error {
  background: var(--red-50);
  border-color: var(--red-border);
  color: var(--red-ink);
}

.notice-warn {
  background: var(--amber-50);
  border-color: var(--amber-border);
  color: var(--amber-ink);
}

.notice-mock {
  background: var(--violet-50);
  border-color: var(--violet-border);
  color: var(--violet-ink);
  display: block;
}

.shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-ink);
  border-right: 1px solid var(--sidebar-line);
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px;
}

.brand-text {
  display: grid;
  min-width: 0;
}

.brand-text strong {
  color: #F4F1EA;
  font-family: var(--font-display);
  font-size: 1.12rem;
  letter-spacing: -0.01em;
}

.brand-office {
  color: var(--sidebar-muted);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav {
  display: grid;
  gap: 4px;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 9px;
  color: var(--sidebar-ink);
  text-decoration: none;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav a:hover {
  background: var(--sidebar-2);
}

.nav a[aria-current="page"] {
  background: rgba(200, 169, 126, 0.16);
  color: #FFFFFF;
  box-shadow: inset 3px 0 0 var(--stone);
}

.nav svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  flex: none;
  opacity: 0.88;
}

.nav a[aria-current="page"] svg {
  color: var(--stone);
  opacity: 1;
}

.nav-badge {
  margin-left: auto;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 11px;
  background: var(--stone);
  color: var(--stone-ink);
  font-size: 0.75rem;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
}

.sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 12px;
  padding: 14px 6px 0;
  border-top: 1px solid var(--sidebar-line);
}

.user {
  display: grid;
  min-width: 0;
}

.user-name {
  color: #F4F1EA;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role {
  color: var(--sidebar-muted);
  font-size: 0.82rem;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: 44px;
  padding: 12px 32px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

.sync {
  font-size: 0.82rem;
  color: var(--muted);
  margin-right: auto;
}

.sync-error {
  color: var(--red-ink);
}

.view-wrap {
  padding: 12px 32px 56px;
  outline: none;
}

#view {
  max-width: 1280px;
  margin: 0 auto;
  display: grid;
  gap: 24px;
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  justify-content: space-between;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}

.page-head h1:focus {
  outline: none;
}

.page-head p {
  margin-top: 4px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  align-content: start;
  min-width: 0;
}

.panel-compact {
  padding: 14px 16px;
}

.panel-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
}

.panel summary {
  cursor: pointer;
  font-weight: 600;
}

details.panel[open] summary {
  margin-bottom: 4px;
}

.subhead {
  font-size: 0.92rem;
  margin-top: 6px;
}

.grid-2 {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.grid-wide-left {
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
}

.split {
  display: grid;
  gap: 22px;
  grid-template-columns: 300px minmax(0, 1fr);
  align-items: start;
}

.split-aside {
  display: grid;
  gap: 14px;
  position: sticky;
  top: 16px;
  max-height: calc(100vh - 32px);
  grid-template-rows: auto minmax(0, 1fr);
}

.list {
  overflow-y: auto;
  min-height: 0;
}

.list-empty {
  padding: 8px 4px;
}

.detail {
  display: grid;
  gap: 20px;
  min-width: 0;
}

.detail-head {
  display: grid;
  gap: 4px;
}

.detail-title {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.item-list,
.job-mini,
.token-list,
.bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.item {
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.item:hover {
  border-color: var(--line-strong);
  background: var(--item-hover);
}

.item.is-active {
  border-color: var(--stone);
  background: var(--emerald-50);
  box-shadow: inset 3px 0 0 var(--stone);
}

.item-title {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-sub {
  color: var(--muted);
  font-size: 0.84rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.item-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.84rem;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  white-space: nowrap;
}

.badge-mock {
  background: var(--violet-50);
  border-color: var(--violet-border);
  color: var(--violet-ink);
}

.badge-ai {
  background: var(--blue-50);
  border-color: var(--blue-border);
  color: var(--blue-ink);
}

.badge-score {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-ink);
}

.badge-expired {
  background: var(--red-50);
  border-color: var(--red-border);
  color: var(--red-ink);
}

.badge-role-admin {
  background: var(--emerald-50);
  border-color: var(--emerald-100);
  color: var(--emerald-700);
}

html[data-theme="light"] .badge-role-admin {
  color: var(--emerald);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid transparent;
}

.chip::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

.chip-queued {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--ink-2);
}

.chip-running {
  background: var(--blue-50);
  border-color: var(--blue-border);
  color: var(--blue-ink);
}

.chip-running::before {
  animation: pulse 1.2s ease-in-out infinite;
}

.chip-assembling {
  background: var(--emerald-50);
  border-color: var(--emerald-100);
  color: var(--emerald-700);
}

html[data-theme="light"] .chip-assembling {
  color: var(--emerald);
}

.chip-assembling::before {
  animation: pulse 1.2s ease-in-out infinite;
}

.chip-ready {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-ink);
}

.chip-review {
  background: var(--amber-50);
  border-color: var(--amber-border);
  color: var(--amber-ink);
}

.chip-approved {
  background: var(--stone);
  color: var(--stone-ink);
}

.chip-failed {
  background: var(--red-50);
  border-color: var(--red-border);
  color: var(--red-ink);
}

.chip-uncertain {
  background: var(--amber-50);
  color: var(--amber-ink);
  border-color: var(--amber-border);
}

.chip-unknown {
  background: var(--surface-2);
  border-color: var(--line);
  color: var(--muted);
}

@keyframes pulse {
  50% {
    opacity: 0.25;
  }
}

.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 3px;
}

.seg {
  font: inherit;
  font-weight: 600;
  font-size: 0.88rem;
  border: 0;
  background: transparent;
  padding: 7px 14px;
  border-radius: 7px;
  color: var(--muted);
  cursor: pointer;
}

.seg.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14);
}

.cards {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 6px;
  align-content: start;
}

.kpi-mock {
  border-top: 3px solid var(--violet);
}

.kpi-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-value {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.kpi-missing {
  color: var(--muted);
  font-size: 1.1rem;
  font-weight: 600;
}

.kpi-note {
  font-size: 0.8rem;
  color: var(--muted);
}

.bars {
  gap: 14px;
}

.bar-row {
  display: grid;
  gap: 5px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
}

.bar-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-value {
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.bar-track {
  height: 10px;
  border-radius: 6px;
  background: var(--track-bg);
  border: 1px solid var(--line);
  overflow: hidden;
}

.bar-fill {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--stone), #E2C79F);
}

.bar-meta {
  font-size: 0.78rem;
  color: var(--muted);
}

.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  text-align: center;
  padding: 44px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.empty p {
  color: var(--muted);
  max-width: 440px;
}

.empty-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  margin-bottom: 4px;
  background:
    linear-gradient(135deg, transparent 46%, var(--emerald-100) 46%, var(--emerald-100) 54%, transparent 54%),
    var(--emerald-50);
  border: 1px solid var(--emerald-100);
}

.project-preview {
  margin: 0;
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--line);
}

.project-preview-empty {
  display: grid;
  place-items: center;
  text-align: center;
  gap: 8px;
  min-height: 180px;
  padding: 28px 20px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong);
  background: var(--surface);
  color: var(--muted);
}

.project-preview-kicker {
  font-size: 0.76rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--stone);
}

html[data-theme="light"] .project-preview-kicker {
  color: var(--emerald);
}

.project-preview-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--emerald-700);
  text-decoration: none;
}

.project-preview-link:hover {
  text-decoration: underline;
}

.project-preview figure {
  margin: 0;
  display: grid;
  gap: 10px;
}

.project-preview-image,
.project-preview figure img {
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 460px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: var(--stage-bg);
  border: 1px solid var(--line);
}

.project-preview-caption,
.project-preview figcaption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  font-size: 0.88rem;
  color: var(--ink-2);
}

.project-preview-caption > span { display: grid; gap: 4px; }
.project-preview-caption strong { font-weight: 600; }

.export-list {
  display: grid;
  gap: 8px;
}

.export-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  cursor: pointer;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.export-item:has(input:checked) {
  border-color: var(--stone);
  background: var(--emerald-50);
}

.export-body {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  align-items: center;
}

.thumbs {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
}

.thumb {
  margin: 0;
  display: grid;
  gap: 6px;
}

.thumb img,
.pane img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--stage-bg);
  border: 1px solid var(--line);
}

.thumb figcaption {
  font-size: 0.82rem;
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.img-missing {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm);
  background: repeating-linear-gradient(
    45deg,
    var(--surface-2),
    var(--surface-2) 10px,
    var(--stage-bg) 10px,
    var(--stage-bg) 20px
  );
  color: var(--muted);
  font-size: 0.84rem;
  text-align: center;
  padding: 8px;
  border: 1px solid var(--line);
}

.members {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}

.member {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.member:has(input:checked) {
  border-color: var(--stone);
  background: var(--emerald-50);
}

.member > span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
  margin: 0;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  display: grid;
  gap: 2px;
}

.stat dt {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 600;
}

.stat dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat dd.kpi-missing {
  font-size: 1rem;
}

.stat .stat-note {
  font-weight: 400;
  font-size: 0.76rem;
  color: var(--muted);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.gallery {
  display: grid;
  gap: 18px;
}

.compare {
  display: grid;
  gap: 10px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.compare:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.compare-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.compare-head h3 {
  margin-right: auto;
  overflow-wrap: anywhere;
}

.compare-panes {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.pane {
  margin: 0;
  display: grid;
  gap: 6px;
  position: relative;
}

.pane figcaption {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.pane-mock img {
  border-color: var(--violet-border);
}

.pane-ribbon {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(91, 56, 158, 0.92);
  color: #FFFFFF;
  font-size: 0.74rem;
  font-weight: 700;
}

.table-wrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.table th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
}

.table tr:last-child td {
  border-bottom: 0;
}

.cred-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.dot-on {
  background: var(--ok);
  box-shadow: 0 0 0 4px var(--ok-bg);
}

.dot-off {
  background: var(--muted);
  box-shadow: 0 0 0 4px var(--surface-2);
}

.danger-zone {
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.copy-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.copy-row input {
  flex: 1 1 200px;
  min-width: 0;
}

.token {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.token-id {
  margin-right: auto;
  overflow-wrap: anywhere;
}

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(400px, calc(100vw - 32px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 12px 16px;
  border-radius: 10px;
  background: var(--sidebar);
  color: #F4F1EA;
  border: 1px solid var(--line-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  font-size: 0.92rem;
}

.toast > span {
  flex: 1;
}

.toast-success {
  background: #0F4D34;
  border-color: var(--ok-border);
}

.toast-error {
  background: #7A1C16;
  border-color: var(--red-border);
}

.toast .btn-link {
  color: #FFFFFF;
}

.toast-close {
  background: none;
  border: 0;
  color: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  opacity: 0.85;
}

.office-identity {
  margin: 0 0 22px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.office-signature {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 6px 0 14px;
}

.office-signature strong,
.office-signature span {
  display: block;
}

.office-logo {
  width: 116px;
  max-width: 100%;
  height: 62px;
  object-fit: contain;
  background: #0D131A;
  border: 1px solid var(--sidebar-line);
  border-radius: 8px;
  padding: 8px;
}

.office-sidebar {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--sidebar-line);
  margin: 4px 6px 8px;
  padding: 12px;
}

.office-sidebar .office-signature {
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
}

.office-sidebar .office-logo {
  width: 145px;
  max-width: 100%;
  height: 74px;
}

.office-sidebar .fineprint {
  color: var(--sidebar-muted);
}

.platform-credit {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0;
}

.sidebar-foot .platform-credit {
  color: var(--sidebar-muted);
  margin: 0;
}

.auth-brand .office-logo {
  width: 116px;
  min-width: 96px;
  max-width: 100%;
  height: 70px;
}

@media (max-width: 1100px) {
  .split {
    grid-template-columns: 260px minmax(0, 1fr);
  }
  .grid-wide-left {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .auth {
    grid-template-columns: 1fr;
    max-width: 520px;
    padding: 20px 16px 36px;
    gap: 20px;
  }
  .auth-card {
    justify-self: stretch;
    max-width: none;
  }
  .shell {
    grid-template-columns: minmax(0, 1fr);
  }
  .sidebar {
    min-width: 0;
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    padding: 10px 12px;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--sidebar-line);
  }
  .brand {
    flex: 1;
    min-width: 0;
  }
  .office-sidebar {
    display: block;
    margin: 0 auto 0 0;
    padding: 0;
    border: 0;
    background: transparent;
  }
  .office-sidebar .office-signature {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
  .office-sidebar .office-logo {
    width: 60px;
    height: 40px;
    padding: 4px;
  }
  .office-sidebar .fineprint {
    display: none;
  }
  .sidebar-foot {
    margin: 0;
    padding: 0;
    border: 0;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .sidebar-foot .platform-credit,
  .user {
    display: none;
  }
  .btn-sidebar {
    width: auto;
    min-height: 34px;
    padding: 6px 12px;
  }
  .nav {
    min-width: 0;
    max-width: 100%;
    order: 3;
    flex-basis: 100%;
    display: flex;
    overflow-x: auto;
    gap: 4px;
    scrollbar-width: none;
  }
  .nav a {
    flex: none;
    padding: 8px 12px;
  }
  .nav a[aria-current="page"] {
    box-shadow: inset 0 -3px 0 var(--stone);
  }
  .topbar {
    padding: 10px 16px 0;
  }
  .view-wrap {
    padding: 10px 16px 40px;
  }
  .split,
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .split-aside {
    position: static;
    max-height: none;
  }
  .list {
    max-height: 320px;
  }
}

@media (max-width: 560px) {
  .btn { white-space: normal; }
  .auth-card, .form, .field { min-width: 0; }
  .copy-row { flex-wrap: wrap; }
  .copy-row input { flex-basis: 100%; }
  h1 {
    font-size: 1.38rem;
  }
  .auth-card {
    padding: 20px 16px;
  }
  .auth-drawing {
    height: 132px;
    padding: 14px;
  }
  .compare-panes {
    grid-template-columns: 1fr;
  }
  .form-inline {
    grid-template-columns: 1fr;
  }
  .panel {
    padding: 16px;
  }
  .kpi-value {
    font-size: 1.5rem;
  }
  .page-actions {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Render setup stays local to a view; no photographic filters. */
.scene-selection { display: grid; gap: 14px; }
.scene-choice { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.scene-preview { display: block; width: 100%; max-width: 360px; max-height: 210px; object-fit: contain; margin: 10px 0; }
.lighting-settings { min-width: 0; padding: 12px 0; }
.lighting-settings > summary { cursor: pointer; font-weight: 600; margin-bottom: 12px; }
.light-editor, .scene-review-actions { min-width: 0; }
.scene-review-actions { display: grid; gap: 12px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.retry-options { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
.fixture-fields { display: flex; flex-wrap: wrap; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; }
.fixture-fields[hidden] { display: none; }

/* The public portfolio belongs only to the office named in the login URL. */
.auth.has-portfolio {
  max-width: 1440px;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 430px);
  gap: 24px 56px;
}
.has-portfolio .auth-intro {
  position: relative;
  isolation: isolate;
  max-width: none;
  min-height: clamp(520px, 76vh, 840px);
  padding: 36px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 16px;
  border-radius: 18px;
  overflow: hidden;
  background: #0d131a;
  box-shadow: var(--shadow);
}
.auth-portfolio {
  position: absolute;
  inset: 0;
  margin: 0;
  z-index: -1;
}
.auth-portfolio img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
}
.auth-portfolio::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(9, 13, 18, .42), transparent 35%, rgba(9, 13, 18, .94) 100%);
}
.auth-portfolio figcaption {
  position: absolute;
  top: 32px;
  right: 32px;
  left: 32px;
  z-index: 1;
  color: #f4f1ea;
  font-size: .72rem;
  line-height: 1.5;
  text-shadow: 0 1px 4px #0d131a;
}
.has-portfolio .auth-intro .eyebrow {
  color: #e5d3b8;
  margin-bottom: 4px;
}
.has-portfolio .auth-intro h2 {
  color: #f4f1ea;
  font-size: clamp(2rem, 3.3vw, 3.1rem);
  text-wrap: balance;
}
.has-portfolio .auth-intro > p { color: #e2ded6; }
.has-portfolio .auth-drawing { display: none; }
.has-portfolio .auth-intro-note { color: #d6d0c4 !important; }
@media (max-width: 900px) {
  .auth.has-portfolio {
    grid-template-columns: minmax(0, 1fr);
    max-width: 560px;
    gap: 20px;
  }
  .has-portfolio .auth-toolbar { grid-row: 1; }
  .has-portfolio .auth-card { grid-row: 2; }
  .has-portfolio .auth-intro {
    grid-row: 3;
    min-height: 400px;
    padding: 24px;
  }
  .auth-portfolio figcaption { top: 20px; left: 24px; right: 24px; }
}
/* Readable, selectable instructions before a paid generation is requested. */
.prompt-preview-text {
  width: 100%;
  min-height: 20rem;
  padding: 1rem;
  resize: vertical;
  color: var(--text, var(--ink));
  background: var(--surface, var(--panel));
  border: 1px solid var(--line);
  border-radius: 10px;
  font: 0.875rem/1.55 ui-monospace, Consolas, monospace;
}
.prompt-preview-scene { min-width: 0; }
.prompt-preview-scene > summary { cursor: pointer; font-weight: 600; margin-bottom: 0.75rem; }
.tracking-wrap { padding: 0 32px; }
.tracking-banner { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface, var(--panel)); }
.tracking-banner p { margin: 4px 0; }
@media (max-width: 700px) {
  .tracking-wrap { padding: 0 16px; }
  .tracking-banner { flex-direction: column; align-items: flex-start; }
}
