:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --ink: #14213d;
  --muted: #64748b;
  --line: #c8d8ef;
  --blue: #0757b8;
  --green: #15803d;
  --amber: #b45309;
  --red: #b91c1c;
  --violet: #6d28d9;
  --shadow: 0 14px 32px rgba(25, 55, 95, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1180px;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

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

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  padding: 22px 28px;
  color: #ffffff;
  background: linear-gradient(120deg, #063f89, #0f766e);
}

.topbar h1 {
  margin: 4px 0 0;
  font-size: 26px;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: inherit;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.topbar .eyebrow {
  opacity: 0.8;
}

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

.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  min-height: 36px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease, background-color 120ms ease;
}

.btn:hover {
  filter: brightness(0.98);
  box-shadow: 0 8px 18px rgba(22, 52, 88, 0.12);
  transform: translateY(-1px);
}

.btn:active,
.btn.clicked {
  transform: translateY(1px) scale(0.98);
  box-shadow: inset 0 2px 5px rgba(15, 23, 42, 0.16);
}

.btn:focus-visible,
.nav-item:focus-visible,
.segment:focus-visible,
.icon-btn:focus-visible {
  outline: 3px solid rgba(7, 87, 184, 0.22);
  outline-offset: 2px;
}

.btn.primary {
  color: #ffffff;
  background: var(--blue);
}

.btn.secondary {
  color: var(--blue);
  background: #eef6ff;
  border-color: #b8d4f5;
}

.btn.success {
  color: #ffffff;
  background: var(--green);
}

.btn.danger {
  color: #ffffff;
  background: var(--red);
}

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

.btn.save-pulse {
  animation: savePulse 620ms ease;
}

.btn.is-busy {
  opacity: 0.75;
  cursor: progress;
}

@keyframes savePulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(21, 128, 61, 0);
  }

  45% {
    transform: scale(1.05);
    box-shadow: 0 0 0 8px rgba(21, 128, 61, 0.18);
  }

  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(21, 128, 61, 0);
  }
}

.workspace {
  display: grid;
  grid-template-columns: 216px 1fr;
  gap: 16px;
  padding: 16px;
}

.sidebar,
.panel,
.flow-strip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar {
  align-self: start;
  position: sticky;
  top: 16px;
  padding: 14px;
}

.brand-block {
  display: grid;
  grid-template-columns: 46px 1fr;
  align-items: center;
  gap: 10px;
  padding-bottom: 14px;
  border-bottom: 1px solid #d9e5f4;
}

.brand-block strong {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: #ffffff;
  background: var(--blue);
  border-radius: 7px;
}

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

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

.nav-item {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  text-align: left;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #214065;
  background: transparent;
  cursor: pointer;
  transition: background-color 120ms ease, color 120ms ease, transform 120ms ease;
}

.nav-item:active {
  transform: translateX(2px);
}

.nav-item.active,
.nav-item:hover {
  color: var(--blue);
  background: #edf5ff;
  border-color: #c8dff9;
}

.content {
  display: grid;
  gap: 14px;
}

.flow-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  padding: 12px;
}

