* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg-0: #0a1830;
  --bg-1: #0d1f3c;
  --panel: #12233f;
  --panel-2: #15294a;
  --border: #263f63;
  --border-soft: rgba(38, 63, 99, 0.6);
  --accent: #2f6fb0;
  --accent-bright: #4a9fe0;
  --text: #eaf1fb;
  --text-muted: #9db3d0;
  --positive: #3fbf87;
  --warning: #e0a53c;
  --negative: #e5674f;
  --font: Arial, Helvetica, "Segoe UI", system-ui, sans-serif;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow: 0 22px 48px rgba(3, 8, 18, 0.5);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg-0: #eef2f8;
  --bg-1: #e4eaf3;
  --panel: #ffffff;
  --panel-2: #f4f7fb;
  --border: #d3ddec;
  --border-soft: rgba(211, 221, 236, 0.8);
  --text: #101a2c;
  --text-muted: #52627c;
  --shadow: 0 16px 36px rgba(20, 34, 58, 0.1);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg-0: #eef2f8;
    --bg-1: #e4eaf3;
    --panel: #ffffff;
    --panel-2: #f4f7fb;
    --border: #d3ddec;
    --border-soft: rgba(211, 221, 236, 0.8);
    --text: #101a2c;
    --text-muted: #52627c;
    --shadow: 0 16px 36px rgba(20, 34, 58, 0.1);
  }
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at 12% -10%, rgba(74, 159, 224, 0.14), transparent 42rem),
    linear-gradient(180deg, var(--bg-0) 0%, var(--bg-1) 100%);
}

.hidden {
  display: none !important;
}

/* ---------------------------------------------------------------------- */
/* Estate Test-environment banner                                          */
/* ---------------------------------------------------------------------- */

.test-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  height: 48px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 0 16px;
  background: #8a1f2d;
  color: #fff;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* Push the full-height app shell below the fixed banner and shrink it so the
   sidebar / view-root internal scroll areas stay within the viewport. The
   login shell already reserves this space via the body.auth-shell padding. */
body.has-test-banner .app-shell {
  margin-top: 48px;
  min-height: calc(100vh - 48px);
  grid-template-rows: calc(100vh - 48px);
}

body.has-test-banner .main-col {
  height: calc(100vh - 48px);
}

/* The banner already announces the environment; drop the redundant topbar chip. */
body.has-test-banner .env-badge {
  display: none;
}

@media (max-width: 980px) {
  body.has-test-banner .app-shell {
    grid-template-rows: auto 1fr;
  }
  body.has-test-banner .main-col {
    height: auto;
  }
}

a {
  color: var(--accent-bright);
}

button {
  font-family: inherit;
}

/* ---------------------------------------------------------------------- */
/* Login shell                                                             */
/* ---------------------------------------------------------------------- */

body.auth-shell {
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(180deg, rgba(7, 13, 26, 0.5), rgba(8, 16, 32, 0.78)),
    url('./assets/login-bg.svg?v=20260731a') center / cover no-repeat,
    #0a1830;
}

body.auth-shell .app-shell,
body.auth-shell .env-badge {
  display: none;
}

body:not(.auth-shell) #loginShell {
  display: none;
}

#loginShell.login-shell {
  width: min(440px, 100%);
  padding: 32px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(18, 35, 63, 0.96);
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.login-brand-icon {
  width: 76px;
  height: 76px;
}

.login-brand-title {
  margin: 0;
  font: 800 26px/1.15 var(--font);
  letter-spacing: -0.01em;
}

.login-tagline {
  margin: 2px 0 0;
  color: var(--accent-bright);
  font-size: 0.86rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-subtagline {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.btn-ms {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-content: center;
  width: 100%;
  padding: 13px 18px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.btn-ms:hover {
  background: var(--accent-bright);
}

.btn-ms svg {
  width: 18px;
  height: 18px;
}

.auth-message {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(229, 103, 79, 0.16);
  color: var(--negative);
  line-height: 1.45;
  font-size: 0.9rem;
}

.auth-message[data-tone="info"] {
  background: rgba(47, 111, 176, 0.16);
  color: var(--accent-bright);
}

.login-copy {
  margin: 18px 0 0;
  color: var(--text-muted);
  line-height: 1.5;
  font-size: 0.9rem;
}

.login-footer-motto {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: 0.76rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------------- */
/* App shell layout                                                        */
/* ---------------------------------------------------------------------- */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 100vh;
  min-height: 100vh;
}

.sidebar {
  grid-row: 1 / -1;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(10, 24, 48, 0.82);
  padding: 20px 14px;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border-soft);
}

.sidebar-brand img {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
}

.sidebar-brand-text {
  min-width: 0;
}

.sidebar-brand-text strong {
  display: block;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  line-height: 1.15;
}

.sidebar-brand-text span {
  display: block;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 2px;
}

.nav-section-label {
  margin: 16px 8px 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav-list {
  display: grid;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-link:hover {
  background: rgba(74, 159, 224, 0.1);
  color: var(--text);
}

.nav-link.active {
  background: linear-gradient(135deg, rgba(47, 111, 176, 0.32), rgba(74, 159, 224, 0.16));
  border-color: var(--border);
  color: var(--text);
}

.nav-link .nav-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  opacity: 0.9;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: 10.5px;
  line-height: 1.5;
}

.main-col {
  display: grid;
  grid-template-rows: auto 1fr;
  min-width: 0;
  height: 100vh;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 24, 48, 0.6);
}

.topbar-title {
  min-width: 0;
}

.topbar-title h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.topbar-title p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.env-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: rgba(224, 165, 60, 0.18);
  color: var(--warning);
  border: 1px solid rgba(224, 165, 60, 0.4);
}

.env-badge[data-env="local"] {
  background: rgba(229, 103, 79, 0.16);
  color: var(--negative);
  border-color: rgba(229, 103, 79, 0.4);
}

.session-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--panel);
  cursor: pointer;
  position: relative;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #17385c);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  flex: 0 0 auto;
}

