@import url('https://fonts.googleapis.com/css2?family=Barlow+Condensed:wght@500;600;700&family=Barlow:wght@400;600;700&display=swap');

:root {
  --bg: #0a0a0a;
  --panel: #0e0e0e;
  --border: #1e1e1e;
  --text: #ffffff;
  --muted: #8a8a8a;
  --red: #e10600;
  --red-dim: #4a0a08;
  --green: #17c964;
  --green-dim: #0d3a24;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Barlow', system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

.label, h1, .tab, .card-market, button, .history-market {
  font-family: 'Barlow Condensed', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

/* ---------- Topbar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: env(safe-area-inset-top) clamp(20px, 5vw, 48px) 0 clamp(20px, 5vw, 48px);
}

.brand {
  display: flex;
  align-items: center;
  gap: clamp(14px, 4vw, 30px);
  padding: clamp(20px, 5vw, 42px) 0 clamp(14px, 4vw, 30px) 0;
}

.brand-bar {
  width: clamp(10px, 2.4vw, 18px);
  height: clamp(36px, 9vw, 66px);
  background: var(--red);
  display: inline-block;
}

.brand h1 {
  margin: 0;
  font-size: clamp(30px, 8vw, 60px);
  font-weight: 700;
  letter-spacing: 0.15em;
}

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  gap: 12px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: clamp(14px, 3vw, 24px) clamp(16px, 5vw, 48px) calc(clamp(14px, 3vw, 24px) + env(safe-area-inset-bottom)) clamp(16px, 5vw, 48px);
}

.tab {
  flex: 1;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: clamp(14px, 3.5vw, 30px) clamp(10px, 2.5vw, 18px);
  font-size: clamp(20px, 5vw, 39px);
  font-weight: 600;
  border-radius: 2px;
}

.tab.active {
  color: var(--text);
  border-color: var(--red);
  background: linear-gradient(180deg, rgba(225,6,0,0.12), transparent);
}

/* ---------- Layout ---------- */

main {
  padding: clamp(18px, 5vw, 48px);
  padding-bottom: calc(clamp(180px, 40vw, 240px) + env(safe-area-inset-bottom));
  max-width: 1920px;
  margin: 0 auto;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Market cards ---------- */

.markets {
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 5vw, 42px);
}

.market-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: clamp(20px, 5vw, 42px) clamp(20px, 5vw, 48px);
}

.card-market {
  font-size: clamp(24px, 6vw, 45px);
  font-weight: 700;
  color: var(--muted);
  margin: 0 0 clamp(16px, 4vw, 30px) 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.price-badge {
  display: inline-flex;
  align-items: center;
  gap: clamp(8px, 2vw, 15px);
  padding: clamp(10px, 3vw, 18px) clamp(14px, 4vw, 27px);
  border-radius: 6px;
  border: 2px solid var(--border);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.price-badge-arrow {
  font-size: clamp(18px, 4.5vw, 33px);
  line-height: 1;
  min-width: clamp(18px, 4vw, 30px);
  text-align: center;
}

.price-badge-value {
  font-family: 'Barlow', sans-serif;
  font-size: clamp(24px, 6.5vw, 51px);
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.price-badge--up {
  border-color: var(--green);
  background: linear-gradient(180deg, rgba(23,201,100,0.1), transparent);
}

.price-badge--up .price-badge-arrow { color: var(--green); }

.price-badge--down {
  border-color: var(--red);
  background: linear-gradient(180deg, rgba(225,6,0,0.1), transparent);
}

.price-badge--down .price-badge-arrow { color: var(--red); }

.view-market-btn {
  width: clamp(56px, 14vw, 102px);
  height: clamp(56px, 14vw, 102px);
  border-radius: 50%;
  background: #fff;
  color: #000;
  border: none;
  font-size: clamp(24px, 6vw, 45px);
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: clamp(14px, 4vw, 30px);
  padding: clamp(14px, 4vw, 30px) 0;
  border-top: 1px solid var(--border);
}

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

.profile-row--triggered {
  border: 2px solid var(--green);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(23,201,100,0.1), transparent);
  padding: clamp(12px, 3vw, 24px) clamp(14px, 4vw, 27px);
  margin: clamp(8px, 2vw, 15px) 0;
}

.profile-row--triggered:first-of-type { border: 2px solid var(--green); }

.profile-name {
  font-size: clamp(16px, 4.5vw, 33px);
  color: var(--muted);
  letter-spacing: 0.08em;
}

.profile-price {
  font-size: clamp(26px, 8.5vw, 66px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.status-dot {
  width: clamp(16px, 4vw, 30px);
  height: clamp(16px, 4vw, 30px);
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}

.status-dot.triggered {
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
}

.ticks {
  grid-column: 1 / -1;
  display: flex;
  gap: clamp(4px, 1.2vw, 9px);
  margin-top: clamp(6px, 1.6vw, 12px);
}

.tick {
  flex: 1;
  height: clamp(6px, 1.6vw, 12px);
  background: var(--border);
  border-radius: 1px;
}

.tick.on { background: var(--green); }

.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: clamp(18px, 5vw, 39px);
  letter-spacing: 0.1em;
  padding: clamp(80px, 20vw, 180px) 0;
}

/* ---------- History ---------- */

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: clamp(14px, 4vw, 30px);
}

.history-list li {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: clamp(18px, 4.5vw, 36px) clamp(20px, 5vw, 42px);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.history-market {
  font-size: clamp(20px, 5.5vw, 42px);
  font-weight: 700;
}

.history-meta {
  color: var(--muted);
  font-size: clamp(16px, 4.5vw, 36px);
}

/* ---------- Settings ---------- */

.settings-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: clamp(20px, 5.5vw, 48px);
  margin-bottom: clamp(20px, 5vw, 42px);
}

.settings-block .label {
  font-size: clamp(18px, 4.5vw, 36px);
  color: var(--muted);
  margin: 0 0 clamp(14px, 4vw, 30px) 0;
}

input[type="password"],
input[type="text"] {
  width: 100%;
  background: #050505;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 18px;
  border-radius: 2px;
  font-family: inherit;
  font-size: 18px;
  margin-bottom: 15px;
}

/* Chrome pinta de azul claro los campos con contraseña guardada, ignorando el fondo
   oscuro de arriba — esto lo fuerza de vuelta al tema oscuro. */
input[type="password"]:-webkit-autofill,
input[type="text"]:-webkit-autofill,
input[type="password"]:-webkit-autofill:focus,
input[type="text"]:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0px 1000px #050505 inset;
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
}

.file-picker-input {
  display: none;
}

.file-picker {
  display: flex;
  align-items: center;
  gap: clamp(14px, 4vw, 30px);
  width: 100%;
  background: #050505;
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: clamp(12px, 3vw, 24px) clamp(14px, 4vw, 30px);
  margin-bottom: clamp(14px, 4vw, 30px);
  cursor: pointer;
}

.file-picker-btn {
  flex-shrink: 0;
  background: var(--red);
  color: #fff;
  font-family: 'Barlow Condensed', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  font-size: clamp(16px, 4.5vw, 33px);
  padding: clamp(10px, 3vw, 18px) clamp(14px, 4vw, 30px);
  border-radius: 2px;
}

.file-picker-name {
  color: var(--muted);
  font-size: clamp(15px, 4.5vw, 33px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 54px;
}

.password-toggle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 54px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.password-toggle:active {
  color: var(--text);
}

.inline-form-row {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  margin-bottom: 15px;
}

.inline-form-row input,
.inline-form-row .password-field {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
}

button {
  width: 100%;
  background: var(--red);
  color: #fff;
  border: none;
  padding: clamp(16px, 5vw, 39px);
  font-size: clamp(18px, 5.5vw, 42px);
  font-weight: 700;
  border-radius: 2px;
}

button.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}

button.green {
  background: var(--green);
}

.hint {
  color: var(--muted);
  font-size: clamp(15px, 4.5vw, 36px);
  margin: clamp(12px, 3vw, 24px) 0 0 0;
}

.hint--ok { color: var(--green); }
.hint--warn { color: var(--red); }

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: clamp(10px, 3vw, 24px);
}

.button-row button {
  width: 100%;
}

.whatsapp-qr {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: clamp(14px, 4vw, 30px) auto clamp(20px, 5.5vw, 45px) auto;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.whatsapp-qr[hidden] {
  display: none;
}

/* ---------- Login ---------- */

.login-body {
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  max-width: 450px;
  padding: clamp(28px, 8vw, 42px) clamp(22px, 6vw, 36px);
  text-align: center;
  transform: translateY(-10px);
}

.login-body .brand {
  justify-content: center;
  gap: clamp(10px, 3vw, 15px);
  padding: clamp(16px, 4vw, 21px) 0 clamp(10px, 3vw, 15px) 0;
}

.login-body .brand-bar {
  width: clamp(7px, 2vw, 9px);
  height: clamp(28px, 7.5vw, 34px);
}

.login-body .brand h1 {
  font-size: clamp(26px, 7.5vw, 34px);
}

.login-sub {
  color: var(--muted);
  font-size: clamp(14px, 3.8vw, 18px);
  letter-spacing: 0.15em;
  margin: 0 0 clamp(24px, 6vw, 36px) 0;
}

.login-card button {
  padding: clamp(16px, 4.5vw, 20px);
  font-size: clamp(17px, 4.5vw, 21px);
}

.login-error {
  color: var(--red);
  font-size: clamp(14px, 3.8vw, 18px);
  min-height: 24px;
}

/* ---------- Screenshot viewer ---------- */

.viewer {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.viewer[hidden] {
  display: none;
}

.viewer img {
  max-width: 100%;
  max-height: 100%;
}

.viewer-status {
  color: var(--muted);
  font-size: clamp(18px, 5vw, 39px);
  letter-spacing: 0.1em;
}

.viewer-close {
  position: absolute;
  top: env(safe-area-inset-top, 16px);
  right: clamp(20px, 5vw, 48px);
  width: clamp(64px, 16vw, 120px);
  height: clamp(64px, 16vw, 120px);
  border-radius: 50%;
  background: #fff;
  color: #000;
}
