/* ============================================================
   Reusable UI Components
   ============================================================ */

/* --- Theme transition (applied to all color-bearing elements) ---
   .no-transitions class is added by JS on page load to suppress
   the initial paint flicker, removed after first frame. */
*, *::before, *::after {
  transition: background-color var(--transition-slow),
              border-color var(--transition-slow),
              color var(--transition-slow),
              box-shadow var(--transition-slow);
}

.no-transitions *,
.no-transitions *::before,
.no-transitions *::after {
  transition: none !important;
}

/* Disable transitions on interactive elements (feels laggy) */
button, a, input, select, canvas {
  transition: none;
}

/* Re-enable only intentional transitions */
button, a {
  transition: background var(--transition-fast),
              color var(--transition-fast),
              border-color var(--transition-fast),
              box-shadow var(--transition-fast),
              transform var(--transition-fast),
              opacity var(--transition-fast);
}

/* --- Site Header --- */
.site-header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-header-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .header-inner {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 var(--space-6);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.site-logo {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.site-logo span {
  color: var(--color-accent);
}

/* --- Header controls (lang + theme toggles) --- */
.header-controls {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* --- Header "актуально" date tag --- */
.header-updated {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--color-text-tertiary);
  padding: 3px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  white-space: nowrap;
  cursor: default;
  letter-spacing: 0.01em;
}

.header-updated::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-success);
  flex-shrink: 0;
}

/* --- Language Toggle --- */
.lang-toggle {
  display: inline-flex;
  background: var(--color-border);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
}

.lang-toggle button {
  padding: 4px 10px;
  border-radius: calc(var(--radius-md) - 2px);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  transition: background var(--transition-fast), color var(--transition-fast),
              box-shadow var(--transition-fast);
}

.lang-toggle button.active {
  background: var(--color-surface);
  color: var(--color-text-primary);
  box-shadow: var(--shadow-xs);
}

/* --- Theme Toggle Button --- */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border-radius: var(--radius-md);
  background: var(--color-surface-2);
  border: 1.5px solid var(--color-border);
  color: var(--color-text-secondary);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}

.theme-toggle:hover {
  background: var(--color-border);
  color: var(--color-text-primary);
}

/* --- Page Layout --- */
.page-main {
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: var(--space-10) var(--space-6);
}

.page-hero {
  text-align: center;
  margin-bottom: var(--space-10);
}

.page-hero h1 {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-3);
}

.page-hero p {
  font-size: var(--text-lg);
  color: var(--color-text-secondary);
  max-width: 560px;
  margin: 0 auto;
}

/* --- Card --- */
.card {
  background: var(--color-surface);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  padding: var(--space-8);
}

.card-sm {
  padding: var(--space-4);
}

/* --- Calculator Layout (2-column: inputs + results) --- */
.calc-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-6);
  align-items: start;
}

.calc-inputs {}
.calc-results {}

/* --- Section heading inside card --- */
.card-section-title {
  font-size: 9px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-section-accent);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-4);
  border-bottom: 1.5px solid var(--color-section-accent);
}

/* --- Input Group --- */
.input-group {
  margin-bottom: var(--space-5);
}

.input-group label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrap input,
.input-wrap select {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-4);
  background: transparent;
  border: none;
  border-bottom: 1.5px solid var(--color-field-border);
  border-radius: 0;
  font-size: var(--text-base);
  color: var(--color-text-primary);
  outline: none;
  transition: border-color var(--transition-fast);
  appearance: none;
  -webkit-appearance: none;
}

.input-wrap input:focus,
.input-wrap select:focus {
  border-bottom-color: var(--color-border-focus);
  /* background-color only — avoid shorthand which resets background-image/repeat/position */
  background-color: transparent;
}

.input-wrap .input-unit {
  position: absolute;
  right: var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-tertiary);
  pointer-events: none;
}

.input-wrap input.has-unit {
  padding-right: 52px;
}

/* Select arrow */
.input-wrap select {
  padding-right: var(--space-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238E8E93' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  cursor: pointer;
}

[data-theme="dark"] .input-wrap select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23AEAEB2' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Input hint */
.input-hint {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.input-hint.warn {
  color: var(--color-warning);
}

.input-hint.error {
  color: var(--color-danger);
}

/* --- Slider input --- */
.input-slider {
  width: 100%;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  outline: none;
  margin-top: var(--space-3);
  -webkit-appearance: none;
  cursor: pointer;
}

.input-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}

.input-slider:focus::-webkit-slider-thumb {
  box-shadow: var(--shadow-focus);
}

/* --- Result Panel --- */
.result-panel {
  background: var(--color-accent);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  color: var(--color-text-inverse);
}

.result-panel .result-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  opacity: 0.8;
  margin-bottom: var(--space-2);
}

