:root {
  color-scheme: light;

  --bg: #f5f6f8;
  --card: #ffffff;
  --inset: #f1f4f9;
  --border: #e2e5ea;
  --border-strong: #cfd5de;
  --text: #1f2430;
  --muted: #6b7280;
  --hover-bg: #eef1f5;
  --input-bg: #ffffff;

  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --on-accent: #ffffff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --danger-border: #fecaca;
  --warn: #b45309;
  --warn-text: #78350f;
  --warn-bg: #fffbeb;
  --warn-border: #fcd34d;
  --success: #059669;

  --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.18);
  --shadow-card: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-pop: 0 8px 24px rgba(15, 23, 42, 0.14);
  --overlay: rgba(15, 23, 42, 0.55);
  --tooltip-bg: #1f2430;
  --tooltip-text: #e5e7eb;
  --grid-color: #eef1f5;
  --legend-bg: rgba(255, 255, 255, 0.85);

  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 10px;
  --header-h: 60px;
  --content-max: 1200px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0f172a;
  --card: #1e293b;
  --inset: #172033;
  --border: #334155;
  --border-strong: #475569;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --hover-bg: #334155;
  --input-bg: #0f172a;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --on-accent: #ffffff;
  --danger: #f87171;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.40);
  --warn: #fcd34d;
  --warn-text: #fcd34d;
  --warn-bg: rgba(245, 158, 11, 0.10);
  --warn-border: rgba(245, 158, 11, 0.35);
  --success: #34d399;

  --focus-ring: 0 0 0 3px rgba(59, 130, 246, 0.28);
  --shadow-card: none;
  --shadow-pop: 0 4px 20px rgba(0, 0, 0, 0.60);
  --overlay: rgba(2, 6, 23, 0.65);
  --tooltip-bg: #0b1220;
  --tooltip-text: #e5e7eb;
  --grid-color: #334155;
  --legend-bg: rgba(30, 41, 59, 0.90);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.3;
  margin-bottom: 0;
}

h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

a {
  color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: var(--content-max);
  min-height: var(--header-h);
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

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

.mobile-label {
  display: none;
}

.subtitle {
  max-width: 640px;
  margin-bottom: 20px;
  color: var(--muted);
  font-size: 14px;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}

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

.btn-secondary {
  background: var(--card);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--hover-bg);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.btn-danger {
  background: var(--card);
  border-color: var(--danger-border);
  color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-bg);
}

.btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
}

.btn-small {
  height: 26px;
  padding: 0 8px;
  font-size: 12px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:focus-visible,
.chips button:focus-visible,
.presets button:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* Page-level states */

.page-error {
  margin-top: 32px;
  padding: 20px;
  border: 1px solid var(--danger-border);
  border-radius: var(--r-lg);
  background: var(--danger-bg);
  color: var(--danger);
}

.page-error h1 {
  color: var(--danger);
  font-size: 20px;
}

.page-error p {
  font-size: 13px;
  line-height: 1.5;
}

.page-error code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.inline-warning {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid var(--warn-border);
  border-radius: var(--r-md);
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 12px;
  line-height: 1.45;
}

#storage-warning {
  margin: 0 0 16px;
}

/* Disclaimer */

.disclaimer {
  margin-bottom: 16px;
  border: 1px solid var(--warn-border);
  border-radius: var(--r-lg);
  background: var(--warn-bg);
  overflow: hidden;
}

.disclaimer-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 14px;
  border: 0;
  background: transparent;
  color: var(--warn-text);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.disclaimer-chevron {
  font-size: 12px;
  transition: transform 0.2s ease;
}

.disclaimer-toggle[aria-expanded="false"] .disclaimer-chevron {
  transform: rotate(-90deg);
}

.disclaimer-content {
  max-height: 0;
  padding: 0 14px;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.25s ease, opacity 0.2s ease, padding 0.25s ease;
}

.disclaimer-content.is-open {
  max-height: 500px;
  padding: 0 14px 12px;
  opacity: 1;
}

.disclaimer-content p {
  margin-bottom: 8px;
  color: var(--warn-text);
  font-size: 12.5px;
  line-height: 1.55;
}

/* Calculation title */

.calc-title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 28px;
  margin-bottom: 12px;
}

.calc-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
  flex-wrap: wrap;
}

.calc-title-label {
  color: var(--muted);
  font-size: 12px;
}

