:root {
  color-scheme: dark;
  --bg: #0a0b0d;
  --surface: #101216;
  --surface-raised: #15171c;
  --surface-soft: #121419;
  --line: #272a31;
  --line-soft: #1b1e24;
  --text: #f1f1ef;
  --muted: #92969f;
  --muted-strong: #b9bcc3;
  --accent: #d8ad5b;
  --accent-soft: rgba(216, 173, 91, .12);
  --success: #8dbd9c;
  --danger: #d4817e;
  --warning: #d6ac69;
  --sidebar: 252px;
  --topbar: 64px;
  --radius: 8px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; }

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.is-hidden { display: none !important; }
.mobile-only { display: none !important; }
.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;
}

.boot-view {
  min-height: 100svh;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: var(--muted);
  letter-spacing: .03em;
}

.brand-mark {
  height: 22px;
  display: flex;
  align-items: end;
  gap: 4px;
}

.brand-mark span {
  display: block;
  width: 3px;
  height: 18px;
  background: var(--accent);
  animation: signal 1s ease-in-out infinite;
}
.brand-mark span:nth-child(2) { height: 11px; animation-delay: .12s; }
.brand-mark span:nth-child(3) { height: 6px; animation-delay: .24s; }

@keyframes signal { 0%, 100% { opacity: .25; } 45% { opacity: 1; } }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 15px;
  font-weight: 680;
  letter-spacing: .17em;
  text-decoration: none;
}

.wordmark-symbol {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 16px;
  font-style: italic;
  letter-spacing: 0;
}

.wordmark.compact { font-size: 13px; }
.wordmark.compact .wordmark-symbol { width: 26px; height: 26px; font-size: 14px; }

.auth-view {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(180px, .55fr) minmax(430px, .78fr) minmax(380px, 1fr);
  position: relative;
  overflow: hidden;
  animation: view-enter .65s var(--ease) both;
}

.auth-brand {
  padding: 42px 48px;
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.auth-brand > p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
  writing-mode: vertical-rl;
}

.auth-panel {
  padding: 11vh clamp(48px, 5.5vw, 88px) 8vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line-soft);
  background: #0c0d10;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.environment-label {
  width: fit-content;
  padding: 5px 8px;
  border: 1px solid rgba(224, 178, 90, .42);
  border-radius: 999px;
  background: rgba(224, 178, 90, .08);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .08em;
  white-space: nowrap;
}

.auth-brand .environment-label { margin-top: 10px; }

.auth-panel h1,
.invite-intro h1 {
  margin: 18px 0 24px;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(40px, 4.3vw, 70px);
  font-weight: 400;
  letter-spacing: -.045em;
  line-height: 1.02;
}

.auth-copy {
  max-width: 420px;
  margin: 0 0 36px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.auth-form { display: grid; gap: 20px; }
.auth-form label { display: grid; gap: 8px; }
.auth-form label > span { color: var(--muted-strong); font-size: 12px; }

.auth-form input,
.search-field input,
.field-input,
.field-select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0d0f12;
  color: var(--text);
  transition: border-color .18s ease, background .18s ease;
}

