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

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #263349;
  --border: #334155;
  --text: #f1f5f9;
  --text2: #94a3b8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #eab308;
  --blue: #3b82f6;
  --purple: #a855f7;
  --accent: #38bdf8;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; }

#app { max-width: 480px; margin: 0 auto; padding-bottom: calc(80px + var(--safe-bottom)); }

/* ── Header ── */
.header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; position: sticky; top: 0; z-index: 10;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.header-title { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 20px; }
.header h1 { font-size: 18px; font-weight: 700; }
.header-actions { display: flex; gap: 8px; }
.btn-icon {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; width: 36px; height: 36px;
  font-size: 16px; cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.btn-icon:active { opacity: 0.7; }

/* ── Signal Card ── */
.signal-card {
  margin: 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border);
  padding: 16px; min-height: 100px;
}
.signal-loading { color: var(--text2); text-align: center; padding: 24px 0; }

.signal-inner { display: flex; flex-direction: column; gap: 8px; }
.signal-top { display: flex; justify-content: space-between; align-items: flex-start; }
.signal-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 20px; font-size: 13px; font-weight: 700;
}
.badge-buy { background: rgba(34,197,94,0.15); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.badge-sell { background: rgba(239,68,68,0.15); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.badge-hold { background: rgba(148,163,184,0.1); color: var(--text2); border: 1px solid var(--border); }
.badge-warn { background: rgba(234,179,8,0.15); color: var(--yellow); border: 1px solid rgba(234,179,8,0.3); }
.badge-kill { background: rgba(239,68,68,0.25); color: var(--red); border: 1px solid var(--red); }

.signal-time { font-size: 11px; color: var(--text2); }
.signal-detail { font-size: 13px; color: var(--text2); line-height: 1.5; }
.signal-weight { font-size: 22px; font-weight: 800; color: var(--text); }
.signal-weight span { font-size: 14px; font-weight: 400; color: var(--text2); margin-left: 4px; }

/* ── Metrics Grid ── */
.metrics-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr;
  gap: 8px; margin: 0 12px 12px;
}
.metric-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 10px;
}
.metric-label { font-size: 10px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.metric-value { font-size: 16px; font-weight: 700; }
.metric-sub { font-size: 10px; color: var(--text2); margin-top: 2px; }
.val-up { color: var(--green); }
.val-down { color: var(--red); }
.val-warn { color: var(--yellow); }
.val-neutral { color: var(--text); }

/* ── Tabs ── */
.tab-bar {
  display: flex; border-bottom: 1px solid var(--border);
  margin: 0 12px; gap: 4px;
}
.tab {
  background: none; border: none; color: var(--text2);
  padding: 10px 16px; font-size: 14px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.tab-content { display: none; margin: 12px; }
.tab-content.active { display: block; }

/* ── Chart ── */
.chart-controls {
  display: flex; gap: 12px; margin-bottom: 8px;
}
.toggle-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text2); cursor: pointer;
}
.toggle-label input { accent-color: var(--accent); }

.chart-container {
  border-radius: var(--radius); overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  height: 280px;
}
.chart-container.rsi { height: 120px; margin-top: 8px; }

/* ── History Table ── */
.history-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.history-table th {
  background: var(--surface2); color: var(--text2);
  padding: 8px 6px; text-align: left; font-weight: 600;
  font-size: 11px; text-transform: uppercase;
}
.history-table td {
  padding: 10px 6px; border-bottom: 1px solid var(--border);
  color: var(--text);
}
.history-table tr:last-child td { border-bottom: none; }
.signal-text { font-size: 11px; font-weight: 600; }

/* ── FAB ── */
.fab-wrap {
  position: fixed; bottom: calc(16px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%);
  z-index: 100;
}
.fab {
  display: flex; align-items: center; gap: 8px;
  background: var(--accent); color: #0f172a;
  border: none; border-radius: 28px;
  padding: 14px 24px; font-size: 15px; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 20px rgba(56,189,248,0.4);
  transition: transform 0.1s, box-shadow 0.1s;
}
.fab:active { transform: scale(0.96); box-shadow: 0 2px 10px rgba(56,189,248,0.3); }
.fab.loading { opacity: 0.7; pointer-events: none; }
.fab-icon { font-size: 18px; }

/* ── Toast ── */
.toast {
  position: fixed; bottom: calc(90px + var(--safe-bottom));
  left: 50%; transform: translateX(-50%);
  background: var(--surface2); color: var(--text);
  padding: 10px 20px; border-radius: 20px;
  font-size: 13px; box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
  white-space: nowrap; z-index: 200;
}
.toast.show { opacity: 1; }

/* ── Conditions ── */
.cond-group { margin-bottom: 12px; }
.cond-group-title {
  font-size: 11px; font-weight: 700; color: var(--text2);
  text-transform: uppercase; letter-spacing: 0.8px;
  padding: 0 4px 6px; border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.cond-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 8px; border-radius: 8px; margin-bottom: 4px;
}
.cond-item.hit   { background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.2); }
.cond-item.safe  { background: rgba(34,197,94,0.06); border: 1px solid rgba(34,197,94,0.15); }
.cond-item.unknown { background: rgba(234,179,8,0.07); border: 1px solid rgba(234,179,8,0.2); }
.cond-item.skip  { background: transparent; border: 1px solid var(--border); opacity: 0.45; }

.cond-icon { font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.cond-text { flex: 1; min-width: 0; }
.cond-name { font-size: 13px; font-weight: 600; color: var(--text); }
.cond-desc { font-size: 11px; color: var(--text2); margin-top: 2px; line-height: 1.4; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: flex-end; justify-content: center;
  z-index: 300; padding-bottom: var(--safe-bottom);
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border-radius: var(--radius) var(--radius) 0 0;
  width: 100%; max-width: 480px; max-height: 85vh; overflow-y: auto;
  border: 1px solid var(--border);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface);
}
.modal-header h2 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 12px 16px; border-top: 1px solid var(--border); }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; color: var(--text2); font-weight: 600; }
.form-group input {
  background: var(--surface2); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; padding: 10px 12px;
  font-size: 15px; width: 100%;
}
.form-group input:focus { outline: none; border-color: var(--accent); }
.form-hint { font-size: 11px; color: var(--text2); }

.btn-primary {
  width: 100%; background: var(--accent); color: #0f172a;
  border: none; border-radius: 10px; padding: 13px;
  font-size: 15px; font-weight: 700; cursor: pointer;
}
.btn-primary:active { opacity: 0.8; }

.position-bar {
  margin: 0 12px 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 14px;
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; color: var(--text2);
}
.position-bar .pos-weight { font-size: 15px; font-weight: 700; color: var(--text); }
.position-bar .pos-entry { color: var(--text2); }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
