/* ==========================================================================
   Portfolio Rebalancer — Design System
   ========================================================================== */

:root {
  /* Color palette */
  --color-bg: #F7F8FA;
  --color-surface: #FFFFFF;
  --color-surface-raised: #FFFFFF;
  --color-border: #E7E9EE;
  --color-border-strong: #D8DCE3;

  --color-text-primary: #14161B;
  --color-text-secondary: #5B6270;
  --color-text-tertiary: #9BA1AD;

  --color-accent: #2F5CF6;
  --color-accent-hover: #2549CC;
  --color-accent-soft: #EDF1FE;

  --color-success: #12875B;
  --color-success-soft: #E7F6EF;
  --color-danger: #D14343;
  --color-danger-soft: #FCEBEB;
  --color-warning: #B7791F;
  --color-warning-soft: #FBF3E4;

  --shadow-sm: 0 1px 2px rgba(20, 22, 27, 0.04), 0 1px 1px rgba(20, 22, 27, 0.03);
  --shadow-md: 0 4px 12px rgba(20, 22, 27, 0.06), 0 2px 4px rgba(20, 22, 27, 0.04);
  --shadow-lg: 0 12px 32px rgba(20, 22, 27, 0.10), 0 4px 10px rgba(20, 22, 27, 0.05);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 999px;

  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "Roboto Mono", Consolas, monospace;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  --transition-fast: 140ms cubic-bezier(.4,0,.2,1);
  --transition-med: 240ms cubic-bezier(.4,0,.2,1);
}

html[data-theme="dark"] {
  --color-bg: #0E0F13;
  --color-surface: #17191F;
  --color-surface-raised: #1D2028;
  --color-border: #272A33;
  --color-border-strong: #34384333;

  --color-text-primary: #F1F2F5;
  --color-text-secondary: #A2A8B4;
  --color-text-tertiary: #6B7180;

  --color-accent: #6E8CFF;
  --color-accent-hover: #8AA1FF;
  --color-accent-soft: #1B2440;

  --color-success: #3FC98A;
  --color-success-soft: #133226;
  --color-danger: #F17070;
  --color-danger-soft: #3A1D1D;
  --color-warning: #E3B04B;
  --color-warning-soft: #362A11;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.40);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
}

/* If the user has not made an explicit choice yet, respect system preference
   until theme.js applies the stored/detected value (avoids a flash to the
   "wrong" default on repeat visits with no toggle interaction yet). */
@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]):not([data-theme="dark"]) {
    --color-bg: #0E0F13;
    --color-surface: #17191F;
    --color-surface-raised: #1D2028;
    --color-border: #272A33;
    --color-border-strong: #34384333;
    --color-text-primary: #F1F2F5;
    --color-text-secondary: #A2A8B4;
    --color-text-tertiary: #6B7180;
    --color-accent: #6E8CFF;
    --color-accent-hover: #8AA1FF;
    --color-accent-soft: #1B2440;
    --color-success: #3FC98A;
    --color-success-soft: #133226;
    --color-danger: #F17070;
    --color-danger-soft: #3A1D1D;
    --color-warning: #E3B04B;
    --color-warning-soft: #362A11;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.40);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

h1, h2, h3, h4, p { margin: 0; }

button {
  font-family: inherit;
  cursor: pointer;
}

input, select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

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

::selection { background: var(--color-accent-soft); }

/* Focus visibility */
:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

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

/* ==========================================================================
   App shell
   ========================================================================== */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(10px) saturate(1.4);
  border-bottom: 1px solid var(--color-border);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--color-accent), #7B9BFF);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 650;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 12px;
  color: var(--color-text-tertiary);
}

