:root {
  --ink: #17212f;
  --muted: #647084;
  --paper: #ffffff;
  --soft: #f5f7f3;
  --line: #dde4df;
  --green: #0f4d45;
  --green-2: #167264;
  --red: #b8242f;
  --gold: #d4952f;
  --blue: #2c5c8f;
  --shadow: 0 18px 48px rgba(23, 33, 47, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 77, 69, 0.08), rgba(255, 255, 255, 0) 420px),
    var(--soft);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  letter-spacing: 0;
}

.skip-link {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 1000;
  transform: translateY(-160%);
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px clamp(14px, 3vw, 28px);
  border-bottom: 1px solid rgba(23, 33, 47, 0.08);
  background: rgba(247, 248, 245, 0.92);
  backdrop-filter: blur(16px);
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  text-decoration: none;
}

.brand img {
  flex: 0 0 auto;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(15, 77, 69, 0.24);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1rem;
  font-weight: 850;
}

.brand small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sync-pill,
.icon-button,
.ghost-button,
.tool-tab {
  border: 1px solid var(--line);
  background: var(--paper);
}

.sync-pill {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 11px;
  border-radius: 999px;
  color: var(--green);
  font-size: 0.84rem;
  font-weight: 850;
}

.sync-pill.offline {
  color: var(--red);
}

.icon-button,
.ghost-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 850;
}

.icon-button {
  width: 42px;
  padding: 0;
}

.ghost-button {
  padding: 8px 12px;
}

.icon-button:hover,
.ghost-button:hover,
.tool-tab:hover {
  border-color: rgba(15, 77, 69, 0.38);
}

svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.app-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(14px, 3vw, 28px);
  display: grid;
  grid-template-columns: minmax(260px, 0.38fr) minmax(0, 0.62fr);
  gap: 18px;
  align-items: start;
}

.tool-panel,
.workspace {
  min-width: 0;
}

.tool-panel {
  position: sticky;
  top: 82px;
  display: grid;
  gap: 14px;
}

.tool-panel-head {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 14px 36px rgba(23, 33, 47, 0.07);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

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

.tool-panel h1 {
  margin: 0;
  font-size: 1.85rem;
  line-height: 1.05;
  font-weight: 900;
}

.tool-panel p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 650;
}

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

.tool-tab {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 9px;
  padding: 10px;
  border-radius: 8px;
  color: var(--ink);
  font-weight: 850;
  text-align: left;
}

.tool-tab span {
  min-width: 0;
  white-space: normal;
}

.tool-tab svg {
  flex: 0 0 auto;
  color: var(--green);
}

.tool-tab.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
  box-shadow: 0 12px 28px rgba(15, 77, 69, 0.25);
}

.tool-tab.active svg {
  color: #fff;
}

.offline-note,
.notice-strip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(212, 149, 47, 0.35);
  border-radius: 8px;
  background: #fff7e7;
  color: #6e4a12;
  font-size: 0.88rem;
  font-weight: 700;
}

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

.notice-strip {
  background: #eef7f5;
  border-color: rgba(15, 77, 69, 0.25);
  color: var(--green);
}

.calculator {
  padding: clamp(16px, 3vw, 24px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

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

.calculator-header h2 {
  margin: 0;
  font-size: clamp(1.45rem, 3vw, 2.25rem);
  line-height: 1.05;
  font-weight: 900;
}

.calc-form {
  margin-bottom: 18px;
  padding: 14px;
  border: 1px solid rgba(15, 77, 69, 0.12);
  border-radius: 8px;
  background: #fbfcfa;
}

.mode-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 6px;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.mode-tab {
  min-height: 46px;
  border: 0;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 900;
  text-align: center;
}

.mode-tab:hover {
  color: var(--green);
}

.mode-tab.active {
  border-bottom-color: var(--green);
  color: var(--green);
}

.mode-panel[hidden] {
  display: none;
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin: -6px;
}

.g-3 > * {
  padding: 6px;
}

.col-6 {
  flex: 0 0 50%;
  max-width: 50%;
}

.col-12 {
  flex: 0 0 100%;
  max-width: 100%;
}

.col-sm-3,
.col-sm-4,
.col-sm-5,
.col-sm-6,
.col-md {
  flex: 0 0 100%;
  max-width: 100%;
}

.form-label {
  margin-bottom: 6px;
  color: #334155;
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.form-control,
.form-select {
  min-height: 50px;
  width: 100%;
  border: 1px solid #cfd9d4;
  border-radius: 8px;
  background-color: #fff;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 760;
  box-shadow: 0 1px 0 rgba(23, 33, 47, 0.03);
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.form-control {
  padding: 11px 12px;
}

.form-select {
  padding: 11px 40px 11px 12px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--green) 50%),
    linear-gradient(135deg, var(--green) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 21px,
    calc(100% - 12px) 21px;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}

.form-control:hover,
.form-select:hover {
  border-color: rgba(15, 77, 69, 0.42);
}

textarea.form-control {
  min-height: 120px;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--green);
  background-color: #fff;
  outline: 0;
  box-shadow: 0 0 0 4px rgba(15, 77, 69, 0.12), 0 10px 24px rgba(15, 77, 69, 0.08);
}

.field-note {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.35;
}

.inline-badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  margin-left: 6px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(15, 77, 69, 0.1);
  color: var(--green);
  font-size: 0.7rem;
  font-weight: 950;
  line-height: 1.2;
  vertical-align: middle;
}

.form-section-title {
  margin: 4px 0 0;
  padding-top: 4px;
  color: var(--green);
  font-size: 0.92rem;
  font-weight: 950;
}

.input-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 8px;
  align-items: stretch;
}

