*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d;
  --surface: #141414;
  --surface2: #1a1a1a;
  --border: #252525;
  --text: #e8e8e8;
  --muted: #8e8e93;
  --muted2: #aaaaaa;
  --green: #00ff88;
  --red: #ff4466;
  --blue: #4488ff;
  --yellow: #ffcc00;
  --purple: #aa77ff;
  --mono: 'IBM Plex Mono', monospace;
  --sans: 'Geist', 'Instrument Sans', sans-serif;
}

html { scroll-behavior: smooth; }
body { font-family: var(--sans); background: var(--bg); color: var(--text); min-height: 100vh; }

/* FOCUS STATES */
button:focus-visible, input:focus-visible, a:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* TOPBAR */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; z-index: 100;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; }
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: blink 2s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }
.brand-name { font-size: 1.15rem; font-weight: 700; letter-spacing: 0.05em; font-family: var(--sans); }
.brand-tag { font-family: var(--mono); font-size: 0.65rem; background: var(--border); padding: 3px 7px; border-radius: 4px; color: var(--green); font-weight: 600; }
.topbar-meta { display: flex; align-items: center; gap: 24px; font-family: var(--mono); font-size: 0.72rem; color: var(--muted); }
.meta-item { display: flex; align-items: center; gap: 6px; }
.meta-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--muted); }
.meta-dot.active { background: var(--green); }
.meta-clock { font-weight: 500; color: var(--text); }

/* TABS NAV */
.tabs {
  display: flex; gap: 8px; padding: 16px 24px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.tab-btn {
  background: none; border: 1px solid transparent; color: var(--muted);
  padding: 10px 18px; border-radius: 8px; font-family: var(--sans);
  font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: all 0.2s;
  display: flex; align-items: center; gap: 8px;
}
.tab-btn:hover { color: var(--text); background: var(--surface); }
.tab-btn.active {
  background: var(--surface); border-color: var(--border); color: #fff;
  font-weight: 600;
}

/* APP BODY */
.app-body { padding: 24px; max-width: 1400px; margin: 0 auto; }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: paneFade 0.3s ease; }
@keyframes paneFade { from{opacity:0;transform:translateY(4px)} to{opacity:1;transform:translateY(0)} }