.nav-tabs {
  display: flex;
  gap: var(--space-1);
  background: var(--color-surface);
  padding: 4px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 13.5px;
  font-weight: 560;
  padding: 8px 16px;
  border-radius: var(--radius-full);
  transition: background var(--transition-fast), color var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-tab:hover { color: var(--color-text-primary); }

.nav-tab.active {
  background: var(--color-accent-soft);
  color: var(--color-accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

main {
  flex: 1;
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: var(--space-6);
}

@media (max-width: 720px) {
  main { padding: var(--space-4); }
  .topbar { padding: var(--space-3) var(--space-4); }
  .brand-sub { display: none; }
}

@media (max-width: 620px) {
  .topbar {
    flex-wrap: wrap;
    row-gap: var(--space-3);
  }
  .brand { flex: 1 1 auto; min-width: 0; }
  .brand-name { font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-actions { flex-shrink: 0; }
  .nav-tabs {
    order: 3;
    width: 100%;
    justify-content: stretch;
  }
  .nav-tab { flex: 1; justify-content: center; padding: 8px 10px; }
}

@media (max-width: 380px) {
  #btn-lang-toggle { padding: 8px; font-size: 0; width: 34px; }
  #btn-lang-toggle::after {
    content: attr(data-short);
    font-size: 12px;
    font-weight: 700;
  }
}

.page { display: none; animation: fadeIn var(--transition-med) ease; }
.page.active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--color-accent);
  color: white;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--color-accent-hover); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text-primary);
  border-color: var(--color-border-strong);
}
.btn-secondary:hover { background: var(--color-accent-soft); border-color: var(--color-accent); color: var(--color-accent); }

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
}
.btn-ghost:hover { background: var(--color-border); color: var(--color-text-primary); }

.btn-danger {
  background: transparent;
  color: var(--color-danger);
}
.btn-danger:hover { background: var(--color-danger-soft); }

.btn-icon {
  padding: 8px;
  border-radius: var(--radius-md);
}

.btn-sm { padding: 6px 12px; font-size: 12.5px; }

/* ==========================================================================
   Cards
   ========================================================================== */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card-pad { padding: var(--space-5); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.card-title {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-size: 12.5px;
  color: var(--color-text-tertiary);
  margin-top: 2px;
}

.section-gap { margin-top: var(--space-5); }

/* ==========================================================================
   Hero / Total value card
   ========================================================================== */

.hero-card {
  background: linear-gradient(160deg, var(--color-surface) 0%, var(--color-accent-soft) 130%);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.hero-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}

.hero-value {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.hero-meta {
  display: flex;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.hero-meta-item { text-align: end; }

.hero-meta-label {
  font-size: 11.5px;
  color: var(--color-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.hero-meta-value {
  font-size: 17px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.hero-meta-value.balanced { color: var(--color-success); }
.hero-meta-value.imbalanced { color: var(--color-danger); }

@media (max-width: 620px) {
  .hero-card { flex-direction: column; align-items: flex-start; }
  .hero-meta { width: 100%; justify-content: space-between; gap: var(--space-3); }
  .hero-meta-item { text-align: start; }
  .hero-value { font-size: 34px; }
}

/* ==========================================================================
   Table
   ========================================================================== */

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

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.data-table thead th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-tertiary);
  padding: 0 var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}

.data-table td {
  padding: var(--space-3) var(--space-3);
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--transition-fast); }
.data-table tbody tr:hover { background: color-mix(in srgb, var(--color-accent-soft) 45%, transparent); }

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

.asset-name-cell {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.asset-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.asset-name-text { font-weight: 600; }

.deviation-bar-track {
  position: relative;
  width: 64px;
  height: 5px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 8px;
}

.deviation-bar-fill {
  position: absolute;
  top: 0; bottom: 0;
  border-radius: var(--radius-full);
  transition: width var(--transition-med);
}

/* Status pill */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 650;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill-success { background: var(--color-success-soft); color: var(--color-success); }
.pill-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.pill-warning { background: var(--color-warning-soft); color: var(--color-warning); }

/* Row actions */
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: var(--space-7) var(--space-4);
  color: var(--color-text-tertiary);
}

.empty-state-icon {
  width: 48px; height: 48px;
  margin: 0 auto var(--space-3);
  color: var(--color-text-tertiary);
  opacity: 0.6;
}

.empty-state-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 4px;
}

.empty-state-text { font-size: 13px; max-width: 320px; margin: 0 auto var(--space-4); }

/* ==========================================================================
   Mobile card list (replaces table on narrow screens)
   ========================================================================== */

.asset-cards { display: none; flex-direction: column; gap: var(--space-3); }

.asset-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  background: var(--color-surface-raised);
}

.asset-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.asset-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 13.5px;
  border-top: 1px dashed var(--color-border);
}

.asset-card-row:first-of-type { border-top: none; }

.asset-card-row .label { color: var(--color-text-tertiary); }
.asset-card-row .val { font-weight: 600; font-variant-numeric: tabular-nums; }

