:root {
  --bg: #f5f7fb;
  --panel: #fff;
  --ink: #111827;
  --muted: #667085;
  --line: #e5e7eb;
  --primary: #ef5a33;
  --primary-2: #d94a26;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #059669;
  --sidebar: #101828;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 6px; color: var(--primary); font-size: 12px; font-weight: 700; text-transform: uppercase; }

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(135deg, #fff2ed 0%, #fff8f5 48%, #f8fafc 100%);
}
.login-panel {
  width: min(920px, 100%);
  min-height: 460px;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 48px;
  align-items: center;
  padding: 56px;
  background: rgba(255,255,255,0.86);
  border: 1px solid rgba(255,255,255,0.9);
  box-shadow: var(--shadow);
}
.login h1 { margin: 0; font-size: 42px; }
.form { display: grid; gap: 16px; }
label { display: grid; gap: 8px; color: #344054; font-weight: 600; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  outline: none;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(239, 90, 51, 0.14); }
.hint { margin: 0; color: var(--muted); font-size: 13px; }
.form-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #fecaca;
  border-radius: 8px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 14px;
  font-weight: 600;
}

.app { min-height: 100vh; display: grid; grid-template-columns: 248px 1fr; }
.sidebar {
  min-height: 100vh;
  background: var(--sidebar);
  color: #fff;
  padding: 22px 16px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 22px;
  position: sticky;
  top: 0;
}
nav { display: grid; gap: 8px; align-content: start; }
.nav {
  border: 0;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  padding: 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.nav:hover, .nav.active { background: rgba(255,255,255,0.1); color: #fff; }
.nav-group {
  position: relative;
}
.subnav {
  display: grid;
  gap: 4px;
  padding-left: 12px;
}
.settings-popover {
  position: absolute;
  left: 100%;
  top: 0;
  z-index: 20;
  min-width: 168px;
  padding: 8px;
  margin-left: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  background: #111c2f;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.24);
}
.settings-popover::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 18px;
  width: 10px;
  height: 10px;
  background: #111c2f;
  border-left: 1px solid rgba(255,255,255,0.12);
  border-bottom: 1px solid rgba(255,255,255,0.12);
  transform: rotate(45deg);
}
.settings-popover.hidden {
  display: none;
}
.subnav-item {
  padding: 9px 12px;
  font-size: 14px;
}
.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  margin-left: 6px;
}
.user-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
}
.user-card span { color: #aab5c5; font-size: 13px; }

.main { min-width: 0; padding: 24px; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
.topbar h2 { margin: 0; font-size: 26px; }
.page { display: none; }
.page.active { display: block; }
.dashboard-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}
.dashboard-toolbar select,
.dashboard-toolbar input {
  max-width: 160px;
}
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.phase-kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.result-kpis {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.card, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}
.card { padding: 18px; display: grid; gap: 8px; }
.card span { color: var(--muted); }
.card strong { font-size: 34px; }
.phase-kpis .card { padding: 14px; }
.phase-kpis .card strong { font-size: 28px; }
.result-kpis .card { padding: 12px; box-shadow: none; }
.result-kpis .card strong { font-size: 24px; }
.panel { padding: 18px; }
.panel h3 { margin: 0 0 14px; }
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.dashboard-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.dashboard-column {
  display: grid;
  gap: 16px;
  align-content: start;
}
.dashboard-project-list {
  gap: 8px;
}
.dashboard-project-item {
  padding: 11px 12px;
}
.compact-list {
  max-height: 360px;
  overflow: auto;
}
.calendar-actions {
  display: flex;
  gap: 6px;
}
.calendar-actions button {
  padding: 6px 9px;
  font-size: 13px;
}
.bid-calendar {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  margin: 10px 0 12px;
}
.calendar-weekday {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}
.calendar-day {
  min-height: 34px;
  display: grid;
  place-items: center;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 4px;
}
.calendar-day.empty {
  border-color: transparent;
  background: transparent;
  cursor: default;
}
.calendar-day.has-project {
  border-color: rgba(23, 105, 255, 0.28);
  background: #f8fbff;
}
.calendar-day.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 105, 255, 0.12);
}
.calendar-day b {
  min-width: 16px;
  height: 16px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
}
.approval-overview {
  display: grid;
  gap: 8px;
}
.overview-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.overview-item span {
  font-weight: 700;
}
.overview-item strong {
  font-size: 24px;
}
.overview-item small {
  grid-column: 1 / -1;
  color: var(--muted);
}
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; align-items: center; }
.toolbar .primary { flex: 0 0 auto; }
.toolbar input { flex: 1 1 auto; min-width: 420px; }
.toolbar select { flex: 0 0 210px; }
.toolbar button { flex: 0 0 auto; }
.filter-dropdown {
  position: relative;
  flex: 0 0 170px;
}
.filter-dropdown-trigger {
  width: 100%;
  justify-content: center;
  white-space: nowrap;
}
.filter-dropdown-panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 18;
  width: 260px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.18);
}
.filter-dropdown-panel.hidden {
  display: none;
}
.filter-dropdown-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.filter-dropdown-actions button {
  flex: 0 0 auto;
}
.toolbar-category-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.table-wrap { overflow: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 13px; color: var(--muted); background: #f9fafb; }
tr:last-child td { border-bottom: 0; }

.primary, .ghost, .danger, .outline, .filter-action {
  border-radius: 8px;
  padding: 9px 13px;
  border: 1px solid transparent;
}
.primary { background: var(--primary); color: #fff; }
.primary:hover { background: var(--primary-2); }
.ghost { background: transparent; color: inherit; border-color: var(--line); }
.danger { background: var(--danger); color: #fff; }
.outline { background: #fff; border-color: var(--line); color: var(--ink); }
.filter-action {
  background: #334155;
  border-color: #334155;
  color: #fff;
  font-weight: 800;
}
.filter-action:hover {
  background: #1f2937;
  border-color: #1f2937;
}
.icon {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: #f2f4f7;
  font-size: 22px;
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.row-actions button { padding: 6px 9px; font-size: 13px; }
.link-button {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 800;
  text-align: left;
}
.link-button:hover { color: var(--primary); }

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.b-drafting { color: #475467; background: #f2f4f7; }
.b-bid_approval, .b-draft_approval { color: #92400e; background: #fef3c7; }
.b-making { color: #175cd3; background: #dbeafe; }
.b-proofing { color: #6d28d9; background: #ede9fe; }
.b-completed { color: #047857; background: #d1fae5; }
.b-project_approval { color: #92400e; background: #fef3c7; }
.b-bid_ai_review { color: #175cd3; background: #dbeafe; }
.b-archive { color: #047857; background: #d1fae5; }
.risk-high { color: #991b1b; background: #fee2e2; }
.risk-medium { color: #92400e; background: #fef3c7; }
.risk-low { color: #065f46; background: #d1fae5; }

.list { display: grid; gap: 10px; }
.item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  display: grid;
  gap: 8px;
}
.item-head { display: flex; justify-content: space-between; gap: 12px; }
.item-title { font-weight: 800; }
.item-meta { color: var(--muted); font-size: 13px; }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 112px 1fr 72px; gap: 10px; align-items: center; }
.bar { height: 10px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--primary); }
.pie-stat-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 22px;
  align-items: center;
}
.pie-chart {
  width: 180px;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}
.pie-chart.empty {
  background: conic-gradient(#e2e8f0 0 100%);
}
.pie-chart > div {
  width: 96px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  align-content: center;
  box-shadow: 0 0 0 1px var(--line);
}
.pie-chart strong {
  font-size: 28px;
  line-height: 1;
}
.pie-chart span {
  color: var(--muted);
  font-size: 13px;
}
.pie-stat-layout.empty .muted {
  font-size: 15px;
  line-height: 1.7;
}
.pie-legend {
  display: grid;
  gap: 8px;
}
.pie-legend-row {
  display: grid;
  grid-template-columns: 10px minmax(70px, 1fr) auto;
  gap: 8px;
  align-items: center;
  font-size: 13px;
}
.pie-legend-row i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.pie-legend-row span {
  font-weight: 800;
}
.pie-legend-row small {
  grid-column: 2 / 4;
  color: var(--muted);
  font-size: 12px;
}
.stacked-bar {
  display: flex;
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5e7eb;
}
.stacked-bar i { display: block; height: 100%; }
.stacked-bar .won { background: var(--success); }
.stacked-bar .lost { background: #94a3b8; }
.trend-chart {
  display: grid;
  gap: 10px;
}
.trend-row {
  display: grid;
  grid-template-columns: 86px 1fr 36px 128px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}
.trend-row b {
  color: var(--ink);
}
.trend-row small {
  color: var(--muted);
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.section-head h3 { margin: 0; }
.compact-head { margin: 0; }
.checkline {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}
.checkline input {
  width: auto;
}
.flow-nodes {
  display: grid;
  gap: 10px;
}
.flow-node {
  display: grid;
  grid-template-columns: 72px minmax(180px, 1fr) minmax(180px, 1fr) auto;
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
}
.flow-node-order {
  align-self: center;
  color: var(--muted);
  font-weight: 800;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(15, 23, 42, 0.48);
  z-index: 30;
  padding: 12px;
}
.dialog {
  width: min(680px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: #fff;
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.dialog.wide { width: min(920px, 100%); }
.dialog.extra-wide { width: min(1180px, 100%); }
.dialog.form-wide { width: min(1120px, 100%); }
.dialog.detail-wide { width: min(1360px, 100%); }
.dialog.form-wide {
  width: 96vw;
  min-width: min(860px, 96vw);
  min-height: calc(100vh - 24px);
  resize: both;
}
.workspace-dialog {
  height: calc(100vh - 24px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 10px;
  overflow: hidden;
}
.workspace-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}
.workspace-head h3 { margin: 0; font-size: 24px; }
.project-summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.project-summary-strip div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #f9fafb;
  display: grid;
  gap: 4px;
}
.project-summary-strip span {
  color: var(--muted);
  font-size: 12px;
}
.project-summary-strip b {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.approval-change-inline {
  padding: 8px 12px;
  border: 1px solid #fbbf24;
  border-radius: 8px;
  background: #fffbeb;
  color: #92400e;
  font-size: 13px;
}
.change-dialog { width: min(760px, 92vw); }
.change-dialog-body {
  max-height: 62vh;
  overflow: auto;
  display: grid;
  gap: 12px;
}
.change-record {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  display: grid;
  gap: 10px;
  background: #fff;
}
.change-record-empty {
  color: var(--muted);
  font-size: 13px;
}
.change-record-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}
.change-field {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr);
  gap: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.change-field b { color: var(--ink); }
.change-values {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
}
.change-values span { color: var(--ink); }
.workspace-form {
  min-height: 0;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
}
.workspace-tabs {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}
.tab {
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  padding: 9px 12px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
}
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab.is-disabled,
.tab:disabled {
  color: #cbd5e1;
  cursor: not-allowed;
  opacity: 0.62;
}
.workspace-body {
  min-height: 0;
  overflow: auto;
  padding: 10px 4px 10px 0;
}
.tab-panel { display: none; }
.tab-panel.active { display: grid; gap: 12px; }
.tab-panel.bid-project-panel.active {
  grid-template-columns: minmax(420px, 0.9fr) minmax(520px, 1.1fr);
  align-items: start;
}
.workspace-actions {
  padding-top: 10px;
  border-top: 1px solid var(--line);
  background: #fff;
}
.grid-form { grid-template-columns: 1fr 1fr; }
.project-form-layout {
  grid-template-columns: minmax(360px, 0.9fr) minmax(460px, 1.1fr);
  align-items: start;
}
.form-section {
  min-width: 0;
  display: grid;
  gap: 12px;
}
.form-section h4 {
  margin: 0;
  font-size: 24px;
}
.field-stack {
  display: grid;
  gap: 12px;
}
.compact-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.bid-project-panel .compact-grid {
  grid-template-columns: minmax(0, 1fr);
}
.field-stack label {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.field-stack .system-field { display: none; }
.field-stack input,
.field-stack select,
.field-stack textarea {
  border-color: transparent;
  padding-left: 0;
  padding-right: 0;
}
.field-stack textarea { min-height: 180px; }
.full { grid-column: 1 / -1; }
select[multiple] { min-height: 156px; }
.category-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  width: 100%;
}
.category-picker button {
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}
.category-picker button.selected {
  border-color: var(--primary);
  color: #0f4fd6;
  background: #fff2ed;
  box-shadow: inset 0 0 0 1px rgba(23, 105, 255, 0.22);
}
.category-picker button:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 105, 255, 0.12);
}
.category-picker.is-disabled {
  opacity: 0.7;
}
.category-picker.is-disabled button {
  cursor: not-allowed;
}
.field-stack .category-picker {
  padding-top: 2px;
}
.detail-grid { display: grid; grid-template-columns: 0.9fr 1.1fr; gap: 16px; }
.file-box {
  border: 1px dashed #b8c4d6;
  border-radius: 8px;
  padding: 14px;
  background: #f8fbff;
  display: grid;
  gap: 10px;
}
.file-box input { border: 0; padding: 0; box-shadow: none; }
.current-file-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 12px;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.current-file-card .item-meta {
  font-size: 15px;
}
.current-file-card strong {
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  word-break: break-all;
}
.current-file-card > span,
.current-file-card > strong {
  grid-column: 1;
}
.current-file-actions {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: flex;
  align-items: center;
}
.current-file-actions .primary {
  padding: 10px 18px;
  font-size: 16px;
}
.upload-inline {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}
.upload-inline input {
  display: none;
}
.file-list {
  display: grid;
  gap: 8px;
}
.file-list-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.file-list-row.pending-add {
  border-color: rgba(22, 163, 74, 0.35);
  background: #f0fdf4;
}
.file-list-row.pending-delete {
  border-color: rgba(220, 38, 38, 0.35);
  background: #fef2f2;
  opacity: 0.78;
}
.file-list-row strong {
  display: block;
  font-size: 16px;
  word-break: break-all;
}
.file-list-row .small {
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
}
.ai-config-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.ai-config-row label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.ai-config-row select {
  min-height: 38px;
  font-size: 14px;
}
.ai-config-row button {
  min-height: 38px;
  padding: 8px 14px;
}
.ai-config-row .ai-model-field {
  grid-column: 1 / -1;
}
.file-picker-button {
  min-height: 40px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}
.selected-file-name {
  min-width: 160px;
  color: var(--muted);
  font-size: 16px;
  word-break: break-all;
}
.template-preview {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.large-textarea {
  min-height: 300px;
  line-height: 1.55;
}
.runtime-prompt-textarea {
  min-height: 420px;
}
.ai-state-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.ai-state-card strong { font-size: 18px; }
.ai-state-card.failed {
  border-color: #fecdd3;
  background: #fff1f2;
}
.ai-state-card.running {
  border-color: #bfdbfe;
  background: #eff6ff;
}
.ai-state-card.done {
  border-color: #bbf7d0;
  background: #f0fdf4;
}
.ai-result-box {
  min-height: 260px;
  max-height: 48vh;
  resize: vertical;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}
.workspace-result {
  max-height: none;
  min-height: 420px;
}
.ai-result-box .section-head { margin-bottom: 8px; }
.ai-result-box h4 { font-size: 24px; }
.ai-result-content { display: grid; gap: 8px; font-size: 15px; line-height: 1.55; }
.ai-result-content .list { gap: 8px; }
.ai-result-content .item { padding: 9px; }
.ai-result-content .item b { font-size: 16px; }
.ai-result-content .item span { font-size: 15px; }
.ai-result-content .ai-state-card strong { font-size: 17px; }
.approval-progress-box {
  min-height: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
}
.approval-progress-box .section-head { margin-bottom: 8px; }
.approval-progress-box h4 { font-size: 18px; }
.approval-progress-content { display: grid; gap: 10px; }
.approval-step {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.approval-change-box {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.approval-change-box.has-change {
  border-color: #fbbf24;
  background: #fffbeb;
}
.approval-change-item {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border: 1px solid rgba(217, 119, 6, 0.2);
  border-radius: 8px;
  background: rgba(255,255,255,0.72);
  color: var(--muted);
  font-size: 13px;
}
.approval-change-item b {
  color: var(--ink);
}
.approval-step-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.approval-card {
  gap: 12px;
}
.approval-card-compact {
  gap: 10px;
}
.approval-card-compact .approval-title {
  font-size: 16px;
}
.approval-card-compact .approval-meta-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.approval-card-compact .approval-meta-grid div {
  padding: 7px 9px;
}
.approval-card-focus {
  outline: 3px solid rgba(23, 105, 255, 0.28);
  box-shadow: 0 0 0 6px rgba(23, 105, 255, 0.08);
}
.notification-card.unread {
  border-color: rgba(23, 105, 255, 0.3);
  background: #f8fbff;
}
.approval-title {
  font-size: 17px;
  line-height: 1.35;
}
.approval-meta-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}
.approval-card:not(.approval-card-compact) .approval-meta-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}
.approval-meta-grid div {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fafb;
}
.approval-meta-grid span {
  color: var(--muted);
  font-size: 12px;
}
.approval-meta-grid b {
  font-size: 14px;
  overflow-wrap: anywhere;
}
.approval-actions {
  justify-content: flex-end;
}
.approval-waiting {
  align-self: center;
  padding: 8px 10px;
}
.approval-node-history {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.approval-node {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto minmax(160px, 2fr);
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}
.approval-node b {
  color: var(--ink);
  font-size: 13px;
}
.approval-node small {
  overflow-wrap: anywhere;
}
.approval-node.active span,
.approval-node.active b {
  color: var(--primary);
}
.approval-dialog-actions {
  justify-content: flex-end;
}
.json-panel {
  white-space: pre-wrap;
  background: #0f172a;
  color: #dbeafe;
  border-radius: 8px;
  padding: 12px;
  max-height: 360px;
  overflow: auto;
  font-size: 12px;
}
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 12px 14px;
  background: #111827;
  color: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 60;
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    min-height: auto;
    position: static;
    grid-template-rows: auto auto;
    gap: 12px;
    padding: 14px 12px;
  }
  .brand { padding: 0; font-size: 18px; }
  .sidebar nav {
    display: flex;
    overflow-x: auto;
    gap: 6px;
    padding-bottom: 2px;
  }
  .nav {
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 9px 10px;
  }
  .user-card { display: none; }
  .main { padding: 14px; }
  .topbar {
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 14px;
  }
  .topbar h2 { font-size: 22px; }
  .topbar .primary { padding: 8px 10px; white-space: nowrap; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input,
  .toolbar select,
  .toolbar button { max-width: none; flex: 1 1 100%; }
  .grid.two, .detail-grid, .grid-form, .project-form-layout, .compact-grid, .project-summary-strip, .kpis, .phase-kpis, .dashboard-layout { grid-template-columns: 1fr; }
  .dashboard-toolbar { flex-wrap: wrap; }
  .dashboard-toolbar select,
  .dashboard-toolbar input,
  .dashboard-toolbar button { flex: 1 1 100%; max-width: none; }
  .flow-node { grid-template-columns: 1fr; }
  .tab-panel.bid-project-panel.active { grid-template-columns: 1fr; }
  .dialog.form-wide {
    width: 100vw;
    height: 100vh;
    min-width: 0;
    max-height: 100vh;
    border-radius: 0;
    resize: none;
    padding: 12px;
  }
  .workspace-dialog {
    height: 100vh;
    min-height: 100vh;
  }
  .workspace-head h3 { font-size: 20px; }
  .workspace-body { padding-right: 0; }
  .form-section h4, .ai-result-box h4 { font-size: 20px; }
  .workspace-result { min-height: 280px; }
  .current-file-card {
    grid-template-columns: 1fr;
  }
  .current-file-actions {
    grid-column: 1;
    grid-row: auto;
  }
  .current-file-actions .primary {
    width: 100%;
  }
  .upload-inline {
    align-items: stretch;
    flex-wrap: wrap;
  }
  .upload-inline .file-picker-button,
  .upload-inline button {
    flex: 1 1 auto;
    text-align: center;
  }
  .selected-file-name {
    flex: 1 1 100%;
    min-width: 0;
  }
  .workspace-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .workspace-actions button:last-child {
    grid-column: 1 / -1;
  }
  .approval-meta-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .approval-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .approval-actions .outline {
    grid-column: 1 / -1;
  }
  .approval-actions button {
    min-height: 42px;
  }
  .approval-dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
  }
  .approval-dialog-actions button {
    min-height: 44px;
  }
  .approval-node { grid-template-columns: 1fr; }
  .login-panel { grid-template-columns: 1fr; padding: 28px; }
}

@media (max-width: 560px) {
  .login { padding: 12px; }
  .login-panel { padding: 22px; min-height: auto; }
  .login h1 { font-size: 30px; }
  .main { padding: 10px; }
  .panel, .card { padding: 12px; }
  .topbar { display: grid; grid-template-columns: 1fr; }
  .topbar .primary { width: 100%; }
  .table-wrap table {
    min-width: 760px;
  }
  .dialog {
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }
  .project-summary-strip b {
    white-space: normal;
  }
  .approval-meta-grid { grid-template-columns: 1fr; }
  .approval-actions { grid-template-columns: 1fr; }
  .approval-actions .outline { grid-column: auto; }
  .workspace-actions { grid-template-columns: 1fr; }
  .workspace-actions button:last-child { grid-column: auto; }
}