.result-panel .result-value {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  line-height: 1;
  margin-bottom: var(--space-1);
}

.result-panel .result-sub {
  font-size: var(--text-sm);
  opacity: 0.7;
}

/* Dark mode: swap accent bg for surface, show value in accent color */
[data-theme="dark"] .result-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-primary);
}

[data-theme="dark"] .result-panel .result-label {
  opacity: 1;
  color: var(--color-text-secondary);
}

[data-theme="dark"] .result-panel .result-value {
  color: var(--color-accent);
}

[data-theme="dark"] .result-panel .result-sub {
  opacity: 1;
  color: var(--color-text-secondary);
}

/* --- Result Row (secondary metrics) --- */
.result-rows {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.result-row .row-label {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.result-row .row-value {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
}

/* --- Alert / Warning Banner --- */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-5);
}

.alert-warn {
  background: var(--color-alert-warn-bg);
  border: 1px solid var(--color-alert-warn-border);
  color: var(--color-alert-warn-text);
}

.alert-error {
  background: var(--color-alert-error-bg);
  border: 1px solid var(--color-alert-error-border);
  color: var(--color-alert-error-text);
}

.alert-success {
  background: var(--color-alert-success-bg);
  border: 1px solid var(--color-alert-success-border);
  color: var(--color-alert-success-text);
}

.alert svg {
  flex-shrink: 0;
  margin-top: 1px;
}

/* --- Chart Container --- */
.chart-container {
  margin-top: var(--space-6);
}

.chart-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-donut-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.chart-legend {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.legend-label {
  color: var(--color-text-secondary);
}

.legend-value {
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  margin-left: auto;
  padding-left: var(--space-4);
}

/* --- Primary Button --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 44px;
  padding: 0 var(--space-6);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  transition: background var(--transition-fast), transform var(--transition-fast),
              box-shadow var(--transition-fast);
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.3);
}

.btn-primary:hover {
  background: var(--color-accent-hover);
  box-shadow: 0 4px 16px rgba(8, 145, 178, 0.35);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--color-surface-2);
  color: var(--color-text-primary);
  border: 1.5px solid var(--color-border);
}

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

/* --- Segment Control (period toggle, etc.) --- */
.segment-ctrl {
  display: inline-flex;
  background: var(--color-border);
  border-radius: var(--radius-md);
  padding: 2px;
  gap: 2px;
  width: 100%;
}

.segment-ctrl button {
  flex: 1;
  padding: 8px var(--space-3);
  border-radius: calc(var(--radius-md) - 2px);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast),
              box-shadow var(--transition-fast);
}

.segment-ctrl button.active {
  background: var(--color-surface);
  color: var(--color-text-primary);
  font-weight: var(--weight-semibold);
  box-shadow: var(--shadow-xs);
}

/* --- Checkbox label --- */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast);
}

.checkbox-label:hover {
  border-color: var(--color-border-focus);
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 2px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

/* --- Annual Limit Tracker --- */
.limit-tracker {
  margin-top: var(--space-2);
}

.limit-bar-wrap {
  height: 10px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.limit-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  background: var(--color-success);
  transition: width 0.25s ease, background-color 0.25s ease;
}

.limit-labels {
  display: flex;
  justify-content: space-between;
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
}

.limit-pct-text {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  margin-top: var(--space-1);
  text-align: center;
}

/* --- Comparison grid (used in Deposit vs OVDP and similar 2-way comparisons) --- */
.result-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-top: var(--space-4);
  align-items: start;
}

.compare-col-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-3);
}

.compare-col .result-rows {
  margin-top: 0;
  gap: var(--space-2);
}

/* --- Homepage Calculator Grid (mobile-first: 1 col default, breakpoints in responsive.css) --- */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  margin-top: var(--space-6);
}

.calc-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  text-decoration: none;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: transform var(--transition-base),
              box-shadow var(--transition-base),
              border-color var(--transition-base);
}

.calc-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-accent);
  text-decoration: none;
}

.calc-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: var(--color-accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
  flex-shrink: 0;
  color: var(--color-accent);
}

.calc-card h3 {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-1);
  line-height: var(--leading-tight);
}

.calc-card p {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  flex: 1;
}

.calc-card .card-cta {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-accent);
}

.badge-ua {
  display: inline-flex;
  align-items: center;
  margin-bottom: var(--space-3);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  background: rgba(8, 145, 178, 0.1);
  color: var(--color-accent);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

[data-theme="dark"] .badge-ua {
  background: rgba(90, 200, 250, 0.14);  /* teal tint in dark */
  color: #5AC8FA;
}

.badge-global {
  display: inline-flex;
  align-items: center;
  margin-bottom: var(--space-3);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--weight-semibold);
  background: rgba(88, 86, 214, 0.1);
  color: #5856D6;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

[data-theme="dark"] .badge-global {
  color: #BDB8FF;
  background: rgba(189, 184, 255, 0.14);
}

/* --- Input unit on the left side ($ prefix) --- */
.input-unit-left {
  position: absolute;
  left: var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-tertiary);
  pointer-events: none;
  z-index: 1;
}