.asset-card-footer {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: var(--space-3);
}

@media (max-width: 680px) {
  .table-wrap.responsive-table { display: none; }
  .asset-cards { display: flex; }
}

/* ==========================================================================
   Form elements
   ========================================================================== */

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

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.field input, .field select {
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  width: 100%;
}

.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

.field-hint { font-size: 11.5px; color: var(--color-text-tertiary); }
.field-error { font-size: 11.5px; color: var(--color-danger); }

.field.has-error input { border-color: var(--color-danger); }

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

.input-affix input { padding-inline-end: 32px; }

.input-affix .affix {
  position: absolute;
  inset-inline-end: 12px;
  font-size: 13px;
  color: var(--color-text-tertiary);
  pointer-events: none;
}

.form-row {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
}
.form-row > * { flex: 1; min-width: 140px; }

/* ==========================================================================
   Deposit calculator
   ========================================================================== */

.deposit-controls {
  display: flex;
  align-items: flex-end;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.deposit-controls .field { flex: 1; min-width: 200px; }

.deposit-summary {
  display: flex;
  gap: var(--space-5);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.deposit-summary-item { min-width: 140px; }

.deposit-result-total {
  display: flex;
  justify-content: space-between;
  padding-top: var(--space-3);
  margin-top: var(--space-2);
  border-top: 1px solid var(--color-border);
  font-weight: 650;
}

.deposit-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

/* ==========================================================================
   Modal
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 16, 0.44);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: var(--space-4);
  animation: overlayIn var(--transition-fast) ease;
}

.modal-overlay.open { display: flex; }

@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--color-surface-raised);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: var(--space-5);
  animation: modalIn var(--transition-med) cubic-bezier(.2,.8,.2,1);
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.modal-title { font-size: 16px; font-weight: 650; }

.modal-body { display: flex; flex-direction: column; gap: var(--space-4); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

/* ==========================================================================
   Toasts
   ========================================================================== */

.toast-region {
  position: fixed;
  bottom: var(--space-5);
  inset-inline-end: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 200;
  max-width: 340px;
}

@media (max-width: 620px) {
  .toast-region { inset-inline-start: var(--space-4); inset-inline-end: var(--space-4); max-width: none; }
}

.toast {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  animation: toastIn var(--transition-med) cubic-bezier(.2,.8,.2,1);
}

.toast.leaving { animation: toastOut var(--transition-fast) ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(var(--toast-offset, 24px)); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateX(var(--toast-offset, 24px)) scale(0.96); }
}

html[dir="rtl"] { --toast-offset: -24px; }
html[dir="ltr"] { --toast-offset: 24px; }

.toast-icon { flex-shrink: 0; margin-top: 1px; }
.toast-success .toast-icon { color: var(--color-success); }
.toast-error .toast-icon { color: var(--color-danger); }
.toast-info .toast-icon { color: var(--color-accent); }

/* ==========================================================================
   Settings page
   ========================================================================== */

.threshold-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.threshold-slider-wrap {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

input[type="range"] {
  -webkit-appearance: none;
  flex: 1;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--color-border-strong);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--color-accent);
  border: 3px solid var(--color-surface);
  box-shadow: 0 0 0 1px var(--color-accent);
  cursor: pointer;
}

.threshold-value {
  font-weight: 700;
  font-size: 15px;
  min-width: 44px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.allocation-total-bar {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 600;
}

.allocation-total-bar.ok { color: var(--color-success); border-color: color-mix(in srgb, var(--color-success) 30%, var(--color-border)); background: var(--color-success-soft); }
.allocation-total-bar.bad { color: var(--color-danger); border-color: color-mix(in srgb, var(--color-danger) 30%, var(--color-border)); background: var(--color-danger-soft); }

.danger-zone {
  border: 1px solid color-mix(in srgb, var(--color-danger) 25%, var(--color-border));
}

.danger-zone .card-title { color: var(--color-danger); }

.settings-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
}

.file-hidden { display: none; }

/* ==========================================================================
   Search bar
   ========================================================================== */

.search-bar {
  position: relative;
  max-width: 260px;
  width: 100%;
}

.search-bar svg {
  position: absolute;
  inset-inline-start: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--color-text-tertiary);
}

