/* JMWS Trading 212 — dashboard stylesheet. Inherits the JMWS look
   but with a trading-green primary. */

:root {
  --primary: #0A6E48;
  --primary-light: #D1FADF;
  --primary-dark: #064E33;
  --danger: #DC2626;
  --danger-light: #FEE2E2;
  --bg: #FAFAF7;
  --bg2: #ffffff;
  --bg3: #f3f3ee;
  --card: #ffffff;
  --card2: #fafafa;
  --text: #111;
  --text2: #555;
  --text3: #888;
  --border: #e5e7eb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 18px rgba(0,0,0,0.05);
  --pos: #16A34A;
  --neg: #DC2626;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; min-height: 100vh; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

.app-header {
  height: 56px; background: var(--card); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; position: sticky; top: 0; z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 50%; background: transparent; border: none;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text2); cursor: pointer; text-decoration: none;
}
.icon-btn i { font-size: 22px; }
.icon-btn.portal-btn { background: rgba(10,110,72,0.10); color: var(--primary); }

.t-badge { font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: 99px; letter-spacing: 0.5px; }
.t-badge-ok { background: var(--primary-light); color: var(--primary-dark); }
.t-badge-err { background: var(--danger-light); color: var(--danger); }
.t-badge-muted { background: var(--bg3); color: var(--text3); }

.t-tabs {
  display: flex; gap: 4px; padding: 8px 16px 0;
  border-bottom: 1px solid var(--border); background: var(--card);
  position: sticky; top: 56px; z-index: 9;
}
.t-tab {
  background: transparent; border: none; padding: 10px 14px;
  font: inherit; font-weight: 600; color: var(--text2); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.t-tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }

#page-content { max-width: 1100px; margin: 0 auto; padding: 24px 16px 80px; }

.t-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.t-card-pad-0 { padding: 0; overflow: hidden; }

.t-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
@media (max-width: 720px) { .t-grid { grid-template-columns: repeat(2, 1fr); } }
.t-stat { padding: 14px; }
.t-stat-label { font-size: 11px; color: var(--text2); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 700; }
.t-stat-value { font-size: 24px; font-weight: 800; line-height: 1.1; margin-top: 4px; }
.t-stat-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }

.t-section-title { margin: 24px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 800; color: var(--text2); }

.t-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.t-table th, .t-table td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.t-table th { background: var(--card2); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--text2); }
.t-table tbody tr:hover { background: var(--card2); }
.t-table tbody tr:last-child td { border-bottom: none; }
.t-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.t-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.t-small { font-size: 12px; }
.t-muted { color: var(--text3); }
.t-center { text-align: center; }
.t-err { color: var(--danger); }
.t-pos { color: var(--pos); font-weight: 600; }
.t-neg { color: var(--neg); font-weight: 600; }
.t-mini { font-size: 11px; color: var(--text3); }

