/* ============================================================
   cTrader Monitor — Design System
   Font: IBM Plex Sans (body) + IBM Plex Mono (numeri)
   Palette: slate scuro con accenti blu/teal
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@300;400;500&display=swap');

/* ---- Reset & Base ----------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-app      : #0f1117;
  --bg-sidebar  : #13161f;
  --bg-card     : #1a1e2b;
  --bg-card-alt : #1e2333;
  --bg-input    : #151821;
  --bg-hover    : #22273a;

  --border      : #2a2f45;
  --border-light: #333a55;

  --text-primary  : #e8eaf2;
  --text-secondary: #8890aa;
  --text-muted    : #555e7a;

  --blue         : #4a9eff;
  --blue-dim     : #1a3a6a;
  --blue-glow    : rgba(74,158,255,.12);
  --teal         : #2dd4bf;
  --teal-dim     : #0d3530;
  --green        : #4ade80;
  --green-dim    : #0f2d1a;
  --red          : #f87171;
  --red-dim      : #2d0f0f;
  --amber        : #fbbf24;
  --amber-dim    : #2d1f00;
  --purple       : #a78bfa;
  --purple-dim   : #1e1240;

  --sidebar-w   : 210px;
  --topbar-h    : 52px;
  --radius-sm   : 6px;
  --radius-md   : 10px;
  --radius-lg   : 14px;

  --font-body   : 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono   : 'IBM Plex Mono', monospace;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  font-size: 14px;
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ---- Layout ----------------------------------------------- */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---- Sidebar ---------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  letter-spacing: .01em;
}
.sidebar-logo .logo-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: var(--font-mono);
}

.sidebar-section {
  padding: 16px 16px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: all .15s;
}
.nav-item:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}
.nav-item.active {
  color: var(--blue);
  background: var(--blue-glow);
  border-left-color: var(--blue);
  font-weight: 500;
}
.nav-icon {
  width: 16px;
  height: 16px;
  opacity: .7;
  flex-shrink: 0;
}
.nav-item.active .nav-icon { opacity: 1; }

/* Account switcher */
.account-switcher {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.account-select-wrap {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 10px;
}
.account-select-wrap label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}
.account-select-wrap select {
  width: 100%;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

/* ---- Main content ----------------------------------------- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: var(--topbar-h);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.topbar-title {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
}
.topbar-title span {
  color: var(--text-muted);
  font-weight: 300;
  margin-left: 6px;
  font-size: 13px;
}
.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.sync-time {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* ---- Buttons ---------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-primary);
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-hover); border-color: var(--border-light); }
.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #000;
  font-weight: 500;
}
.btn-primary:hover { opacity: .9; }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { border-color: var(--red-dim); color: var(--red); }
.btn-danger:hover { background: var(--red-dim); }

/* ---- Cycle banner ----------------------------------------- */
.cycle-banner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.cycle-banner-left .cycle-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.cycle-banner-left .cycle-detail {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  font-family: var(--font-mono);
}
.cycle-banner-right {
  text-align: right;
}
.cycle-amount {
  font-size: 24px;
  font-weight: 500;
  font-family: var(--font-mono);
  color: var(--blue);
}
.cycle-progress-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
}
.progress-bar-wrap {
  margin-top: 8px;
  background: var(--bg-app);
  border-radius: 4px;
  height: 4px;
  width: 200px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--blue);
  transition: width .4s ease;
}

