/* ============================================
   AbayEdgeCapital - Standalone dashboard CSS
   No Tailwind required - everything styled here
   ============================================ */

:root {
  --primary: #000000;
  --primary-muted: #0f172a;
  --accent: #0a5368;
  --accent-light: #1ab2e7;
  --accent-dark: #2f6a7b;
  --white: #ffffff;
  --green: #059669;
  --red: #dc2626;
  --sidebar-bg: #0a5368;
  --radius: 10px;
  --radius-lg: 12px;
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-card: 0 4px 20px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.04);
  --shadow-elevated: 0 25px 50px -12px rgba(0,0,0,0.15);
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: #e2e8f0;
  color: #1e293b;
  margin: 0;
  min-height: 100vh;
}

/* ---- Layout (app shell) ---- */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
  background: linear-gradient(160deg, #f1f5f9 0%, #e2e8f0 50%, #cbd5e1 100%);
}

.app-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, #0d3d4d 100%);
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.12);
}

.sidebar-brand {
  padding: 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.sidebar-brand a {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
  letter-spacing: -0.02em;
}

.app-sidebar nav {
  padding: 0.75rem;
  flex: 1;
  overflow-y: auto;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  margin-bottom: 2px;
  font-size: 0.95rem;
  color: rgba(255,255,255,0.88);
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.15s, color 0.15s;
}
.sidebar-link:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.sidebar-link.active {
  background: var(--accent-light);
  color: #fff;
  font-weight: 600;
}
.sidebar-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.9;
}

.app-shell > div:last-child {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-header {
  height: 56px;
  flex-shrink: 0;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.25rem;
  gap: 1rem;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  padding: 0 0.5rem;
}
.header-nav-link {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748b;
  text-decoration: none;
  border-radius: 8px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.header-nav-link:hover {
  color: var(--accent);
  background: rgba(10, 82, 104, 0.08);
}
.header-nav-link.active {
  color: var(--accent);
  font-weight: 600;
  background: rgba(10, 82, 104, 0.12);
}

.app-header h1 {
  font-size: 1rem;
  font-weight: 600;
  color: #1e293b;
  margin: 0;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-header .user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: #64748b;
}
.app-header .role-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
}
.app-header .role-badge.admin {
  background: var(--accent);
  color: #fff;
}
.app-header .role-badge.user {
  background: #e2e8f0;
  color: var(--accent-dark);
}
.app-header .role-badge.manager {
  background: #dbeafe;
  color: #1e40af;
}
.app-header .role-badge.trader {
  background: #e2e8f0;
  color: #475569;
}

.sidebar-add-trade {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.15);
  margin-top: auto;
}
.btn-add-trade-sidebar {
  display: block;
  text-align: center;
  padding: 0.6rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent-light);
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.2s;
}
.btn-add-trade-sidebar:hover {
  background: rgba(255,255,255,0.25);
  color: #fff;
}
.header-actions { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.btn-add-trade-header {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
}
.btn-add-trade-header:hover { background: rgba(10, 82, 104, 0.1); color: var(--accent-dark); }
.btn-theme-toggle {
  width: 2rem; height: 2rem; padding: 0;
  border: 1px solid #e2e8f0; border-radius: 8px; background: #fff;
  font-size: 1.1rem; cursor: pointer;
}

.app-header #btn-logout {
  background: none;
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
  padding: 0.25rem 0;
}
.app-header #btn-logout:hover { color: var(--accent-dark); text-decoration: underline; }

/* Role badge (header + tables) */
.role-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.5rem;
  border-radius: 9999px;
  font-weight: 600;
  display: inline-block;
}
.role-badge.admin {
  background: var(--accent);
  color: #fff;
}
.role-badge.user {
  background: #e2e8f0;
  color: var(--accent-dark);
}
.role-badge.manager {
  background: #dbeafe;
  color: #1e40af;
}
.role-badge.trader {
  background: #94a3b8;
  color: #fff;
}

.app-shell main {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1.25rem;
  max-width: 1400px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}
@media (min-width: 1024px) {
  .app-shell main { padding: 1.5rem 2rem; }
}

/* ---- Page content (grid & spacing) ---- */
.page-content { }
.page-header {
  margin-bottom: 1.5rem;
}
.page-header .page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 0.35rem 0;
}
.page-content .page-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 0.25rem 0;
}
.page-header .page-subtitle,
.page-content .page-subtitle {
  font-size: 0.9rem;
  color: #64748b;
  margin: 0;
  line-height: 1.4;
}
.page-content .page-subtitle { margin: 0 0 1.25rem 0; }

.actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.actions-row .page-title { margin: 0; }

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
}
.filter-row label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #64748b;
  margin-bottom: 0.25rem;
}
.filter-row input,
.filter-row select {
  padding: 0.4rem 0.6rem;
  font-size: 0.875rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  min-width: 100px;
}
.filter-row input:focus,
.filter-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(10, 82, 104, 0.15);
}
.app-shell[data-theme="dark"] .filter-row input,
.app-shell[data-theme="dark"] .filter-row select { background: #1e293b; border-color: #475569; color: #f1f5f9; }

.stat-block {
  background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
  border: 1px solid rgba(10, 83, 104, 0.12);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  box-shadow: 0 2px 12px rgba(10, 83, 104, 0.06);
}
.app-shell[data-theme="dark"] .stat-block { background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%); border-color: rgba(148, 163, 184, 0.2); border-left-color: var(--accent); }