.t-pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; display: inline-block; }
.t-pill-sell { background: var(--primary-light); color: var(--primary-dark); }
.t-pill-buy { background: rgba(59,130,246,0.14); color: #1d4ed8; }
.t-pill-hold { background: var(--bg3); color: var(--text2); }
.t-pill-exec { background: #fef3c7; color: #92400e; }
.t-level-info { background: var(--bg3); color: var(--text2); }
.t-level-warn { background: #fef3c7; color: #92400e; }
.t-level-error { background: var(--danger-light); color: var(--danger); }
.t-level-trade { background: var(--primary-light); color: var(--primary-dark); }
.t-level-config { background: rgba(59,130,246,0.14); color: #1d4ed8; }

/* Controls */
.t-kv { width: 100%; font-size: 12.5px; margin-top: 10px; }
.t-kv th { text-align: left; font-weight: 600; color: var(--text2); padding: 4px 12px 4px 0; }
.t-kv td { color: var(--text); padding: 4px 0; }
.t-toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.t-toggle input { display: none; }
.t-toggle-track { width: 44px; height: 24px; background: var(--bg3); border-radius: 99px; position: relative; transition: background 0.15s; }
.t-toggle-knob { position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,0.2); transition: transform 0.15s; }
.t-toggle input:checked + .t-toggle-track { background: var(--primary); }
.t-toggle input:checked + .t-toggle-track .t-toggle-knob { transform: translateX(20px); }
.t-toggle-label { font-weight: 700; font-size: 13px; }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid transparent; background: var(--bg3); color: var(--text); padding: 9px 14px; border-radius: 10px; font: inherit; font-weight: 600; cursor: pointer; }
.btn:hover { background: var(--border); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #9b1c1c; }

.t-form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; margin: 12px 0; }
@media (max-width: 600px) { .t-form-grid { grid-template-columns: 1fr; } }
.t-form-grid label { display: flex; flex-direction: column; font-size: 12px; font-weight: 700; color: var(--text2); gap: 4px; }
.t-form-grid input { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.t-strategy-list { margin: 12px 0 4px; padding-left: 20px; line-height: 1.7; }
.t-strategy-list li { color: var(--text); margin-bottom: 4px; }
.t-strategy-list strong { color: var(--primary-dark); }

/* ─── Renovated Account tab ──────────────────────────────────────── */
.t-account-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  margin-top: 4px;
}
@media (max-width: 900px) {
  .t-account-grid { grid-template-columns: 1fr; }
}

.t-account-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-content: start;
}
@media (max-width: 480px) {
  .t-account-stats { grid-template-columns: 1fr; }
}
.t-stat-wide { grid-column: 1 / -1; }
.t-stat-freshness-card { padding: 8px 14px; min-height: auto; text-align: center; }
.t-stat-freshness-card .t-stat-sub { margin: 0; font-size: 11.5px; }

.t-positions-rail {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
  position: sticky;
  top: 16px;
}
@media (max-width: 900px) {
  .t-positions-rail { max-height: none; position: static; }
}

.t-positions-header {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.t-positions-header h3 { margin: 0; font-size: 14px; font-weight: 700; color: var(--text); }
.t-pending-pill {
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.t-pending-pill i { font-size: 13px; }

.t-positions-list {
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.t-position-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--bg);
}
.t-position-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.t-position-name {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t-position-worth {
  font-weight: 700;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
}
.t-position-mid {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--text2);
  margin-top: 2px;
}
.t-position-pl {
  margin-top: 6px;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.t-position-pct { font-size: 11.5px; font-weight: 600; opacity: 0.85; }
.t-positions-empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text3);
}
.t-positions-empty i { font-size: 30px; opacity: 0.4; }
.t-positions-empty p { margin: 8px 0 0; font-size: 13px; }

/* ─── News tab ──────────────────────────────────────────────── */
.t-news-header { margin-bottom: 14px; }
.t-news-header .t-small { margin: 4px 0 0; line-height: 1.55; }
.t-news-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}
.t-news-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}
.t-news-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.t-news-name { font-weight: 700; font-size: 15px; color: var(--text); }
.t-news-ticker { font-family: ui-monospace, SFMono-Regular, monospace; font-size: 11.5px; color: var(--text3); margin-top: 1px; }
.t-news-sentiment { text-align: right; }
.t-news-score { font-weight: 800; font-size: 18px; line-height: 1; }
.t-news-label { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; margin-top: 3px; }
.t-news-headlines {
  margin: 10px 0 4px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.t-news-headlines li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  line-height: 1.4;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg);
}
.t-news-headlines li a {
  color: var(--text);
  text-decoration: none;
  flex: 1;
}
.t-news-headlines li a:hover { text-decoration: underline; }
.t-news-headline-meta { font-size: 10.5px; font-weight: 700; white-space: nowrap; padding-top: 1px; }
.t-news-foot { font-size: 10.5px; color: var(--text3); margin-top: 8px; }
