:root {
  color-scheme: light;
  --ink: #25252b;
  --muted: #6d7079;
  --line: #dfe1dc;
  --paper: #f6f7f2;
  --surface: #ffffff;
  --wash: #eef5f3;
  --future-dusk: #25243f;
  --future-dusk-2: #302e52;
  --teal: #007f78;
  --teal-strong: #00645f;
  --teal-soft: #e8f5f3;
  --mocha: #a47864;
  --mocha-soft: #f3ebe6;
  --gold: #d79222;
  --gold-soft: #fff3d8;
  --coral: #d75f56;
  --green: #287a52;
  --accent: var(--teal);
  --accent-strong: var(--teal-strong);
  --amber: #b87918;
  --red: #bd4a42;
  --shadow: 0 18px 42px rgba(37, 36, 63, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(90deg, rgba(37, 36, 63, 0.03), transparent 32%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-height: 100vh;
  padding: 18px 14px;
  background: var(--future-dusk);
  color: #f7f5ef;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 6px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 8px;
}

.brand-name {
  font-size: 18px;
  font-weight: 740;
}

.brand-mode {
  margin-top: 2px;
  color: #c6c4d8;
  font-size: 12px;
}

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

.nav-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  min-height: 42px;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dddceb;
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  background: var(--future-dusk-2);
  color: #ffffff;
}

.nav-item.is-active {
  box-shadow: inset 3px 0 0 var(--teal);
}

.nav-icon,
[data-icon] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
}

.sidebar-status {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  align-items: start;
  margin-top: auto;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
}

.status-dot {
  width: 10px;
  height: 10px;
  margin-top: 5px;
  border-radius: 50%;
  background: #48d2b0;
}

.status-title {
  font-size: 13px;
  font-weight: 700;
}

.status-caption {
  overflow: hidden;
  margin-top: 2px;
  color: #c6c4d8;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 18px;
}

.topbar h1 {
  margin: 0;
  font-size: 27px;
  line-height: 1.1;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.icon-button {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 680;
}

.icon-button:not(.text-button) {
  width: 38px;
  padding: 0;
}

.icon-button:hover {
  border-color: #b9bdc5;
  box-shadow: 0 4px 14px rgba(37, 36, 63, 0.09);
}

.notice {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #b9ded8;
  border-radius: 8px;
  background: var(--teal-soft);
  color: #155d57;
  font-size: 14px;
}

.notice.is-error {
  border-color: #efc7c3;
  background: #fff0ef;
  color: var(--red);
}

.is-hidden {
  display: none !important;
}

.mode-banner {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  margin-bottom: 14px;
  padding: 11px 12px;
  border: 1px solid #b8deda;
  border-radius: 8px;
  background: var(--teal-soft);
  color: #195a55;
  font-size: 13px;
  line-height: 1.4;
}

.mode-banner strong,
.mode-banner span:last-child {
  display: block;
}

.mode-banner strong {
  color: #123f3c;
}

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

.workflow-step {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 42px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  appearance: none;
  background: #ffffff;
  color: var(--muted);
  text-align: left;
}

.workflow-step:not(:disabled):hover {
  border-color: #b7d9d4;
  background: #f8fcfb;
}

.workflow-step:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.workflow-step span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: #eff1ee;
  color: #555862;
  font-size: 12px;
  font-weight: 760;
}

.workflow-step strong {
  overflow: hidden;
  font-size: 12px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workflow-step.is-done {
  border-color: #c7e3dd;
  color: #225f59;
}

.workflow-step.is-done span {
  background: var(--teal-soft);
  color: var(--teal-strong);
}

.workflow-step.is-current {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 127, 120, 0.1);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.main-view,
.confirm-panel {
  min-width: 0;
}

.section-band {
  margin-bottom: 16px;
  padding: 18px;
  border: 1px solid rgba(37, 36, 63, 0.12);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.section-band.is-flat {
  box-shadow: none;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 14px;
}

.section-title {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.section-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

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

.field {
  display: grid;
  gap: 6px;
}

.field.span-2 {
  grid-column: 1 / -1;
}

.field label {
  color: #3f3f48;
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field select,
.field textarea,
.table-input,
.table-select,
.chat-input {
  width: 100%;
  min-width: 0;
  border: 1px solid #cfd3ce;
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
}

.field input,
.field select,
.table-input,
.table-select,
.chat-input {
  height: 38px;
  padding: 8px 10px;
}

.field textarea {
  min-height: 78px;
  resize: vertical;
  padding: 9px 10px;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.table-input:focus,
.table-select:focus,
.chat-input:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(0, 127, 120, 0.16);
}

.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--red);
  outline-color: rgba(189, 74, 66, 0.14);
}

.field-error {
  color: var(--red);
  font-size: 12px;
  line-height: 1.3;
}

.switch-row {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #3e4148;
  font-size: 13px;
  font-weight: 680;
}

.switch-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--teal);
}

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

.button {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 720;
}

.button:hover {
  background: var(--accent-strong);
}

.button.secondary {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.button.secondary:hover {
  border-color: #b7bbc3;
  background: #f7f8f3;
}

.button.danger {
  background: var(--red);
}

.button.danger:hover {
  background: #8d2c27;
}

.button.warning {
  background: var(--gold);
}

.button.warning:hover {
  background: #a86c15;
}

.button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(0, 127, 120, 0.22);
  outline-offset: 2px;
}

