*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg-deep: #0c1222;
  --bg-main: #0f172a;
  --bg-card: #0f172a;
  --bg-elevated: #1e293b;
  --border: #1e293b;
  --border-light: #334155;
  --text: #e2e8f0;
  --text-dim: #94a3b8;
  --text-faint: #64748b;
  --text-ghost: #475569;
  --accent: #38bdf8;
  --accent2: #818cf8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.4);
  --bg-glass: rgba(15,23,42,0.72);
  --gradient-accent: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Rubik', 'Segoe UI', sans-serif;
  --bg-grad-1: rgba(56,189,248,0.08);
  --bg-grad-2: rgba(129,140,248,0.07);
}
[data-theme="light"] {
  --bg-deep: #eef2f7;
  --bg-main: #f7fafc;
  --bg-card: #ffffff;
  --bg-elevated: #f1f5f9;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text: #0f172a;
  --text-dim: #334155;
  --text-faint: #64748b;
  --text-ghost: #94a3b8;
  --accent: #0284c7;
  --accent2: #4f46e5;
  --green: #16a34a;
  --red: #dc2626;
  --yellow: #ca8a04;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
  --shadow-md: 0 4px 12px rgba(15,23,42,0.08);
  --shadow-lg: 0 12px 28px rgba(15,23,42,0.12);
  --bg-glass: rgba(255,255,255,0.85);
  --gradient-accent: linear-gradient(135deg, #0284c7 0%, #4f46e5 100%);
  --bg-grad-1: rgba(2,132,199,0.06);
  --bg-grad-2: rgba(79,70,229,0.06);
}
body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 15% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(900px 500px at 90% 10%, var(--bg-grad-2), transparent 60%),
    linear-gradient(135deg, var(--bg-deep) 0%, var(--bg-main) 50%, var(--bg-deep) 100%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.3s ease, color 0.3s ease;
}
::selection { background: rgba(56,189,248,0.3); color: #fff; }
button, input, select, textarea { font-family: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px;
}
/* Smoother scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 10px; border: 2px solid var(--bg-deep); }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
/* HEADER */
.header {
  padding: 18px 28px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-top { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
.title {
  font-size: 22px; font-weight: 800;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}
.subtitle { font-size: 13px; color: var(--text-faint); margin-top: 2px; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.btn {
  padding: 9px 20px; border: none; border-radius: 10px; cursor: pointer;
  font-weight: 700; font-size: 14px; font-family: var(--sans);
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s, background 0.2s;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { opacity: 0.92; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #7c3aed); color: #fff;
  box-shadow: 0 4px 14px rgba(124,58,237,0.25);
}
.btn-primary:hover { box-shadow: 0 6px 20px rgba(124,58,237,0.4); }
.btn-success { background: var(--green); color: #000; box-shadow: 0 4px 14px rgba(34,197,94,0.2); }
.btn-small { padding: 7px 14px; font-size: 13px; }
.btn-outline { background: var(--bg-elevated); border: 1px solid var(--border-light); color: var(--text-dim); font-size: 13px; padding: 7px 14px; }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: transparent; color: var(--red); border: 1px solid var(--red); padding: 4px 10px; font-size: 12px; font-weight: 700; border-radius: 6px; }
.btn-danger:hover { background: rgba(239,68,68,0.1); }
.btn-icon {
  padding: 8px 12px; background: var(--bg-elevated); border: 1px solid var(--border-light);
  border-radius: 10px; cursor: pointer; font-size: 16px;
  transition: transform 0.15s, border-color 0.2s, background 0.2s;
}
.btn-icon:hover { transform: translateY(-1px); border-color: var(--accent); background: rgba(56,189,248,0.08); }
/* API BAR */
.api-bar {
  display: none; align-items: center; gap: 10px; margin-top: 12px;
  padding: 10px 14px; background: var(--bg-elevated); border-radius: 8px; flex-wrap: wrap;
}
.api-bar.show { display: flex; }
.api-bar input {
  flex: 1; min-width: 200px; padding: 6px 10px; background: var(--bg-deep);
  border: 1px solid var(--border-light); border-radius: 6px; color: var(--text);
  font-size: 13px; font-family: var(--mono);
}
.api-bar a { color: var(--accent); font-size: 12px; text-decoration: none; }
/* DATA BAR */
.data-bar {
  display: none; align-items: center; gap: 10px; margin-top: 8px;
  padding: 10px 14px; background: var(--bg-elevated); border-radius: 8px; flex-wrap: wrap;
}
.data-bar.show { display: flex; }
/* TABS */
.tabs {
  display: flex; gap: 2px; padding: 0 16px; background: var(--bg-main);
  border-bottom: 1px solid var(--border); overflow-x: auto;
}
.tab {
  padding: 12px 18px; background: transparent; color: var(--text-dim);
  border: none; border-bottom: 2px solid transparent; cursor: pointer;
  font-size: 13px; font-weight: 600; font-family: var(--sans);
  white-space: nowrap; transition: all 0.2s; display: flex; align-items: center; gap: 6px;
  position: relative;
}
.tab:hover { color: var(--text); background: rgba(56,189,248,0.04); }
.tab.active {
  color: var(--accent); border-bottom-color: var(--accent);
  background: linear-gradient(180deg, rgba(56,189,248,0.08), transparent);
}
.tab.active::after {
  content: ""; position: absolute; left: 50%; bottom: -2px; transform: translateX(-50%);
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}
/* CONTENT */
.content { flex: 1; padding: 20px 24px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; }
.section-title {
  font-size: 18px; font-weight: 700; color: #f1f5f9;
  display: inline-flex; align-items: center; gap: 8px;
}
.section-title::before {
  content: ""; width: 4px; height: 20px; border-radius: 2px;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
}
.timestamp { font-size: 12px; color: var(--text-faint); font-family: var(--mono); }
.hint { font-size: 12px; color: var(--text-ghost); margin-bottom: 12px; }
/* TABLE */
.table-wrap {
  overflow: auto; border-radius: 14px; border: 1px solid var(--border);
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 220px);
  position: relative;
}
table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
th {
  padding: 12px 14px; text-align: right; font-weight: 700; color: var(--text-dim);
  border-bottom: 1px solid var(--border); background: var(--bg-deep);
  z-index: 5;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.7px;
  position: sticky; top: 0;
}
td { padding: 10px 14px; text-align: right; font-family: var(--mono); font-size: 13px; border-bottom: 1px solid var(--border); }
td.label { font-family: var(--sans); font-weight: 600; color: var(--text); }
tbody tr { transition: background 0.15s; }
tbody tr:nth-child(even) { background: rgba(255,255,255,0.015); }
tbody tr:hover { background: rgba(56,189,248,0.06); }
tbody tr:last-child td { border-bottom: none; }
.cell-val {
  cursor: pointer; padding: 2px 6px; border-radius: 4px;
  display: inline-block; min-width: 40px; text-align: center;
  transition: background 0.15s;
}
.cell-val:hover { background: rgba(56,189,248,0.1); }
.cell-edit { display: inline-flex; gap: 4px; align-items: center; }
.cell-edit input {
  width: 80px; padding: 3px 6px; background: var(--bg-elevated);
  border: 1px solid var(--accent); border-radius: 4px; color: var(--text);
  font-family: var(--mono); font-size: 13px; text-align: center;
}
.cell-edit button { padding: 2px 8px; border: none; border-radius: 4px; cursor: pointer; font-weight: 700; font-size: 12px; }
.positive { color: var(--green); }
.negative { color: var(--red); }
/* FEAR GRID */
.fear-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.fear-card {
  background: linear-gradient(180deg, var(--bg-card), rgba(15,23,42,0.6));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  position: relative;
  overflow: hidden;
}
.fear-card::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  opacity: 0.6;
}
.fear-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.fear-label { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.fear-value { font-size: 30px; font-weight: 800; font-family: var(--mono); color: var(--accent); margin-bottom: 6px; letter-spacing: -0.5px; }
.fear-desc { font-size: 12px; color: var(--text-faint); line-height: 1.5; }
.fear-badge { margin-top: 8px; padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 700; display: inline-block; color: #fff; }
.fear-bar { height: 8px; background: var(--bg-elevated); border-radius: 4px; overflow: hidden; margin-top: 8px; }
.fear-bar-fill { height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--red) 0%, var(--yellow) 50%, var(--green) 100%); }
.fear-bar-labels { display: flex; justify-content: space-between; font-size: 10px; color: var(--text-faint); margin-top: 2px; }
/* PORTFOLIO */
.add-form { background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.form-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-input {
  padding: 8px 12px; background: var(--bg-elevated); border: 1px solid var(--border-light);
  border-radius: 6px; color: var(--text); font-size: 13px; font-family: var(--sans);
}
.form-input:focus { outline: none; border-color: var(--accent); }
.notes-input {
  padding: 4px 8px; background: var(--bg-elevated); border: 1px solid var(--border-light);
  border-radius: 4px; color: var(--text); font-size: 12px; font-family: var(--sans); width: 140px;
}
.empty-state { text-align: center; padding: 40px; color: var(--text-dim); background: var(--bg-card); border-radius: 10px; border: 1px dashed var(--border-light); }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 16px; }
.summary-card {
  background: linear-gradient(180deg, var(--bg-card), rgba(15,23,42,0.7));
  border: 1px solid var(--border); border-radius: 12px;
  padding: 16px; text-align: center;
  transition: transform 0.15s, border-color 0.2s;
}
.summary-card:hover { transform: translateY(-1px); border-color: var(--border-light); }
.summary-label { font-size: 11px; color: var(--text-faint); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
.summary-value { font-size: 24px; font-weight: 800; font-family: var(--mono); color: var(--accent); letter-spacing: -0.5px; }
/* SCANNER */
.scanner-card {
  background: linear-gradient(180deg, var(--bg-card), rgba(15,23,42,0.7));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  margin-top: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.scanner-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.scanner-symbol { font-size: 28px; font-weight: 800; color: var(--accent); font-family: var(--mono); }
.scanner-name { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.scanner-price-block { text-align: left; }
.scanner-price { font-size: 32px; font-weight: 800; font-family: var(--mono); }
.scanner-change { font-size: 16px; font-weight: 700; font-family: var(--mono); margin-top: 4px; }
.scanner-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.scanner-item {
  background: var(--bg-elevated);
  padding: 11px 13px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border: 1px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.scanner-item:hover { border-color: var(--border-light); background: rgba(56,189,248,0.05); }
.scanner-label { color: var(--text-dim); font-family: var(--sans); font-size: 12px; font-weight: 600; }
.scanner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.scanner-actions a { text-decoration: none; }
.chip {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  cursor: pointer;
  font-family: var(--mono);
  transition: all 0.15s;
}
.chip:hover { background: var(--accent); color: #000; border-color: var(--accent); }
.chip.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 700; }
.sector-region-btn { padding: 6px 16px; font-size: 13px; font-family: var(--sans); }
.footer { padding: 12px 24px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; font-size: 11px; color: var(--text-ghost); flex-wrap: wrap; gap: 8px; }
/* LOADING */
.loading-overlay {
  position: fixed; inset: 0; background: rgba(12,18,34,0.85); display: flex;
  flex-direction: column; align-items: center; justify-content: center; z-index: 999;
}
.spinner { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { color: var(--text-dim); margin-top: 16px; font-family: var(--mono); }
.hidden { display: none !important; }
/* STATUS */
.status-bar { padding: 8px 16px; font-size: 12px; font-family: var(--mono); text-align: center; }
.status-bar.success { background: rgba(34,197,94,0.1); color: var(--green); }
.status-bar.error { background: rgba(239,68,68,0.1); color: var(--red); }
.tfoot-total { background: var(--bg-elevated); }
.tfoot-total td { font-weight: 700; }
select.form-input { min-width: 120px; }

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* MOBILE RESPONSIVE                                                              */
/* ═══════════════════════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* TABLET (≤ 1024px)                                                              */
/* ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .content { padding: 16px 16px; }
  .fear-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* MOBILE (≤ 768px) — tightened, touch-friendly                                   */
/* ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  .header { padding: 10px 12px 8px; }
  .header-top { flex-direction: column; gap: 10px; align-items: stretch; }
  .title { font-size: 18px; }
  .subtitle { font-size: 11px; }
  .header-actions {
    justify-content: space-between;
    gap: 6px;
    width: 100%;
  }
  .header-actions > .btn-primary { flex: 1; justify-content: center; }
  .btn { padding: 9px 14px; font-size: 13px; min-height: 40px; border-radius: 8px; }
  .btn-icon { padding: 8px 10px; font-size: 15px; min-width: 40px; min-height: 40px; }
  .btn-small { min-height: 36px; }

  /* Tabs: horizontal scrollable pill bar — always full width */
  .tabs {
    padding: 0 8px;
    gap: 2px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--bg-main);
  }
  .tabs::-webkit-scrollbar { display: none; }
  .tab {
    padding: 12px 12px;
    font-size: 12px;
    gap: 4px;
    min-height: 44px;
    flex-shrink: 0;
  }
  .tab.active::after { display: none; }

  .content { padding: 14px 10px 24px; }
  .section-title { font-size: 16px; }
  .section-title::before { height: 16px; }
  .section-header { margin-bottom: 10px; gap: 6px; }

  /* Tables: smaller but still readable, no text wrap */
  table { font-size: 12px; }
  th { padding: 8px 8px; font-size: 10px; letter-spacing: 0.3px; }
  td { padding: 8px 8px; font-size: 12px; }

  .fear-grid { grid-template-columns: 1fr; gap: 10px; }
  .fear-card { padding: 16px; border-radius: 12px; }
  .fear-value { font-size: 24px; }

  .summary-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .summary-card { padding: 12px 10px; }
  .summary-value { font-size: 20px; }
  .summary-label { font-size: 10px; }

  .form-row { flex-direction: column; gap: 8px; }
  .form-input { width: 100% !important; min-width: unset !important; min-height: 40px; }
  .add-form { padding: 14px; border-radius: 10px; }

  .api-bar { flex-direction: column; align-items: stretch; }
  .api-bar input { min-width: unset !important; width: 100% !important; }

  /* Scanner — condensed but clear */
  .scanner-card { padding: 16px; border-radius: 12px; }
  .scanner-header { flex-direction: column; text-align: center; gap: 10px; }
  .scanner-price-block { text-align: center; }
  .scanner-symbol { font-size: 22px; }
  .scanner-price { font-size: 26px; }
  .scanner-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .scanner-item { padding: 9px 10px; font-size: 12px; }
  .scanner-actions { justify-content: center; gap: 6px; }

  .footer { flex-direction: column; text-align: center; gap: 4px; padding: 10px 12px; }
  .hint { font-size: 11px; }
  .cell-val { min-width: 30px; font-size: 11px; padding: 4px 6px; }
  .cell-val:active { background: rgba(56,189,248,0.15); }
  .table-wrap { border-radius: 10px; }
  .notes-input { width: 100%; min-width: 80px; }

  /* Touch-friendly chips */
  .chip { padding: 8px 14px; font-size: 13px; min-height: 36px; display: inline-flex; align-items: center; }
  .refresh-btn { min-width: 36px; min-height: 36px; font-size: 16px; }
  .ref-btn { min-height: 28px; padding: 4px 8px; font-size: 11px; }

  /* NK Logo in header - mobile */
  .nk-logo-text { width: 38px; height: 38px; font-size: 16px; }
  .nk-brand { gap: 10px; }

  /* Status bar — readable on small screens */
  .status-bar { font-size: 11px; padding: 8px 12px; }
}

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* SMALL MOBILE (≤ 480px)                                                         */
/* ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  .header { padding: 10px 10px 6px; }
  .title { font-size: 16px; }
  .content { padding: 12px 8px 20px; }
  .tab { font-size: 11px; padding: 10px 10px; }
  .section-title { font-size: 15px; }
  .scanner-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .scanner-item { padding: 8px 9px; font-size: 11px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  td.label { max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .fear-value { font-size: 22px; }
  .fear-card { padding: 14px; }

  /* Hide lowest-priority table columns to keep readability */
  .hide-sm { display: none !important; }
}

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* TINY MOBILE (≤ 360px)                                                          */
/* ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 360px) {
  .btn { padding: 8px 10px; font-size: 12px; }
  .scanner-grid { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  table { font-size: 11px; }
  td { padding: 6px 6px; font-size: 11px; }
  th { padding: 6px 6px; font-size: 9px; }
}

/* NK Logo styling — matches nk-planning.co.il monogram */
.nk-logo-text {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, #0f1923 0%, #080d12 100%);
  color: #c9a227;
  font-family: var(--sans);
  font-weight: 900;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid #c9a227;
  box-shadow: 0 4px 15px rgba(201, 162, 39, 0.3), inset 0 1px 0 rgba(255,255,255,0.1);
  letter-spacing: 1px;
  flex-shrink: 0;
  transition: transform 0.2s, box-shadow 0.2s;
}
.nk-logo-text:hover {
  transform: scale(1.05) rotate(-5deg);
  box-shadow: 0 8px 25px rgba(201, 162, 39, 0.4);
}
.nk-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* REFRESH BUTTON (per-section)                                                   */
/* ═══════════════════════════════════════════════════════════════════════════════ */
.refresh-btn {
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text-faint);
  font-size: 14px;
  padding: 4px 8px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1;
}
.refresh-btn:hover { background: rgba(56,189,248,0.1); border-color: var(--accent); color: var(--accent); }
.refresh-btn.spinning { animation: spin 0.8s linear infinite; pointer-events: none; opacity: 0.6; }

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* API PANEL — tiered sources panel                                               */
/* ═══════════════════════════════════════════════════════════════════════════════ */
.api-panel {
  margin-top: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  overflow: hidden;
  display: none;
}
.api-panel.show { display: block; }

.api-tier-section { border-bottom: 1px solid var(--border); }
.api-tier-section:last-child { border-bottom: none; }

.api-tier-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(0,0,0,0.2);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.api-tier-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.api-tier-auto  { background: rgba(34,197,94,0.15);  color: var(--green);  border: 1px solid rgba(34,197,94,0.3);  }
.api-tier-free  { background: rgba(56,189,248,0.12); color: var(--accent); border: 1px solid rgba(56,189,248,0.25); }
.api-tier-paid  { background: rgba(234,179,8,0.12);  color: var(--yellow); border: 1px solid rgba(234,179,8,0.25);  }

.api-sources-grid { padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 8px; }

.api-source-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: 8px;
  flex-wrap: wrap;
  transition: border-color 0.15s;
}
.api-source-row:hover { border-color: var(--border-light); }

.api-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.api-dot-on  { background: var(--green);  box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.api-dot-off { background: var(--text-ghost); }

.api-source-info { flex: 1; min-width: 160px; }
.api-source-name { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 2px; }
.api-source-desc { font-size: 11px; color: var(--text-dim); margin-bottom: 3px; }
.api-source-uses { font-size: 10px; color: var(--text-faint); font-style: italic; }

.api-source-links { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; flex-shrink: 0; }
.api-site-link   { color: var(--accent);  font-size: 11px; text-decoration: none; white-space: nowrap; }
.api-signup-link { color: var(--yellow);  font-size: 11px; text-decoration: none; white-space: nowrap; }
.api-site-link:hover, .api-signup-link:hover { text-decoration: underline; }

.api-key-input {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
  padding: 5px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-family: var(--mono);
}
.api-key-input:focus { outline: none; border-color: var(--accent); }
.api-key-input::placeholder { color: var(--text-ghost); font-size: 11px; }

.api-save-btn {
  padding: 5px 12px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.api-save-btn:hover { opacity: 0.85; }

/* mobile tweaks for API panel */
@media (max-width: 768px) {
  .api-source-row { flex-direction: column; }
  .api-source-links { align-items: flex-start; flex-direction: row; flex-wrap: wrap; }
  .api-key-input { max-width: 100%; min-width: unset; width: 100%; }
}

/* Reference point */
.ref-btn {
  background: none; border: 1px solid var(--border-light); border-radius: 4px;
  color: var(--text-faint); font-size: 10px; padding: 2px 6px; cursor: pointer;
  font-family: var(--sans); transition: all 0.15s;
}
.ref-btn:hover { background: var(--accent); color: #000; border-color: var(--accent); }
.ref-btn.active { background: rgba(56,189,248,0.15); border-color: var(--accent); color: var(--accent); }
.ref-date { font-size: 10px; color: var(--text-faint); display: block; margin-top: 2px; }

/* Market-open/closed indicator (macro page) */
.market-dot {
  display: inline-block; font-size: 12px; line-height: 1;
  vertical-align: middle; margin-inline-end: 4px;
  cursor: help;
}
.market-open {
  color: #22c55e;
  text-shadow: 0 0 6px rgba(34,197,94,0.85), 0 0 2px rgba(34,197,94,0.9);
  animation: marketPulse 1.8s ease-in-out infinite;
}
.market-closed {
  color: #ef4444;
  opacity: 0.75;
}
@keyframes marketPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
.market-status-txt { font-size: 12px; font-weight: 600; }
.market-name { font-size: 10px; color: var(--text-faint); margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* BOTTOM NAVIGATION (mobile)                                                     */
/* ═══════════════════════════════════════════════════════════════════════════════ */
.bottom-nav { display: none; }
@media (max-width: 768px) {
  .tabs { display: none !important; }
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
    z-index: 95;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    box-shadow: 0 -4px 20px rgba(0,0,0,0.25);
    overflow-x: auto;
    scrollbar-width: none;
    justify-content: space-between;
  }
  .bottom-nav::-webkit-scrollbar { display: none; }
  .bottom-nav-item {
    flex: 1 0 auto;
    min-width: 56px;
    background: transparent;
    border: none;
    color: var(--text-faint);
    font-family: var(--sans);
    font-size: 10px;
    font-weight: 600;
    padding: 6px 4px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    border-radius: 10px;
    transition: color 0.15s, background 0.15s, transform 0.15s;
  }
  .bottom-nav-item .bn-icon { font-size: 20px; line-height: 1; }
  .bottom-nav-item:active { transform: scale(0.94); }
  .bottom-nav-item.active {
    color: var(--accent);
    background: rgba(56,189,248,0.10);
  }
  .content { padding-bottom: 90px !important; }
  .footer { display: none; }
}

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* COMMAND PALETTE (Ctrl+K)                                                       */
/* ═══════════════════════════════════════════════════════════════════════════════ */
.cmd-overlay {
  position: fixed; inset: 0; background: rgba(8,12,24,0.65);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  z-index: 1000; display: flex; align-items: flex-start; justify-content: center;
  padding-top: 12vh; animation: fadeIn 0.15s ease;
}
[data-theme="light"] .cmd-overlay { background: rgba(15,23,42,0.4); }
.cmd-overlay.hidden { display: none; }
.cmd-modal {
  width: min(560px, 92vw);
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: slideDown 0.2s ease;
}
.cmd-input-wrap { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.cmd-input-wrap .cmd-icon { font-size: 18px; color: var(--text-faint); }
.cmd-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text); font-size: 15px; font-family: var(--sans);
}
.cmd-kbd {
  font-family: var(--mono); font-size: 11px;
  padding: 2px 6px; border-radius: 4px;
  background: var(--bg-elevated); color: var(--text-faint);
  border: 1px solid var(--border-light);
}
.cmd-results { max-height: 50vh; overflow-y: auto; padding: 6px; }
.cmd-group-label { font-size: 10px; font-weight: 700; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.5px; padding: 8px 12px 4px; }
.cmd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text);
  transition: background 0.1s;
}
.cmd-item:hover, .cmd-item.cmd-active {
  background: rgba(56,189,248,0.12);
  color: var(--accent);
}
.cmd-item .cmd-item-icon { font-size: 16px; opacity: 0.85; }
.cmd-item .cmd-item-meta { margin-right: auto; font-size: 11px; color: var(--text-faint); }
.cmd-empty { padding: 24px; text-align: center; color: var(--text-faint); font-size: 13px; }

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

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* SKELETON LOADERS                                                               */
/* ═══════════════════════════════════════════════════════════════════════════════ */
.skeleton {
  display: inline-block;
  background: linear-gradient(90deg, var(--bg-elevated) 0%, var(--border-light) 50%, var(--bg-elevated) 100%);
  background-size: 200% 100%;
  animation: skel 1.4s ease-in-out infinite;
  border-radius: 4px;
  height: 14px; width: 60px;
  vertical-align: middle;
  opacity: 0.6;
}
.skeleton.sk-block { display: block; height: 18px; width: 100%; margin: 4px 0; }
.skeleton.sk-card  { height: 80px; width: 100%; border-radius: 12px; }
.skeleton.sk-row   { height: 40px; width: 100%; margin-bottom: 6px; border-radius: 6px; }
@keyframes skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.section-loading .table-wrap { position: relative; min-height: 200px; }
.section-loading .table-wrap::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(56,189,248,0.05) 50%, transparent 100%);
  animation: skel 1.6s linear infinite;
  pointer-events: none;
}

/* Lightweight inline loading bar */
.loading-bar {
  position: fixed; top: 0; left: 0; right: 0; height: 3px;
  z-index: 200;
  background: rgba(56,189,248,0.15);
  overflow: hidden;
}
.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient-accent);
  transition: width 0.25s ease;
  box-shadow: 0 0 12px rgba(56,189,248,0.6);
}
.loading-progress {
  position: fixed; top: 10px; right: 18px; z-index: 201;
  background: var(--bg-card); border: 1px solid var(--accent);
  border-radius: 20px; padding: 6px 14px;
  font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 700;
  box-shadow: 0 4px 16px rgba(56,189,248,0.25);
  display: flex; align-items: center; gap: 8px;
  min-width: 200px;
}
.loading-progress-label { flex: 1; color: var(--text-dim); font-size: 11px; font-family: var(--sans); }
.loading-progress-pct { color: var(--accent); font-weight: 800; }
@media (max-width: 768px) {
  .loading-progress {
    top: auto; bottom: 80px; right: 10px; left: 10px;
    min-width: unset; justify-content: center;
    padding: 8px 12px; font-size: 11px;
  }
}