.loading-msg {
  text-align: center;
  padding: 2rem;
  color: #64748b;
  font-size: 0.95rem;
}
.page-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 1.5rem;
  color: #991b1b;
  max-width: 32rem;
}
.page-error .hint { font-size: 0.875rem; color: #b91c1c; margin-top: 0.75rem; opacity: 0.9; }
.page-error .btn-retry { margin-top: 1rem; }
.app-shell[data-theme="dark"] .page-error { background: #450a0a; border-color: #7f1d1d; color: #fecaca; }

/* Spacing between sections – consistent across all pages (calc-cards, Key Metrics, charts, etc.) */
.space-y-6 > * + * { margin-top: 2rem; }
.space-y-4 > * + * { margin-top: 1.25rem; }
.space-y-8 > * + * { margin-top: 2.5rem; }

/* ---- Cards (shadows, rounded corners, spacing per spec) ---- */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: box-shadow 0.2s ease;
}
.card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,0.1), 0 3px 10px rgba(0,0,0,0.05);
}
.card.p-4 { padding: 1rem 1.25rem; }
.card.p-5 { padding: 1.25rem 1.5rem; }

/* Modal (e.g. user edit) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}
.modal-content {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
  width: 100%;
  max-height: 90vh;
  overflow: auto;
}
.app-shell[data-theme="dark"] .modal-content { background: #1e293b; border: 1px solid #334155; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #e2e8f0;
}
.app-shell[data-theme="dark"] .modal-header { border-color: #334155; }
.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
  padding: 0.25rem;
}
.modal-close:hover { color: #0f172a; }
.app-shell[data-theme="dark"] .modal-close:hover { color: #f1f5f9; }
.modal-body { padding: 1.25rem; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid #e2e8f0;
}
.app-shell[data-theme="dark"] .modal-footer { border-color: #334155; }

.card.card-elevated {
  box-shadow: var(--shadow-elevated);
  border-radius: 16px;
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--primary);
  margin: 0 0 1rem 0;
}

.stat-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--primary);
}

/* ---- Metrics grid (responsive: grid-cols-1 md:grid-cols-2 lg:grid-cols-3 per spec) ---- */
.metrics-grid {
  display: grid;
  row-gap: 1.25rem;
  column-gap: 1.25rem;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) { .metrics-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .metrics-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1280px) { .metrics-grid { grid-template-columns: repeat(6, 1fr); } }

.metrics-grid-4 {
  display: grid;
  row-gap: 1.25rem;
  column-gap: 1.25rem;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) { .metrics-grid-4 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1024px) { .metrics-grid-4 { grid-template-columns: repeat(4, 1fr); } }

.charts-grid {
  display: grid;
  row-gap: 1.75rem;
  column-gap: 1.75rem;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) { .charts-grid { grid-template-columns: 1fr 1fr; } }

/* Charts: 2 rows x 3 columns grid */
.charts-grid-2x3 {
  display: grid;
  row-gap: 1.5rem;
  column-gap: 1.75rem;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) {
  .charts-grid-2x3 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1100px) {
  .charts-grid-2x3 { grid-template-columns: repeat(3, 1fr); }
}

/* Charts: 6 columns in one row */
.charts-grid-6 {
  display: grid;
  row-gap: 1.25rem;
  column-gap: 1rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  .charts-grid-6 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .charts-grid-6 { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 1280px) {
  .charts-grid-6 { grid-template-columns: repeat(6, 1fr); }
}
.charts-grid-6 .chart-card-elevated {
  padding: 0.75rem 1rem;
  min-height: 0;
}
.charts-grid-6 .chart-card-title { font-size: 0.875rem; }
.charts-grid-6 .chart-card-subtitle { font-size: 0.7rem; margin-bottom: 0.5rem; }
.charts-grid-6 .chart-fixed { min-height: 140px; max-height: 180px; }
.charts-grid-6 .chart-card-doughnut .winloss-chart-container,
.charts-grid-6 .chart-card-pie .winloss-chart-container {
  width: 120px;
  height: 120px;
  margin: 0 auto;
}
.charts-grid-6 .winloss-center { font-size: 0.8125rem; }
.charts-grid-6 .winloss-center .winloss-rate { font-size: 1.25rem; }
.charts-grid-6 .winloss-legend { flex-direction: column; gap: 0.25rem; }
.charts-grid-6 .winloss-legend-item { font-size: 0.75rem; }

.chart-card-elevated {
  background: var(--white);
  border-radius: 14px;
  padding: 1rem 1.25rem;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.15);
  border: 1px solid rgba(10, 83, 104, 0.08);
  overflow: hidden;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}