/* CRYPTO VIEW */
.ticker-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 0; margin-bottom: 24px;
  overflow: hidden; white-space: nowrap; position: relative;
}
.ticker-inner { display: inline-block; animation: ticker 25s linear infinite; }
@keyframes ticker {
  0% { transform: translate3d(0, 0, 0); }
  100% { transform: translate3d(-50%, 0, 0); }
}
.ticker-item { display: inline-flex; align-items: center; gap: 8px; padding: 0 24px; border-right: 1px solid var(--border); }
.ticker-sym { font-family: var(--mono); font-size: 0.75rem; font-weight: 600; color: #fff; }
.ticker-price { font-family: var(--mono); font-size: 0.75rem; color: var(--text); }
.pos { color: var(--green); }
.neg { color: var(--red); }

.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; transition: border-color 0.25s;
  border-left: 3px solid var(--accent);
}
.stat-card:hover { border-color: var(--accent); }
.stat-symbol { font-family: var(--mono); font-size: 0.65rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-price { font-family: var(--mono); font-size: 1.6rem; font-weight: 600; color: #fff; margin: 12px 0; }
.stat-row { display: flex; justify-content: space-between; align-items: center; font-family: var(--mono); font-size: 0.7rem; }
.stat-change { font-weight: 600; }
.stat-vol { color: var(--muted); }
.sparkline { margin-top: 14px; opacity: 0.85; }

.two-cols { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 24px; }
.three-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin-bottom: 24px; }
.chart-panel { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; margin-bottom: 24px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.panel-title { font-size: 0.95rem; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.panel-title-desc { font-size: 0.72rem; color: var(--muted); font-weight: 400; font-family: var(--mono); }
.period-tabs { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 6px; border: 1px solid var(--border); }
.period-btn {
  background: none; border: none; color: var(--muted);
  padding: 5px 12px; border-radius: 4px; font-family: var(--mono);
  font-size: 0.65rem; font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.period-btn.active { background: var(--surface); color: #fff; }

.chart-svg { width: 100%; height: 200px; display: block; overflow: visible; }

.table-container { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 8px; border: 1px solid var(--border); }
.market-table { width: 100%; border-collapse: collapse; text-align: left; }
.market-table th, .market-table td { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.market-table th { background: var(--surface2); font-family: var(--mono); font-size: 0.68rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 500; }
.market-table td { background: var(--surface); font-size: 0.85rem; }
.market-table tr:last-child td { border-bottom: none; }
.coin-info { display: flex; align-items: center; gap: 12px; }
.coin-icon { width: 28px; height: 28px; border-radius: 6px; display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-family: var(--mono); font-weight: 600; }
.coin-name { font-weight: 600; color: #fff; }
.coin-sym { font-family: var(--mono); font-size: 0.68rem; color: var(--muted); margin-top: 2px; }
.td-price { font-family: var(--mono); font-weight: 500; }

/* WEATHER VIEW */
.weather-search { display: flex; gap: 10px; margin-bottom: 24px; max-width: 500px; }
.weather-input {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 11px 16px; font-family: var(--sans);
  font-size: 0.9rem; color: #fff; outline: none;
  transition: border-color 0.2s;
}
.weather-input:focus { border-color: rgba(68,136,255,0.5); }
.weather-input::placeholder { color: var(--muted); }
.search-btn {
  background: var(--blue); color: #fff; border: none;
  padding: 11px 24px; border-radius: 8px; font-family: var(--sans);
  font-size: 0.875rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s; white-space: nowrap;
}
.search-btn:hover { background: #5599ff; transform: translateY(-1px); }
.search-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.weather-main {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px;
  display: none;
}
.weather-main.loaded { display: block; }
.weather-hero { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 20px; margin-bottom: 24px; }
.weather-city { font-size: 1.8rem; font-weight: 600; letter-spacing: -0.02em; }
.weather-country { font-size: 0.85rem; color: var(--muted2); margin-top: 4px; font-family: var(--mono); }
.weather-temp-block { text-align: right; }
.weather-temp { font-family: var(--mono); font-size: 4rem; font-weight: 600; line-height: 1; color: #fff; }
.weather-desc { font-size: 0.9rem; color: var(--muted2); margin-top: 4px; }
.weather-icon { font-size: 2rem; }

.weather-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 8px; }
.w-stat { background: var(--surface2); border-radius: 8px; padding: 14px; }
.w-stat-label { font-size: 0.68rem; font-family: var(--mono); color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 6px; }
.w-stat-val { font-family: var(--mono); font-size: 1rem; font-weight: 600; color: var(--text); }

.forecast-row { display: flex; gap: 8px; margin-top: 20px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: thin; }
.forecast-day { background: var(--surface2); border-radius: 8px; padding: 12px 8px; text-align: center; flex: 1 0 80px; }
.fc-day { font-family: var(--mono); font-size: 0.65rem; color: var(--muted); margin-bottom: 8px; letter-spacing: 0.06em; }
.fc-icon { font-size: 1.4rem; margin-bottom: 6px; }
.fc-high { font-family: var(--mono); font-size: 0.85rem; font-weight: 600; color: var(--text); }
.fc-low { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); margin-top: 2px; }

.weather-error { display: none; padding: 20px; text-align: center; color: var(--red); font-size: 0.9rem; background: rgba(255,68,102,0.05); border: 1px solid rgba(255,68,102,0.15); border-radius: 10px; }
.weather-error.show { display: block; }
.weather-loading { display: none; padding: 40px; text-align: center; color: var(--muted2); font-family: var(--mono); font-size: 0.8rem; }
.weather-loading.show { display: block; }
.loader { display: inline-block; width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.7s linear infinite; margin-right: 8px; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* MISC */
.section-label { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 14px; font-family: var(--mono); }
.mini-num { font-family: var(--mono); }
.badge-up { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 0.7rem; font-weight: 600; font-family: var(--mono); background: rgba(0,255,136,0.1); color: var(--green); }
.badge-dn { display: inline-block; padding: 2px 7px; border-radius: 4px; font-size: 0.7rem; font-weight: 600; font-family: var(--mono); background: rgba(255,68,102,0.1); color: var(--red); }

.fear-gauge { text-align: center; padding: 20px 10px; }
.gauge-ring { width: 100px; height: 100px; border-radius: 50%; border: 6px solid var(--border); margin: 0 auto 12px; display: flex; align-items: center; justify-content: center; position: relative; }
.gauge-val { font-family: var(--mono); font-size: 1.6rem; font-weight: 700; }
.gauge-label { font-size: 0.72rem; color: var(--muted2); }
.gauge-status { font-size: 0.75rem; font-weight: 600; margin-top: 4px; }

@media (max-width: 768px) {
  .two-cols { grid-template-columns: 1fr; }
  .topbar { padding: 12px 16px; }
  .tabs { padding: 12px 16px; }
  .app-body { padding: 16px; }
}
@media (max-width: 480px) {
  .app-body { padding: 12px; }
  .weather-hero { flex-direction: column; align-items: flex-start; }
  .weather-temp-block { text-align: left; margin-top: 12px; }
  .topbar-meta { display: none; }
}