.search-bar input {
  width: 100%;
  padding: 8px 12px;
  padding-inline-start: 32px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border-strong);
  background: var(--color-bg);
  font-size: 13px;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-accent-soft);
}

/* ==========================================================================
   Loader
   ========================================================================== */

.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,12,16,0.15);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 300;
}
.loader-overlay.active { display: flex; }

.loader-spinner {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-accent);
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Confirm dialog reuses modal styles; utility text colors
   ========================================================================== */

.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.text-danger { color: var(--color-danger); }
.text-success { color: var(--color-success); }

.flex-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }

footer.app-footer {
  text-align: center;
  padding: var(--space-6) var(--space-4) var(--space-7);
  font-size: 12px;
  color: var(--color-text-tertiary);
}

footer.app-footer p {
  margin: 0 0 var(--space-2);
}

.footer-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.footer-link {
  background: none;
  border: none;
  padding: 4px 2px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-tertiary);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

.footer-link:hover,
.footer-link:focus-visible {
  color: var(--color-accent);
}

.footer-links-sep {
  color: var(--color-text-tertiary);
  font-size: 12px;
}

/* ==========================================================================
   SEO helper text (keyword-rich descriptions under each tool)
   ========================================================================== */

.tool-seo-text {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px dashed var(--color-border);
  font-size: 12px;
  line-height: 1.7;
  color: var(--color-text-tertiary);
}

/* ==========================================================================
   AdSense placeholder slots
   ========================================================================== */

.ad-slot {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(
    45deg,
    var(--color-border) 0px, var(--color-border) 10px,
    transparent 10px, transparent 20px
  );
  background-color: var(--color-surface);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  opacity: 0.7;
}

.ad-slot {
  display: none !important;
}
.ad-slot-top { margin: 0 auto var(--space-2); }
.ad-slot-bottom { margin: var(--space-6) auto var(--space-2); }
.ad-slot-inline { min-height: 100px; margin-top: 30px; }

.ad-slot-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-tertiary);
}

@media (max-width: 720px) {
  .ad-slot { margin-inline: var(--space-4); width: auto; }
}

/* ==========================================================================
   Language / theme toggle buttons in top bar
   ========================================================================== */

#btn-lang-toggle {
  font-size: 12.5px;
  font-weight: 650;
  padding: 8px 12px;
  width: auto;
}

/* ==========================================================================
   Phone tuning (small screens): full-width controls, no iOS input zoom,
   comfortable tap targets, no accidental horizontal scroll.
   ========================================================================== */

@media (max-width: 620px) {
  /* iOS Safari zooms the page if a focused input's font-size is < 16px. */
  .field input,
  .field select,
  .search-bar input,
  input[type="number"],
  input[type="text"] {
    font-size: 16px;
  }

  .card-header > .search-bar { max-width: none; }
  .card-header > .btn { width: 100%; justify-content: center; }
  .card-header > div:first-child { width: 100%; }

  .hero-value { word-break: break-word; }

  .modal { max-width: none; width: 100%; }
  .modal-footer { flex-direction: column-reverse; }
  .modal-footer .btn { width: 100%; }

  .deposit-controls { flex-direction: column; align-items: stretch; }
  .deposit-controls .field,
  .deposit-controls .btn { width: 100%; }

  .deposit-actions { flex-direction: column-reverse; }
  .deposit-actions .btn { width: 100%; }

  .settings-actions-grid { grid-template-columns: 1fr; }

  body { overflow-x: hidden; }
}

/* ==========================================================================
   Static content pages (About Us, Privacy Policy, Terms of Use)
   ========================================================================== */

.static-page {
  max-width: 760px;
  margin: 0 auto;
}

.static-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-2);
}

.static-meta {
  font-size: 12.5px;
  color: var(--color-text-tertiary);
  margin-bottom: var(--space-5);
}

.static-subtitle {
  font-size: 17px;
  font-weight: 650;
  margin-top: var(--space-6);
  margin-bottom: var(--space-2);
}

.static-page p {
  font-size: 14.5px;
  line-height: 1.85;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
}

.static-page a {
  color: var(--color-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

@media (max-width: 620px) {
  .static-title { font-size: 22px; }
}

@media print {
  .topbar, .toast-region, .modal-overlay, .btn, .row-actions, .search-bar, .deposit-actions, footer.app-footer, .ad-slot, .tool-seo-text { display: none !important; }
  body { background: white; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