.calc-title {
  max-width: 520px;
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-status {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.save-status.is-error {
  color: var(--danger);
}

/* Cards */

.card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--card);
  box-shadow: var(--shadow-card);
}

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

.card-subtitle {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r-sm);
  background: var(--hover-bg);
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
  vertical-align: middle;
}

.badge-source {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-new {
  background: var(--hover-bg);
  color: var(--muted);
}

.ta-card + .ta-card,
.new-tas .card + .card {
  margin-top: 16px;
}

.ta-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, 1fr);
  gap: 20px;
}

.ta-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.field-row .field-hint {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.label,
.field > label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.field-error {
  margin: 2px 0 0;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.4;
}

.info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  border-radius: 50%;
  background: var(--muted);
  color: var(--card);
  font-size: 9px;
  font-weight: 700;
  font-style: normal;
  line-height: 1;
  vertical-align: middle;
  cursor: default;
  user-select: none;
}

.info:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Inputs */

input,
select {
  width: 100%;
  height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--input-bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
}

input::placeholder {
  color: var(--muted);
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring);
  outline: none;
}

input:disabled,
select:disabled {
  background: var(--inset);
  color: var(--muted);
  cursor: not-allowed;
}

input.input-error,
select.input-error {
  border-color: var(--danger);
}

.new-geo:disabled {
  color: var(--text);
  opacity: 1;
}

input[type="number"] {
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  accent-color: var(--accent);
}

/* Segmented control */

.segmented {
  display: flex;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--card);
}

.segment {
  position: relative;
  flex: 1;
  min-width: 0;
}

.segment input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.segment span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 8px;
  border-right: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  text-align: center;
}

.segment:last-child span {
  border-right: 0;
}

.segment input:checked + span {
  background: var(--accent);
  color: var(--on-accent);
}

.segment input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* Age range */

.age-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
}

.age-inputs label {
  color: var(--muted);
  font-size: 12px;
}

.age-inputs input {
  width: 72px;
}

.dual-range {
  position: relative;
  height: 32px;
  margin-top: 2px;
}

.dual-range .range-track {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  transform: translateY(-50%);
}

.dual-range .range-fill {
  position: absolute;
  top: 50%;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  transform: translateY(-50%);
}

.dual-range input[type="range"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 32px;
  margin: 0;
  background: transparent;
  pointer-events: none;
  -webkit-appearance: none;
  appearance: none;
}

.dual-range input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
}

.dual-range input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border: 2px solid var(--card);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: pointer;
  pointer-events: auto;
  -webkit-appearance: none;
}

.dual-range input[type="range"]::-moz-range-track {
  height: 4px;
  background: transparent;
}

.dual-range input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 2px solid var(--card);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  cursor: pointer;
  pointer-events: auto;
}

.dual-range.is-empty {
  opacity: 0.45;
}

.dual-range.is-empty input[type="range"] {
  pointer-events: none;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.presets button {
  height: 26px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

.presets button:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.presets button.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

/* Income chips */

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

.chips button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--card);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.chips button:hover {
  background: var(--hover-bg);
}

.chips button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.chips button[aria-pressed="true"]::before {
  content: "✓";
  font-size: 11px;
}

/* Reach */

.reach-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.reach-input-row input {
  width: 96px;
}

.reach-suffix {
  color: var(--muted);
  font-size: 13px;
}

#source-reach-range {
  width: 100%;
  margin-top: 8px;
}

/* Result panel */

.result-panel {
  min-width: 0;
  padding: 16px;
  border-radius: var(--r-md);
  background: var(--inset);
  align-self: start;
}

