:root {
  --bg: #f7f8fc;
  --surface: #ffffff;
  --surface-2: #fbfcff;
  --surface-3: #f0f3fa;
  --ink: #171a1f;
  --muted: #6f737d;
  --line: #dfe2e9;
  --line-strong: #c7ccd6;
  --nav: #fbfcff;
  --nav-soft: #eaf2ff;
  --brand-dark: #126bc8;
  --green: #167c4a;
  --green-soft: #e8f4ee;
  --teal: #126bc8;
  --teal-soft: #e8f2ff;
  --blue: #126bc8;
  --blue-soft: #e8f2ff;
  --amber: #a36512;
  --amber-soft: #f8eddc;
  --red: #bf4a45;
  --red-soft: #f8e7e5;
  --purple: #4c5be8;
  --shadow: 0 16px 38px rgba(33, 45, 70, 0.09);
  --radius: 8px;
  --font: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  letter-spacing: 0;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(18, 107, 200, 0.24);
  outline-offset: 2px;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(320px, 540px);
  place-content: center;
  padding: clamp(24px, 5vw, 64px);
  background: #eef3fb;
}

.login-panel {
  width: 100%;
  display: grid;
  align-content: center;
  gap: 16px;
  min-width: 0;
  padding: clamp(30px, 4vw, 52px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(33, 45, 70, 0.12);
}

.login-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}

.brand-symbol,
.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #ffffff;
  font-family: "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  font-weight: 800;
  line-height: 1;
  background:
    radial-gradient(circle at 78% 16%, rgba(255, 255, 255, 0.24), transparent 28%),
    linear-gradient(135deg, #1478d4 0%, #22d5f8 54%, #3a62ed 100%);
  box-shadow: 0 12px 24px rgba(18, 107, 200, 0.22);
}

.brand-symbol {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  font-size: 40px;
}

.brand-symbol-small {
  width: 64px;
  height: 64px;
}

.brand-image-icon {
  display: block;
  object-fit: contain;
  overflow: hidden;
  background: #020719;
}

.login-heading h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.18;
}

.login-panel label {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.login-panel input,
.login-panel select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: #ffffff;
}

.login-panel input {
  padding: 0 13px;
}

.admin-code-field[hidden] {
  display: none;
}

.login-check {
  display: flex !important;
  grid-template-columns: none;
  align-items: center;
  gap: 9px !important;
  color: var(--muted);
  font-size: 13px;
}

.login-check input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--blue);
}

.login-submit {
  width: 100%;
  min-height: 46px;
  margin-top: 2px;
}

.login-note {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.login-active .app-shell,
.login-active .detail-drawer {
  display: none;
}

body:not(.login-active) .login-screen {
  display: none;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 14;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  overflow-y: auto;
  color: var(--ink);
  background: var(--nav);
  border-right: 1px solid var(--line);
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 13px;
  font-size: 30px;
}

.brand strong,
.brand span,
.sidebar-status strong,
.sidebar-status span {
  display: block;
}

.brand strong {
  font-size: 18px;
}

.brand span,
.sidebar-status span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.nav-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink);
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item:focus-visible {
  color: var(--ink);
  background: var(--surface-3);
  border-color: var(--line);
  outline: none;
}

.nav-item.active {
  color: #0d4f96;
  background: var(--nav-soft);
  border-color: #bdd3f3;
  box-shadow: none;
}

[data-icon] {
  display: inline-flex;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: currentColor;
}

[data-icon] svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sidebar-status {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
}

.status-dot.live {
  background: var(--blue);
  box-shadow: 0 0 0 6px rgba(18, 107, 200, 0.13);
}

.status-dot.paused {
  background: var(--amber);
  box-shadow: 0 0 0 6px rgba(169, 101, 0, 0.13);
}

.workspace {
  min-width: 0;
  padding: 22px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 0 18px;
  background: rgba(247, 248, 252, 0.92);
  backdrop-filter: blur(14px);
}

.search-shell {
  display: flex;
  align-items: center;
  flex: 1 1 auto;
  gap: 10px;
  min-width: 220px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: var(--surface);
}

.search-shell input {
  width: 100%;
  min-width: 0;
  border: 0;
  color: var(--ink);
  outline: 0;
  background: transparent;
}

.topbar-actions,
.toolbar,
.heading-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.role-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--muted);
  font-size: 13px;
}

.role-control select {
  width: 112px;
  min-height: 38px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--muted);
  font-size: 13px;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle span {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: #c7d0ca;
  transition: background 0.18s ease;
}

