:root {
  --bg: #f4f1ea;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: #ffffff;
  --line: rgba(15, 15, 15, 0.08);
  --text: #101010;
  --muted: #66625d;
  --accent: #101010;
  --accent-soft: rgba(16, 16, 16, 0.08);
  --danger: #b0482f;
  --warning-bg: rgba(208, 115, 43, 0.12);
  --warning-border: rgba(208, 115, 43, 0.28);
  --shadow: 0 28px 80px rgba(17, 17, 17, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(0, 0, 0, 0.06), transparent 28%),
    radial-gradient(circle at bottom right, rgba(194, 180, 156, 0.2), transparent 34%),
    linear-gradient(180deg, #f6f3ed 0%, #efe8dc 100%);
}

.hidden {
  display: none !important;
}

.app-shell {
  width: min(1380px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 56px;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-card,
.summary-card,
.top-bar,
.overview-strip,
.section-card,
.offer-card,
.record-card,
.compact-card,
.brand-panel,
.report-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  border-radius: 28px;
}

.auth-card {
  width: min(560px, 100%);
  padding: 32px;
}

.auth-logo,
.brand-logo {
  display: block;
  width: auto;
}

.auth-logo {
  height: 52px;
  margin-bottom: 20px;
}

.brand-logo {
  height: 40px;
}

.eyebrow,
.section-tag {
  margin: 0 0 10px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

h1,
h2,
h3,
.auth-title {
  margin: 0;
}

h1,
.auth-title {
  font-size: clamp(2.1rem, 4vw, 4.2rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.brand-panel h1 {
  font-size: clamp(1.85rem, 3vw, 3rem);
  line-height: 0.98;
  max-width: 13ch;
}

h2 {
  font-size: 1.55rem;
}

.hero-copy,
.section-copy,
.auth-copy,
.summary-note {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.65;
}

.summary-card,
.top-bar,
.overview-strip,
.section-card,
.record-card,
.compact-card,
.report-card {
  padding: 24px;
}

.overview-strip {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 20px 24px;
  align-items: start;
}

.overview-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.overview-metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(120px, 1fr));
  gap: 10px;
  align-items: stretch;
}

.metric-pill {
  display: grid;
  gap: 8px;
  min-height: 82px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(16, 16, 16, 0.04);
  align-content: space-between;
}

.metric-pill span {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
}

.metric-pill strong {
  font-size: 1rem;
  line-height: 1.1;
}

.compact-pill {
  min-height: 72px;
}

.workbook-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 14px 0 18px;
}

.overview-actions {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
}

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

.summary-card dl {
  display: grid;
  gap: 16px;
  margin: 0;
}

.summary-card div,
.offer-results div,
#reportSummary div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.summary-card div:last-child,
.offer-results div:last-child,
#reportSummary div:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

dt,
.offer-results span,
.component-preview span,
.offer-summary-meta {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 800;
}

.header-actions,
.action-cluster,
.inline-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.top-bar {
  margin-top: 24px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

.top-bar-brand {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.58));
}

.workspace-badge {
  display: grid;
  gap: 4px;
  padding: 14px 18px;
  min-width: 240px;
  border-radius: 18px;
  background: rgba(16, 16, 16, 0.04);
}

.workspace-badge span {
  color: var(--muted);
  font-size: 0.85rem;
}

.workspace-badge strong {
  font-size: 1rem;
}

.workspace-badge-inline {
  min-width: 220px;
  padding: 10px 14px;
}

.settings-dialog {
  width: min(460px, calc(100% - 32px));
  border: 0;
  padding: 0;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(16, 16, 16, 0.24);
  backdrop-filter: blur(4px);
}

.settings-card {
  padding: 24px;
  border-radius: 28px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.settings-header {
  margin-bottom: 16px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.tab-button,
button,
.import-button {
  border: 0;
  border-radius: 14px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease, opacity 180ms ease;
}

.tab-button,
.secondary,
.icon-button,
.ghost {
  background: var(--accent-soft);
  color: var(--text);
}

.tab-button.active,
button:not(.secondary):not(.icon-button):not(.ghost),
.import-button {
  background: var(--accent);
  color: white;
}

button[disabled] {
  cursor: not-allowed;
  opacity: 0.45;
}

button:hover:not([disabled]),
.tab-button:hover,
.import-button:hover {
  transform: translateY(-1px);
}

.tab-panel {
  display: none;
  margin-top: 24px;
}

.tab-panel.active {
  display: grid;
  gap: 24px;
}

.subtabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.subtab-button {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease, color 180ms ease, border-color 180ms ease;
}

.subtab-button.active {
  background: var(--accent);
  color: white;
  border-color: transparent;
}

.subtab-button:hover {
  transform: translateY(-1px);
}

.import-section,
.output-section {
  display: none;
}

.import-section.active,
.output-section.active {
  display: block;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  margin-bottom: 18px;
}

.section-copy {
  max-width: 58ch;
  margin: 0;
}

.auth-form,
.form-grid {
  display: grid;
  gap: 16px;
}

.auth-form {
  margin: 24px 0;
}

.form-grid {
  margin-bottom: 20px;
}

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

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

.product-grid {
  grid-template-columns: 220px 1.5fr 180px 180px 180px;
}

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

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

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

.product-grid .wide-field,
.adjustment-grid .wide-field {
  grid-column: span 5;
}

label {
  display: grid;
  gap: 10px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid rgba(16, 16, 16, 0.12);
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus {
  outline: 2px solid rgba(16, 16, 16, 0.12);
  border-color: rgba(16, 16, 16, 0.24);
}

.import-button {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.import-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.list-tools {
  margin-bottom: 18px;
}

.list-tools input {
  max-width: 480px;
}

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

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

thead th {
  padding: 18px 16px;
  text-align: left;
  font-size: 0.9rem;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.9);
}

tbody td {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
}

tbody tr {
  background: rgba(255, 255, 255, 0.34);
}

.currency {
  font-weight: 800;
}

.import-totals {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.report-summary {
  margin-bottom: 24px;
}

.import-totals div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(16, 16, 16, 0.04);
}

.import-totals span {
  color: var(--muted);
}

.stack-list,
.offers-list,
.report-columns {
  display: grid;
  gap: 16px;
}

.compact-list {
  margin-bottom: 18px;
}

.record-card header,
.compact-card,
.offer-top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
}

.record-meta,
.compact-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  margin-top: 10px;
}

.record-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.record-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.86);
}