.auth-form input:hover,
.search-field input:hover,
.field-input:hover,
.field-select:hover { border-color: #393d46; }

.auth-form input:focus,
.search-field input:focus,
.field-input:focus,
.field-select:focus { border-color: var(--accent); background: #111318; outline: none; }

input::placeholder { color: #5f646e; }

.primary-button {
  min-height: 48px;
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #14120d;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  font-weight: 680;
  text-decoration: none;
  cursor: pointer;
  transition: transform .2s var(--ease), background .2s ease;
}
.primary-button:hover { transform: translateY(-2px); background: #e4bb6b; }
.primary-button:active { transform: translateY(0); }
.primary-button:disabled { cursor: wait; opacity: .55; transform: none; }
.primary-button i { font-size: 16px; font-style: normal; }

.form-error { min-height: 20px; margin: -8px 0 0; color: var(--danger); font-size: 12px; }
.client-settings-modal { width: min(760px, calc(100vw - 32px)); }
.client-settings-modal h3 { margin: 24px 0 10px; color: var(--muted-strong); font-size: 12px; letter-spacing: .08em; }
.settings-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; border: 1px solid var(--line); background: var(--line); }
.setting-check { display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 10px 12px; background: var(--surface-raised); color: var(--muted-strong); cursor: pointer; }
.setting-check input { accent-color: var(--accent); }

.auth-foot {
  display: flex;
  gap: 6px;
  margin-top: 30px;
  color: var(--muted);
  font-size: 12px;
}
.auth-foot a, .text-link { color: var(--text); text-underline-offset: 4px; }

.auth-aside {
  position: relative;
  min-height: 100%;
  background: #101216;
  overflow: hidden;
}

.orbital {
  width: min(34vw, 520px);
  aspect-ratio: 1;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -54%);
}

.orbital-ring {
  position: absolute;
  inset: 0;
  border: 1px solid #33353a;
  border-radius: 50%;
}
.orbital-ring::after {
  content: "";
  position: absolute;
  top: -4px;
  left: calc(50% - 4px);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 24px rgba(216, 173, 91, .55);
}
.ring-one { animation: orbit 22s linear infinite; }
.ring-two { inset: 18%; border-color: #25282f; animation: orbit 16s linear infinite reverse; }
.ring-two::after { background: #767b84; box-shadow: none; }
.orbital-core {
  position: absolute;
  inset: 35%;
  border-radius: 50%;
  border: 1px solid var(--accent);
  display: grid;
  place-content: center;
  justify-items: center;
  color: var(--text);
  font-family: Georgia, serif;
  font-size: clamp(24px, 3vw, 44px);
}
.orbital-core span { margin-top: 4px; color: var(--muted); font-family: inherit; font-size: 10px; letter-spacing: .13em; }

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

.auth-note {
  position: absolute;
  right: 40px;
  bottom: 38px;
  left: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 18px;
  color: var(--muted);
}
.auth-note span { color: var(--accent); font-size: 11px; }
.auth-note p { max-width: 310px; margin: 0; font-size: 12px; }

@keyframes view-enter {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Workspace */
.workspace { min-height: 100svh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar);
  padding: 0 14px;
  background: #0d0f12;
  border-right: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
}

.sidebar-head {
  min-height: var(--topbar);
  padding: 0 8px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.scope-summary { padding: 20px 4px 12px; }
.scope-summary > span,
.main-nav > p,
.main-nav > div > p {
  display: block;
  margin: 0 8px 8px;
  color: #676b74;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .11em;
  text-transform: uppercase;
}

#scope-button {
  width: 100%;
  padding: 11px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1px 8px;
  text-align: left;
  cursor: pointer;
  transition: border-color .18s ease, transform .18s var(--ease);
}
#scope-button:hover { border-color: #444852; transform: translateY(-1px); }
#scope-button strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
#scope-button small { color: var(--muted); font-size: 9px; letter-spacing: .08em; }
#scope-button i { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--muted); font-size: 12px; font-style: normal; }

.main-nav { flex: 1; overflow-y: auto; padding: 8px 0 18px; scrollbar-width: thin; }
.main-nav > p:not(:first-child), .main-nav > div > p { margin-top: 24px; }
.main-nav > div:empty { display: none; }
.nav-item {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 12px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: color .18s ease, background .18s ease, transform .18s ease;
}
.nav-item:hover { color: var(--text); transform: translateX(2px); }
.nav-item.is-active { background: #181a20; color: var(--text); }
.nav-item.is-active .nav-glyph { color: var(--accent); }
.nav-glyph { width: 15px; color: #727680; font-size: 15px; text-align: center; }

.sidebar-foot { position: relative; padding: 12px 4px 14px; border-top: 1px solid var(--line-soft); }
.environment-status { display: flex; align-items: center; gap: 8px; padding: 3px 8px 11px; color: var(--muted); font-size: 10px; }
.environment-status i, .freshness i, .status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 3px rgba(141, 189, 156, .09);
}
.profile-button {
  width: 100%;
  padding: 7px 7px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 9px;
  text-align: left;
  cursor: pointer;
}
.profile-button:hover { background: var(--surface-raised); }
.profile-button > span:first-child {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
}
.profile-button span:nth-child(2) { min-width: 0; display: grid; }
.profile-button strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; }
.profile-button small { color: var(--muted); font-size: 9px; }
.profile-button > i { color: var(--muted); font-style: normal; }
.profile-menu {
  position: absolute;
  right: 4px;
  bottom: 62px;
  left: 4px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #17191e;
  box-shadow: 0 18px 48px rgba(0, 0, 0, .42);
}
.profile-menu button { width: 100%; padding: 9px 10px; border: 0; border-radius: 4px; background: transparent; color: var(--muted-strong); text-align: left; cursor: pointer; }
.profile-menu button:hover { background: #202329; color: var(--text); }

.workspace-main { min-height: 100svh; margin-left: var(--sidebar); }
.topbar {
  position: sticky;
  top: 0;
  z-index: 25;
  height: var(--topbar);
  padding: 0 clamp(24px, 3.5vw, 56px);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 11, 13, .94);
  backdrop-filter: blur(16px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.breadcrumb { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11px; }
.breadcrumb span:last-child { color: var(--text); }
.breadcrumb b { color: #575b63; font-weight: 400; }
.topbar-tools { display: flex; align-items: center; gap: 13px; }
.topbar > .environment-label { margin-left: auto; }
.freshness { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; }
.quiet-button, .icon-button, .period-button, .secondary-button {
  border: 1px solid var(--line);
  border-radius: 5px;
  background: transparent;
  color: var(--muted-strong);
  cursor: pointer;
  transition: color .18s ease, border-color .18s ease, background .18s ease;
}
.quiet-button { padding: 6px 10px; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; text-decoration: none; }
.quiet-button:hover, .icon-button:hover, .secondary-button:hover { color: var(--text); border-color: #484c56; }
.icon-button { width: 34px; height: 34px; font-size: 19px; }

.content {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 38px clamp(24px, 3.5vw, 56px) 72px;
  outline: none;
}
.content > * { animation: section-enter .42s var(--ease) both; }
@keyframes section-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.view-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.view-title h1 { margin: 5px 0 0; font-size: clamp(26px, 3vw, 40px); font-weight: 560; letter-spacing: -.04em; line-height: 1.1; }
.view-title p { max-width: 630px; margin: 9px 0 0; color: var(--muted); font-size: 12px; }
.view-actions { display: flex; align-items: center; gap: 8px; }
.period-tabs { display: flex; align-items: center; padding: 3px; border: 1px solid var(--line); border-radius: 6px; }
.period-button { min-width: 42px; padding: 6px 9px; border: 0; font-size: 10px; }
.period-button.is-active { background: #24262d; color: var(--text); }
.secondary-button { min-height: 36px; padding: 0 12px; font-size: 11px; }
.secondary-button.accent { border-color: rgba(216, 173, 91, .35); color: var(--accent); }

.kpi-strip {
  display: grid;
  grid-template-columns: 1.25fr repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}
.kpi {
  min-width: 0;
  padding: 26px 24px 25px 0;
  position: relative;
}
.kpi + .kpi { padding-left: 24px; border-left: 1px solid var(--line); }
.kpi-label { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 10px; letter-spacing: .04em; }
.kpi-value {
  display: block;
  margin-top: 10px;
  overflow: hidden;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-size: clamp(23px, 2.6vw, 39px);
  font-weight: 530;
  letter-spacing: -.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kpi:not(:first-child) .kpi-value { font-size: clamp(21px, 2.15vw, 34px); }
.kpi-value.accent { color: var(--accent); }
.kpi-foot { display: flex; align-items: center; gap: 7px; margin-top: 8px; color: var(--muted); font-size: 10px; }
.change-positive { color: var(--success); }
.change-negative { color: var(--danger); }
.status-inline { color: var(--success); }
.status-inline.warning { color: var(--warning); }
.status-inline.danger { color: var(--danger); }

.section { padding-top: 32px; }
.section + .section { margin-top: 18px; }
.section-head { display: flex; align-items: start; justify-content: space-between; gap: 24px; margin-bottom: 20px; }
.section-head h2 { margin: 0; font-size: 15px; font-weight: 570; letter-spacing: -.01em; }
.section-head p { max-width: 520px; margin: 5px 0 0; color: var(--muted); font-size: 11px; }
.section-meta { color: var(--muted); font-size: 10px; }

.chart-wrap {
  position: relative;
  min-height: 320px;
  border-bottom: 1px solid var(--line);
}
.chart-svg { display: block; width: 100%; height: 320px; overflow: visible; }
.chart-grid { stroke: #202329; stroke-width: 1; }
.chart-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; animation: draw-chart .85s var(--ease) both; }
.chart-area { fill: rgba(216, 173, 91, .055); }
.chart-axis { fill: #6e727b; font-size: 9px; }
.chart-target { stroke: #393d44; stroke-width: 1; stroke-dasharray: 4 6; }
.chart-cursor { stroke: #555a64; stroke-width: 1; stroke-dasharray: 2 4; opacity: 0; pointer-events: none; }
.chart-dot { fill: var(--accent); stroke: var(--bg); stroke-width: 3; opacity: 0; pointer-events: none; }
.chart-svg.is-hovered .chart-cursor, .chart-svg.is-hovered .chart-dot { opacity: 1; }
@keyframes draw-chart { from { stroke-dasharray: 1800; stroke-dashoffset: 1800; } to { stroke-dasharray: 1800; stroke-dashoffset: 0; } }
.chart-tooltip {
  position: absolute;
  z-index: 5;
  min-width: 142px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(20, 22, 27, .96);
  box-shadow: 0 12px 36px rgba(0, 0, 0, .25);
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 14px));
}
.chart-tooltip span { display: block; color: var(--muted); font-size: 9px; }
.chart-tooltip strong { display: block; margin-top: 2px; font-variant-numeric: tabular-nums; font-size: 12px; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(330px, .7fr); gap: clamp(38px, 5vw, 76px); }
.allocation-list { display: grid; gap: 15px; }
.allocation-row { display: grid; grid-template-columns: minmax(90px, 1fr) minmax(130px, 2fr) auto; gap: 15px; align-items: center; }
.allocation-label { min-width: 0; display: flex; align-items: center; gap: 8px; font-size: 11px; }
.allocation-label i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.allocation-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.allocation-bar { height: 3px; background: #20232a; overflow: hidden; }
.allocation-bar i { display: block; height: 100%; background: var(--accent); transform-origin: left; animation: bar-grow .65s var(--ease) both; }
@keyframes bar-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
.allocation-row strong { min-width: 48px; color: var(--muted-strong); font-variant-numeric: tabular-nums; font-size: 10px; text-align: right; }

.risk-list { display: grid; grid-template-columns: repeat(2, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.risk-item { min-height: 96px; padding: 16px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; }
.risk-item span { color: var(--muted); font-size: 10px; }
.risk-item strong { font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 540; }
.risk-item small { color: var(--muted); font-size: 9px; }

.data-table-wrap { width: 100%; overflow-x: auto; border-top: 1px solid var(--line); scrollbar-width: thin; }
.data-table { width: 100%; min-width: 790px; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.data-table th { height: 42px; padding: 0 12px; border-bottom: 1px solid var(--line); color: #737780; font-size: 9px; font-weight: 620; letter-spacing: .07em; text-align: right; white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { padding-left: 0; text-align: left; }
.data-table td { height: 58px; padding: 0 12px; border-bottom: 1px solid var(--line-soft); color: var(--muted-strong); font-size: 11px; text-align: right; white-space: nowrap; }
.data-table tbody tr { cursor: pointer; transition: background .16s ease; }
.data-table tbody tr:hover { background: rgba(255, 255, 255, .018); }
.data-table td:first-child strong { display: block; color: var(--text); font-size: 11px; font-weight: 560; }
.data-table td:first-child small { display: block; color: var(--muted); font-size: 9px; }
.status-tag { display: inline-flex; align-items: center; gap: 6px; color: var(--success); }
.status-tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-tag.warning { color: var(--warning); }
.status-tag.danger { color: var(--danger); }
.status-tag.muted { color: var(--muted); }

.timeline { border-top: 1px solid var(--line); }
.timeline-item { display: grid; grid-template-columns: 94px 14px minmax(0, 1fr) auto; gap: 14px; min-height: 66px; padding: 15px 0; border-bottom: 1px solid var(--line-soft); align-items: start; }
.timeline-time { color: var(--muted); font-size: 9px; line-height: 1.6; }
.timeline-marker { width: 7px; height: 7px; margin-top: 4px; border-radius: 50%; border: 2px solid var(--accent); }
.timeline-content strong { display: block; font-size: 11px; font-weight: 540; }
.timeline-content p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.timeline-scope { color: var(--muted); font-size: 9px; }

.scope-drawer {
  position: fixed;
  z-index: 80;
  inset: 0 0 0 auto;
  width: min(440px, 92vw);
  padding: 28px;
  background: #111318;
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 80px rgba(0, 0, 0, .38);
  transform: translateX(102%);
  transition: transform .32s var(--ease);
}
.scope-drawer.is-open { transform: none; }
.drawer-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; }
.drawer-head h2 { margin: 6px 0 0; font-size: 22px; font-weight: 540; }
.search-field { display: block; margin: 25px 0 15px; }
.search-field input { height: 42px; }
.scope-tree { height: calc(100svh - 155px); overflow-y: auto; padding-right: 4px; }
.tree-item { margin-bottom: 2px; }
.tree-node {
  width: 100%;
  min-height: 42px;
  padding: 8px 9px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  text-align: left;
  cursor: pointer;
}
.tree-node:hover, .tree-node.is-active { background: #1b1e24; }
.tree-node.is-active { color: var(--accent); }
.tree-toggle { color: var(--muted); font-size: 9px; }
.tree-copy { min-width: 0; display: grid; }
.tree-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; font-weight: 530; }
.tree-copy small { color: var(--muted); font-size: 8px; letter-spacing: .05em; }
.tree-count { color: var(--muted); font-size: 9px; }
.tree-children { margin-left: 17px; padding-left: 9px; border-left: 1px solid var(--line); }
.mobile-scrim {
  position: fixed;
  z-index: 70;
  inset: 0;
  background: rgba(0, 0, 0, .58);
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease;
}
.mobile-scrim.is-open { opacity: 1; pointer-events: auto; }

/* Admin and utility surfaces */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 22px 0 14px; }
.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 8px; }
.toolbar .search-field { width: min(320px, 100%); margin: 0; }
.toolbar .search-field input { height: 36px; }
.count-label { color: var(--muted); font-size: 10px; }
.admin-summary { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 6px; margin-top: 28px; }
.admin-summary > div { padding: 17px; }
.admin-summary > div + div { border-left: 1px solid var(--line); }
.admin-summary span { display: block; color: var(--muted); font-size: 9px; }
.admin-summary strong { display: block; margin-top: 6px; font-size: 22px; font-weight: 540; }
.audit-detail { color: var(--muted); max-width: 300px; overflow: hidden; text-overflow: ellipsis; }
.sync-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; padding: 1px; background: var(--line); border: 1px solid var(--line); margin-top: 26px; }
.sync-service { min-height: 132px; padding: 20px; background: var(--bg); }
.sync-service-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sync-service h3 { margin: 0; font-size: 12px; font-weight: 550; }
.sync-service p { margin: 20px 0 0; color: var(--muted); font-size: 10px; }
.sync-service footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; color: var(--muted); font-size: 9px; }

.modal-backdrop { position: fixed; z-index: 100; inset: 0; background: rgba(0, 0, 0, .7); display: grid; place-items: center; padding: 20px; }
.modal {
  width: min(510px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #15171c;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .5);
  animation: modal-in .28s var(--ease) both;
}
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.modal-head { display: flex; align-items: start; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.modal h2 { margin: 0; font-size: 18px; font-weight: 560; }
.modal p { margin: 6px 0 0; color: var(--muted); font-size: 10px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid label { display: grid; gap: 7px; }
.form-grid label.wide { grid-column: 1 / -1; }
.form-grid label span { color: var(--muted); font-size: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }

/* Loading, empty and errors */
.skeleton-head, .skeleton-line, .skeleton-block { position: relative; overflow: hidden; background: #181a20; }
.skeleton-head::after, .skeleton-line::after, .skeleton-block::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .035), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { transform: translateX(100%); } }
.skeleton-head { width: 220px; height: 34px; border-radius: 5px; }
.skeleton-line { height: 16px; border-radius: 3px; }
.skeleton-block { height: 300px; margin-top: 32px; border-radius: 5px; }
.skeleton-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 30px; background: var(--line); }
.skeleton-kpis div { height: 108px; background: #121419; }

.state-page { min-height: 58vh; display: grid; place-content: center; justify-items: center; text-align: center; }
.state-page span { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; display: grid; place-items: center; color: var(--accent); font-family: Georgia, serif; font-size: 20px; }
.state-page h2 { margin: 18px 0 7px; font-size: 18px; font-weight: 560; }
.state-page p { max-width: 420px; margin: 0 0 18px; color: var(--muted); font-size: 11px; }
.empty-inline { padding: 42px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; text-align: center; }
.loader { width: 18px; height: 18px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast-region { position: fixed; z-index: 200; right: 20px; bottom: 20px; display: grid; gap: 8px; pointer-events: none; }
.toast { min-width: 250px; max-width: 390px; padding: 12px 14px; border: 1px solid var(--line); border-left: 2px solid var(--accent); border-radius: 5px; background: #181a1f; box-shadow: 0 16px 44px rgba(0, 0, 0, .4); color: var(--muted-strong); font-size: 11px; animation: toast-in .3s var(--ease) both; }
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Invitation */
.invite-page {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(440px, 1.05fr) minmax(420px, .95fr);
  position: relative;
}
.invite-wordmark { position: absolute; z-index: 2; top: 40px; left: 48px; }
.invite-intro { padding: 17vh clamp(48px, 7vw, 110px) 8vh 48px; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: center; }
.invite-intro p { max-width: 520px; color: var(--muted); line-height: 1.9; }
.invite-security { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 54px; background: var(--line); border: 1px solid var(--line); }
.invite-security span { padding: 16px; background: var(--bg); color: var(--accent); font-size: 10px; }
.invite-security small { display: block; margin-top: 8px; color: var(--muted); }
.invite-form-panel { padding: 15vh clamp(48px, 7vw, 108px); display: grid; align-content: center; background: #0d0f12; }
.invite-form-panel h2 { margin: 8px 0 24px; font-size: 29px; font-weight: 540; letter-spacing: -.03em; }
.invitation-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; margin-bottom: 25px; background: var(--line); border: 1px solid var(--line); }
.invitation-meta span { padding: 12px; background: var(--surface); color: var(--muted); font-size: 9px; }
.invitation-meta strong { display: block; margin-top: 4px; color: var(--text); font-size: 11px; font-weight: 540; word-break: break-all; }
.checkbox-line { grid-template-columns: auto 1fr !important; align-items: start; gap: 9px !important; }
.checkbox-line input { width: 15px; height: 15px; margin: 2px 0 0; accent-color: var(--accent); }
.checkbox-line span { line-height: 1.6; }
.inline-state { min-height: 260px; display: grid; place-content: center; justify-items: center; text-align: center; }
.inline-state p { max-width: 340px; color: var(--muted); font-size: 11px; }
.success-ring { width: 54px; height: 54px; margin-bottom: 16px; border: 1px solid var(--accent); border-radius: 50%; display: grid; place-items: center; color: var(--accent); font-size: 20px; }
.success-state .primary-button { width: 100%; min-width: 240px; margin-top: 20px; }

@media (max-width: 1080px) {
  .auth-view { grid-template-columns: 120px minmax(430px, 1fr) minmax(300px, .8fr); }
  .auth-brand { padding: 34px 25px; }
  .detail-grid { grid-template-columns: 1fr; }
  .admin-summary { grid-template-columns: repeat(2, 1fr); }
  .admin-summary > div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .admin-summary > div:nth-child(4) { border-top: 1px solid var(--line); }
}

@media (max-width: 820px) {
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .mobile-only { display: inline-grid !important; place-items: center; }
  .auth-view { grid-template-columns: 1fr; }
  .auth-brand { min-height: 84px; padding: 24px; border: 0; }
  .auth-brand > p { display: none; }
  .auth-panel { min-height: calc(100svh - 84px); padding: 8vh 24px 9vh; border: 0; }
  .auth-panel h1 { font-size: 42px; }
  .auth-aside { display: none; }
  .sidebar { transform: translateX(-102%); transition: transform .3s var(--ease); }
  .sidebar.is-open { transform: none; }
  .workspace-main { margin-left: 0; }
  .topbar { padding: 0 18px; }
  .topbar .freshness { display: none; }
  .content { padding: 27px 18px 60px; }
  .view-head { align-items: flex-start; flex-direction: column; }
  .view-actions { width: 100%; justify-content: space-between; }
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .kpi { padding: 20px 14px 20px 0; }
  .kpi + .kpi { padding-left: 14px; }
  .kpi:nth-child(3) { padding-left: 0; border-left: 0; border-top: 1px solid var(--line); }
  .kpi:nth-child(4) { border-top: 1px solid var(--line); }
  .kpi-value { font-size: 25px; }
  .chart-wrap, .chart-svg { min-height: 250px; height: 250px; }
  .sync-grid { grid-template-columns: 1fr; }
  .timeline-item { grid-template-columns: 72px 12px 1fr; gap: 9px; }
  .timeline-scope { grid-column: 3; }
  .invite-page { grid-template-columns: 1fr; }
  .invite-wordmark { top: 24px; left: 24px; }
  .invite-intro { padding: 15vh 24px 48px; border: 0; border-bottom: 1px solid var(--line); }
  .invite-intro h1 { font-size: 45px; }
  .invite-security { margin-top: 32px; }
  .invite-form-panel { padding: 60px 24px 80px; }
}

@media (max-width: 520px) {
  .auth-panel h1, .invite-intro h1 { font-size: 37px; }
  .period-tabs { overflow-x: auto; max-width: 100%; }
  .view-actions { align-items: stretch; flex-direction: column; }
  .period-tabs { align-self: flex-start; }
  .kpi-strip { grid-template-columns: 1fr; }
  .kpi, .kpi + .kpi { padding: 18px 0; border-left: 0; border-top: 1px solid var(--line); }
  .kpi:first-child { border-top: 0; }
  .allocation-row { grid-template-columns: minmax(90px, 1fr) minmax(80px, 1.4fr) auto; gap: 9px; }
  .risk-list { grid-template-columns: 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .toolbar .search-field { width: 100%; }
  .admin-summary { grid-template-columns: 1fr; }
  .admin-summary > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid label.wide { grid-column: auto; }
  .invite-security { grid-template-columns: 1fr; }
  .invitation-meta { grid-template-columns: 1fr; }
  .toast-region { right: 12px; bottom: 12px; left: 12px; }
  .toast { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