.toggle span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.18);
  transition: transform 0.18s ease;
}

.toggle input:checked + span {
  background: var(--teal);
}

.toggle input:checked + span::after {
  transform: translateX(18px);
}

.icon-button,
.primary-action,
.tool-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
}

.icon-button {
  width: 38px;
  padding: 0;
}

.primary-action {
  padding: 0 14px;
  border-color: var(--teal);
  color: #ffffff;
  background: var(--teal);
  font-weight: 700;
}

.primary-action:hover {
  background: #0f5fb2;
}

.tool-button {
  padding: 0 12px;
  color: var(--muted);
}

.tool-button.active {
  border-color: #bdd3f3;
  color: var(--teal);
  background: var(--teal-soft);
}

.tool-button[data-confirm="true"] {
  border-color: #e2aba8;
  color: var(--red);
  background: var(--red-soft);
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 18px;
  animation: enter 0.18s ease;
}

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

.view-header,
.panel-heading,
.drawer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.view-header h1,
.panel-heading h2,
.drawer-heading h2 {
  margin: 0;
  letter-spacing: 0;
}

.view-header h1 {
  font-size: 30px;
  line-height: 1.18;
}

.panel-heading h2,
.drawer-heading h2 {
  font-size: 18px;
  line-height: 1.3;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-meta {
  display: grid;
  justify-items: end;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.header-meta strong {
  color: var(--ink);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 12px;
}

.metric-card {
  position: relative;
  min-width: 0;
  min-height: 126px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.metric-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: var(--teal);
}

.metric-card:nth-child(2)::before {
  background: var(--blue);
}

.metric-card:nth-child(3)::before {
  background: var(--amber);
}

.metric-card:nth-child(4)::before {
  background: var(--red);
}

.metric-card:nth-child(5)::before {
  background: var(--green);
}

.metric-card:nth-child(6)::before {
  background: var(--teal);
}

.metric-card span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  line-height: 1.05;
}

.metric-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

.trend.up {
  color: var(--green);
}

.trend.down {
  color: var(--red);
}

.command-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.module-hub {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 12px;
}

.module-card {
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.module-card strong,
.module-card span {
  display: block;
}

.module-card strong {
  font-size: 14px;
  line-height: 1.35;
}

.module-card span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

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

.panel-heading {
  margin-bottom: 16px;
}

.panel-heading.compact {
  margin-bottom: 12px;
}

.segmented {
  display: inline-flex;
  gap: 6px;
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
}

.segmented button {
  min-width: 58px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  background: #ffffff;
}

.segmented button.active {
  color: #ffffff;
  border-color: var(--teal);
  background: var(--teal);
  box-shadow: none;
}

.network-panel canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1.85 / 1;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(218, 224, 236, 0.55) 1px, transparent 1px),
    linear-gradient(180deg, rgba(218, 224, 236, 0.55) 1px, transparent 1px),
    #fcfdff;
  background-size: 42px 42px;
}

.agent-score,
.sync-badge,
.health-pill,
.status-chip,
.deal-stage,
.risk-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.agent-score,
.sync-badge,
.health-pill.good {
  color: var(--green);
  background: var(--green-soft);
}

.health-pill.watch,
.status-chip.warn,
.risk-chip.medium {
  color: var(--amber);
  background: var(--amber-soft);
}

.health-pill.danger,
.status-chip.danger,
.risk-chip.high {
  color: var(--red);
  background: var(--red-soft);
}

.range-control {
  display: grid;
  grid-template-columns: minmax(104px, 1fr) minmax(110px, 1.3fr) 44px;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.range-control input {
  accent-color: var(--blue);
}

.range-control strong {
  color: var(--ink);
  text-align: right;
}

.agent-list,
.event-stream,
.timeline,
.finance-flow {
  display: grid;
  gap: 10px;
}

.agent-card,
.event-item,
.timeline-item,
.action-card,
.journey-card,
.service-card,
.governance-card,
.deal-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.agent-card {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
}

.agent-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  color: var(--teal);
  background: var(--teal-soft);
}

.agent-card h3,
.action-card h3,
.journey-card h3,
.service-card h3,
.governance-card h3,
.deal-card h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.32;
}

.agent-card p,
.action-card p,
.journey-card p,
.service-card p,
.governance-card p,
.deal-card p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.agent-card footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
}

.mini-action {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid #bdd3f3;
  border-radius: var(--radius);
  color: var(--teal);
  background: #f7fbff;
  font-weight: 700;
}

