/* Trading Agent — mobile-first responsive styles */

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #334155;
  --border: #334155;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --danger: #ef4444;
  --success: #10b981;
  --info: #38bdf8;
  --radius: 10px;
  --radius-sm: 6px;
  --gap: 16px;
  --gap-lg: 24px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-muted: #64748b;
    --shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0; padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.5;
  color: var(--text); background: var(--bg);
  min-height: 100vh; min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
body.centered {
  display: flex; align-items: center; justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.topbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.topbar__brand { font-weight: 600; font-size: 1.1rem; }
.topbar__nav { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }

.container {
  max-width: 900px; margin: 0 auto;
  padding: var(--gap);
  padding-bottom: calc(var(--gap) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--gap);
}

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.card--narrow { width: 100%; max-width: 380px; margin: 20px; }
.card h1, .card h2 { margin: 0 0 12px 0; line-height: 1.2; }
.card h1 { font-size: 1.5rem; }
.card h2 { font-size: 1.2rem; }
.card p { margin: 8px 0; }

form { display: flex; flex-direction: column; gap: 14px; }
label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 0.9rem; color: var(--text-muted);
}
input[type="text"], input[type="password"] {
  width: 100%; padding: 12px 14px; font-size: 16px;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none; transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none; appearance: none;
}
input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 20px; font-size: 1rem; font-weight: 500;
  color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; text-decoration: none; min-height: 44px;
  transition: background 0.15s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--border); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn--ghost { background: transparent; border-color: var(--border); padding: 8px 14px; min-height: 36px; font-size: 0.9rem; }

.alert { padding: 10px 14px; border-radius: var(--radius-sm); font-size: 0.9rem; margin-bottom: 4px; }
.alert--error { background: rgba(239, 68, 68, 0.15); border: 1px solid rgba(239, 68, 68, 0.4); color: var(--danger); }

.badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 0.85rem; font-weight: 500; }
.badge--info { background: rgba(56, 189, 248, 0.15); color: var(--info);    border: 1px solid rgba(56, 189, 248, 0.3); }
.badge--buy  { background: rgba(16, 185, 129, 0.18); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.4); }
.badge--sell { background: rgba(239, 68, 68, 0.15);  color: var(--danger);  border: 1px solid rgba(239, 68, 68, 0.4); }
.badge--hold { background: rgba(148, 163, 184, 0.15); color: var(--text-muted); border: 1px solid var(--border); }

.ok  { color: var(--success); font-weight: 500; }
.err { color: var(--danger);  font-weight: 500; }
.pl-plus  { color: var(--success); }
.pl-minus { color: var(--danger); }

.account-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 16px; flex-wrap: wrap;
}
.account-value {
  font-size: 2rem; font-weight: 600;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.account-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; margin-top: 16px; padding-top: 16px;
  border-top: 1px solid var(--border);
}
.account-sub {
  font-size: 1.1rem; font-weight: 500;
  font-variant-numeric: tabular-nums; margin-top: 2px;
}

.table-wrap { overflow-x: auto; margin: 0 -4px; }
table.signals { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.signals th, table.signals td {
  padding: 8px 10px; text-align: left;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.signals th {
  color: var(--text-muted); font-weight: 500; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.03em;
}
table.signals td.num, table.signals th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.signals tbody tr:last-child td { border-bottom: none; }
table.signals td.reasoning {
  white-space: normal;
  max-width: 400px;
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Signal-Accordion (pro Symbol) */
.sig-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.sig-row + .sig-row { border-top: 1px solid var(--border); }

.sig-row summary {
  display: grid;
  grid-template-columns: 3.5rem auto 1fr 1fr auto 1rem;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.1s;
}
.sig-row summary::-webkit-details-marker { display: none; }
.sig-row summary:hover { background: var(--surface-2); }
.sig-row[open] summary { background: var(--surface-2); }

.sig-sym {
  font-weight: 600;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}
.sig-score, .sig-price {
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
  text-align: right;
}
.sig-time {
  font-size: 0.8rem;
  white-space: nowrap;
}
.sig-chevron {
  color: var(--text-muted);
  transition: transform 0.15s;
  display: inline-block;
  font-size: 0.9rem;
}
.sig-row[open] .sig-chevron { transform: rotate(90deg); }

.sig-history {
  padding: 4px 14px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.muted { color: var(--text-muted); font-size: 0.9rem; }
code {
  background: var(--surface-2); padding: 2px 6px; border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.9em; word-break: break-word;
}
.list { padding-left: 20px; margin: 8px 0; }
.list li { margin: 6px 0; }

@media (max-width: 480px) {
  .topbar { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); }
  .topbar__brand { font-size: 1rem; }
  .topbar__nav { gap: 8px; font-size: 0.85rem; }
  .container { padding: 12px; gap: 12px; }
  .card { padding: 16px; }
  .card h1 { font-size: 1.3rem; }
  .card h2 { font-size: 1.1rem; }
  .card--narrow { margin: 12px; }
  .account-value { font-size: 1.6rem; }

  .sig-row summary {
    grid-template-columns: 3rem auto 1fr auto 1rem;
    gap: 8px;
    padding: 10px 12px;
  }
  .sig-price { display: none; }
  .sig-time { font-size: 0.75rem; }
  .sig-history { padding: 4px 12px 10px; }
}
