/* ============ BASE ============ */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #1b2330;
  --ink-soft: #5b6675;
  --line: #e2e6ec;
  --brand: #0f62d1;
  --brand-dark: #0a4ba3;
  --hot: #d94a3d;
  --cold: #2f7ec9;
  --total: #1f8a5b;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
}
body {
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial,
    sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

/* ============ TOPBAR ============ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 8px;
}
.brand-logo {
  height: 34px;
  width: auto;
  display: block;
}
.brand-sub {
  color: var(--ink-soft);
  font-size: 13px;
}
.topbar-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* ============ BUTTONS ============ */
.btn {
  font: inherit;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 8px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}
.btn:hover {
  background: #f0f3f8;
}
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover {
  background: var(--brand-dark);
}
.btn-add {
  margin-top: 10px;
}

/* ============ LAYOUT ============ */
.layout {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  padding: 20px 24px 60px;
  max-width: 1400px;
  margin: 0 auto;
  align-items: start;
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
}
.section-title {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  margin: 22px 0 10px;
}
.section-title:first-child,
.panel-inputs .meta-row + .section-title {
  margin-top: 0;
}
.section-title-spaced {
  margin-top: 28px;
}

/* ============ FIELDS ============ */
.meta-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}
.field > span {
  font-size: 12px;
  color: var(--ink-soft);
  font-weight: 600;
}
.field input,
.field textarea,
.field select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  width: 100%;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 98, 209, 0.12);
}
.notes-field {
  margin-top: 12px;
}
.notes-field textarea {
  resize: vertical;
}

.config-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  max-width: max-content;
}
.config-grid .field {
  margin-bottom: 0;
}
.inline-error {
  color: var(--hot);
  font-size: 12px;
  font-weight: 600;
  margin: 8px 0 0;
}

/* margin toggle */
.margin-field .margin-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.margin-controls input[type="number"] {
  width: 70px;
}
.unit {
  color: var(--ink-soft);
  font-weight: 600;
}
.switch {
  position: relative;
  display: inline-block;
  width: 38px;
  height: 20px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.slider {
  position: absolute;
  inset: 0;
  cursor: pointer;
  background: #c4ccd6;
  border-radius: 20px;
  transition: 0.2s;
}
.slider::before {
  content: "";
  position: absolute;
  height: 14px;
  width: 14px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.switch input:checked + .slider {
  background: var(--brand);
}
.switch input:checked + .slider::before {
  transform: translateX(18px);
}

/* ============ MODALITY TABLE ============ */
.table-wrap {
  overflow: auto;
  max-width: calc(100vw - 90px);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.mod-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 680px;
}
.mod-table th,
.mod-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.mod-table thead th {
  background: #f7f9fc;
  color: var(--ink-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.mod-table tbody tr:last-child td {
  border-bottom: none;
}
.mod-table input,
.mod-table select {
  font: inherit;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  width: 100%;
}
.mod-table input:focus,
.mod-table select:focus {
  outline: none;
  border-color: var(--brand);
}
.mod-table .col-size {
  max-width: 110px;
}
.mod-table .col-volume {
  max-width: 100px;
}
.mod-table .col-num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.mod-table .btn-remove {
  border: none;
  background: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 5px;
}
.mod-table .btn-remove:hover {
  background: #fdecea;
  color: var(--hot);
}

/* ============ RESULTS ============ */
.results {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.card {
  padding: 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  border-left-width: 5px;
  background: #fff;
}
.card-hot {
  border-left-color: var(--hot);
}
.card-cold {
  border-left-color: var(--cold);
}
.card-total {
  border-left-color: var(--total);
  background: #f3fbf7;
}
.card-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ink-soft);
  font-weight: 700;
}
.card-value {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.card-hint {
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.annual-line {
  margin-top: 14px;
  font-size: 13px;
  color: var(--ink-soft);
}
.annual-line strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ============ SAVED LIST ============ */
.saved-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.saved-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.saved-item .si-name {
  font-weight: 700;
}
.saved-item .si-date {
  font-size: 11px;
  color: var(--ink-soft);
}
.saved-item .si-actions {
  display: flex;
  gap: 6px;
}
.saved-item .si-actions button {
  font-size: 12px;
  padding: 4px 8px;
}
.saved-empty {
  color: var(--ink-soft);
  font-size: 13px;
}

/* action buttons in the inputs panel */
.actions-block {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

/* ============ PRINT REPORT (screen-hidden) ============ */
#print-report {
  display: none;
}

/* ============ PRINT ============ */
@media print {
  body {
    background: #fff;
    font-size: 11px;
  }
  #app {
    display: none !important;
  }
  #print-report {
    display: block;
    padding: 0;
  }

  .pr-page {
    max-width: 100%;
  }
  .pr-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 2px solid #0a4ba3;
    padding-bottom: 10px;
    margin-bottom: 16px;
  }
  .pr-brand-logo {
    height: 36px;
    width: auto;
    display: block;
  }
  .pr-brand-sub {
    font-size: 11px;
    font-weight: 600;
    color: #5b6675;
    letter-spacing: 0.3px;
    margin-top: 4px;
  }
  .pr-title {
    font-size: 14px;
    font-weight: 700;
  }
  .pr-meta {
    font-size: 11px;
    color: #5b6675;
    text-align: right;
    line-height: 1.6;
  }

  .pr-section {
    margin: 14px 0;
  }
  .pr-section h3 {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #5b6675;
    margin: 0 0 6px;
    border-bottom: 1px solid #e2e6ec;
    padding-bottom: 3px;
  }
  table.pr-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
  }
  table.pr-table th,
  table.pr-table td {
    border: 1px solid #d4d9e0;
    padding: 5px 8px;
    text-align: left;
  }
  table.pr-table th {
    background: #f0f3f8;
  }
  table.pr-table td.n {
    text-align: right;
    font-variant-numeric: tabular-nums;
  }

  .pr-cards {
    display: flex;
    gap: 10px;
    margin-top: 8px;
  }
  .pr-card {
    flex: 1;
    border: 1px solid #d4d9e0;
    border-radius: 6px;
    padding: 10px;
  }
  .pr-card.hot {
    border-left: 4px solid #d94a3d;
  }
  .pr-card.cold {
    border-left: 4px solid #2f7ec9;
  }
  .pr-card.total {
    border-left: 4px solid #1f8a5b;
    background: #f3fbf7;
  }
  .pr-card .l {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #5b6675;
    font-weight: 700;
  }
  .pr-card .v {
    font-size: 18px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
  }
  .pr-kv {
    font-size: 11px;
    line-height: 1.9;
  }
  .pr-kv span {
    display: inline-block;
    min-width: 200px;
    color: #5b6675;
  }
  .pr-notes {
    font-size: 11px;
    white-space: pre-wrap;
  }
  .pr-footer {
    margin-top: 24px;
    font-size: 9px;
    color: #98a1ad;
    border-top: 1px solid #e2e6ec;
    padding-top: 6px;
  }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .meta-row {
    grid-template-columns: 1fr;
  }
}