/* Info modal (click-to-explain for PE / Shiller / Fear indicators) */
.info-modal-backdrop {
  position: fixed; inset: 0; background: rgba(12,18,34,0.85);
  z-index: 1000; display: flex; align-items: center; justify-content: center;
  padding: 16px; cursor: pointer;
  animation: fadeIn 0.18s ease;
}
.info-modal {
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: 16px; padding: 24px 26px; max-width: 580px; width: 100%;
  max-height: 85vh; overflow-y: auto; cursor: default;
  box-shadow: var(--shadow-lg);
  text-align: right;
}
.info-modal h3 {
  color: var(--accent); font-size: 19px; margin-bottom: 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.info-modal h3 .info-close {
  background: transparent; border: none; color: var(--text-faint);
  cursor: pointer; font-size: 20px; padding: 4px 10px; border-radius: 6px;
}
.info-modal h3 .info-close:hover { color: var(--red); background: rgba(239,68,68,0.08); }
.info-modal .info-section { margin-bottom: 14px; }
.info-modal .info-section-label {
  font-size: 11px; color: var(--text-faint); text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 700; margin-bottom: 5px;
}
.info-modal .info-section-body { font-size: 13.5px; color: var(--text); line-height: 1.6; }
.info-modal .info-source {
  font-size: 11px; color: var(--text-ghost); font-family: var(--mono);
  padding-top: 10px; border-top: 1px dashed var(--border);
  margin-top: 12px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.cell-info { cursor: help !important; border-bottom: 1px dotted var(--text-faint); }
.cell-info:hover { color: var(--accent); background: rgba(56,189,248,0.08); }
.inline-info-btn {
  cursor: pointer; opacity: 0.55; font-size: 11px; margin-inline-start: 4px;
  transition: opacity 0.15s;
}
.inline-info-btn:hover { opacity: 1; }

/* Scanner: historical financials table */
.fin-hist-table {
  width: 100%; border-collapse: collapse; font-size: 12px; font-family: var(--mono);
}
.fin-hist-table th, .fin-hist-table td {
  padding: 8px 10px; text-align: center; border-bottom: 1px solid var(--border);
}
.fin-hist-table th {
  background: var(--bg-deep); color: var(--accent);
  font-size: 11px; font-weight: 700;
}
.fin-hist-table td.label {
  text-align: right; font-family: var(--sans); font-weight: 600;
  color: var(--text-dim); background: var(--bg-deep);
}
.fear-card.clickable { cursor: pointer; }
.fear-card.clickable:hover { border-color: var(--accent); }

/* Help modal (dashboard guide) */
.info-modal.help-modal { max-width: 760px; }
.help-intro {
  font-size: 13.5px; color: var(--text-dim); line-height: 1.55;
  margin-bottom: 16px; padding: 10px 12px;
  background: var(--bg-deep); border-right: 3px solid var(--accent);
  border-radius: 6px;
}
.help-section { margin-bottom: 18px; }
.help-section-title {
  font-size: 14px; font-weight: 700; color: var(--accent);
  margin-bottom: 6px;
}
.help-section-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 6px;
}
.help-section-list li {
  font-size: 13px; color: var(--text); line-height: 1.55;
  padding: 6px 10px; background: var(--bg-elevated);
  border-radius: 6px; border-right: 2px solid var(--border-light);
}
.help-footer {
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 11px; color: var(--text-ghost); font-style: italic;
}
.help-btn { background: rgba(56,189,248,0.08); }
.help-btn:hover { background: rgba(56,189,248,0.18); }

/* Scanner comparison */
.compare-panel {
  margin-top: 16px; padding: 14px 16px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 12px; display: flex; flex-direction: column; gap: 10px;
}
.compare-header {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px;
}
.compare-slots {
  display: flex; flex-wrap: wrap; gap: 8px;
}
.compare-slot {
  padding: 6px 12px; background: var(--bg-elevated);
  border: 1px solid var(--border-light); border-radius: 20px;
  font-size: 12px; font-family: var(--mono); color: var(--text);
  display: inline-flex; align-items: center; gap: 6px;
}
.compare-slot .remove {
  background: transparent; border: none; color: var(--red);
  cursor: pointer; font-size: 14px; padding: 0 4px; border-radius: 4px;
}
.compare-slot.empty { color: var(--text-ghost); border-style: dashed; }
.compare-table-wrap { overflow-x: auto; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.compare-table th, .compare-table td {
  padding: 10px 12px; text-align: center; border-bottom: 1px solid var(--border);
  font-family: var(--mono);
}
.compare-table th:first-child, .compare-table td:first-child {
  text-align: right; font-family: var(--sans); font-weight: 600; color: var(--text-dim);
  background: var(--bg-deep); position: sticky; right: 0;
}
.compare-table th { background: var(--bg-deep); color: var(--accent); font-size: 12px; }
.compare-table .best { background: rgba(34,197,94,0.12); color: var(--green); font-weight: 700; }
.compare-table .worst { background: rgba(239,68,68,0.10); color: var(--red); font-weight: 700; }

/* Mobile: scale down modals and compare panel */
@media (max-width: 768px) {
  .info-modal { padding: 18px 16px; max-height: 88vh; }
  .info-modal h3 { font-size: 16px; margin-bottom: 10px; }
  .info-modal .info-section-body { font-size: 12.5px; }
  .help-section-list li { font-size: 12.5px; padding: 6px 8px; }

  .compare-panel { padding: 10px 10px; }
  .compare-header { flex-direction: column; align-items: stretch; }
  .compare-slots { justify-content: center; }
  .compare-table { font-size: 11.5px; }
  .compare-table th, .compare-table td { padding: 8px 6px; }
}

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* TOAST notifications (replaces blocking status bar)                             */
/* ═══════════════════════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed; bottom: 20px; left: 20px; z-index: 950;
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; max-width: 380px;
}
@media (max-width: 768px) {
  .toast-container { bottom: 80px; left: 10px; right: 10px; max-width: unset; }
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-right: 4px solid var(--accent);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13px; color: var(--text);
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn 0.25s ease;
  max-width: 380px;
}
.toast.toast-success { border-right-color: var(--green); }
.toast.toast-error   { border-right-color: var(--red); }
.toast.toast-info    { border-right-color: var(--accent); }
.toast.toast-out { animation: toastOut 0.2s ease forwards; }
@keyframes toastIn  { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to   { opacity: 0; transform: translateX(20px); } }

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* THEME TOGGLE button                                                            */
/* ═══════════════════════════════════════════════════════════════════════════════ */
.theme-toggle {
  position: relative;
  width: 44px; height: 40px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px;
  transition: transform 0.15s, border-color 0.2s, background 0.2s;
}
.theme-toggle:hover { border-color: var(--accent); transform: translateY(-1px); }
.theme-toggle .icon-sun  { display: none; }
[data-theme="light"] .theme-toggle .icon-sun  { display: inline; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* IMPROVED VISUAL HIERARCHY                                                      */
/* ═══════════════════════════════════════════════════════════════════════════════ */
.tab-panel { animation: tabFade 0.25s ease; }
@keyframes tabFade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.section-title { letter-spacing: -0.3px; }
.section-title::before {
  background: var(--gradient-accent);
  box-shadow: 0 0 12px rgba(56,189,248,0.4);
}
[data-theme="light"] .section-title::before { box-shadow: 0 0 12px rgba(2,132,199,0.3); }

tbody tr:nth-child(even) { background: rgba(255,255,255,0.018); }
[data-theme="light"] tbody tr:nth-child(even) { background: rgba(15,23,42,0.025); }
[data-theme="light"] tbody tr:hover { background: rgba(2,132,199,0.06); }

.fear-card, .summary-card, .scanner-card, .add-form, .table-wrap {
  box-shadow: var(--shadow-sm);
}
.fear-card:hover { box-shadow: var(--shadow-lg); }

/* ═══════════════════════════════════════════════════════════════════════════════ */
/* MOBILE CARD VIEW for portfolio + indices tables                                */
/* ═══════════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .responsive-table .table-wrap {
    border: none; background: transparent; box-shadow: none;
    overflow: visible; max-height: none;
  }
  .responsive-table table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table tfoot,
  .responsive-table tr,
  .responsive-table td { display: block; width: 100%; }
  .responsive-table thead { display: none; }
  .responsive-table tr {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
  }
  .responsive-table tr:hover { background: var(--bg-card); }
  .responsive-table td {
    border: none !important;
    padding: 5px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    white-space: normal;
    text-align: left;
  }
  .responsive-table td::before {
    content: attr(data-label);
    font-family: var(--sans);
    color: var(--text-faint);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    flex-shrink: 0;
  }
  .responsive-table td.label {
    border-bottom: 1px solid var(--border) !important;
    padding-bottom: 8px;
    margin-bottom: 6px;
    font-size: 15px;
    font-weight: 700;
    justify-content: flex-start;
  }
  .responsive-table td.label::before { display: none; }
  .responsive-table tfoot tr { background: var(--bg-elevated); border-color: var(--border-light); }
  .responsive-table .cell-val { min-width: unset; }
  .responsive-table .notes-input { flex: 1; }
}

/* fade hint for horizontally-scrollable tables on desktop */
@media (min-width: 769px) {
  .table-wrap { scroll-behavior: smooth; }
}