.flow-step {
  position: relative;
  display: grid;
  gap: 7px;
  min-height: 112px;
  padding: 14px;
  border: 1px solid #cbdced;
  border-radius: 7px;
  background: #fbfdff;
  cursor: pointer;
  outline: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.flow-step:hover,
.flow-step:focus-visible {
  border-color: #4f9ceb;
  box-shadow: 0 0 0 3px rgba(79, 156, 235, 0.16);
  transform: translateY(-1px);
}

.flow-step span {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #ffffff;
  background: #5f7897;
  font-weight: 700;
}

.flow-step strong {
  color: #0b4d99;
}

.flow-step small {
  color: var(--muted);
  line-height: 1.35;
}

.flow-step.active {
  border-color: #4f9ceb;
  background: #f1f8ff;
}

.flow-step.done span,
.flow-step.active span {
  background: var(--blue);
}

.panel {
  display: none;
  padding: 14px;
}

.panel.active {
  display: block;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.section-title.compact {
  margin-bottom: 10px;
}

.section-title .eyebrow {
  color: var(--blue);
}

h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  color: #0b4d99;
}

h3 {
  font-size: 15px;
}

.search-box input,
.form-grid input,
.form-grid select,
.form-grid textarea,
.toolbar select {
  width: 100%;
  border: 1px solid #cbd8e6;
  border-radius: 5px;
  color: var(--ink);
  background: #ffffff;
}

.toolbar select {
  width: auto;
  min-width: 210px;
  height: 36px;
  padding: 0 10px;
}

.search-box input {
  width: 360px;
  height: 38px;
  padding: 0 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  padding: 14px;
  border: 1px solid #d4e2f1;
  border-radius: 7px;
  background: #fbfdff;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}

.metric:hover {
  border-color: #94bfe9;
  box-shadow: 0 8px 18px rgba(25, 55, 95, 0.08);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 22px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid #d7e3f2;
  border-radius: 7px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid #e3ebf5;
  font-size: 13px;
  text-align: left;
  vertical-align: top;
}

th {
  color: #234569;
  background: #f3f7fc;
  font-weight: 700;
}

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

tbody tr {
  cursor: pointer;
}

tbody tr:hover {
  background: #f7fbff;
}

.status {
  display: inline-block;
  min-width: 84px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.status.review { color: #075985; background: #e0f2fe; }
.status.doing { color: #854d0e; background: #fef3c7; }
.status.approved { color: #166534; background: #dcfce7; }
.status.rejected { color: #991b1b; background: #fee2e2; }
.status.revise { color: #6d28d9; background: #ede9fe; }

.two-column {
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 14px;
}

.two-column.active {
  display: grid;
}

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

.form-grid label {
  display: grid;
  gap: 5px;
  color: #38536f;
  font-size: 12px;
  font-weight: 700;
}

.form-grid input,
.form-grid select {
  height: 36px;
  padding: 0 10px;
}

.form-grid textarea {
  padding: 10px;
  resize: vertical;
}

.span-2 {
  grid-column: span 2;
}

.info-panel {
  padding: 14px;
  border: 1px solid #d5e2f1;
  border-radius: 7px;
  background: #fbfdff;
}

.tree-list {
  display: grid;
  gap: 9px;
  margin: 12px 0 0;
  padding-left: 17px;
  color: #38536f;
  line-height: 1.35;
}

.costing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 280px;
  gap: 12px;
}

.costing-context {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.context-chip {
  padding: 10px 12px;
  border: 1px solid #d5e2f1;
  border-radius: 7px;
  background: #fbfdff;
}

.context-chip span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.context-chip strong {
  display: block;
  margin-top: 4px;
  font-size: 13px;
}

.cost-input,
.cost-select {
  width: 100%;
  min-width: 92px;
  height: 32px;
  border: 1px solid #cbd8e6;
  border-radius: 5px;
  color: var(--ink);
  background: #ffffff;
  padding: 0 8px;
}

.cost-input.wide {
  min-width: 170px;
}

.cost-input.supplier {
  min-width: 150px;
}

.cost-select.group {
  min-width: 150px;
}

.cost-select.method {
  min-width: 220px;
}

.product-overview {
  margin-bottom: 12px;
}

.product-table-wrap {
  max-height: 220px;
}

.product-table th,
.product-table td {
  white-space: nowrap;
}

.product-table tr.selected td {
  background: #eaf4ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.add-row-inline {
  width: 100%;
  justify-content: center;
}

tfoot td {
  background: #f8fbff;
  border-bottom: 0;
}

.row-action {
  min-height: 30px;
  border: 1px solid #fecaca;
  border-radius: 5px;
  color: var(--red);
  background: #fff5f5;
  cursor: pointer;
  font-weight: 700;
}

.summary-box {
  padding: 14px;
  border: 1px solid #d5e2f1;
  border-radius: 7px;
  background: #fbfdff;
}

.method-help {
  display: grid;
  gap: 7px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid #dbe6f2;
}

.method-help h4 {
  margin: 0;
  color: #244966;
  font-size: 13px;
}

.method-help p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.breakdown-line,
.summary-total,
.summary-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid #e0e9f4;
}

.summary-total {
  margin-top: 6px;
  border-top: 2px solid #bed4ec;
  border-bottom: 0;
  font-weight: 700;
}

.summary-table {
  border: 1px solid #d7e3f2;
  border-radius: 7px;
  overflow: hidden;
}

.summary-row {
  padding: 11px 14px;
  background: #ffffff;
}

.summary-row.strong {
  color: #0b4d99;
  font-weight: 700;
  background: #f2f8ff;
}

.mini-table td {
  font-size: 12px;
}

.deal-context {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.deal-context div {
  padding: 12px;
  border: 1px solid #d5e2f1;
  border-radius: 7px;
  background: #fbfdff;
}

.deal-context span,
.deal-settings span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.deal-context strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
}

.deal-settings {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.deal-settings label {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid #d5e2f1;
  border-radius: 7px;
  background: #ffffff;
}

.deal-input {
  width: 100%;
  height: 34px;
  border: 1px solid #cbd8e6;
  border-radius: 5px;
  color: var(--ink);
  background: #ffffff;
  padding: 0 8px;
}

.deal-input.price {
  min-width: 130px;
  font-weight: 700;
}

.deal-table-wrap {
  max-height: 58vh;
}

.deal-table {
  min-width: 1500px;
}

.deal-table th {
  position: sticky;
  top: 0;
  z-index: 1;
}

.deal-table td {
  white-space: nowrap;
}

.product-name {
  min-width: 170px;
}

.product-name small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.approval-grid.active {
  display: grid;
}

.approval-grid {
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.approval-card {
  min-height: 160px;
  padding: 18px;
  border: 1px solid #d5e2f1;
  border-radius: 7px;
  background: #fbfdff;
}

.approval-card p {
  color: var(--muted);
  line-height: 1.45;
}

.approval-mail-card {
  grid-column: 1 / -1;
}

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

.mail-grid label {
  display: grid;
  gap: 5px;
  color: #38536f;
  font-size: 12px;
  font-weight: 700;
}

.mail-grid input,
.mail-grid textarea {
  width: 100%;
  border: 1px solid #cbd8e6;
  border-radius: 5px;
  color: var(--ink);
  background: #ffffff;
  padding: 9px 10px;
}

.mail-grid input {
  height: 36px;
}

.mail-hint,
.mail-preview {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.approval-actions {
  display: flex;
  gap: 14px;
  margin-top: 22px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid #c9d8e9;
  border-radius: 50%;
  background: #ffffff;
  cursor: pointer;
  font-size: 26px;
  font-weight: 700;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.icon-btn:hover {
  background: #f8fbff;
  box-shadow: 0 8px 18px rgba(22, 52, 88, 0.12);
  transform: translateY(-1px);
}

.icon-btn:active,
.icon-btn.clicked {
  transform: translateY(1px) scale(0.96);
}

.icon-btn.approve { color: var(--green); }
.icon-btn.reject { color: var(--red); }
.icon-btn.revise { color: var(--violet); }

.documents-panel.active {
  display: block;
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid #cbd8e6;
  border-radius: 7px;
  background: #f3f7fc;
}

.segment {
  min-height: 32px;
  border: 0;
  border-radius: 5px;
  padding: 0 12px;
  color: #36536f;
  background: transparent;
  cursor: pointer;
}

.segment.active {
  color: #ffffff;
  background: var(--blue);
}

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

.process-lane {
  display: grid;
  gap: 10px;
  align-content: start;
}

.process-step {
  padding: 13px;
  border: 1px solid #d5e2f1;
  border-radius: 7px;
  background: #fbfdff;
}

.doc-check {
  width: 18px;
  height: 18px;
  accent-color: var(--blue);
}

.doc-actions {
  display: flex;
  gap: 8px;
  min-width: 150px;
}

.mini-btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

.automation-flow {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}

.automation-flow span {
  min-height: 50px;
  display: grid;
  place-items: center;
  border: 1px dashed #92b4d8;
  border-radius: 7px;
  background: #f5fbff;
  font-weight: 700;
  color: #244966;
}

dialog {
  border: 0;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  max-width: 480px;
}

dialog::backdrop {
  background: rgba(10, 20, 35, 0.38);
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 50;
  max-width: 360px;
  padding: 12px 14px;
  border: 1px solid #b8d4f5;
  border-radius: 7px;
  color: #123b66;
  background: #ffffff;
  box-shadow: 0 16px 42px rgba(15, 35, 65, 0.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 180ms ease, transform 180ms ease;
  font-size: 13px;
  font-weight: 700;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.success {
  border-color: #86efac;
  color: #166534;
}

.toast.warn {
  border-color: #fde68a;
  color: #854d0e;
}

.toast.error {
  border-color: #fecaca;
  color: #991b1b;
}

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .topbar,
  .workspace,
  .flow-strip,
  .metric-grid,
  .costing-layout,
  .costing-context,
  .deal-context,
  .deal-settings,
  .document-grid,
  .automation-flow {
    grid-template-columns: 1fr;
  }

  .workspace {
    display: block;
  }

  .sidebar {
    position: static;
    margin-bottom: 14px;
  }

  .two-column.active,
  .approval-grid.active {
    display: grid;
    grid-template-columns: 1fr;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .mail-grid {
    grid-template-columns: 1fr;
  }

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

  .search-box input {
    width: 100%;
  }

  .section-title {
    align-items: stretch;
    flex-direction: column;
  }
}