.mini-action:disabled,
.mini-action[aria-disabled="true"] {
  border-color: var(--line-strong);
  color: var(--muted);
  background: var(--surface-3);
  cursor: not-allowed;
  opacity: 0.72;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.card-actions .mini-action {
  margin-top: 0;
}

.customer-layout,
.finance-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 18px;
}

select {
  min-height: 40px;
  max-width: 100%;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
}

select:disabled,
input:disabled,
textarea:disabled {
  color: var(--muted);
  background: var(--surface-3);
  cursor: not-allowed;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(118px, 1fr));
  gap: 12px;
}

.profile-field {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.profile-field span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.profile-field strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
  line-height: 1.2;
}

.timeline-item,
.event-item {
  position: relative;
  padding: 12px 12px 12px 34px;
}

.timeline-item::before,
.event-item::before {
  content: "";
  position: absolute;
  top: 17px;
  left: 13px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--teal);
}

.timeline-item strong,
.event-item strong {
  display: block;
  font-size: 14px;
}

.timeline-item span,
.event-item span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.action-grid,
.journey-grid,
.service-grid,
.governance-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}

.action-card,
.journey-card,
.service-card,
.governance-card {
  padding: 15px;
}

.action-card header,
.journey-card header,
.service-card header,
.governance-card header,
.deal-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.action-card button,
.journey-card button,
.service-card button {
  margin-top: 14px;
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(220px, 1fr));
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 8px;
}

.project-board {
  grid-template-columns: repeat(6, minmax(220px, 1fr));
}

.project-actions-panel {
  border-color: #cbd9ef;
  background:
    linear-gradient(180deg, rgba(232, 242, 255, 0.62), rgba(255, 255, 255, 0.94)),
    var(--surface);
}

.project-action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.project-action-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 8px 18px rgba(33, 45, 70, 0.05);
}

.project-action-card strong,
.project-action-card span {
  display: block;
}

.project-action-card strong {
  font-size: 14px;
  line-height: 1.35;
}

.project-action-card span {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.pipeline-column {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 520px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.column-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
}

.column-heading h2 {
  margin: 0;
  font-size: 15px;
}

.column-heading span {
  color: var(--muted);
  font-size: 12px;
}

.deal-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  text-align: left;
  box-shadow: 0 1px 0 rgba(22, 32, 29, 0.04);
}

button.deal-card {
  width: 100%;
  color: inherit;
}

.deal-card:hover,
.deal-card:focus-visible {
  border-color: #bdd3f3;
  box-shadow: 0 9px 24px rgba(18, 107, 200, 0.14);
  outline: none;
}

.deal-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e9f2;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--purple));
}

.mini-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.mini-summary div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.mini-summary span,
.mini-summary strong {
  display: block;
}

.mini-summary span {
  color: var(--muted);
  font-size: 12px;
}

.mini-summary strong {
  margin-top: 6px;
  font-size: 16px;
  line-height: 1.25;
}

.performance-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
}

