:root {
  color-scheme: light;
  --ink: #202724;
  --ink-2: #38413d;
  --muted: #69736e;
  --muted-2: #8b948f;
  --paper: #f4f6f3;
  --surface: #ffffff;
  --surface-2: #eef1ed;
  --line: #dbe0dc;
  --line-strong: #c8cec9;
  --side: #202724;
  --side-2: #2b3531;
  --accent: #1d756d;
  --accent-soft: #e2f0ed;
  --coral: #b85d43;
  --coral-soft: #f6e7e1;
  --amber: #ad7a21;
  --amber-soft: #f7edd8;
  --green: #357456;
  --green-soft: #e3efe8;
  --blue: #3d7085;
  --blue-soft: #e2edf1;
  --shadow: 0 12px 34px rgba(32, 39, 36, 0.09);
  --radius: 6px;
  --sidebar: 226px;
  --topbar: 58px;
  --font: Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html,
body {
  margin: 0;
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button,
select {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(29, 117, 109, 0.23);
  outline-offset: 2px;
}

a {
  color: inherit;
}

.app-root {
  min-height: 100vh;
}

.loading-screen,
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background: #e9ede9;
}

.loading-mark {
  display: grid;
  gap: 14px;
  justify-items: center;
  color: var(--muted);
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--line-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

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

.login-shell {
  width: min(920px, 100%);
  min-height: 530px;
  display: grid;
  grid-template-columns: minmax(300px, 1.05fr) minmax(340px, 0.95fr);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.login-identity {
  position: relative;
  overflow: hidden;
  padding: 52px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: #f6faf7;
  background: var(--side);
}

.login-identity::after {
  content: "";
  position: absolute;
  width: 320px;
  height: 320px;
  right: -170px;
  bottom: -150px;
  border: 44px solid rgba(255,255,255,0.05);
  border-radius: 50%;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 34px;
  height: 34px;
  position: relative;
  flex: 0 0 auto;
  border: 1px solid rgba(255,255,255,0.4);
  background: #f2f5f2;
}

.brand-mark::before,
.brand-mark::after {
  content: "";
  position: absolute;
  background: var(--accent);
}

.brand-mark::before {
  width: 8px;
  height: 22px;
  left: 7px;
  top: 6px;
}

.brand-mark::after {
  width: 8px;
  height: 14px;
  right: 7px;
  bottom: 6px;
  background: var(--coral);
}

.brand-name {
  font-size: 19px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.brand-sub {
  margin-top: 3px;
  color: rgba(255,255,255,0.64);
  font-size: 11px;
}

.login-copy {
  position: relative;
  z-index: 1;
  max-width: 390px;
}

.login-copy h1 {
  margin: 0 0 16px;
  font-size: 32px;
  line-height: 1.28;
  font-weight: 650;
}

.login-copy p {
  margin: 0;
  color: rgba(255,255,255,0.69);
  line-height: 1.8;
}

.login-signal {
  position: relative;
  z-index: 1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.login-signal span {
  padding: 5px 8px;
  border: 1px solid rgba(255,255,255,0.17);
  color: rgba(255,255,255,0.72);
  font-size: 11px;
}

.login-panel {
  padding: 52px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-panel h2 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 650;
}

.login-panel > p {
  margin: 0 0 28px;
  color: var(--muted);
}

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

.form-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.field.full {
  grid-column: 1 / -1;
}

.field label {
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 600;
}

.field-hint {
  margin-top: -2px;
  color: var(--muted-2);
  font-size: 11px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: #fff;
  color: var(--ink);
}

.textarea {
  min-height: 122px;
  resize: vertical;
  line-height: 1.6;
}

.input:hover,
.select:hover,
.textarea:hover {
  border-color: #aeb8b2;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(29,117,109,0.1);
}

.login-demo {
  margin-top: 18px;
  padding-top: 15px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.demo-users {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.demo-user {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 4px 7px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 11px;
}

.shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  grid-template-rows: var(--topbar) minmax(0, 1fr);
}

.sidebar {
  grid-row: 1 / -1;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 30;
  width: var(--sidebar);
  display: flex;
  flex-direction: column;
  background: var(--side);
  color: #f3f7f4;
  transition: transform 180ms ease, width 180ms ease;
}

.sidebar-head {
  height: var(--topbar);
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-project {
  margin: 13px 12px 6px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.035);
}

.sidebar-project-label {
  color: rgba(255,255,255,0.47);
  font-size: 10px;
  text-transform: uppercase;
}

.project-select {
  width: 100%;
  margin-top: 4px;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: #fff;
  font-weight: 600;
  line-height: 1.45;
}

.project-code {
  margin-top: 5px;
  color: rgba(255,255,255,0.5);
  font-size: 10px;
}

.nav-list {
  min-height: 0;
  padding: 7px 8px 14px;
  overflow-y: auto;
  display: grid;
  align-content: start;
  gap: 2px;
}

.nav-section-label {
  margin: 14px 10px 5px;
  color: rgba(255,255,255,0.35);
  font-size: 10px;
}

.nav-item {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: rgba(255,255,255,0.7);
  text-align: left;
}

.nav-item:hover {
  background: rgba(255,255,255,0.06);
  color: #fff;
}

.nav-item.active {
  background: #eef4f1;
  color: var(--side);
}

.nav-index {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: rgba(255,255,255,0.39);
  font-size: 10px;
}

.nav-item.active .nav-index {
  color: var(--accent);
}

.nav-badge {
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 9px;
  background: rgba(255,255,255,0.1);
  color: inherit;
  font-size: 10px;
  text-align: center;
}

.nav-item.active .nav-badge {
  background: var(--coral-soft);
  color: var(--coral);
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
  min-width: 0;
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
}

.avatar {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  font-weight: 700;
  font-size: 12px;
}

.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 600;
}

.user-role {
  overflow: hidden;
  color: rgba(255,255,255,0.42);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar {
  grid-column: 2;
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--topbar);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.96);
}

.menu-button {
  display: none;
}

.global-search {
  width: min(420px, 42vw);
  position: relative;
}

.global-search input {
  width: 100%;
  height: 34px;
  padding: 7px 34px 7px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}

.global-search button {
  position: absolute;
  right: 3px;
  top: 3px;
}

.topbar-spacer {
  flex: 1;
}

.topbar-context {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.main {
  grid-column: 2;
  min-width: 0;
  min-height: calc(100vh - var(--topbar));
  padding: 22px 24px 40px;
}

.page {
  width: min(1580px, 100%);
  margin: 0 auto;
}

.page-head {
  min-height: 48px;
  margin-bottom: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.page-title {
  margin: 0;
  font-size: 21px;
  line-height: 1.35;
  font-weight: 670;
}

.page-subtitle {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.page-actions,
.toolbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  min-height: 34px;
  padding: 7px 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink-2);
  white-space: nowrap;
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

.btn:hover {
  border-color: #aeb8b2;
  background: #fafbf9;
}

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.btn.primary:hover {
  background: #17675f;
}

.btn.danger {
  border-color: #cf9d8e;
  color: var(--coral);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn.icon {
  width: 34px;
  padding: 0;
  font-size: 17px;
}

.btn.small {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 11px;
}

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

.status-banner {
  margin-bottom: 15px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-left: 4px solid var(--coral);
  background: var(--coral-soft);
}

.status-banner strong {
  flex: 0 0 auto;
  color: #8d3d29;
  font-size: 13px;
}

.status-banner p {
  margin: 0;
  color: #754d41;
  font-size: 12px;
}

.status-banner.info {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.status-banner.info strong,
.status-banner.info p {
  color: #365f6f;
}

.status-banner.compact {
  margin: 0;
  padding: 9px 11px;
  align-items: flex-start;
}

.status-banner.compact strong {
  font-size: 11px;
}

.status-banner.compact p {
  font-size: 11px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  border: 1px solid var(--line);
  background: var(--surface);
}

.kpi {
  min-width: 0;
  min-height: 96px;
  padding: 14px 15px 12px;
  border-right: 1px solid var(--line);
}

.kpi:last-child {
  border-right: 0;
}

.kpi-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 11px;
}

.kpi-value {
  margin-top: 7px;
  overflow-wrap: anywhere;
  font-size: 21px;
  line-height: 1.2;
  font-weight: 680;
}

.kpi-note {
  margin-top: 6px;
  color: var(--muted-2);
  font-size: 10px;
}

.tone-critical { color: var(--coral); }
.tone-warning { color: var(--amber); }
.tone-positive { color: var(--green); }
.tone-accent { color: var(--accent); }

.content-grid {
  margin-top: 15px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
  gap: 15px;
}

.content-grid.equal {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.content-grid.wide-left {
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.55fr);
}

.stack {
  display: grid;
  align-content: start;
  gap: 15px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--surface);
}

.panel-head {
  min-height: 45px;
  padding: 10px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 670;
}

.panel-meta {
  color: var(--muted);
  font-size: 10px;
  white-space: nowrap;
}

.panel-body {
  padding: 14px;
  min-width: 0;
}

.panel-body.flush {
  padding: 0;
}

.panel-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.badge,
.status-chip {
  max-width: 100%;
  min-height: 20px;
  padding: 2px 7px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: 10px;
  line-height: 1.35;
  white-space: nowrap;
}

.badge::before,
.status-chip::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--muted-2);
}

.status-chip.critical,
.status-chip.hold,
.status-chip.blocked,
.status-chip.rejected {
  border-color: #e2b7aa;
  background: var(--coral-soft);
  color: #913f2a;
}

.status-chip.critical::before,
.status-chip.hold::before,
.status-chip.blocked::before,
.status-chip.rejected::before { background: var(--coral); }

.status-chip.warning,
.status-chip.review,
.status-chip.in_progress,
.status-chip.submitted {
  border-color: #e4cc9e;
  background: var(--amber-soft);
  color: #7e591b;
}

.status-chip.warning::before,
.status-chip.review::before,
.status-chip.in_progress::before,
.status-chip.submitted::before { background: var(--amber); }

.status-chip.approved,
.status-chip.passed,
.status-chip.done,
.status-chip.completed,
.status-chip.active,
.status-chip.implemented,
.status-chip.closed {
  border-color: #b9d7c5;
  background: var(--green-soft);
  color: #2e6549;
}

.status-chip.approved::before,
.status-chip.passed::before,
.status-chip.done::before,
.status-chip.completed::before,
.status-chip.active::before,
.status-chip.implemented::before,
.status-chip.closed::before { background: var(--green); }

.status-chip.info,
.status-chip.indexed,
.status-chip.partial {
  border-color: #bfd3db;
  background: var(--blue-soft);
  color: #366679;
}

.status-chip.info::before,
.status-chip.indexed::before,
.status-chip.partial::before { background: var(--blue); }

.table-wrap {
  width: 100%;
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 12px;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-strong);
  background: #f1f3f0;
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.data-table td {
  max-width: 390px;
  padding: 9px 10px;
  border-bottom: 1px solid #e8ebe8;
  color: var(--ink-2);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.data-table tbody tr:hover td {
  background: #fafbf9;
}

.data-table tbody tr.clickable {
  cursor: pointer;
}

.data-table .number {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.data-table .sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  background: inherit;
}

.user-admin-table {
  min-width: 900px;
}

.membership-list {
  display: grid;
  gap: 4px;
  min-width: 150px;
}

.membership-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  color: var(--ink-2);
  font-size: 11px;
}

.membership-line .mono {
  color: var(--accent);
  font-size: 10px;
}

.permission-preview {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 180px;
}

.permission-code {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 9px;
  line-height: 1.35;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.permission-option {
  min-width: 0;
  padding: 9px 10px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border: 1px solid var(--line);
  background: #fafbf9;
  cursor: pointer;
}

.permission-option:hover {
  border-color: var(--line-strong);
  background: var(--surface);
}

.permission-option input {
  flex: 0 0 auto;
  margin-top: 2px;
  accent-color: var(--accent);
}

.permission-option span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.permission-option strong {
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
  font-weight: 600;
}

.permission-option small {
  color: var(--muted);
  font-size: 10px;
}

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

.tiny {
  color: var(--muted);
  font-size: 10px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.94em;
}

.ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gate-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.gate-cell {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fafbf9;
  cursor: pointer;
}

.gate-cell:hover {
  border-color: var(--line-strong);
}

.gate-cell.hold {
  border-top: 3px solid var(--coral);
}

.gate-cell.review {
  border-top: 3px solid var(--amber);
}

.gate-cell.passed {
  border-top: 3px solid var(--green);
}

.gate-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
}

.gate-name {
  margin-top: 7px;
  min-height: 34px;
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 650;
}

.gate-owner {
  margin-top: 7px;
  color: var(--muted);
  font-size: 9px;
}

.bar-list {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(72px, 0.8fr) minmax(80px, 2fr) minmax(64px, 90px);
  gap: 10px;
  align-items: center;
}

.bar-label {
  overflow: hidden;
  color: var(--ink-2);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  height: 12px;
  position: relative;
  overflow: hidden;
  background: #e9ede9;
}

.bar-fill {
  height: 100%;
  min-width: 2px;
  background: var(--accent);
}

.bar-fill.coral { background: var(--coral); }
.bar-fill.amber { background: var(--amber); }
.bar-fill.green { background: var(--green); }
.bar-fill.blue { background: var(--blue); }

.bar-value {
  color: var(--ink-2);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.dual-bar {
  height: 16px;
  position: relative;
  background: #edf0ed;
}

.dual-bar .control,
.dual-bar .target {
  position: absolute;
  left: 0;
  height: 6px;
}

.dual-bar .control {
  top: 1px;
  background: #aeb8b2;
}

.dual-bar .target {
  bottom: 1px;
  background: var(--accent);
}

.chart-canvas {
  width: 100%;
  height: 220px;
  display: block;
}

.chart-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-swatch {
  width: 16px;
  height: 3px;
  background: var(--accent);
}

.timeline-list {
  display: grid;
}

.timeline-item {
  position: relative;
  padding: 3px 0 15px 22px;
}

.timeline-item::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 6px;
  bottom: -4px;
  width: 1px;
  background: var(--line);
}

.timeline-item:last-child::before {
  display: none;
}

.timeline-item::after {
  content: "";
  position: absolute;
  left: 1px;
  top: 6px;
  width: 9px;
  height: 9px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.timeline-title {
  font-size: 11px;
  font-weight: 620;
}

.timeline-meta {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.stage-rail {
  display: grid;
  grid-template-columns: repeat(8, minmax(110px, 1fr));
  overflow-x: auto;
  border: 1px solid var(--line);
  background: var(--surface);
}

.stage {
  min-width: 110px;
  padding: 13px 12px;
  position: relative;
  border-right: 1px solid var(--line);
}

.stage:last-child { border-right: 0; }

.stage::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 3px;
  background: var(--line-strong);
}

.stage.done::after { background: var(--green); }
.stage.active::after { background: var(--amber); }
.stage.blocked::after { background: var(--coral); }

.stage-index {
  color: var(--muted-2);
  font-size: 9px;
}

.stage-name {
  margin-top: 5px;
  font-size: 11px;
  font-weight: 650;
}

.stage-state {
  margin-top: 9px;
  color: var(--muted);
  font-size: 9px;
}

.workflow-list {
  display: grid;
  gap: 12px;
}

.workflow-row {
  min-width: 0;
  max-width: 100%;
  padding: 12px;
  border: 1px solid var(--line);
}

.workflow-top {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.workflow-top > div:first-child {
  min-width: 0;
}

.workflow-title {
  overflow-wrap: anywhere;
  font-size: 12px;
  font-weight: 650;
}

.workflow-steps {
  width: 100%;
  min-width: 0;
  margin-top: 12px;
  display: flex;
  align-items: flex-start;
  gap: 0;
  overflow-x: auto;
}

.workflow-step {
  min-width: 118px;
  position: relative;
  padding-right: 18px;
  color: var(--muted);
  font-size: 9px;
}

.workflow-step::before {
  content: "";
  display: block;
  width: 9px;
  height: 9px;
  margin-bottom: 5px;
  border: 2px solid #aeb8b2;
  border-radius: 50%;
  background: var(--surface);
}

.workflow-step::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 13px;
  right: 4px;
  height: 1px;
  background: var(--line-strong);
}

.workflow-step:last-child::after { display: none; }
.workflow-step.approved::before { border-color: var(--green); background: var(--green); }
.workflow-step.active::before { border-color: var(--amber); background: var(--amber-soft); }
.workflow-step.rejected::before { border-color: var(--coral); background: var(--coral); }

.toolbar {
  min-height: 48px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.toolbar-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.search-inline {
  width: min(340px, 100%);
  position: relative;
}

.search-inline .input {
  min-height: 34px;
  padding-right: 32px;
}

.search-inline .btn {
  position: absolute;
  right: 2px;
  top: 2px;
}

.filter-chips {
  margin: 10px 0;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.filter-chip {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  font-size: 11px;
}

.filter-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.tabbar,
.segmented {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface);
}

.tab,
.segment {
  min-height: 32px;
  padding: 6px 10px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 11px;
}

.tab:last-child,
.segment:last-child { border-right: 0; }

.tab.active,
.segment.active {
  background: var(--ink);
  color: #fff;
}

.risk-list {
  display: grid;
  gap: 8px;
}

.risk-item {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.risk-item:last-child { border-bottom: 0; }

.risk-copy h4 {
  margin: 0 0 4px;
  font-size: 12px;
}

.risk-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.risk-action {
  margin-top: 6px !important;
  color: var(--ink-2) !important;
}

.decision-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.decision-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.decision-card:hover { border-color: var(--line-strong); }

.decision-card-head {
  padding: 12px 13px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.decision-no {
  color: var(--muted);
  font-size: 9px;
}

.decision-card h3 {
  margin: 4px 0 0;
  font-size: 14px;
}

.decision-card-body {
  padding: 12px 13px;
}

.decision-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.decision-foot {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
  color: var(--muted-2);
  font-size: 10px;
}

.score {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}

.option-grid {
  display: grid;
  gap: 8px;
}

.option-row {
  padding: 10px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1.4fr) repeat(3, minmax(70px, 0.5fr));
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
}

.option-row.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.option-title {
  font-weight: 650;
}

.option-desc {
  margin-top: 2px;
  color: var(--muted);
  font-size: 10px;
}

.option-metric {
  text-align: right;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.option-metric small {
  display: block;
  color: var(--muted-2);
  font-size: 9px;
}

.editor-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 520px;
}

.editor-sidebar {
  border-right: 1px solid var(--line);
  background: #f8faf7;
}

.editor-side-head {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 650;
}

.template-item {
  width: 100%;
  padding: 11px 12px;
  display: block;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  text-align: left;
}

.template-item:hover,
.template-item.active { background: var(--accent-soft); }

.template-item strong {
  display: block;
  font-size: 11px;
}

.template-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.editor-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.editor-toolbar {
  min-height: 48px;
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
}

.editor-area {
  width: 100%;
  min-height: 470px;
  padding: 24px min(5vw, 60px);
  border: 0;
  outline: 0;
  resize: vertical;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.75;
}

.gantt-shell {
  --gantt-label-width: 220px;
  --gantt-timeline-width: 760px;
  display: grid;
  grid-template-columns: var(--gantt-label-width) var(--gantt-timeline-width);
  min-width: calc(var(--gantt-label-width) + var(--gantt-timeline-width));
}

.gantt-scroll {
  overflow: auto;
  isolation: isolate;
}

.gantt-labels {
  position: sticky;
  left: 0;
  z-index: 5;
  border-right: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: 8px 0 14px rgba(32, 39, 36, 0.07);
}

.gantt-labels,
.gantt-grid {
  display: grid;
  grid-template-rows: 42px;
  grid-auto-rows: 42px;
}

.gantt-header {
  height: 42px;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-strong);
  background: #eef1ed;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.gantt-label {
  min-width: 0;
  padding: 7px 10px;
  border-bottom: 1px solid #e8ebe8;
  display: grid;
  align-content: center;
  background: var(--surface);
  cursor: pointer;
}

.gantt-label strong {
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gantt-label span {
  display: block;
  overflow: hidden;
  color: var(--muted-2);
  font-size: 9px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gantt-grid {
  position: relative;
  background: var(--surface);
}

.gantt-months {
  height: 42px;
  position: relative;
  border-bottom: 1px solid var(--line-strong);
  background: #eef1ed;
}

.gantt-month {
  position: absolute;
  inset-block: 0;
  padding: 9px 5px;
  border-right: 1px solid var(--line);
  color: var(--muted);
  font-size: 9px;
  text-align: center;
  white-space: nowrap;
}

.gantt-month.quarter {
  border-left: 1px solid var(--line-strong);
  color: var(--ink-2);
  font-weight: 650;
}

.gantt-boundaries {
  position: absolute;
  inset: 42px 0 0;
  z-index: 0;
  pointer-events: none;
}

.gantt-boundary {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid #e5e9e5;
}

.gantt-boundary.quarter {
  border-left-color: var(--line-strong);
}

.gantt-row {
  position: relative;
  z-index: 1;
  border-bottom: 1px solid #e8ebe8;
  cursor: pointer;
}

.gantt-bar {
  position: absolute;
  top: 11px;
  height: 20px;
  min-width: 4px;
  border-radius: 2px;
  background: var(--accent);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
}

.gantt-bar.blocked { background: var(--coral); }
.gantt-bar.done { background: var(--green); }
.gantt-bar.not_started { background: #89948e; }

.gantt-progress {
  height: 100%;
  background: rgba(255,255,255,0.28);
}

.resource-meter {
  min-width: 150px;
}

.resource-meter-top {
  margin-bottom: 4px;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 9px;
}

.meter {
  height: 7px;
  overflow: hidden;
  background: #e7ebe7;
}

.meter-fill {
  height: 100%;
  background: var(--accent);
}

.meter-fill.over { background: var(--coral); }

.alert-row td {
  background: #fffaf2;
}

.alert-row.critical td {
  background: #fff4f0;
}

.detail-list {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 9px 13px;
  margin: 0;
}

.detail-list dt {
  color: var(--muted);
  font-size: 11px;
}

.detail-list dd {
  margin: 0;
  min-width: 0;
  color: var(--ink-2);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.modal-backdrop,
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(28, 34, 31, 0.48);
}

.modal {
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal.wide { width: min(940px, 100%); }

.modal-head,
.drawer-head {
  min-height: 52px;
  padding: 10px 13px 10px 17px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2,
.drawer-head h2 {
  margin: 0;
  font-size: 15px;
}

.modal-body,
.drawer-body {
  min-height: 0;
  padding: 18px;
  overflow: auto;
}

.modal-foot {
  min-height: 56px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  border-top: 1px solid var(--line);
  background: #fafbf9;
}

.drawer-backdrop {
  z-index: 70;
  place-items: stretch end;
  padding: 0;
  background: rgba(28,34,31,0.27);
}

.drawer {
  width: min(460px, 100vw);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: -10px 0 28px rgba(20,28,24,0.12);
}

.drawer-body {
  flex: 1;
}

.toast-root {
  position: fixed;
  z-index: 120;
  right: 18px;
  bottom: 18px;
  width: min(360px, calc(100vw - 36px));
  display: grid;
  gap: 8px;
}

.toast {
  padding: 11px 13px;
  border: 1px solid var(--line-strong);
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--ink-2);
  font-size: 12px;
}

.toast.error { border-left-color: var(--coral); }
.toast.warning { border-left-color: var(--amber); }

.skeleton {
  height: 14px;
  border-radius: 2px;
  background: #e5e9e5;
  animation: pulse 1.2s ease-in-out infinite alternate;
}

@keyframes pulse {
  from { opacity: 0.55; }
  to { opacity: 1; }
}

.mobile-nav {
  display: none;
}

@media (max-width: 1320px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .kpi:nth-child(3) { border-right: 0; }
  .kpi:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .gate-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 1080px) {
  :root { --sidebar: 72px; }
  .sidebar-head { padding: 0 18px; }
  .sidebar .brand-copy,
  .sidebar-project,
  .nav-label,
  .nav-badge,
  .sidebar-user > div:last-child,
  .nav-section-label { display: none; }
  .nav-item { grid-template-columns: 1fr; justify-items: center; padding: 8px; }
  .nav-index { font-size: 11px; color: rgba(255,255,255,0.68); }
  .sidebar-footer { display: grid; place-items: center; }
  .content-grid,
  .content-grid.equal,
  .content-grid.wide-left { grid-template-columns: 1fr; }
  .decision-list { grid-template-columns: 1fr; }
  .permission-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  :root { --topbar: 52px; }
  .shell { display: block; padding-bottom: 58px; }
  .sidebar {
    width: min(286px, 86vw);
    transform: translateX(-102%);
  }
  .shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar .brand-copy,
  .sidebar-project,
  .nav-label,
  .nav-badge,
  .sidebar-user > div:last-child,
  .nav-section-label { display: block; }
  .nav-item { grid-template-columns: 26px minmax(0,1fr) auto; justify-items: stretch; }
  .topbar { height: var(--topbar); padding: 0 10px; gap: 6px; }
  .menu-button { display: inline-flex; }
  .global-search { width: auto; min-width: 0; flex: 1; }
  .topbar-context { display: none; }
  .topbar-spacer { display: none; }
  .topbar .quick-add { width: 34px; padding: 0; }
  .topbar .quick-add-label { display: none; }
  .main { padding: 14px 12px 24px; min-height: calc(100vh - var(--topbar)); }
  .page-head { min-height: 0; margin-bottom: 14px; display: block; }
  .page-title { font-size: 18px; }
  .page-actions { margin-top: 11px; justify-content: flex-start; }
  .status-banner { align-items: flex-start; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { min-height: 86px; }
  .kpi:nth-child(2n) { border-right: 0; }
  .kpi:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
  .kpi-value { font-size: 18px; }
  .gate-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .bar-row { grid-template-columns: 90px minmax(110px, 1fr) 70px; gap: 7px; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-left,
  .toolbar-actions { width: 100%; }
  .search-inline { width: 100%; }
  .data-table.desktop-table thead { display: none; }
  .data-table.desktop-table,
  .data-table.desktop-table tbody,
  .data-table.desktop-table tr,
  .data-table.desktop-table td { display: block; width: 100%; }
  .data-table.desktop-table tr { padding: 10px; border-bottom: 1px solid var(--line); }
  .data-table.desktop-table td { max-width: none; padding: 3px 0; border: 0; }
  .data-table.desktop-table td::before { content: attr(data-label); display: inline-block; width: 82px; color: var(--muted); font-size: 10px; }
  .user-admin-table { min-width: 0; }
  .membership-list { display: inline-grid; vertical-align: top; }
  .option-row { grid-template-columns: 22px minmax(0,1fr); }
  .option-metric { text-align: left; padding-left: 32px; }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-sidebar { border-right: 0; border-bottom: 1px solid var(--line); max-height: 180px; overflow: auto; }
  .editor-area { min-height: 420px; padding: 18px; }
  .form-grid.two { grid-template-columns: 1fr; }
  .permission-grid { grid-template-columns: 1fr; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal { width: 100%; max-height: 94vh; border-radius: 6px 6px 0 0; }
  .drawer { width: 100vw; }
  .detail-list { grid-template-columns: 94px minmax(0,1fr); }
  .mobile-nav {
    position: fixed;
    inset: auto 0 0;
    z-index: 45;
    height: 58px;
    display: grid;
    grid-template-columns: repeat(var(--mobile-count, 5), 1fr);
    border-top: 1px solid var(--line);
    background: rgba(255,255,255,0.98);
  }
  .mobile-nav button {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 10px;
  }
  .mobile-nav button.active { color: var(--accent); font-weight: 700; }
  .login-screen { padding: 0; align-items: stretch; }
  .login-shell { min-height: 100vh; grid-template-columns: 1fr; }
  .login-identity { min-height: 245px; padding: 32px 26px; }
  .login-copy h1 { font-size: 25px; margin-bottom: 10px; }
  .login-signal { display: none; }
  .login-panel { padding: 30px 26px 42px; }
  .gantt-shell { --gantt-label-width: 172px; }
  .gantt-label { padding-inline: 8px; }
}

@media (max-width: 410px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi,
  .kpi:nth-child(3),
  .kpi:nth-child(2n) { border-right: 0; border-bottom: 1px solid var(--line); }
  .kpi:last-child { border-bottom: 0; }
  .gate-grid { grid-template-columns: 1fr; }
  .gate-name { min-height: 0; }
}

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