/* ---- Payout conditions pills ------------------------------ */
.conditions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}
.cond-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 400;
  border: 1px solid;
}
.cond-ok   { background: var(--green-dim);  color: var(--green);  border-color: #1a4a2a; }
.cond-fail { background: var(--red-dim);    color: var(--red);    border-color: #4a1a1a; }
.cond-warn { background: var(--amber-dim);  color: var(--amber);  border-color: #4a3500; }
.cond-info { background: var(--purple-dim); color: var(--purple); border-color: #2a1a5a; }

/* ---- Metric cards ----------------------------------------- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
.metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.metric-value {
  font-size: 22px;
  font-weight: 500;
  font-family: var(--font-mono);
  color: var(--text-primary);
}
.metric-value.pos { color: var(--green); }
.metric-value.neg { color: var(--red); }
.metric-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 3px;
  font-family: var(--font-mono);
}

/* ---- Chart cards ------------------------------------------ */
.charts-row {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
}
.charts-row-2-1 { grid-template-columns: 2fr 1fr; }
.charts-row-3   { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.charts-row-2   { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.chart-card-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.chart-wrap { position: relative; }

/* ---- Outcome badges --------------------------------------- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
}
.badge-tp     { background: var(--green-dim);  color: var(--green); }
.badge-tp12   { background: var(--purple-dim); color: var(--purple); }
.badge-tp1be  { background: var(--blue-dim);   color: var(--blue); }
.badge-be     { background: #1a1a35;           color: #7788cc; }
.badge-sl     { background: var(--red-dim);    color: var(--red); }

/* ---- Tables ----------------------------------------------- */
.table-wrap {
  overflow-x: auto;
}
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  font-weight: 400;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); color: var(--text-primary); }
.data-table td.mono { font-family: var(--font-mono); }
.data-table td.pos  { color: var(--green); font-family: var(--font-mono); }
.data-table td.neg  { color: var(--red);   font-family: var(--font-mono); }
.data-table td.primary { color: var(--text-primary); font-weight: 500; }

/* ---- Section card ----------------------------------------- */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

/* ---- Forms ------------------------------------------------ */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 400;
}
.form-label .required { color: var(--red); margin-left: 2px; }
.form-input, .form-select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
.form-input:focus, .form-select:focus { border-color: var(--blue); }
.form-input.mono { font-family: var(--font-mono); font-size: 12px; }
.form-hint { font-size: 11px; color: var(--text-muted); }

/* ---- Flash messages --------------------------------------- */
.flash-list { list-style: none; margin-bottom: 12px; }
.flash-msg {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 6px;
  border: 1px solid;
}
.flash-success { background: var(--green-dim);  color: var(--green);  border-color: #1a4a2a; }
.flash-warning { background: var(--amber-dim);  color: var(--amber);  border-color: #4a3500; }
.flash-error   { background: var(--red-dim);    color: var(--red);    border-color: #4a1a1a; }

/* ---- Cycle history cards ---------------------------------- */
.cycle-history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.cycle-hist-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.cycle-hist-card.active-cycle {
  border-color: var(--blue-dim);
  box-shadow: 0 0 0 1px var(--blue-dim);
}
.cycle-num {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 4px;
}
.cycle-profit {
  font-size: 26px;
  font-weight: 500;
  font-family: var(--font-mono);
}
.cycle-stat-row {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  gap: 8px;
}
.cycle-stat { text-align: center; }
.cycle-stat .cs-label { font-size: 10px; color: var(--text-muted); text-transform: uppercase; }
.cycle-stat .cs-val   { font-size: 13px; font-family: var(--font-mono); color: var(--text-primary); }

/* ---- Status dot ------------------------------------------- */
.status-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  margin-right: 5px;
  flex-shrink: 0;
}
.dot-active { background: var(--green); box-shadow: 0 0 5px var(--green); }
.dot-paid   { background: var(--blue); }
.dot-closed { background: var(--text-muted); }

/* ---- Spinner ---------------------------------------------- */
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Tabs ------------------------------------------------- */
.tabs {
  display: flex;
  gap: 2px;
  background: var(--bg-app);
  border-radius: var(--radius-sm);
  padding: 3px;
  margin-bottom: 16px;
  width: fit-content;
}
.tab-btn {
  padding: 5px 14px;
  border-radius: 5px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  transition: all .15s;
  text-decoration: none;
  display: inline-block;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active {
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 500;
}

/* ---- Empty state ------------------------------------------ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state p { margin-top: 8px; font-size: 13px; }

/* ---- Scrollbar -------------------------------------------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ---- Responsive ------------------------------------------- */
@media (max-width: 900px) {
  .metrics-grid       { grid-template-columns: repeat(2, 1fr); }
  .charts-row-2-1,
  .charts-row-3       { grid-template-columns: 1fr; }
  .form-grid          { grid-template-columns: 1fr; }
}
