@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Manrope:wght@400;500;600;700;800&family=Noto+Sans+SC:wght@400;500;600;700&display=swap");

:root {
  --ink: #102230;
  --muted: #60717b;
  --line: #d8e0df;
  --paper: #f8faf7;
  --canvas: #edf2ee;
  --white: #ffffff;
  --teal: #027a70;
  --teal-dark: #045c57;
  --teal-soft: #e1f3ee;
  --orange: #f05d28;
  --orange-soft: #fff0e8;
  --yellow: #dfaf25;
  --red: #bb3f45;
  --red-soft: #faebec;
  --shadow: 0 18px 42px rgba(20, 42, 47, 0.08);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--canvas);
  font-family: "Noto Sans SC", "Manrope", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

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

button { cursor: pointer; }

button:disabled { cursor: not-allowed; }

a { color: inherit; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 20;
  padding: 8px 12px;
  color: var(--white);
  background: var(--ink);
  transform: translateY(-180%);
}

.skip-link:focus { transform: translateY(0); }

:focus-visible {
  outline: 3px solid rgba(240, 93, 40, 0.7);
  outline-offset: 3px;
}

.app-header {
  height: 68px;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid rgba(16, 34, 48, 0.12);
  background: rgba(248, 250, 247, 0.94);
  position: sticky;
  top: 0;
  z-index: 10;
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  font-family: "Manrope", "Noto Sans SC", sans-serif;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--white);
  background: var(--teal);
  font-size: 16px;
  line-height: 1;
}

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

.context-name { padding-left: 14px; border-left: 1px solid var(--line); font-weight: 600; white-space: nowrap; }

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 11px;
  white-space: nowrap;
}

.connection-state i { width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); }
.connection-state.is-online { color: var(--teal-dark); }
.connection-state.is-online i { background: var(--teal); }
.connection-state.is-offline { color: var(--red); }
.connection-state.is-offline i { background: var(--red); }

.back-link { margin-left: auto; color: var(--muted); font-size: 13px; text-decoration: none; white-space: nowrap; }
.back-link:hover { color: var(--teal-dark); }

main { max-width: 1440px; margin: 0 auto; padding: 44px clamp(20px, 4vw, 64px) 64px; }

.workspace-intro { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 48px; align-items: end; margin-bottom: 38px; }

.eyebrow { margin: 0 0 10px; color: var(--teal); font-family: "DM Mono", monospace; font-size: 11px; font-weight: 500; letter-spacing: 0; }

h1, h2, h3, p { margin-top: 0; }

.workspace-intro h1 { max-width: 840px; margin-bottom: 15px; font-family: "Manrope", "Noto Sans SC", sans-serif; font-size: clamp(32px, 4.4vw, 56px); line-height: 1.16; letter-spacing: 0; }
.workspace-intro > div > p:not(.eyebrow) { max-width: 760px; margin-bottom: 0; color: var(--muted); font-size: 16px; }

.intro-readout { padding: 22px 24px; border-top: 3px solid var(--orange); background: var(--white); box-shadow: var(--shadow); }
.intro-readout span, .intro-readout small { display: block; color: var(--muted); font-size: 12px; }
.intro-readout strong { display: block; margin: 5px 0 8px; font-family: "Manrope", "Noto Sans SC", sans-serif; font-size: 23px; }

.workspace-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }

.nav-tab {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: var(--muted);
  border: 0;
  border-top: 1px solid transparent;
  background: transparent;
  text-align: left;
  transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
}

.nav-tab + .nav-tab { border-left: 1px solid var(--line); }
.nav-tab:hover { color: var(--ink); background: rgba(255, 255, 255, 0.6); }
.nav-tab.is-active { color: var(--ink); border-top-color: var(--teal); background: var(--white); }
.tab-index { color: var(--orange); font-family: "DM Mono", monospace; font-size: 11px; }

.app-shell { min-height: 580px; background: var(--white); box-shadow: var(--shadow); }
.view { min-width: 0; }

.strategy-grid { display: grid; grid-template-columns: 1.18fr 0.82fr; }

.form-band { padding: 32px; border-bottom: 1px solid var(--line); }
.product-band { border-right: 1px solid var(--line); }
.notes-band { grid-column: 1 / -1; }