.chart-card-elevated:hover {
  box-shadow: 0 20px 40px -12px rgba(10, 83, 104, 0.2);
}
.chart-card-elevated::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-light) 100%);
  margin: -1rem -1.25rem 0.75rem -1.25rem;
}
.chart-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 0.2rem 0;
  letter-spacing: -0.02em;
}
.chart-card-subtitle {
  font-size: 0.75rem;
  color: #64748b;
  margin: 0 0 0.75rem 0;
  letter-spacing: 0.02em;
}
.app-shell[data-theme="dark"] .chart-card-subtitle { color: #94a3b8; }
.chart-fixed {
  min-height: 180px;
  max-height: 220px;
  position: relative;
}
.chart-fixed canvas { width: 100% !important; height: 100% !important; }
.chart-card-doughnut .winloss-wrap {
  padding: 0.5rem 0 0 0;
}
.chart-card-doughnut .winloss-chart-container {
  width: 160px;
  height: 160px;
  margin: 0 auto;
}
@media (min-width: 768px) {
  .chart-card-doughnut .winloss-chart-container {
    width: 180px;
    height: 180px;
  }
}

/* Charts: two columns - Performance (left) | Wins vs Losses (right) - legacy */
.charts-two-col {
  display: grid;
  row-gap: 1.75rem;
  column-gap: 1.75rem;
  grid-template-columns: 1fr;
}
@media (min-width: 900px) {
  .charts-two-col { grid-template-columns: 1fr 1fr; }
}
.charts-two-col .chart-card { min-width: 0; }
.charts-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}
.chart-block { flex: 1; min-height: 0; }
.chart-block-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  margin: 0 0 0.75rem 0;
}
.app-shell[data-theme="dark"] .chart-block-title { color: #94a3b8; }
.chart-container-sm { min-height: 180px; }
.chart-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 0.9rem;
  margin: 0;
}
.chart-card-winloss { display: flex; flex-direction: column; }
.winloss-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: 0.5rem 0;
}
.winloss-chart-container {
  position: relative;
  width: 220px;
  height: 220px;
  flex-shrink: 0;
}
.winloss-chart-container canvas { width: 100% !important; height: 100% !important; }
.winloss-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.winloss-rate {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.winloss-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-top: 0.15rem;
}
.app-shell[data-theme="dark"] .winloss-label { color: #94a3b8; }
.winloss-legend {
  display: flex;
  gap: 1.5rem;
  font-size: 0.9rem;
  color: #334155;
}
.app-shell[data-theme="dark"] .winloss-legend { color: #cbd5e1; }
.winloss-legend-item { display: flex; align-items: center; gap: 0.5rem; }
.winloss-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.winloss-dot-wins { background: linear-gradient(135deg, #059669 0%, #047857 100%); }
.winloss-dot-losses { background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%); }

/* Dashboard calculator cards - premium look */
.calc-cards {
  display: grid;
  row-gap: 1.75rem;
  column-gap: 1.75rem;
  grid-template-columns: 1fr;
}
@media (min-width: 768px) { .calc-cards { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .calc-cards { grid-template-columns: repeat(4, 1fr); } }

/* Calculators page: 6 cards in 2 rows of 3 */
.calc-cards-2rows {
  grid-template-columns: 1fr;
}
@media (min-width: 768px) {
  .calc-cards-2rows { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .calc-cards-2rows { grid-template-columns: repeat(3, 1fr); }
}
.calc-card {
  background: #fff;
  border-radius: 16px;
  padding: 0;
  box-shadow: 0 8px 32px rgba(10, 83, 104, 0.12), 0 2px 12px rgba(0,0,0,0.06);
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(10, 83, 104, 0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.calc-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 40px rgba(10, 83, 104, 0.15), 0 4px 16px rgba(0,0,0,0.08);
}
.calc-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent-light) 100%);
}
.calc-card-inner {
  padding: 1.5rem 1.75rem;
}
.calc-card-header {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.calc-card-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1;
}
.calc-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.calc-card-desc {
  font-size: 0.8125rem;
  color: #64748b;
  margin: 0.25rem 0 0 0;
  line-height: 1.45;
}
.app-shell[data-theme="dark"] .calc-card-desc { color: #94a3b8; }
.calc-card-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  align-items: flex-end;
  margin-bottom: 1.25rem;
}
.calc-card-field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.calc-card-field label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
}
.app-shell[data-theme="dark"] .calc-card-field label { color: #94a3b8; }
.calc-card-field .input-field {
  min-width: 110px;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
}
.calc-card-result-wrap {
  background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  border: 1px solid rgba(10, 83, 104, 0.1);
}
.app-shell[data-theme="dark"] .calc-card-result-wrap {
  background: linear-gradient(135deg, rgba(10, 83, 104, 0.25) 0%, rgba(26, 178, 231, 0.12) 100%);
  border-color: rgba(26, 178, 231, 0.2);
}
.calc-card-result {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.calc-card-result-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.app-shell[data-theme="dark"] .calc-card-result-label { color: #94a3b8; }

/* Dark theme for calc cards */
.app-shell[data-theme="dark"] .calc-card {
  background: #1e293b;
  border-color: rgba(148, 163, 184, 0.15);
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.app-shell[data-theme="dark"] .calc-card:hover {
  box-shadow: 0 12px 40px rgba(0,0,0,0.4);
}
.app-shell[data-theme="dark"] .calc-card-title { color: #e2e8f0; }
.app-shell[data-theme="dark"] .calc-card-result { color: var(--accent-light); }

/* Live rates widget */
.live-rates-card {
  background: linear-gradient(145deg, #fff 0%, #f8fafc 100%);
  border: 1px solid rgba(10, 83, 104, 0.1);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  box-shadow: 0 4px 14px rgba(10, 83, 104, 0.05);
}
.app-shell[data-theme="dark"] .live-rates-card {
  background: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
  border-color: rgba(148, 163, 184, 0.15);
}
.live-rates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.75rem 1.25rem;
  margin-top: 0.75rem;
}
.live-rate-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255,255,255,0.6);
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}
.app-shell[data-theme="dark"] .live-rate-item {
  background: rgba(30, 41, 59, 0.6);
  border-color: #334155;
}
.live-rate-pair { font-size: 0.75rem; font-weight: 700; color: #475569; }
.app-shell[data-theme="dark"] .live-rate-pair { color: #94a3b8; }
.live-rate-value { font-size: 1rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); }
.live-rates-loading, .live-rates-error { font-size: 0.85rem; color: #64748b; margin-top: 0.5rem; }
.app-shell[data-theme="dark"] .live-rates-loading,
.app-shell[data-theme="dark"] .live-rates-error { color: #94a3b8; }

/* ---- Buttons ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff !important;
  background: linear-gradient(180deg, var(--accent) 0%, var(--accent-dark) 100%);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 2px 6px rgba(10,82,104,0.35);
  transition: box-shadow 0.2s;
}
.btn-primary:hover {
  box-shadow: 0 6px 16px rgba(10,82,104,0.45);
}

.btn-secondary {
  display: inline-block;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #475569;
  background: #fff;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-secondary:hover {
  background: #f8fafc;
  border-color: var(--accent);
  color: var(--accent);
}

/* ---- Form rows (strategy form, etc.) ---- */
.form-row {
  margin-bottom: 1rem;
}
.form-row label { display: block; margin-bottom: 0.25rem; }
.form-row label { font-size: 0.8125rem; font-weight: 600; color: #475569; }
.app-shell[data-theme="dark"] .form-row label { color: #94a3b8; }

/* Trade form sections */
.trade-form-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(10, 83, 104, 0.1);
  box-shadow: 0 4px 20px rgba(10, 83, 104, 0.06);
  overflow: hidden;
}
.app-shell[data-theme="dark"] .trade-form-card {
  background: #1e293b;
  border-color: #334155;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}
.form-section {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #f1f5f9;
}
.app-shell[data-theme="dark"] .form-section { border-color: #334155; }
.form-section:last-of-type { border-bottom: none; }
.form-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  margin: 0 0 1rem 0;
  padding-bottom: 0.5rem;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
}
@media (max-width: 640px) { .form-grid-2 { grid-template-columns: 1fr; } }
.form-grid-2 .form-row { margin-bottom: 0; }
.form-grid-2 .form-row-full { grid-column: 1 / -1; }

/* Confluence page & tickable checkboxes */
.confluence-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.5rem 1.5rem;
}
.confluence-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 0.9rem;
}
.app-shell[data-theme="dark"] .confluence-item { background: #1e293b; }
.confluence-checkbox { font-size: 1rem; color: var(--accent); }
.confluence-checkboxes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.5rem 1rem;
}
.confluence-checkboxes label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  padding: 0.4rem 0;
}
.app-shell[data-theme="dark"] .confluence-checkboxes label { color: #94a3b8; }
.confluence-checkboxes input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Items grid – 3 columns for setups & trades */
.items-grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}
@media (min-width: 640px) {
  .items-grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .items-grid-3 { grid-template-columns: repeat(3, 1fr); }
}

.item-card {
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
}
.item-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(10, 83, 104, 0.12), 0 4px 12px rgba(0,0,0,0.08);
}
.app-shell[data-theme="dark"] .item-card {
  background: #1e293b;
  border-color: rgba(148, 163, 184, 0.2);
}
.app-shell[data-theme="dark"] .item-card:hover {
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
}

.item-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.item-card-header .item-card-pair { flex: 1; min-width: 0; }
.app-shell[data-theme="dark"] .item-card-header { border-color: #334155; }
.item-card-pair {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
}
.item-card-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.item-card-badge.buy { background: rgba(5, 150, 105, 0.15); color: #059669; }
.item-card-badge.sell { background: rgba(220, 38, 38, 0.15); color: #dc2626; }
.item-card-badge.win { background: rgba(5, 150, 105, 0.2); color: #059669; }
.item-card-badge.loss { background: rgba(220, 38, 38, 0.2); color: #dc2626; }

.item-card-body {
  padding: 1rem 1.25rem;
  flex: 1;
}
.item-card-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 0.8125rem;
  padding: 0.35rem 0;
  gap: 0.5rem;
}
.item-card-row:not(:last-child) { border-bottom: 1px solid #f8fafc; }
.app-shell[data-theme="dark"] .item-card-row:not(:last-child) { border-color: #334155; }
.item-card-label { color: #64748b; font-weight: 500; }
.app-shell[data-theme="dark"] .item-card-label { color: #94a3b8; }
.item-card-value { font-weight: 600; color: var(--primary); font-variant-numeric: tabular-nums; }
.item-card-value.positive { color: #059669; }
.item-card-value.negative { color: #dc2626; }

.item-card-thumb {
  width: 100%;
  height: 100px;
  object-fit: cover;
  background: #f1f5f9;
}
.app-shell[data-theme="dark"] .item-card-thumb { background: #334155; }

.item-card-footer {
  padding: 0.75rem 1.25rem;
  background: #f8fafc;
  border-top: 1px solid #f1f5f9;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.app-shell[data-theme="dark"] .item-card-footer {
  background: #0f172a;
  border-color: #334155;
}
.item-card-footer a,
.item-card-footer button {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.2rem 0;
}
.item-card-footer a:hover,
.item-card-footer button:hover { text-decoration: underline; }
.item-card-footer button.btn-delete-item { color: #dc2626; }
.item-card-footer .item-card-divider {
  width: 1px;
  height: 1em;
  background: #cbd5e1;
  margin: 0 0.15rem;
}
.app-shell[data-theme="dark"] .item-card-footer .item-card-divider { background: #475569; }

/* Detail view – 3 columns for setup/trade View page */
.detail-view-wrapper {
  max-width: 1100px;
}
.detail-view-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem 1.5rem;
}
@media (max-width: 768px) {
  .detail-view-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .detail-view-grid { grid-template-columns: 1fr; }
}
.detail-view-grid > div {
  padding: 0.5rem 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid #f1f5f9;
}
.app-shell[data-theme="dark"] .detail-view-grid > div {
  background: #0f172a;
  border-color: #334155;
}
.detail-view-grid dt { color: #64748b; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 0.25rem; }
.detail-view-grid dd { font-weight: 600; margin: 0; font-size: 0.9375rem; }
.app-shell[data-theme="dark"] .detail-view-grid dt { color: #94a3b8; }

.form-row-two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}
@media (max-width: 640px) { .form-row-two-cols { grid-template-columns: 1fr; } }
.form-row-two-cols .stat-label { display: block; margin-bottom: 0.25rem; font-size: 0.8125rem; font-weight: 600; color: #475569; }

.input-field {
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  box-sizing: border-box;
}
.input-field:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10, 82, 104, 0.15);
}
textarea.input-field {
  min-height: 80px;
  resize: vertical;
}
.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}
.form-message {
  margin-top: 0.75rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 6px;
}
.form-message--hidden { display: none; }
.form-message--error { background: #fef2f2; color: #991b1b; }
.form-message--success { background: #f0fdf4; color: #166534; }
.btn-danger {
  padding: 0.4rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: #b91c1c;
  background: #fff;
  border: 1px solid #fecaca;
  border-radius: 8px;
  cursor: pointer;
}
.btn-danger:hover { background: #fef2f2; border-color: #b91c1c; }

/* ---- Strategy list ---- */
.strategy-list { display: flex; flex-direction: column; gap: 0; }
.strategy-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 1rem 0;
  border-bottom: 1px solid #f1f5f9;
}
.strategy-item:last-child { border-bottom: none; }
.strategy-item-main { flex: 1; min-width: 0; }
.strategy-item-name { display: block; font-size: 1rem; color: var(--primary); margin-bottom: 0.25rem; }
.strategy-item-meta { font-size: 0.75rem; color: #64748b; }
.strategy-item-desc { font-size: 0.875rem; color: #475569; margin: 0.5rem 0 0 0; line-height: 1.4; }
.strategy-item-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* ---- CTA (Add first trade) ---- */
.cta-empty {
  text-align: center;
  padding: 2.5rem 1.5rem;
  background: linear-gradient(135deg, #f0fdf9 0%, #ccfbf1 100%);
  border: 2px dashed var(--accent);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
}
.cta-empty h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 0.5rem 0;
}
.cta-empty p {
  font-size: 0.95rem;
  color: #64748b;
  margin: 0 0 1.25rem 0;
}
.cta-empty .btn-primary { font-size: 1rem; padding: 0.75rem 1.5rem; }

/* ---- Tables (professional data tables) ---- */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.app-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.9rem;
  min-width: 800px;
}
.app-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}
.app-table th {
  text-align: left;
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #475569;
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}
.app-table th:first-child { border-top-left-radius: 12px; padding-left: 1.5rem; }
.app-table th:last-child { border-top-right-radius: 12px; padding-right: 1.5rem; }
.app-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}
.app-table td:first-child { padding-left: 1.5rem; }
.app-table td:last-child { padding-right: 1.5rem; }
.app-table tbody tr {
  transition: background 0.15s ease;
}
/* Zebra stripes + hover per spec */
.app-table tbody tr:nth-child(odd) { background: #fff; }
.app-table tbody tr:nth-child(even) { background: #f8fafc; }
.app-table tbody tr:hover { background: #ecfdf5 !important; }
.app-table tbody tr:last-child td { border-bottom: none; }
.app-table tbody tr:last-child td:first-child { border-bottom-left-radius: 12px; }
.app-table tbody tr:last-child td:last-child { border-bottom-right-radius: 12px; }
.app-table .cell-numeric {
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: 500;
}
.app-table .cell-actions {
  white-space: nowrap;
}
.app-table .cell-actions a,
.app-table .cell-actions button {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-right: 0.5rem;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  transition: background 0.15s;
}
.app-table .cell-actions a:hover {
  background: rgba(10, 82, 104, 0.1);
}
.app-table .cell-actions a:last-child,
.app-table .cell-actions button:last-child { margin-right: 0; }

/* Empty state for tables */
.table-empty {
  padding: 3rem 1.5rem;
  text-align: center;
  color: #64748b;
  font-size: 0.9375rem;
}
.table-empty p { margin: 0 0 0.5rem 0; }
.table-empty p + a { margin-top: 0.75rem; display: inline-block; }

/* Error state (e.g. failed to fetch) */
.page-error {
  padding: 2rem 1.5rem;
  text-align: center;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  color: #991b1b;
}
.page-error p { margin: 0 0 1rem 0; font-weight: 500; }
.page-error .hint { font-size: 0.875rem; color: #b91c1c; margin-bottom: 1rem; }
.page-error .btn-retry {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}
.page-error .btn-retry:hover { background: var(--accent-dark); }

/* ---- Badges (rounded, colored: green wins, red losses per spec) ---- */
.badge-win {
  display: inline-block;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: var(--green);
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-loss {
  display: inline-block;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: var(--red);
  border-radius: 9999px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ---- Form ---- */
.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}
.filter-row label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}
.filter-row input,
.filter-row select {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  min-width: 120px;
  background: #fff;
}
.filter-row input:focus,
.filter-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(10,82,104,0.15);
}
.filter-row .btn-secondary { flex-shrink: 0; }

/* ---- Actions row ---- */
.actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.actions-row .btn-primary { margin-left: auto; }

/* ---- Chart container ---- */
.chart-container {
  min-height: 220px;
  position: relative;
}
.chart-container canvas { width: 100% !important; height: 100% !important; }

/* ---- Text colors ---- */
.text-primary { color: var(--primary) !important; }
.text-green-600 { color: var(--green) !important; }
.text-red-600 { color: var(--red) !important; }
.text-gray-600 { color: #475569 !important; }
.text-gray-700 { color: #334155 !important; }
.text-accent { color: var(--accent) !important; }
a.text-accent:hover { text-decoration: underline; }
.btn-delete-trade {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: inherit;
  font-weight: 600;
  padding: 0;
}
.btn-delete-trade:hover { text-decoration: underline; }

/* ---- Login page ---- */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--accent) 0%, #0d3d4d 50%, #000 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.login-page__grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  max-width: 960px;
  width: 100%;
  min-height: 560px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.4);
  overflow: hidden;
}
@media (max-width: 768px) {
  .login-page__grid { grid-template-columns: 1fr; min-height: auto; }
  .login-page__brand { padding: 2rem 1.5rem; min-height: 200px; }
}
.login-page__brand {
  background: linear-gradient(160deg, var(--accent) 0%, #0d3d4d 40%, #062530 100%);
  padding: 3rem 2.5rem;
  display: flex;
  align-items: center;
}
.login-page__brand-inner { width: 100%; }
.login-page__logo {
  width: 56px;
  height: 56px;
  background: rgba(255,255,255,0.2);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  margin-bottom: 1.5rem;
}
.login-page__title { font-size: 1.75rem; font-weight: 700; color: #fff; margin: 0 0 0.5rem 0; }
.login-page__tagline { font-size: 0.9375rem; color: rgba(255,255,255,0.85); margin: 0 0 2rem 0; line-height: 1.4; }
.login-page__features { list-style: none; padding: 0; margin: 0; font-size: 0.875rem; color: rgba(255,255,255,0.8); line-height: 1.8; }
.login-page__features li::before { content: "✓ "; color: var(--accent-light); font-weight: 600; margin-right: 0.5rem; }
.login-page__form-wrap { padding: 3rem 2.5rem; display: flex; align-items: center; justify-content: center; }
.login-page__form-card { width: 100%; max-width: 340px; }
.login-page__tabs { display: flex; border-bottom: 1px solid #e2e8f0; margin-bottom: 1.75rem; list-style: none; padding: 0; margin: 0; }
.login-page__tab { padding: 0.75rem 1.25rem; font-size: 0.9375rem; font-weight: 600; color: #64748b; background: none; border: none; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.login-page__tab--active { color: var(--accent); border-bottom-color: var(--accent); }
.login-page__form { display: flex; flex-direction: column; gap: 1.25rem; }
.login-page__field { display: flex; flex-direction: column; gap: 0.375rem; }
.login-page__label { font-size: 0.8125rem; font-weight: 600; color: #334155; }
.login-page__input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
}
.login-page__input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(10,82,104,0.15); }
.login-page__submit {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 0.5rem;
}
.login-page__submit:hover { background: var(--accent-dark); }
.login-page__message { margin-top: 1.25rem; font-size: 0.8125rem; }
.login-page__message--error { color: #b91c1c; }
.login-page__message--success { color: #047857; }
.login-page__message[hidden] { display: none; }

/* ---- Loading ---- */
.loading-msg {
  text-align: center;
  padding: 3rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--accent);
}

/* ---- Dark theme (brand colors: dark green/teal) ---- */
.app-shell[data-theme="dark"] {
  --primary: #e2e8f0;
  --bg: #0f172a;
  --accent: #0a5368;
  --accent-light: #1ab2e7;
  --accent-dark: #2f6a7b;
  --green: #4ade80;
  --red: #f87171;
}
.app-shell[data-theme="dark"] body,
.app-shell[data-theme="dark"] .app-shell { background: #0a1628; color: #e2e8f0; }
.app-shell[data-theme="dark"] .app-sidebar { background: linear-gradient(180deg, #0a5368 0%, #062530 100%); }
.app-shell[data-theme="dark"] .app-header { background: #0d3d4d; border-color: rgba(10, 83, 104, 0.5); }
.app-shell[data-theme="dark"] .header-nav-link { color: #94a3b8; }
.app-shell[data-theme="dark"] .header-nav-link:hover { color: var(--accent-light); background: rgba(10, 83, 104, 0.25); }
.app-shell[data-theme="dark"] .header-nav-link.active { color: var(--accent-light); background: rgba(10, 83, 104, 0.35); }
.app-shell[data-theme="dark"] .app-header h1 { color: #e2e8f0; }
.app-shell[data-theme="dark"] .card { background: #1e293b; border-color: #334155; }
.app-shell[data-theme="dark"] .chart-card-elevated {
  background: #1e293b;
  border-color: rgba(148, 163, 184, 0.15);
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.4);
}
.app-shell[data-theme="dark"] .chart-card-elevated:hover {
  box-shadow: 0 20px 40px -12px rgba(0,0,0,0.5);
}
.app-shell[data-theme="dark"] .chart-card-title { color: #e2e8f0; }
.app-shell[data-theme="dark"] .table-wrapper { background: #1e293b; border-color: #334155; }
.app-shell[data-theme="dark"] .app-table th { background: #334155; color: #94a3b8; border-color: #475569; }
.app-shell[data-theme="dark"] .app-table td { color: #cbd5e1; border-color: #334155; }
.app-shell[data-theme="dark"] .app-table tbody tr:nth-child(odd) { background: #1e293b; }
.app-shell[data-theme="dark"] .app-table tbody tr:nth-child(even) { background: #334155; }
.app-shell[data-theme="dark"] .app-table tbody tr:hover { background: #475569 !important; }
.app-shell[data-theme="dark"] .trade-thumb { border-color: #475569; }
.app-shell[data-theme="dark"] .section-title { color: #e2e8f0; }
.app-shell[data-theme="dark"] .stat-label { color: #94a3b8; }
.app-shell[data-theme="dark"] .stat-value { color: #e2e8f0; }
.app-shell[data-theme="dark"] .input-field,
.app-shell[data-theme="dark"] .filter-row input,
.app-shell[data-theme="dark"] .filter-row select {
  background: #334155; border-color: #475569; color: #e2e8f0;
}
.app-shell[data-theme="dark"] .btn-secondary { background: #334155; border-color: #475569; color: #e2e8f0; }
.app-shell[data-theme="dark"] .btn-secondary:hover { background: #475569; border-color: var(--accent); color: var(--accent); }
.app-shell[data-theme="dark"] .btn-theme-toggle { background: #334155; border-color: #475569; color: #e2e8f0; }
.app-shell[data-theme="dark"] .strategy-item { border-color: #334155; }
.app-shell[data-theme="dark"] .strategy-item-name { color: #e2e8f0; }
.app-shell[data-theme="dark"] .strategy-item-desc { color: #94a3b8; }
.app-shell[data-theme="dark"] .cta-empty { background: #1e293b; border-color: #475569; }
.app-shell[data-theme="dark"] .cta-empty h3 { color: #e2e8f0; }
.app-shell[data-theme="dark"] .cta-empty p { color: #94a3b8; }

/* ---- The Edge page (rules, strategies, docs) ---- */
.edge-page { max-width: 1200px; }
.edge-hero {
  background: linear-gradient(135deg, rgba(10, 83, 104, 0.08) 0%, rgba(10, 83, 104, 0.03) 100%);
  border: 1px solid rgba(10, 83, 104, 0.2);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  margin-bottom: 2rem;
}
.edge-hero-text {
  margin: 0;
  font-size: 0.95rem;
  color: #475569;
  font-weight: 500;
}
.app-shell[data-theme="dark"] .edge-hero { background: linear-gradient(135deg, rgba(10, 83, 104, 0.15) 0%, rgba(10, 83, 104, 0.05) 100%); border-color: rgba(10, 83, 104, 0.3); }
.app-shell[data-theme="dark"] .edge-hero-text { color: #94a3b8; }

.edge-accordion {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}
@media (min-width: 768px) {
  .edge-accordion { grid-template-columns: 1fr 1fr; }
}
.edge-category {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}
.edge-category--collapsed .edge-category-chevron { transform: rotate(-90deg); }
.app-shell[data-theme="dark"] .edge-category { background: #1e293b; border-color: #334155; }

.edge-category-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: #f8fafc;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  text-align: left;
  transition: background 0.15s;
}
.edge-category-toggle:hover { background: #f1f5f9; }
.app-shell[data-theme="dark"] .edge-category-toggle { background: #334155; color: #e2e8f0; }
.app-shell[data-theme="dark"] .edge-category-toggle:hover { background: #475569; }

.edge-category-icon {
  flex-shrink: 0;
  color: var(--accent);
}
.edge-category-title { flex: 1; }
.edge-category-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: #64748b;
  background: #e2e8f0;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}
.app-shell[data-theme="dark"] .edge-category-badge { background: #475569; color: #94a3b8; }
.edge-category-chevron {
  flex-shrink: 0;
  color: #64748b;
  transition: transform 0.2s;
}

.edge-category-content {
  border-top: 1px solid #e2e8f0;
  padding: 0.5rem;
}
.app-shell[data-theme="dark"] .edge-category-content { border-color: #334155; }

.edge-item {
  border-radius: 8px;
  margin-bottom: 0.25rem;
  overflow: hidden;
}
.edge-item:last-child { margin-bottom: 0; }
.edge-item-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 500;
  color: #334155;
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.edge-item-toggle:hover { background: rgba(10, 83, 104, 0.06); color: var(--accent); }
.edge-item--open .edge-item-toggle { background: rgba(10, 83, 104, 0.08); color: var(--accent); }
.app-shell[data-theme="dark"] .edge-item-toggle { color: #cbd5e1; }
.app-shell[data-theme="dark"] .edge-item-toggle:hover,
.app-shell[data-theme="dark"] .edge-item--open .edge-item-toggle { background: rgba(10, 83, 104, 0.15); color: var(--accent-light); }

.edge-item-title { flex: 1; }
.edge-item-chevron {
  flex-shrink: 0;
  color: #94a3b8;
  transition: transform 0.2s;
}
.edge-item--open .edge-item-chevron { transform: rotate(180deg); }

.edge-item-content[hidden] { display: none; }
.edge-item-body {
  padding: 1rem 1.25rem 1rem 2.5rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #475569;
  border-top: 1px solid #f1f5f9;
}
.app-shell[data-theme="dark"] .edge-item-body { color: #94a3b8; border-color: #334155; }

/* ---- Trade screenshot thumbnail ---- */
.trade-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  display: block;
}
.app-shell[data-theme="dark"] .trade-thumb { border-color: #475569; }

/* ---- Journal page (A4-sized) ---- */
.journal-page { max-width: 100%; }
.journal-form-a4 { padding: 0.5rem 0; }
.journal-a4-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1rem 1.25rem;
  max-width: 210mm;
  margin: 0 auto;
  font-size: 0.875rem;
}
.journal-form-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.journal-title-row {
  text-align: center;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid #e2e8f0;
}
.journal-main-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin: 0 0 0.15rem 0;
}
.journal-motto {
  font-size: 0.8rem;
  font-style: italic;
  color: #64748b;
  margin: 0;
}
.journal-form .journal-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  margin-bottom: 0.6rem;
}
.journal-form .journal-row-top { margin-bottom: 0.5rem; }
.journal-field {
  flex: 1;
  min-width: 80px;
}
.journal-field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 0.2rem;
}
.journal-field input[readonly],
.journal-field input[type="text"],
.journal-field input[type="number"] {
  width: 100%;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: #f8fafc;
}
.journal-field input:not([readonly]) {
  background: #fff;
}
.journal-section {
  margin-top: 0.75rem;
  padding-top: 0.6rem;
  border-top: 1px solid #f1f5f9;
}
.journal-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: #334155;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 0 0 0.4rem 0;
  padding: 0.25rem 0;
  background: #f1f5f9;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
}
.journal-form textarea {
  width: 100%;
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  resize: vertical;
  min-height: 2.5rem;
}
.journal-structure-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.journal-tf-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.journal-tf-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
}
.journal-check-inline {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  cursor: pointer;
  margin: 0;
}
.journal-emotional-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
}
.journal-two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.journal-radio-row {
  display: flex;
  gap: 1rem;
}
.journal-radio-row label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  font-size: 0.8rem;
  text-transform: none;
}
.journal-stars {
  display: flex;
  gap: 0.2rem;
}
.journal-star {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: #fbbf24;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.journal-star:hover { opacity: 0.8; }
.journal-form-actions {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 0.5rem;
}
.journal-trade-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.journal-trade-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  font-size: 0.9rem;
  transition: background 0.15s, border-color 0.15s;
}
.journal-trade-item:hover {
  background: #f1f5f9;
  border-color: var(--accent);
}
.journal-trade-item.journaled { border-left: 3px solid var(--accent); }
.journal-trade-date { min-width: 90px; color: #64748b; }
.journal-trade-pair { font-weight: 600; min-width: 80px; }
.journal-trade-direction.buy { color: var(--green); }
.journal-trade-direction.sell { color: var(--red); }
.journal-trade-result { font-size: 0.75rem; }
.journal-trade-result.win { color: var(--green); }
.journal-trade-result.loss { color: var(--red); }
.journal-badge {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
  background: var(--accent);
  color: #fff;
  border-radius: 4px;
  margin-left: auto;
}
@media (max-width: 640px) {
  .journal-structure-grid { grid-template-columns: 1fr 1fr; }
  .journal-two-col { grid-template-columns: 1fr; }
}

@media (max-width: 1023px) {
  .app-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .app-sidebar.open { transform: translateX(0); }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 40;
    display: none;
  }
  .sidebar-backdrop.show { display: block; }
  .lg-only-hidden { display: inline-block !important; }
}
@media (min-width: 1024px) {
  .lg-only-hidden { display: none !important; }
}
