:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-heading: #0f172a;
  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.1);

  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warning: #d97706;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --success: #059669;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;

  --box-top: #f3d5a5;
  --box-left: #ddb376;
  --box-right: #c79856;
  --box-stroke: #8c6228;
  --prod-fill: rgba(37, 99, 235, 0.28);
  --prod-stroke: #2563eb;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

[data-theme="dark"] {
  --bg-page: #090d16;
  --bg-card: #121a2b;
  --bg-subtle: #1a243b;
  --bg-input: #0e1524;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-heading: #ffffff;
  --border-color: #25334f;
  --border-strong: #334569;

  --accent: #3b82f6;
  --accent-hover: #60a5fa;
  --accent-soft: rgba(59, 130, 246, 0.16);

  --danger: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.14);
  --danger-border: rgba(248, 113, 113, 0.35);
  --warning: #fbbf24;
  --warning-bg: rgba(245, 158, 11, 0.14);
  --warning-border: rgba(251, 191, 36, 0.35);
  --success: #34d399;
  --success-bg: rgba(16, 185, 129, 0.14);
  --success-border: rgba(52, 211, 153, 0.35);

  --box-top: #c2995f;
  --box-left: #a37b42;
  --box-right: #86612d;
  --box-stroke: #f3d5a5;
  --prod-fill: rgba(96, 165, 250, 0.32);
  --prod-stroke: #60a5fa;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-main);
  background-color: var(--bg-page);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.55;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.hero-title {
  font-family: var(--font-heading);
  color: var(--text-heading);
  margin-top: 0;
}

.mono, code { font-family: var(--font-mono); }

.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
  width: 100%;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
}

.eu-pill {
  display: inline-flex;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--border-color);
  margin-bottom: 0.6rem;
}

.hero-title {
  font-size: 1.38rem;
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 0.45rem;
}

.hero-desc {
  color: var(--text-muted);
  font-size: 0.94rem;
  margin: 0;
  max-width: 78ch;
}

.presets-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.presets-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.preset-chip {
  appearance: none;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-main);
  padding: 0.42rem 0.8rem;
  min-height: 36px;
  border-radius: 999px;
  font-size: 0.81rem;
  font-weight: 500;
  font-family: var(--font-main);
  cursor: pointer;
  transition: all 0.15s ease;
}

.preset-chip:hover,
.preset-chip.active {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.shipping-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(0, 0.95fr);
  gap: 1.5rem;
  align-items: start;
}

.step-block {
  padding-bottom: 1.3rem;
  margin-bottom: 1.3rem;
  border-bottom: 1px solid var(--border-color);
}

.step-block:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

.block-head-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.step-title {
  font-size: 1.04rem;
  font-weight: 700;
  margin: 0;
}

.step-sub {
  margin: 0 0 0.85rem;
  font-size: 0.84rem;
  color: var(--text-muted);
}

.unit-select {
  width: auto !important;
  min-width: 110px !important;
}

.inline-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}

.inline-switch input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.product-fields.is-disabled {
  opacity: 0.55;
  pointer-events: none;
}

.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.85rem; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.75rem; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 0;
  margin-bottom: 0.75rem;
}

.form-label {
  font-size: 0.82rem;
  font-weight: 600;
}

.form-control,
.form-select {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 0.55rem 0.75rem;
  font-family: var(--font-main);
  font-size: 0.9rem;
  color: var(--text-main);
  background-color: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

.form-select {
  appearance: none;
  padding-right: 40px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}

[data-theme="dark"] .form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}

.form-select option {
  background-color: var(--bg-card);
  color: var(--text-main);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-main);
}

.btn:hover { border-color: var(--accent); color: var(--accent); }

/* SVG & Results */
.svg-stage {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 210px;
}

.svg-stage svg {
  width: 100%;
  max-width: 340px;
  height: auto;
  display: block;
}

.kpi-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.kpi-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.kpi-box.kpi-highlight {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.kpi-label { font-size: 0.76rem; font-weight: 600; color: var(--text-muted); }
.kpi-value { font-size: 1.25rem; font-weight: 700; color: var(--text-heading); }
.kpi-note { font-size: 0.78rem; color: var(--text-muted); }

.divisor-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.div-card {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem;
  text-align: center;
}

.div-card.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.div-title { font-size: 0.74rem; color: var(--text-muted); font-weight: 600; }
.div-val { font-size: 1rem; font-weight: 700; color: var(--text-heading); margin: 0.15rem 0; }
.div-sub { font-size: 0.72rem; color: var(--text-muted); }

.trim-box {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.9rem;
  font-size: 0.84rem;
}

.trim-box h4 {
  font-size: 0.9rem;
  margin: 0 0 0.45rem;
}

.trim-box p { margin: 0.3rem 0; color: var(--text-muted); }
.trim-box strong { color: var(--text-heading); }

/* Tables */
.section-title { font-size: 1.15rem; font-weight: 700; margin-bottom: 0.25rem; }
.section-desc { margin: 0 0 1rem; font-size: 0.88rem; color: var(--text-muted); }

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.carrier-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.carrier-table th,
.carrier-table td {
  padding: 0.72rem 0.65rem;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
  white-space: nowrap;
}

.carrier-table th {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--bg-subtle);
}

.carrier-table tr.is-best {
  background: var(--success-bg);
}

.status-pill {
  display: inline-flex;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 700;
}

.status-ok { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-border); }
.status-warn { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-border); }
.status-err { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger-border); }

/* FAQ */
.faq-list { display: grid; gap: 0.75rem; margin-top: 0.85rem; }
.faq-item { border: 1px solid var(--border-color); border-radius: var(--radius-md); background: var(--bg-subtle); padding: 0.85rem 1rem; }
.faq-question { font-family: var(--font-heading); font-weight: 600; font-size: 0.96rem; color: var(--text-heading); cursor: pointer; list-style: none; }
.faq-answer { margin: 0.65rem 0 0; font-size: 0.9rem; color: var(--text-muted); }

@media (max-width: 960px) {
  .shipping-workspace { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .card-main { padding: 1.1rem; }
  .form-grid-2,
  .form-grid-3,
  .form-grid-4,
  .kpi-grid-2,
  .divisor-cards {
    grid-template-columns: 1fr;
  }
  .preset-chip,
  .unit-select,
  .btn {
    width: 100% !important;
    justify-content: center;
  }
}