.band-heading, .section-heading { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.band-heading { margin-bottom: 26px; }
.band-heading h2, .section-heading h2 { margin: 0; font-family: "Manrope", "Noto Sans SC", sans-serif; font-size: 22px; line-height: 1.3; }

.field-grid { display: grid; gap: 17px; }
.product-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.budget-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.notes-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.wide { grid-column: span 2; }

.field { display: grid; gap: 7px; min-width: 0; color: var(--ink); font-size: 13px; font-weight: 600; }
.field > span, .platform-picker legend { color: var(--ink); font-size: 13px; }
.field b, .platform-picker b { color: var(--orange); }
.field small { color: var(--muted); font-size: 11px; font-weight: 400; line-height: 1.45; }

input, textarea, select {
  width: 100%;
  min-width: 0;
  border: 1px solid #bdc9c5;
  border-radius: 0;
  color: var(--ink);
  background: var(--white);
  padding: 10px 11px;
  font-size: 14px;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

input::placeholder, textarea::placeholder { color: #94a19e; }
input:hover, textarea:hover, select:hover { border-color: #879793; }
input:focus, textarea:focus, select:focus { border-color: var(--teal); outline: 0; box-shadow: 0 0 0 3px rgba(2, 122, 112, 0.12); }
textarea { resize: vertical; min-height: 86px; }

.unit-input { position: relative; }
.unit-input input { padding-right: 36px; }
.unit-input em { position: absolute; top: 11px; right: 12px; color: var(--muted); font-size: 12px; font-style: normal; font-weight: 400; }

.platform-picker { grid-column: span 2; display: flex; flex-wrap: wrap; gap: 8px; margin: 3px 0 0; padding: 0; border: 0; }
.platform-picker legend { width: 100%; margin-bottom: 2px; font-weight: 600; }
.platform-picker label { position: relative; }
.platform-picker input { position: absolute; opacity: 0; pointer-events: none; }
.platform-picker span { display: block; min-width: 75px; padding: 9px 12px; border: 1px solid #bdc9c5; background: var(--white); color: var(--muted); text-align: center; transition: 140ms ease; }
.platform-picker input:checked + span { border-color: var(--teal); color: var(--teal-dark); background: var(--teal-soft); }
.platform-picker input:focus-visible + span { outline: 3px solid rgba(240, 93, 40, 0.7); outline-offset: 2px; }

.form-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 24px; margin-top: 23px; }
.form-actions > p { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 12px; }
.preflight-checks { display: grid; gap: 8px; min-width: 0; }
.acknowledgement { display: flex; align-items: flex-start; gap: 8px; color: var(--ink); font-size: 12px; font-weight: 500; line-height: 1.45; }
.acknowledgement input { width: 16px; height: 16px; flex: 0 0 auto; margin: 1px 0 0; accent-color: var(--teal); }
.acknowledgement-risk { color: #75401e; }
.guardrail-status { min-height: 18px; margin: 0; color: var(--teal-dark); font-size: 12px; }
.guardrail-status.is-warning { color: #9a4d21; }
.command-cluster { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 9px; }

.primary-command, .secondary-command, .icon-button, .refresh-link {
  border: 0;
  border-radius: 0;
  font-family: "Noto Sans SC", "Manrope", sans-serif;
  font-weight: 700;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease, border-color 140ms ease;
}
.primary-command { padding: 11px 17px; color: var(--white); background: var(--teal); }
.primary-command:hover:not(:disabled) { background: var(--teal-dark); transform: translateY(-1px); }
.primary-command:disabled { color: #d5e8e4; background: #80aaa3; }
.primary-command span { margin-right: 6px; font-size: 18px; line-height: 0; vertical-align: -1px; }
.secondary-command { padding: 10px 14px; color: var(--teal-dark); border: 1px solid var(--teal); background: transparent; }
.secondary-command:hover:not(:disabled) { color: var(--white); background: var(--teal); }
.secondary-command:disabled { color: #a1aeab; border-color: #c3cdca; background: #f7f9f8; }
.icon-button { width: 40px; height: 40px; display: inline-grid; place-items: center; color: var(--teal-dark); border: 1px solid var(--teal); background: var(--white); font-size: 22px; line-height: 1; }
.icon-button:hover { color: var(--white); background: var(--teal); }

.result-panel { margin: 0; border-top: 3px solid var(--teal); background: #fcfdfb; }
.result-empty { min-height: 184px; display: flex; align-items: center; gap: 22px; padding: 34px; }
.empty-number { color: #c5d1ce; font-family: "DM Mono", monospace; font-size: 42px; }
.result-empty h2 { margin-bottom: 5px; font-family: "Manrope", "Noto Sans SC", sans-serif; font-size: 20px; }
.result-empty p { margin: 0; max-width: 580px; color: var(--muted); }
.result-content { padding: 30px 32px 36px; }

.plan-overview { display: grid; grid-template-columns: 1.5fr repeat(3, minmax(120px, 0.5fr)); border-bottom: 1px solid var(--line); }
.plan-overview > div { padding: 0 18px 22px; border-left: 1px solid var(--line); }
.plan-overview > div:first-child { padding-left: 0; border-left: 0; }
.plan-overview span, .plan-overview small { display: block; color: var(--muted); font-size: 11px; }
.plan-overview strong { display: block; margin: 4px 0; font-family: "Manrope", "Noto Sans SC", sans-serif; font-size: 19px; overflow-wrap: anywhere; }

.result-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr); gap: 28px; padding-top: 27px; }
.result-block h3 { margin-bottom: 14px; font-family: "Manrope", "Noto Sans SC", sans-serif; font-size: 16px; }
.product-status-list, .action-list, .review-list { margin: 0; padding: 0; list-style: none; }
.product-status-list { display: grid; gap: 8px; }
.product-status-list li { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid #e4eae7; }
.product-status-list b { font-size: 12px; font-weight: 600; }
.product-status-list span { color: var(--muted); overflow-wrap: anywhere; }
.status-qualified { color: var(--teal-dark); }
.status-deferred { color: var(--red); }
.budget-split { display: grid; gap: 10px; }
.budget-row { display: grid; grid-template-columns: 72px 1fr 68px; gap: 10px; align-items: center; font-size: 12px; }
.budget-row > span { color: var(--muted); }
.budget-track { height: 8px; overflow: hidden; background: #dde8e5; }
.budget-track i { display: block; height: 100%; background: var(--orange); }
.budget-row strong { text-align: right; font-family: "DM Mono", monospace; font-size: 11px; }
.platform-plan { padding-top: 18px; margin-top: 18px; border-top: 1px solid var(--line); }
.platform-plan h4 { margin: 0 0 9px; font-size: 14px; }
.action-list { display: grid; gap: 8px; }
.action-list li { padding: 10px 12px; border-left: 3px solid var(--teal); background: var(--white); font-size: 12px; }
.action-list b { display: block; margin-bottom: 2px; font-size: 12px; }
.action-list small { color: var(--muted); }
.warning-note { margin: 0 0 18px; padding: 10px 12px; border-left: 3px solid var(--orange); color: #75401e; background: var(--orange-soft); font-size: 12px; }
.model-advisory { display: grid; gap: 14px; margin-top: 28px; padding-top: 24px; border-top: 2px solid var(--orange); }
.model-advisory h3 { margin: 0; font-family: "Manrope", "Noto Sans SC", sans-serif; font-size: 17px; }
.model-advisory > p { max-width: 780px; margin: 0; color: var(--muted); font-size: 13px; }
.advisory-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.advisory-grid > div { padding: 14px; border-left: 3px solid var(--orange); background: #fffaf5; }
.advisory-grid h4 { margin: 0 0 8px; font-size: 13px; }
.advisory-grid p, .advisory-grid ul { margin: 0; color: var(--muted); font-size: 12px; }
.advisory-grid ul { padding-left: 18px; }

.portfolio-layout, .feedback-layout, .account-layout { padding: 34px; }
.section-heading { margin-bottom: 29px; }
.section-heading > p { max-width: 420px; margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.portfolio-toolbar, .feedback-controls { display: flex; align-items: end; gap: 10px; margin-bottom: 17px; }
.field.compact { width: 150px; }
.portfolio-toolbar .secondary-command { margin-left: auto; }

.product-table-wrap, .feedback-table-wrap { overflow-x: auto; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; white-space: nowrap; }
th { padding: 11px 10px; color: var(--muted); background: #f3f6f4; font-size: 11px; font-weight: 600; text-align: left; }
td { min-width: 112px; padding: 7px 6px; border-top: 1px solid #e4eae7; }
td input, td select { min-width: 96px; padding: 7px 8px; font-size: 12px; }
td:nth-last-child(2) input { min-width: 180px; }
td:last-child { min-width: 40px; text-align: center; }
.row-remove { width: 28px; height: 28px; padding: 0; color: #8c5a5d; border: 0; background: transparent; font-size: 22px; line-height: 1; }
.row-remove:hover { color: var(--red); background: var(--red-soft); }

.portfolio-summary { min-height: 61px; display: flex; align-items: center; margin-top: 18px; padding: 14px 16px; color: var(--muted); border-left: 3px solid var(--teal); background: var(--teal-soft); font-size: 13px; }
.portfolio-summary.is-warning { color: #75401e; border-left-color: var(--orange); background: var(--orange-soft); }

.feedback-controls { flex-wrap: wrap; }
.feedback-controls .primary-command { margin-left: auto; }
.review-result { margin-top: 25px; }
.review-empty { padding: 28px 0; color: var(--muted); border-top: 1px solid var(--line); }
.review-overview { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 20px; border: 1px solid var(--line); }
.review-overview div { padding: 15px; border-left: 1px solid var(--line); }
.review-overview div:first-child { border-left: 0; }
.review-overview span { display: block; color: var(--muted); font-size: 11px; }
.review-overview strong { display: block; margin-top: 3px; font-family: "Manrope", "Noto Sans SC", sans-serif; font-size: 20px; }
.review-records { display: grid; gap: 10px; }
.review-record { display: grid; grid-template-columns: minmax(170px, 0.6fr) minmax(0, 1fr) minmax(160px, 0.45fr); gap: 18px; padding: 16px; border-left: 3px solid var(--teal); background: #f7faf8; }
.review-record.is-pause { border-left-color: var(--red); background: #fff9f9; }
.review-record.is-repair { border-left-color: var(--orange); background: #fffbf6; }
.review-record h3 { margin-bottom: 3px; font-size: 14px; overflow-wrap: anywhere; }
.review-record p, .review-record ul { margin: 0; color: var(--muted); font-size: 12px; }
.review-record ul { padding-left: 17px; }
.decision-label { display: inline-block; margin-top: 9px; color: var(--teal-dark); font-family: "DM Mono", monospace; font-size: 10px; }
.review-record.is-pause .decision-label { color: var(--red); }
.review-record.is-repair .decision-label { color: #a44b1d; }

.account-status { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto; gap: 18px; align-items: center; padding: 25px; border-top: 3px solid var(--yellow); background: #fffdf6; }
.account-status.is-ready { border-top-color: var(--teal); background: #f4fbf8; }
.account-icon { width: 45px; height: 45px; display: grid; place-items: center; color: var(--white); background: #f15b2a; font-family: "Manrope", sans-serif; font-weight: 800; }
.account-status span { color: var(--muted); font-family: "DM Mono", monospace; font-size: 11px; }
.account-status h3 { margin: 4px 0; font-family: "Manrope", "Noto Sans SC", sans-serif; font-size: 20px; }
.account-status p { margin: 0; color: var(--muted); font-size: 13px; }
.account-actions { display: grid; gap: 8px; justify-items: start; }
.account-readout { margin: 12px 0 0; padding: 11px 13px; color: var(--muted); border-left: 3px solid var(--line); background: #f7faf8; font-size: 12px; }
.agent-monitor { margin-top: 20px; padding: 20px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.agent-monitor-heading { display: flex; justify-content: space-between; gap: 16px; align-items: start; }
.agent-monitor-heading .eyebrow { margin: 0 0 4px; }
.agent-monitor-heading h3 { margin: 0; font-family: "Manrope", "Noto Sans SC", sans-serif; font-size: 16px; }
.agent-monitor-heading > span { flex: 0 0 auto; padding: 4px 8px; color: #0f766e; border: 1px solid #8fd4ca; background: #f4fbf8; font-family: "DM Mono", monospace; font-size: 10px; }
.agent-schedule { margin: 12px 0; color: var(--muted); font-size: 12px; }
.agent-proposals { display: grid; gap: 8px; }
.agent-proposals > p { margin: 0; color: var(--muted); font-size: 12px; }
.agent-proposal { padding: 12px; border-left: 3px solid var(--teal); background: #f7faf8; }
.agent-proposal h4 { margin: 0 0 5px; font-size: 13px; }
.agent-proposal p { margin: 0 0 7px; color: var(--muted); font-size: 12px; }
.agent-proposal ul { margin: 0; padding-left: 18px; color: var(--ink); font-size: 12px; }

.account-steps { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; margin-top: 28px; background: var(--line); }
.account-steps article { min-height: 174px; padding: 22px; background: var(--white); }
.account-steps span { color: var(--orange); font-family: "DM Mono", monospace; font-size: 12px; }
.account-steps h3 { margin: 24px 0 7px; font-family: "Manrope", "Noto Sans SC", sans-serif; font-size: 16px; }
.account-steps p { margin: 0; color: var(--muted); font-size: 12px; }

.run-history { margin-top: 32px; border-top: 1px solid var(--line); }
.history-heading { display: flex; align-items: center; justify-content: space-between; padding: 19px 0 14px; }
.history-heading h3 { margin: 0; font-family: "Manrope", "Noto Sans SC", sans-serif; font-size: 16px; }
.refresh-link { padding: 4px 0; color: var(--teal-dark); background: transparent; font-size: 12px; }
.refresh-link:hover { color: var(--orange); }
.history-list { display: grid; gap: 7px; }
.history-list > p { margin: 0; color: var(--muted); font-size: 13px; }
.history-item { display: grid; grid-template-columns: 120px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 11px 12px; background: #f5f8f6; font-size: 12px; }
.history-item time { color: var(--muted); font-family: "DM Mono", monospace; font-size: 10px; }
.history-item span { overflow-wrap: anywhere; }
.history-item strong { color: var(--teal-dark); font-size: 11px; }

@media (max-width: 980px) {
  .workspace-intro { grid-template-columns: 1fr; gap: 24px; }
  .intro-readout { max-width: 360px; }
  .strategy-grid { grid-template-columns: 1fr; }
  .product-band { border-right: 0; }
  .result-grid { grid-template-columns: 1fr; }
  .account-status { grid-template-columns: 54px 1fr; }
  .account-actions { grid-column: 1 / -1; }
  .review-record { grid-template-columns: 1fr 1fr; }
  .review-record > div:last-child { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .app-header { height: auto; min-height: 62px; flex-wrap: wrap; gap: 8px; padding-top: 12px; padding-bottom: 12px; }
  .header-context { order: 3; width: 100%; }
  .context-name { padding-left: 0; border-left: 0; }
  .back-link { font-size: 12px; }
  main { padding: 28px 14px 42px; }
  .workspace-intro h1 { font-size: 34px; }
  .workspace-intro > div > p:not(.eyebrow) { font-size: 14px; }
  .workspace-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-tab { min-height: 59px; gap: 8px; font-size: 13px; }
  .nav-tab:nth-child(3) { border-left: 0; }
  .nav-tab:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .form-band, .portfolio-layout, .feedback-layout, .account-layout { padding: 24px 17px; }
  .band-heading, .section-heading { display: block; }
  .section-heading > p { margin-top: 11px; }
  .product-fields, .budget-fields, .notes-fields { grid-template-columns: 1fr; }
  .wide, .platform-picker { grid-column: span 1; }
  .plan-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; }
  .plan-overview > div { padding: 12px; border-top: 1px solid var(--line); }
  .plan-overview > div:first-child { grid-column: 1 / -1; padding-left: 0; border-top: 0; }
  .result-content { padding: 24px 17px; }
  .form-actions { grid-template-columns: 1fr; }
  .command-cluster { justify-content: flex-start; }
  .portfolio-toolbar, .feedback-controls { align-items: flex-end; }
  .portfolio-toolbar .secondary-command, .feedback-controls .primary-command { width: 100%; margin-left: 0; }
  .feedback-controls .field.compact { width: calc(50% - 22px); }
  .review-overview { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .review-overview div:nth-child(3) { border-left: 0; border-top: 1px solid var(--line); }
  .review-overview div:nth-child(4) { border-top: 1px solid var(--line); }
  .review-record { grid-template-columns: 1fr; gap: 11px; }
  .review-record > div:last-child { grid-column: auto; }
  .account-steps { grid-template-columns: 1fr; }
  .advisory-grid { grid-template-columns: 1fr; }
  .account-steps article { min-height: 0; }
  .account-steps h3 { margin-top: 12px; }
  .history-item { grid-template-columns: 1fr; gap: 3px; }
}

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