.input-action .icon-button {
  min-height: 48px;
  width: 48px;
}

.combo-field {
  display: grid;
  gap: 8px;
}

.combo-field .form-control {
  min-height: 46px;
}

.combo-field .form-select {
  min-height: 52px;
}

.split-field {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(92px, 0.85fr);
  gap: 8px;
}

.duty-alert {
  display: grid;
  gap: 4px;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(15, 77, 69, 0.24);
  border-radius: 8px;
  background: rgba(15, 77, 69, 0.08);
  color: var(--ink);
}

.duty-alert strong {
  font-size: 0.9rem;
  font-weight: 950;
}

.duty-alert span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 760;
  line-height: 1.45;
}

.duty-alert.warning {
  border-color: rgba(212, 149, 47, 0.45);
  background: rgba(212, 149, 47, 0.14);
}

.duty-alert.danger {
  border-color: rgba(184, 36, 47, 0.34);
  background: rgba(184, 36, 47, 0.1);
}

.duty-alert.danger strong,
.duty-alert.danger span {
  color: var(--red);
}

.check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.check-option {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1px solid #cfd9d4;
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-weight: 850;
  box-shadow: 0 1px 0 rgba(23, 33, 47, 0.03);
}

.check-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--green);
}

.crsp-configurator {
  margin-top: 0;
  margin-bottom: 14px;
}

.crsp-version-options .check-option {
  align-items: flex-start;
  flex: 1 1 230px;
}

.check-copy {
  display: grid;
  gap: 2px;
}

.check-copy small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 760;
  line-height: 1.3;
}

.rate-editor {
  margin-top: 14px;
  padding: 12px;
  border: 1px dashed rgba(15, 77, 69, 0.35);
  border-radius: 8px;
  background: #fff;
}

.rate-editor summary {
  cursor: pointer;
  color: var(--green);
  font-weight: 900;
}

.result-card {
  padding: 18px;
  border: 1px solid rgba(23, 33, 47, 0.1);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 77, 69, 0.08), rgba(212, 149, 47, 0.08)),
    #fff;
}

.result-card.primary {
  background:
    linear-gradient(135deg, rgba(15, 77, 69, 0.12), rgba(184, 36, 47, 0.06)),
    #fff;
}

.result-hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(23, 33, 47, 0.1);
}

.result-hero span {
  display: block;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 850;
}

.result-hero strong {
  display: block;
  margin-top: 2px;
  color: var(--green);
  font-size: clamp(1.85rem, 6vw, 3.1rem);
  line-height: 1;
  font-weight: 950;
}

.result-badge {
  flex: 0 0 auto;
  padding: 7px 9px;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 900;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.mini-stat {
  min-height: 78px;
  padding: 12px;
  border: 1px solid rgba(23, 33, 47, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.mini-stat span,
.schedule-table span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.mini-stat strong {
  display: block;
  margin-top: 4px;
  font-size: 1.02rem;
  font-weight: 900;
}

.quote-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.breakdown {
  margin-top: 14px;
  display: grid;
  gap: 8px;
}

.breakdown-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(23, 33, 47, 0.08);
}

.breakdown-row:last-child {
  border-bottom: 0;
}

.breakdown-row span:first-child {
  color: var(--muted);
  font-weight: 750;
}

.breakdown-row strong {
  text-align: right;
  white-space: nowrap;
}

.schedule-table {
  width: 100%;
  margin-top: 14px;
  overflow-x: auto;
}

.schedule-table table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.schedule-table th,
.schedule-table td {
  padding: 9px 8px;
  border-bottom: 1px solid rgba(23, 33, 47, 0.08);
  text-align: right;
}

.schedule-table th:first-child,
.schedule-table td:first-child {
  text-align: left;
}

.schedule-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.chart-wrap {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

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

.seo-copy h3 {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 900;
}

.seo-copy p {
  color: var(--muted);
}

.seo-copy details {
  margin-top: 8px;
  padding: 10px 0;
  border-top: 1px solid rgba(23, 33, 47, 0.08);
}

.seo-copy summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 850;
}

.toast-copy {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 850;
  box-shadow: var(--shadow);
}

.toast-copy[hidden] {
  display: none;
}

.muted-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.warning-text {
  color: var(--red);
  font-weight: 900;
}

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

  .tool-panel {
    position: static;
  }

  .tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
    gap: 8px;
  }

  .tool-tab {
    width: 100%;
  }
}

@media (min-width: 576px) {
  .col-sm-3 {
    flex-basis: 25%;
    max-width: 25%;
  }

  .col-sm-4 {
    flex-basis: 33.3333%;
    max-width: 33.3333%;
  }

  .col-sm-5 {
    flex-basis: 41.6667%;
    max-width: 41.6667%;
  }

  .col-sm-6 {
    flex-basis: 50%;
    max-width: 50%;
  }
}

@media (min-width: 768px) {
  .col-md {
    flex: 1 0 0;
    max-width: 100%;
  }
}

@media (max-width: 640px) {
  .split-field {
    grid-template-columns: 1fr;
  }

  .app-header {
    align-items: flex-start;
  }

  .brand small,
  .sync-pill span {
    display: none;
  }

  .app-shell {
    padding: 12px;
    gap: 12px;
  }

  .tool-panel-head {
    padding: 16px;
  }

  .tool-panel h1 {
    font-size: 1.5rem;
  }

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

  .calculator {
    padding: 14px;
  }

  .calculator-header {
    display: grid;
  }

  .ghost-button {
    width: 100%;
  }

  .result-hero {
    display: grid;
  }

  .result-badge {
    width: max-content;
  }

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

  .breakdown-row {
    align-items: flex-start;
  }
}