/* --- Ghost button (text-only, for toggles) --- */
.btn-ghost {
  background: none;
  border: none;
  color: var(--color-accent);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
}

.btn-ghost:hover {
  background: var(--color-accent-light);
}

/* --- Data Table (amortization schedule, etc.) --- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table th {
  text-align: right;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--color-border);
}

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

.data-table td {
  text-align: right;
  padding: var(--space-2) var(--space-3);
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover td {
  background: var(--color-surface-2);
}

/* --- FAQ Section --- */
.faq-section {
  margin-top: var(--space-12);
}

.faq-section h2 {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-6);
}

.faq-item {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-3);
  background: var(--color-surface);
}

.faq-item:last-child {
  margin-bottom: 0;
}

.faq-item summary {
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  cursor: pointer;
  font-size: var(--text-base);
}

.faq-item p {
  margin-top: var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
}
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-6);
}

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

.breadcrumb .sep {
  opacity: 0.4;
}

/* --- Section divider (replaces coloured category banners) --- */
.section-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-10);
  margin-bottom: var(--space-2);
}

.section-divider-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.section-divider-dot.ua     { background: #0891B2; }
.section-divider-dot.global { background: #5856D6; }

.section-divider-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.section-divider-line {
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* --- SEO text block (under calculator on each page) --- */
.seo-section {
  margin-top: var(--space-16);
  padding-top: var(--space-8);
  border-top: 1px solid var(--color-border);
}

.seo-section h2 {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-4);
}

.seo-section h3 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text-primary);
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}

.seo-section p {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-3);
}

.seo-section ul {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  padding-left: var(--space-5);
  margin-bottom: var(--space-3);
}

.seo-section ul li {
  margin-bottom: var(--space-1);
}

.disclaimer-box {
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-left: 3px solid var(--color-warning);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  margin-top: var(--space-8);
}

/* --- PDF Export Button --- */
.pdf-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  justify-content: center;
  padding: 11px var(--space-5);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-family: var(--font-family);
  color: var(--color-accent);
  background: transparent;
  border: 1.5px solid var(--color-accent);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
}

.pdf-btn::before {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none' stroke='%230891B2' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 1v8M4 6l3 3 3-3'/%3E%3Crect x='1' y='10' width='12' height='3' rx='1'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  flex-shrink: 0;
}

.pdf-btn:hover {
  background: var(--color-accent);
  color: var(--color-text-inverse);
}

.pdf-btn:hover::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14' fill='none' stroke='%23ffffff' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 1v8M4 6l3 3 3-3'/%3E%3Crect x='1' y='10' width='12' height='3' rx='1'/%3E%3C/svg%3E");
}

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

/* --- Site Footer --- */
.site-footer {
  border-top: 1px solid var(--color-border);
  background: var(--color-surface);
  padding: var(--space-8) var(--space-6);
  margin-top: var(--space-16);
  text-align: center;
}

.site-footer p {
  font-size: var(--text-sm);
  color: var(--color-text-tertiary);
}

.site-footer a {
  color: var(--color-text-tertiary);
  text-decoration: underline;
}

/* --- Share Bar --- */
.share-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}

.share-bar__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
}

.share-bar__buttons {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
  flex: 1;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  cursor: pointer;
  text-decoration: none;
  border: 1.5px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-primary);
  white-space: nowrap;
  transition: background var(--transition-fast),
              border-color var(--transition-fast),
              color var(--transition-fast);
}

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

.share-btn--copied {
  border-color: var(--color-success) !important;
  color: var(--color-success) !important;
  background: var(--color-alert-success-bg) !important;
}

.share-btn--native {
  background: var(--color-accent);
  color: var(--color-text-inverse);
  border-color: transparent;
  flex: 1;
}

.share-btn--native:hover {
  background: var(--color-accent-hover);
  color: var(--color-text-inverse);
  border-color: transparent;
}

/* ── Tooltip trigger (ℹ icon next to labels) ──────────────── */
.tooltip-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 5px;
  font-size: 9px;
  font-weight: 800;
  color: var(--color-accent);
  background: var(--color-accent-light);
  border: 1.5px solid var(--color-accent);
  border-radius: 50%;
  cursor: pointer;
  line-height: 1;
  vertical-align: middle;
  position: relative;
  flex-shrink: 0;
  transition: background var(--transition-fast), color var(--transition-fast);
}
/* Extended 44×44px touch target without changing visual size */
.tooltip-trigger::after {
  content: '';
  position: absolute;
  inset: -14px;
}
.tooltip-trigger:hover,
.tooltip-trigger:focus-visible {
  background: var(--color-accent);
  color: #fff;
  outline: none;
}

