:root {
  --ink: #121927;
  --muted: #697386;
  --paper: #f5f6f2;
  --surface: #fff;
  --line: #dde1e7;
  --accent: #2864ff;
  --accent-deep: #164bd1;
  --sidebar: #111722;
  --success: #138a63;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }

.gate { min-height: 100vh; display: grid; align-content: center; justify-items: start; padding: clamp(2rem, 8vw, 8rem); background: var(--sidebar); color: #f8f9fc; }
.gate-mark { width: 3rem; height: 3rem; display: grid; place-items: center; margin-bottom: 3rem; border-radius: 0.8rem; background: var(--accent); font-weight: 800; font-size: 1.35rem; transform: rotate(-4deg); }
.eyebrow { margin: 0 0 0.7rem; color: #8490a5; font-size: 0.72rem; font-weight: 750; letter-spacing: 0.16em; }
.gate h1 { max-width: 9ch; margin: 0; font-size: clamp(3rem, 8vw, 7rem); line-height: 0.93; letter-spacing: -0.065em; }
.gate-copy { max-width: 34rem; margin: 2rem 0 1.4rem; color: #aeb7c8; font-size: 1.05rem; line-height: 1.65; }
.gate-note { color: #778399; font-size: 0.85rem; }

.primary-action { display: inline-flex; min-height: 3rem; align-items: center; justify-content: center; padding: 0 1.25rem; border: 0; border-radius: 0.7rem; background: var(--accent); color: #fff; font-weight: 720; text-decoration: none; cursor: pointer; transition: transform 160ms ease, background 160ms ease; }
.primary-action:hover { background: var(--accent-deep); transform: translateY(-1px); }
.primary-action.compact { min-height: 2.45rem; padding-inline: 1rem; font-size: 0.88rem; }
.text-action { border: 0; background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; padding: 0.35rem; }

.shell { min-height: 100vh; display: grid; grid-template-columns: 16rem minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.5rem 1.25rem; color: #dce2ed; background: var(--sidebar); }
.brand { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 3rem; font-size: 1.05rem; }
.brand span { width: 2rem; height: 2rem; display: grid; place-items: center; border-radius: 0.55rem; background: var(--accent); color: #fff; font-weight: 800; }
.tenant-label { color: #758197; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; }
.sidebar select { width: 100%; margin: 0.55rem 0 2rem; padding: 0.7rem; border: 1px solid #303a49; border-radius: 0.55rem; background: #1b2330; color: #eef1f6; }
nav { display: grid; gap: 0.2rem; }
.nav-item { position: relative; padding: 0.8rem 0.9rem; border: 0; border-radius: 0.55rem; background: transparent; color: #909bad; text-align: left; cursor: pointer; transition: color 150ms ease, background 150ms ease, transform 150ms ease; }
.nav-item:hover { color: #fff; transform: translateX(2px); }
.nav-item.active { background: #202938; color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -1.25rem; top: 0.65rem; bottom: 0.65rem; width: 3px; background: var(--accent); border-radius: 2px; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding-top: 1rem; border-top: 1px solid #293241; color: #8995a8; font-size: 0.8rem; }

.workspace { min-width: 0; padding: clamp(1.5rem, 4vw, 4rem); }
.workspace-head { display: flex; justify-content: space-between; align-items: flex-start; padding-bottom: 2rem; border-bottom: 1px solid var(--line); }
.workspace-head h2 { margin: 0; font-size: clamp(1.8rem, 3vw, 2.8rem); letter-spacing: -0.045em; }
.sync-status { display: flex; align-items: center; gap: 0.5rem; color: var(--muted); font-size: 0.78rem; }
.sync-status::before { content: ""; width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px #d9f0e7; }
.view { display: none; padding-top: 2.5rem; animation: view-in 260ms ease both; }
.view.active { display: block; }
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.metric-line { display: grid; grid-template-columns: repeat(4, 1fr); margin-bottom: 4rem; border-bottom: 1px solid var(--line); }
.metric-line > div { min-height: 9rem; padding: 1.2rem 1.5rem 1.5rem 0; border-right: 1px solid var(--line); }
.metric-line > div:not(:first-child) { padding-left: 1.5rem; }
.metric-line > div:last-child { border-right: 0; }
.metric-line span { display: block; color: var(--muted); font-size: 0.8rem; }
.metric-line strong { display: block; margin-top: 1rem; font-size: clamp(2rem, 4vw, 4rem); letter-spacing: -0.06em; font-variant-numeric: tabular-nums; }
.section-block { max-width: 62rem; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 2rem; margin-bottom: 1.5rem; }
.section-heading h3 { margin: 0; font-size: 1.15rem; }
.section-heading p { margin: 0.45rem 0 0; color: var(--muted); font-size: 0.85rem; }
.status-list { display: grid; grid-template-columns: 1fr auto; margin: 0; border-top: 1px solid var(--line); }
.status-list div { display: contents; }
.status-list dt, .status-list dd { margin: 0; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.status-list dd { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

.table-wrap { overflow: auto; border-top: 1px solid var(--ink); }
table { width: 100%; border-collapse: collapse; min-width: 42rem; }
th { padding: 0.8rem 1rem 0.8rem 0; color: var(--muted); font-size: 0.7rem; letter-spacing: 0.08em; text-align: left; text-transform: uppercase; }
td { padding: 1rem 1rem 1rem 0; border-top: 1px solid var(--line); font-size: 0.88rem; }
.status { display: inline-flex; padding: 0.25rem 0.55rem; border-radius: 99px; background: #e8ebef; color: #4e5969; font-size: 0.72rem; font-weight: 700; }
.status.active, .status.ready { background: #dff3e9; color: #0c7351; }
.status.pending, .status.draft { background: #fff0cd; color: #8a5b00; }
.empty { padding: 3rem 0; color: var(--muted); text-align: center; }
.challenge { margin-top: 2rem; padding: 1.25rem 0; border-top: 2px solid var(--accent); border-bottom: 1px solid var(--line); }
.challenge dl { display: grid; grid-template-columns: 7rem 1fr; gap: 0.6rem; font-family: ui-monospace, monospace; font-size: 0.82rem; overflow-wrap: anywhere; }
.challenge dt { color: var(--muted); }
.challenge dd { margin: 0; }
.challenge p { color: var(--muted); font-size: 0.78rem; }

dialog { width: min(32rem, calc(100vw - 2rem)); padding: 0; border: 0; border-radius: 0.9rem; box-shadow: 0 2rem 7rem #1017254d; }
dialog::backdrop { background: #0d1420a6; backdrop-filter: blur(3px); }
dialog form { display: grid; gap: 1.2rem; padding: 1.5rem; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-head h3 { margin: 0; font-size: 1.4rem; }
.close { border: 0; background: transparent; color: var(--muted); font-size: 1.8rem; cursor: pointer; }
dialog label { display: grid; gap: 0.45rem; color: var(--muted); font-size: 0.78rem; font-weight: 650; }
dialog input, dialog select { width: 100%; padding: 0.8rem; border: 1px solid #cfd4dc; border-radius: 0.55rem; color: var(--ink); background: #fff; }
dialog input:focus, dialog select:focus { outline: 3px solid #2864ff22; border-color: var(--accent); }
.dialog-actions { display: flex; justify-content: flex-end; align-items: center; gap: 0.8rem; margin-top: 0.5rem; }
.form-error { min-height: 1.2rem; margin: 0; color: #b3261e; font-size: 0.78rem; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; padding: 1rem; }
  .brand { margin-bottom: 1rem; }
  .tenant-label, .sidebar select { display: none; }
  nav { display: flex; overflow-x: auto; }
  .nav-item { flex: 0 0 auto; }
  .nav-item.active::before { left: 0.8rem; right: 0.8rem; top: auto; bottom: 0; width: auto; height: 2px; }
  .sidebar-foot { position: absolute; right: 1rem; top: 0.75rem; border: 0; }
  .workspace { padding: 1.25rem; }
  .metric-line { grid-template-columns: repeat(2, 1fr); }
  .metric-line > div:nth-child(2) { border-right: 0; }
  .metric-line > div:nth-child(3), .metric-line > div:nth-child(4) { border-top: 1px solid var(--line); }
  .metric-line > div:nth-child(3) { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