.loader {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: #ffffff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.button.secondary .loader {
  border-color: rgba(0, 127, 120, 0.22);
  border-top-color: var(--teal);
}

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

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

.kpi {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.kpi-label {
  color: var(--muted);
  font-size: 12px;
}

.kpi-value {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 780;
}

.kpi-change {
  margin-top: 2px;
  color: var(--green);
  font-size: 12px;
}

.summary {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
  padding: 12px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--teal-soft);
}

.summary p {
  margin: 0;
  line-height: 1.45;
}

.risk-list,
.tag-list,
.audit-list,
.op-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid #b8deda;
  border-radius: 999px;
  background: #f4fbfa;
  color: #265f5a;
  font-size: 12px;
}

.risk-item,
.audit-item,
.op-item {
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-size: 13px;
  line-height: 1.35;
}

.risk-item {
  border-color: #efcf94;
  background: var(--gold-soft);
  color: #79500f;
}

.data-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  position: relative;
  scrollbar-color: var(--teal) #edf0eb;
}

.data-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table th,
.data-table td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.data-table th {
  background: #f4f5f0;
  color: #454550;
  font-size: 12px;
  font-weight: 760;
}

.data-table td {
  font-size: 13px;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.table-input {
  height: 34px;
  padding: 6px 8px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table-select {
  height: 34px;
  padding: 5px 8px;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
}

#planTable {
  min-width: 1080px;
}

#planTable th:nth-child(1),
#planTable td:nth-child(1) {
  width: 250px;
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 8px 0 14px rgba(37, 36, 63, 0.06);
}

#planTable th:nth-child(1) {
  z-index: 3;
  background: #f4f5f0;
}

#planTable td:nth-child(1) {
  background: #ffffff;
}

#planTable th:nth-child(2),
#planTable td:nth-child(2) {
  width: 118px;
}

#planTable th:nth-child(3),
#planTable td:nth-child(3) {
  width: 190px;
}

#planTable th:nth-child(4),
#planTable td:nth-child(4) {
  width: 170px;
}

#planTable th:nth-child(5),
#planTable td:nth-child(5) {
  width: 290px;
}

#planTable th:nth-child(6),
#planTable td:nth-child(6) {
  width: 58px;
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.mini-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
}

.mini-button:hover {
  border-color: var(--red);
  color: var(--red);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eff1ee;
  color: #3e4148;
  font-size: 12px;
  font-weight: 680;
}

.status-pill.ok {
  background: #eaf7ef;
  color: var(--green);
}

.status-pill.warn {
  background: var(--gold-soft);
  color: #80520f;
}

.status-pill.risk {
  background: #fff0ef;
  color: var(--red);
}

.table-hint,
.budget-note,
.decision-note {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.budget-note {
  margin: 10px 0 0;
}

.decision-note {
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid #c7e3dd;
  border-radius: 8px;
  background: #f4fbfa;
  color: #275f5a;
}

.confirm-panel {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
}

.confirm-empty,
.confirm-box {
  padding: 16px;
  border: 1px solid rgba(37, 36, 63, 0.12);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.confirm-empty {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.confirm-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
  margin-bottom: 12px;
}

.confirm-title h2 {
  margin: 0;
  font-size: 17px;
}

.confirm-summary {
  margin: 0 0 12px;
  color: #34343b;
  font-size: 13px;
  line-height: 1.45;
}

.op-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.op-summary {
  color: var(--ink);
}

.split {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.cluster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.cluster {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  min-width: 0;
}

.cluster h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.cluster p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.cluster ul {
  display: grid;
  gap: 5px;
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.cluster-more {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.cluster-more summary {
  cursor: pointer;
  color: var(--teal-strong);
  font-weight: 700;
}

.cluster-more ul {
  margin-top: 6px;
}

.chat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.chart {
  display: grid;
  grid-template-columns: repeat(7, minmax(36px, 1fr));
  gap: 10px;
  align-items: end;
  height: 230px;
  padding: 16px 12px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.bar-cell {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  height: 100%;
  text-align: center;
}

.bar-track {
  display: flex;
  align-items: end;
  justify-content: center;
  min-height: 0;
}

.bar {
  width: 68%;
  min-height: 8px;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #47c7b0, var(--teal));
}

.period-select {
  height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.bar-label {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  display: grid;
  gap: 6px;
  padding: 24px;
  border: 1px dashed #b9bdc5;
  border-radius: 8px;
  background: #f8f9f4;
  color: var(--muted);
  text-align: center;
}

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

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.note-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
  color: #3f3f48;
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 1440px) {
  .content-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .confirm-panel {
    position: static;
  }
}

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    padding: 12px;
  }

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

  .sidebar-status {
    margin-top: 0;
  }

  .workspace {
    padding: 16px;
  }

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

  .form-grid,
  .split,
  .settings-grid,
  .cluster-grid,
  .kpi-grid,
  .workflow {
    grid-template-columns: 1fr;
  }

  .workflow-step strong {
    white-space: normal;
  }
}

@media (max-width: 520px) {
  .nav {
    grid-template-columns: 1fr;
  }

  .topbar h1 {
    font-size: 23px;
  }

  .chat-row {
    grid-template-columns: 1fr;
  }

  .top-actions,
  .toolbar {
    width: 100%;
  }

  .button,
  .text-button {
    width: 100%;
  }
}
