:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-muted: #f0f4f8;
  --text: #172033;
  --muted: #667085;
  --border: #d7dee8;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #d97706;
  --danger: #b42318;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: #0f172a;
  color: #e5edf7;
  padding: 20px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-weight: 800;
}

.brand-title {
  font-size: 15px;
  font-weight: 750;
}

.brand-subtitle {
  margin-top: 2px;
  color: #9fb0c6;
  font-size: 12px;
}

.safety {
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: var(--radius);
  background: rgba(15, 118, 110, 0.18);
  padding: 12px;
  margin-bottom: 18px;
}

.safety-title {
  color: #ccfbf1;
  font-size: 13px;
  font-weight: 750;
}

.safety-text {
  margin-top: 5px;
  color: #cbd5e1;
  font-size: 12px;
  line-height: 1.5;
}

.group-list {
  display: grid;
  gap: 8px;
}

.group-button {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.group-button:hover,
.group-button.active {
  border-color: rgba(45, 212, 191, 0.7);
  background: rgba(20, 184, 166, 0.16);
}

.group-code {
  display: grid;
  height: 36px;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  color: #ccfbf1;
  font-weight: 800;
}

.group-name {
  font-size: 13px;
  font-weight: 700;
}

.group-caption {
  margin-top: 2px;
  color: #9fb0c6;
  font-size: 11px;
  line-height: 1.35;
}

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

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

.topbar p,
.section-heading p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.topbar-actions {
  display: flex;
  gap: 10px;
}

.button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.button.primary {
  background: var(--primary);
  color: #fff;
}

.button.primary:hover {
  background: var(--primary-dark);
}

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

.formula-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(15, 118, 110, 0.08), var(--surface) 60%);
  padding: 12px 16px;
  margin-bottom: 14px;
}

.formula-banner-tag {
  display: grid;
  place-items: center;
  min-width: 44px;
  height: 44px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 17px;
}

.formula-banner-title {
  font-size: 14px;
  font-weight: 750;
}

.formula-banner-text {
  margin-top: 3px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.step-badge {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  vertical-align: middle;
  margin-right: 6px;
}

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

.metric,
.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric {
  padding: 14px;
}

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

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 24px;
  line-height: 1.15;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(320px, 0.75fr);
  gap: 14px;
  align-items: start;
}

.panel {
  padding: 16px;
}

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

.select {
  min-width: 180px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font-size: 13px;
}

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

.form-grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

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

.param-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 12px;
  margin-bottom: 14px;
}

.param-title {
  font-size: 12px;
  font-weight: 750;
  color: var(--primary-dark);
  margin-bottom: 10px;
}

.param-prices {
  margin-top: 10px;
}

.param-note {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
}

.lines-block {
  margin-top: 18px;
}

.section-heading--tight {
  margin-bottom: 10px;
}

.h2-sm {
  font-size: 15px;
}

.button--sm {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.lines-table {
  min-width: 520px;
}

.lines-table th,
.lines-table td {
  padding: 6px 6px;
}

.lines-table input {
  height: 32px;
  font-size: 12px;
}

.num-input {
  text-align: right;
}

.cell-total {
  font-weight: 750;
  white-space: nowrap;
}

.cell-derived {
  color: var(--accent);
  font-weight: 700;
  background: rgba(217, 119, 6, 0.07);
  white-space: nowrap;
}

.row-del {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--danger);
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 12px;
}

.row-del:hover {
  background: #fef2f2;
  border-color: var(--danger);
}

.partner-card {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 14px;
}

.field-inline {
  margin-bottom: 10px;
}

.select--full {
  width: 100%;
  min-width: 0;
}

.partner-formula {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.5;
}

.doc-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-muted);
  border: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

label {
  display: grid;
  gap: 6px;
}

label span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

input {
  width: 100%;
  min-width: 0;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text);
  padding: 0 10px;
  font-size: 13px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(20, 184, 166, 0.22);
  outline-offset: 1px;
}

.total-box {
  border-radius: var(--radius);
  background: #0f172a;
  color: #fff;
  padding: 16px;
  margin-bottom: 12px;
}

.total-box span,
.total-box small {
  display: block;
  color: #cbd5e1;
  font-size: 12px;
}

.total-box strong {
  display: block;
  margin: 8px 0 4px;
  font-size: 34px;
  line-height: 1.1;
}

.breakdown-list {
  display: grid;
  gap: 8px;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  padding: 10px;
}

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

.breakdown-item strong {
  font-size: 14px;
}

.table-panel {
  margin-top: 14px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--border);
  padding: 11px 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.numeric {
  text-align: right;
}

tbody tr:hover {
  background: #f8fafc;
}

.formula {
  color: var(--text);
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 12px;
}

.muted {
  color: var(--muted);
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .group-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 860px) {
  .workspace {
    padding: 16px;
  }

  .topbar,
  .section-heading {
    flex-direction: column;
  }

  .topbar-actions,
  .button,
  .select {
    width: 100%;
  }

  .topbar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .summary-grid,
  .form-grid,
  .group-list {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .summary-grid,
  .form-grid,
  .group-list {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 24px;
  }

  .metric strong,
  .total-box strong {
    font-size: 26px;
  }

  .topbar-actions {
    grid-template-columns: 1fr;
  }
}