.compact-card {
  padding: 18px 20px;
}

.compact-main {
  display: grid;
  gap: 8px;
}

.offer-card {
  overflow: hidden;
  background: rgba(255, 255, 255, 0.76);
}

.offer-summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 22px;
  cursor: pointer;
  list-style: none;
}

.offer-summary::-webkit-details-marker {
  display: none;
}

.offer-summary-main {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
}

.offer-summary-name {
  font-size: 1rem;
}

.offer-summary-margin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(16, 16, 16, 0.08);
  font-weight: 800;
}

.offer-body {
  padding: 0 22px 22px;
  border-top: 1px solid var(--line);
}

.history-card .offer-body {
  padding-top: 18px;
}

.history-actions {
  margin-bottom: 16px;
}

.offer-fields {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  flex: 1;
}

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

.components {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.components-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  margin-bottom: 12px;
}

.component-list {
  display: grid;
  gap: 12px;
}

.component-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-radius: 18px;
  background: rgba(16, 16, 16, 0.03);
  border: 1px solid rgba(16, 16, 16, 0.06);
}

.component-preview {
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--panel-strong);
}

.component-preview strong {
  display: block;
  margin-top: 4px;
}

.offer-results {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.warning-box {
  margin-bottom: 16px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--danger);
  font-weight: 700;
}

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

.report-card h3 {
  margin-bottom: 12px;
}

.empty-state {
  color: var(--muted);
  padding: 16px 0 4px;
}

@media (max-width: 1100px) {
  .hero,
  .top-bar,
  .overview-strip,
  .section-header,
  .record-card header,
  .compact-card,
  .offer-top,
  .import-grid,
  .product-grid,
  .adjustment-grid,
  .output-grid,
  .output-grid-3,
  .offer-fields,
  .offer-results,
  .component-row,
  .offer-summary,
  .summary-top,
  .import-totals,
  .report-columns,
  .report-grid,
  .overview-metrics,
  .workbook-summary {
    grid-template-columns: 1fr;
  }

  .top-bar,
  .overview-strip,
  .section-header,
  .record-card header,
  .compact-card,
  .offer-top,
  .offer-summary,
  .summary-top,
  .overview-actions {
    display: grid;
    align-items: start;
    justify-items: stretch;
  }

  .product-grid .wide-field,
  .adjustment-grid .wide-field {
    grid-column: auto;
  }

  .components-head {
    flex-direction: column;
  }
}