.metric + .metric {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.metric-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.metric-value {
  margin-top: 4px;
  color: var(--text);
  font-size: 28px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.metric-note,
.formula {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.metric-people {
  margin-top: 4px;
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

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

.delta-badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 1px 6px;
  border-radius: var(--r-sm);
  background: var(--hover-bg);
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.result-panel .inline-warning {
  margin-top: 8px;
}

.empty-result {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 160px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  text-align: center;
}

.empty-text {
  max-width: 260px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

/* Add audience */

.new-tas {
  margin-top: 16px;
}

.add-ta {
  width: 100%;
  margin-top: 12px;
  border-style: dashed;
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.add-ta:hover {
  background: var(--hover-bg);
}

/* Comparison table */

#comparison-card {
  margin-top: 16px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

th.num,
td.num {
  text-align: right;
}

td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

td.num {
  font-variant-numeric: tabular-nums;
}

.audience-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.audience-dot {
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.audience-name {
  font-weight: 500;
}

.table-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.45;
}

/* Footer */

.footer {
  margin-top: 32px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

/* Drawer */

.drawer-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: var(--overlay);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1501;
  display: flex;
  flex-direction: column;
  width: min(400px, 100vw);
  border-left: 1px solid var(--border);
  background: var(--card);
  box-shadow: var(--shadow-pop);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.drawer-actions {
  padding: 12px 18px;
}

.drawer-actions .btn {
  width: 100%;
}

.calc-list {
  flex: 1;
  padding: 8px 12px;
  overflow-y: auto;
}

.drawer-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
}

.calc-item {
  margin-bottom: 6px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  background: transparent;
}

.calc-item:hover {
  background: var(--hover-bg);
}

.calc-item.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.calc-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.calc-item-title {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calc-item-sub {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.calc-item-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.calc-item-actions button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
}

.calc-item-actions button:hover {
  color: var(--accent);
}

.calc-item-actions .delete:hover {
  color: var(--danger);
}

.drawer-empty {
  padding: 24px 8px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

/* Modals */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--overlay);
  backdrop-filter: blur(2px);
}

.modal {
  display: flex;
  flex-direction: column;
  width: min(880px, 92vw);
  max-height: 88vh;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--card);
  box-shadow: var(--shadow-pop);
}

.modal-small {
  width: min(460px, 92vw);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  font-size: 13.5px;
  line-height: 1.55;
}

.modal-body p {
  margin-bottom: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.help-layout {
  display: grid;
  grid-template-columns: 180px 1fr;
  padding: 0;
  overflow: hidden;
}

.help-toc {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 8px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.help-toc a {
  padding: 7px 10px;
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.help-toc a:hover {
  background: var(--hover-bg);
  color: var(--text);
}

.help-content {
  max-height: calc(88vh - 60px);
  padding: 18px 22px;
  overflow-y: auto;
}

.help-content section {
  margin-bottom: 20px;
}

.help-content p,
.help-content li {
  font-size: 13px;
  line-height: 1.55;
}

.help-content ul {
  padding-left: 20px;
}

.help-content code {
  padding: 1px 4px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.help-table {
  width: 100%;
  margin: 8px 0 12px;
  border-collapse: collapse;
  font-size: 13px;
}

.help-table th,
.help-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.help-table th:last-child,
.help-table td:last-child {
  text-align: right;
  white-space: nowrap;
}

/* Tooltip and toast */

.tooltip {
  position: fixed;
  z-index: 3000;
  width: 240px;
  max-width: calc(100vw - 24px);
  padding: 8px 10px;
  border-radius: var(--r-lg);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  box-shadow: var(--shadow-pop);
  font-size: 12px;
  line-height: 1.55;
  pointer-events: none;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 2500;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: var(--tooltip-bg);
  color: var(--tooltip-text);
  box-shadow: var(--shadow-pop);
  font-size: 13px;
}

/* Responsive */

@media (max-width: 1023px) {
  .ta-grid {
    grid-template-columns: 1fr;
  }

  .result-panel {
    margin-top: 4px;
  }
}

@media (max-width: 719px) {
  .container {
    padding: 16px 16px 32px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .header-inner {
    min-height: 54px;
    padding: 10px 16px;
  }

  .brand {
    max-width: 45vw;
    overflow: hidden;
    font-size: 15px;
    text-overflow: ellipsis;
  }

  .desktop-label {
    display: none;
  }

  .mobile-label {
    display: inline;
  }

  .theme-label {
    display: none;
  }

  .header-actions {
    gap: 6px;
  }

  .header-actions .btn {
    padding: 0 8px;
  }

  .btn-icon {
    width: 28px;
  }

  h1 {
    font-size: 20px;
  }

  .subtitle {
    font-size: 13px;
  }

  .card {
    padding: 16px;
  }

  .metric-value {
    font-size: 24px;
  }

  .calc-title-bar {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .calc-title {
    max-width: 100%;
    white-space: normal;
  }

  .card-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .card-actions {
    width: 100%;
  }

  .help-layout {
    grid-template-columns: 1fr;
  }

  .help-toc {
    flex-direction: row;
    padding: 8px;
    overflow-x: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .help-toc a {
    white-space: nowrap;
  }

  .help-content {
    max-height: calc(88vh - 120px);
  }

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

  .drawer {
    width: 100vw;
  }

  .toast {
    right: 16px;
    bottom: 16px;
    left: 16px;
  }
}