.session-chip-meta {
  display: grid;
  line-height: 1.2;
  text-align: left;
}

.session-chip-meta strong {
  font-size: 12.5px;
  font-weight: 700;
}

.session-chip-meta span {
  font-size: 10.5px;
  color: var(--text-muted);
}

.user-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 40;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.user-menu button {
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.user-menu button:hover {
  background: rgba(74, 159, 224, 0.12);
}

.view-root {
  overflow-y: auto;
  padding: 22px 26px 60px;
}

/* ---------------------------------------------------------------------- */
/* Generic building blocks                                                 */
/* ---------------------------------------------------------------------- */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}

.card + .card,
.stack > * + * {
  margin-top: 16px;
}

.stack {
  display: grid;
}

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

.row.between {
  justify-content: space-between;
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.card-head h2, .card-head h3 {
  margin: 0;
}

.eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 10.5px;
  font-weight: 800;
  color: var(--accent-bright);
}

h1, h2, h3, h4 {
  font-family: var(--font);
  color: var(--text);
}

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

.grid {
  display: grid;
  gap: 16px;
}

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

.kpi-tile {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: grid;
  gap: 4px;
}

.kpi-tile .kpi-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
}

.kpi-tile strong {
  font-size: 1.5rem;
}

.kpi-tile.tone-positive strong { color: var(--positive); }
.kpi-tile.tone-warning strong { color: var(--warning); }
.kpi-tile.tone-negative strong { color: var(--negative); }

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 9px 16px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--accent);
}

.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  border-color: transparent;
  color: #fff;
}

.btn.primary:hover {
  filter: brightness(1.08);
}

.btn.danger {
  border-color: rgba(229, 103, 79, 0.4);
  color: var(--negative);
}

.btn.danger:hover {
  background: rgba(229, 103, 79, 0.12);
}

.btn.small {
  padding: 6px 11px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Forms */

label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  display: block;
  margin-bottom: 5px;
}

.field {
  display: grid;
  gap: 4px;
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="email"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-0);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
}

:root[data-theme="light"] input,
:root[data-theme="light"] select,
:root[data-theme="light"] textarea {
  background: #fff;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent-bright);
  outline-offset: 1px;
}

.checkbox-field {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-field label {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

/* Tables */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-soft);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.8px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  padding: 9px 12px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
}

th.num, td.num {
  text-align: right;
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}

tbody tr:hover {
  background: rgba(74, 159, 224, 0.06);
}

tbody tr.clickable {
  cursor: pointer;
}

td input, td select {
  padding: 6px 8px;
  font-size: 12.5px;
}

.empty-row td, .loading-row td, .error-row td {
  text-align: center;
  padding: 30px 12px;
  color: var(--text-muted);
}

.error-row td {
  color: var(--negative);
}

/* Chips / badges */

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  background: rgba(157, 179, 208, 0.16);
  color: var(--text-muted);
}

.chip.tone-positive { background: rgba(63, 191, 135, 0.16); color: var(--positive); }
.chip.tone-warning { background: rgba(224, 165, 60, 0.16); color: var(--warning); }
.chip.tone-negative { background: rgba(229, 103, 79, 0.16); color: var(--negative); }
.chip.tone-accent { background: rgba(74, 159, 224, 0.16); color: var(--accent-bright); }

.num-positive { color: var(--positive); }
.num-warning { color: var(--warning); }
.num-negative { color: var(--negative); }

/* Status / toast messages */

.status-banner {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(74, 159, 224, 0.1);
  color: var(--accent-bright);
  font-size: 13px;
}

.status-banner[data-tone="error"] {
  background: rgba(229, 103, 79, 0.14);
  color: var(--negative);
}

.status-banner[data-tone="success"] {
  background: rgba(63, 191, 135, 0.14);
  color: var(--positive);
}

.status-banner[data-tone="warning"] {
  background: rgba(224, 165, 60, 0.14);
  color: var(--warning);
}

.toast-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 500;
  display: grid;
  gap: 8px;
}

.toast {
  min-width: 260px;
  max-width: 380px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: 13px;
}