/* ── Floating tooltip ──────────────────────────────────────── */
#ui-tooltip {
  max-width: 220px;
  background: #0F172A;
  color: #F8FAFC;
  font-size: var(--text-xs);
  line-height: var(--leading-relaxed);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  pointer-events: none;
}
#ui-tooltip .tooltip-title {
  display: block;
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-1);
}
#ui-tooltip .tooltip-row {
  display: block;
  margin-top: var(--space-1);
  opacity: 0.85;
}
#ui-tooltip .tooltip-val {
  color: #5AC8FA;
  font-weight: var(--weight-medium);
}

/* ── Advanced spoiler toggle ───────────────────────────────── */
.advanced-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3) 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  background: none;
  border: none;
  border-top: 1px solid var(--color-field-border);
  cursor: pointer;
  margin-top: var(--space-4);
  text-align: left;
  transition: color var(--transition-fast);
}
.advanced-toggle::before {
  content: '▸';
  font-size: 10px;
  transition: transform var(--transition-fast);
}
.advanced-toggle.advanced-open::before {
  transform: rotate(90deg);
}
.advanced-toggle:hover {
  color: var(--color-text-primary);
}

/* ── Sticky result footer (mobile — shown via responsive.css) ─ */
.sticky-result-footer {
  display: none;
}

/* ── PDF Print Styles (@media print) ─────────────────────── */

/* Screen: hide the print section */
.pdf-print-only { display: none; }

@media print {
  /* Hide everything except the PDF section */
  body > *:not(#pdf-print-section) { display: none !important; }
  #pdf-print-section { display: block !important; }

  /* Reset page */
  body { background: white; color: black; font-family: Georgia, serif; margin: 0; }

  .pdf-doc {
    max-width: 100%;
    padding: 0;
    color: #111;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 11pt;
    line-height: 1.5;
  }

  .pdf-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 2px solid #0891B2;
    padding-bottom: 6pt;
    margin-bottom: 4pt;
  }
  .pdf-header strong { font-size: 14pt; font-family: system-ui, sans-serif; }
  .pdf-header-url   { font-size: 9pt; color: #555; font-family: system-ui, sans-serif; }
  .pdf-date         { font-size: 9pt; color: #666; margin: 2pt 0 12pt; font-family: system-ui, sans-serif; }

  .pdf-title   { font-size: 18pt; margin: 0 0 12pt; font-weight: bold; }
  .pdf-section { font-size: 9pt; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; color: #0891B2; border-bottom: 1.5pt solid #0891B2; padding-bottom: 3pt; margin: 16pt 0 6pt; }

  .pdf-table { width: 100%; border-collapse: collapse; margin-bottom: 8pt; }
  .pdf-th, .pdf-td-label, .pdf-td-value { padding: 4pt 6pt; font-size: 10pt; border-bottom: 1pt solid #E5E5EA; }
  .pdf-th          { font-weight: bold; font-family: system-ui, sans-serif; background: #F5F5F7; text-align: left; }
  .pdf-td-label    { color: #555; width: 55%; }
  .pdf-td-value    { font-family: system-ui, sans-serif; font-variant-numeric: tabular-nums; text-align: right; }

  .pdf-disclaimer  { font-size: 8pt; color: #888; margin-top: 20pt; font-style: italic; border-top: 1pt solid #E5E5EA; padding-top: 6pt; }
}

/* ═══════════════════════════════════════════════════════════
   Compact result column — one-screen layout
   ═══════════════════════════════════════════════════════════ */

/* result-body: result-rows + compact donut side-by-side */
.result-body {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: var(--space-4);
  align-items: start;
  margin-top: var(--space-3);
}
/* Single child (no donut) spans full width */
.result-body > :only-child {
  grid-column: 1 / -1;
}
/* Stack on mobile */
@media (max-width: 767px) {
  .result-body {
    grid-template-columns: 1fr;
  }
}

/* Compact donut sidebar */
.result-donut {
  width: 150px;
  flex-shrink: 0;
}
.result-donut .chart-title {
  font-size: 10px;
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-2);
}
.result-donut .chart-donut-wrap {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
}
.result-donut canvas {
  display: block;
  width: 100% !important;
  max-height: 150px;
  height: auto;
}
.result-donut .legend-item {
  font-size: var(--text-xs);
}

/* Main charts (line/bar/area) — compact fixed height */
.chart-main {
  display: block;
  width: 100%;
  height: 150px !important;
}

/* Share + PDF in one row */
.result-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-3);
  flex-wrap: wrap;
}
.result-actions .btn,
.result-actions > button {
  margin-top: 0 !important;
}
.result-actions > #share-bar-container {
  flex: 1;
  min-width: 0;
}