.performance-card,
.performance-row,
.timesheet-card {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.performance-card {
  background: var(--surface-2);
}

.performance-card span,
.performance-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.performance-card strong {
  display: block;
  margin-top: 7px;
  font-size: 18px;
  line-height: 1.2;
}

.performance-card small {
  margin-top: 6px;
}

.performance-section {
  display: grid;
  gap: 8px;
}

.performance-section h3 {
  margin: 6px 0 0;
  font-size: 15px;
}

.performance-row {
  display: grid;
  gap: 5px;
}

.performance-row span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.timesheet-card {
  display: grid;
  gap: 8px;
}

.timesheet-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.timesheet-card h3 {
  margin: 0;
  font-size: 15px;
}

.timesheet-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.data-table {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.table-row {
  display: grid;
  grid-template-columns: 0.85fr 1.25fr 1.35fr 0.8fr 0.8fr 0.8fr 1.3fr 0.7fr;
  gap: 10px;
  min-width: 980px;
  padding: 11px 12px;
  align-items: center;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

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

.table-row.table-head {
  position: sticky;
  top: 0;
  z-index: 1;
  color: var(--muted);
  background: #f7f9f6;
  font-size: 12px;
}

.table-row span,
.table-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.table-row span {
  color: var(--muted);
  font-size: 13px;
}

.table-row span:nth-child(1),
.table-row span:nth-child(2),
.table-row span:nth-child(3) {
  color: var(--ink);
  font-weight: 700;
}

.contract-upload-panel {
  border-color: #cbd9ef;
}

.contract-upload-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(260px, 1.2fr) auto;
  gap: 12px;
  align-items: end;
}

.contract-upload-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.file-picker input {
  min-height: auto;
  padding: 9px 10px;
}

.file-picker span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.contract-upload-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.preview-section {
  display: grid;
  gap: 10px;
}

.contract-preview-frame {
  width: 100%;
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.contract-preview-image {
  display: block;
  width: 100%;
  max-height: 620px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.contract-preview-text {
  max-height: 560px;
  margin: 0;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: #ffffff;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.contract-preview-empty {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 28px 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: var(--surface-2);
}

.contract-preview-empty [data-icon] {
  width: 34px;
  height: 34px;
  color: var(--blue);
}

.contract-preview-empty strong {
  color: var(--ink);
}

.contract-preview-empty p,
.preview-hint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.finance-flow {
  grid-template-columns: repeat(6, minmax(112px, 1fr));
}

.flow-node {
  position: relative;
  min-height: 112px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.flow-node::after {
  content: "";
  position: absolute;
  top: 50%;
  right: -14px;
  width: 14px;
  height: 1px;
  background: var(--line);
}

.flow-node:last-child::after {
  display: none;
}

.flow-node strong {
  display: block;
  font-size: 14px;
}

.flow-node span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 32;
  width: min(430px, calc(100vw - 24px));
  height: 100vh;
  overflow-y: auto;
  padding: 22px;
  border-left: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  transform: translateX(110%);
  transition: transform 0.2s ease;
}

.detail-drawer.open {
  transform: translateX(0);
}

.drawer-section {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.drawer-section h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.drawer-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.drawer-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.drawer-list strong {
  color: var(--ink);
  text-align: right;
}

.entry-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.entry-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.field-label {
  display: block;
  min-height: 22px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  line-height: 22px;
}

.entry-form input,
.entry-form select,
.entry-form textarea {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--surface);
}

.entry-form textarea {
  min-height: 92px;
  padding-top: 10px;
  resize: vertical;
}

.entry-form input[readonly] {
  color: var(--muted);
  background: #f1f4f8;
}

.entry-form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  max-width: min(520px, calc(100vw - 32px));
  padding: 12px 16px;
  border-radius: var(--radius);
  color: #ffffff;
  background: rgba(22, 31, 48, 0.94);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translate(-50%, 16px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
  background: var(--surface-2);
}

.profile-grid > .empty-state,
.action-grid > .empty-state,
.journey-grid > .empty-state,
.service-grid > .empty-state,
.governance-grid > .empty-state {
  grid-column: 1 / -1;
}

@media (max-width: 1240px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

  .command-grid,
  .customer-layout,
  .finance-layout {
    grid-template-columns: 1fr;
  }

  .finance-flow {
    grid-template-columns: repeat(3, minmax(112px, 1fr));
  }

  .performance-grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }

  .module-hub {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .project-action-grid {
    grid-template-columns: repeat(2, minmax(180px, 1fr));
  }

  .contract-upload-grid {
    grid-template-columns: 1fr;
  }

  .flow-node::after {
    display: none;
  }
}

@media (max-width: 920px) {
  .login-screen {
    grid-template-columns: 1fr;
    place-content: start center;
    padding: 28px 18px;
  }

  .login-panel {
    padding: 26px 20px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: relative;
    z-index: 14;
    height: auto;
    padding: 14px;
  }

  .nav-list {
    grid-template-columns: repeat(4, minmax(130px, 1fr));
    overflow-x: auto;
  }

  .sidebar-status {
    display: none;
  }

  .topbar,
  .view-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .action-grid,
  .journey-grid,
  .service-grid,
  .governance-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
  }

  .module-hub {
    grid-template-columns: 1fr;
  }

  .project-action-grid {
    grid-template-columns: 1fr;
  }

  .contract-upload-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 680px) {
  .login-heading {
    align-items: flex-start;
  }

  .login-heading h1 {
    font-size: 24px;
  }

  .workspace {
    padding: 16px;
  }

  .view-header h1 {
    font-size: 24px;
  }

  .metric-grid,
  .profile-grid,
  .action-grid,
  .journey-grid,
  .service-grid,
  .governance-grid,
  .performance-grid,
  .finance-flow,
  .module-hub,
  .project-action-grid {
    grid-template-columns: 1fr;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(124px, 1fr));
  }

  .pipeline-board {
    grid-template-columns: repeat(5, minmax(230px, 80vw));
  }

  .project-board {
    grid-template-columns: repeat(6, minmax(230px, 80vw));
  }

  .range-control {
    grid-template-columns: 1fr;
  }

  .range-control strong {
    text-align: left;
  }
}