.toast[data-tone="error"] { border-color: rgba(229, 103, 79, 0.5); color: var(--negative); }
.toast[data-tone="success"] { border-color: rgba(63, 191, 135, 0.5); color: var(--positive); }

/* Workflow stepper */

.stepper {
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  padding: 4px 0;
}

.stepper-step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  position: relative;
  white-space: nowrap;
}

.stepper-step:not(:last-child)::after {
  content: "";
  width: 28px;
  height: 1px;
  background: var(--border);
  margin-left: 8px;
}

.stepper-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 800;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  flex: 0 0 auto;
}

.stepper-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.stepper-step.done .stepper-dot {
  background: var(--positive);
  border-color: var(--positive);
  color: #06281a;
}

.stepper-step.done .stepper-label {
  color: var(--text);
}

.stepper-step.current .stepper-dot {
  background: var(--accent-bright);
  border-color: var(--accent-bright);
  color: #06182c;
}

.stepper-step.current .stepper-label {
  color: var(--text);
}

/* Baseline timeline */

.baseline-timeline {
  display: grid;
  gap: 10px;
}

.baseline-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--panel-2);
}

.baseline-item .baseline-type {
  font-weight: 800;
  font-size: 13px;
}

.baseline-item .baseline-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.baseline-item .baseline-figures {
  text-align: right;
  font-size: 12.5px;
}

/* Margin explainer */

.margin-explainer {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  padding: 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(47, 111, 176, 0.12), rgba(74, 159, 224, 0.04));
}

.margin-explainer .figure {
  display: grid;
  gap: 2px;
}

.margin-explainer .figure-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.margin-explainer .figure-value {
  font-size: 1.4rem;
  font-weight: 800;
}

.margin-note {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--text-muted);
  border-top: 1px solid var(--border-soft);
  padding-top: 10px;
  margin-top: 4px;
}

/* Variance groups */

.variance-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.variance-group {
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  padding: 14px;
}

.variance-group.preventable {
  border-color: rgba(229, 103, 79, 0.4);
  background: rgba(229, 103, 79, 0.06);
}

.variance-group.recoverable {
  border-color: rgba(63, 191, 135, 0.4);
  background: rgba(63, 191, 135, 0.06);
}

.variance-group h4 {
  margin: 0 0 10px;
  font-size: 13px;
}

.variance-reason-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-soft);
  font-size: 12.5px;
}

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

.bar-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  font-size: 12.5px;
}

.bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--panel-2);
  overflow: hidden;
  position: relative;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-bright);
}

.bar-fill.negative {
  background: var(--negative);
}

/* Checklist */

.checklist {
  display: grid;
  gap: 8px;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-soft);
  font-size: 13px;
}

.checklist-item .check-mark {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
  flex: 0 0 auto;
}

.checklist-item.pass .check-mark {
  background: var(--positive);
  color: #06281a;
}

.checklist-item.fail .check-mark {
  background: var(--negative);
  color: #2c0a05;
}

/* Import panel */

.import-panel textarea {
  min-height: 140px;
  font-family: ui-monospace, "Consolas", "SFMono-Regular", monospace;
  font-size: 12px;
}

.import-result {
  margin-top: 10px;
  font-size: 12.5px;
}

.import-result .import-errors {
  margin-top: 8px;
  max-height: 160px;
  overflow-y: auto;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  padding: 8px 10px;
}

.import-errors div {
  padding: 3px 0;
  color: var(--negative);
}

/* Modal */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 12, 24, 0.66);
}

.modal-card {
  width: min(640px, 100%);
  max-height: min(86vh, 900px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--panel);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-soft);
}

.modal-head h3 {
  margin: 0;
  font-size: 15px;
}

.modal-close {
  border: 0;
  border-radius: 8px;
  width: 32px;
  height: 32px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  display: grid;
  gap: 14px;
}

.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border-soft);
}

/* JSON preview */

.json-preview {
  max-height: 320px;
  overflow: auto;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--bg-0);
  border: 1px solid var(--border-soft);
  font-family: ui-monospace, "Consolas", "SFMono-Regular", monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Sub nav (project workspace) */

.subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 18px;
}

.subnav a, .subnav button {
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.subnav a.active, .subnav button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-bright));
  border-color: transparent;
  color: #fff;
}

/* Tabs (admin) */

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}

.tab-btn {
  padding: 9px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.tab-btn.active {
  color: var(--accent-bright);
  border-bottom-color: var(--accent-bright);
}

/* Loading / empty / error states */

.state-panel {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
}

.state-panel.state-error {
  color: var(--negative);
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent-bright);
  margin: 0 auto 10px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Responsive */

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    padding: 10px 12px;
  }

  .sidebar-brand {
    border-bottom: 0;
    margin-bottom: 0;
    padding: 4px 10px;
  }

  .nav-list {
    display: flex;
    gap: 4px;
  }

  .nav-section-label { display: none; }
  .sidebar-footer { display: none; }
  .main-col { height: auto; }
  .view-root { overflow-y: visible; }

  .grid.cols-4, .grid.cols-3, .grid.cols-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .view-root { padding: 16px; }
  .topbar { padding: 10px 16px; }
}
