/* PCS OMXS30 Dashboard — minimalistic, dark-friendly */

:root {
  --bg: #0f1419;
  --bg-elev: #1a2028;
  --bg-elev2: #232a35;
  --fg: #e0e6ed;
  --fg-muted: #8b95a3;
  --border: #2d3744;
  --accent: #4dabf7;
  --accent-hover: #339af0;
  --green: #51cf66;
  --green-dark: #2b8a3e;
  --yellow: #ffd43b;
  --yellow-dark: #b8860b;
  --red: #ff6b6b;
  --red-dark: #c92a2a;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.5;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.header-left { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.header-left h1 { margin: 0; font-size: 20px; }
.home-link {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 13px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: all 0.15s;
  white-space: nowrap;
}
.home-link:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--bg-elev2);
}
.strategy-badge {
  background: var(--bg-elev2);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--fg-muted);
  border: 1px solid var(--border);
}

.header-right { display: flex; align-items: center; gap: 12px; font-size: 13px; }
#spot-value { font-weight: 600; color: var(--accent); }
.muted { color: var(--fg-muted); font-size: 12px; }

#refresh-btn {
  background: var(--bg-elev2);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
#refresh-btn:hover { background: var(--accent); }

/* ============= TRADE/NO-TRADE SIGNAL BAR ============= */
.signal-bar {
  padding: 16px 24px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.signal-bar.go {
  background: linear-gradient(135deg, rgba(81, 207, 102, 0.15), rgba(81, 207, 102, 0.05));
  border-bottom-color: var(--green);
}
.signal-bar.nogo {
  background: linear-gradient(135deg, rgba(255, 107, 107, 0.15), rgba(255, 107, 107, 0.05));
  border-bottom-color: var(--red);
}
.signal-bar.pending {
  background: var(--bg-elev);
  border-bottom-color: var(--fg-muted);
}
.signal-main {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 280px;
}
.signal-icon {
  font-size: 36px;
  line-height: 1;
}
.signal-text {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.signal-bar.go .signal-text { color: var(--green); }
.signal-bar.nogo .signal-text { color: var(--red); }
.signal-bar.pending .signal-text { color: var(--fg-muted); }

.signal-details {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}
.signal-item {
  display: flex;
  flex-direction: column;
  font-size: 13px;
}
.signal-item .signal-label {
  color: var(--fg-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.signal-item span:last-child {
  font-weight: 600;
  font-size: 15px;
}
.signal-item .pass { color: var(--green); }
.signal-item .fail { color: var(--red); }

nav.tabs {
  display: flex;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}

.tab-btn {
  background: transparent;
  color: var(--fg-muted);
  border: none;
  padding: 12px 20px;
  cursor: pointer;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.tab-btn:hover { color: var(--fg); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

main {
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

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

h2 { margin: 0 0 16px 0; font-size: 22px; }
h3 { margin: 16px 0 8px 0; font-size: 17px; }

.empty-state {
  text-align: center;
  color: var(--fg-muted);
  padding: 40px;
  background: var(--bg-elev);
  border: 1px dashed var(--border);
  border-radius: 6px;
}

/* ============= SUMMARY BAR ============= */
.summary-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.summary-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  min-width: 140px;
}
.summary-card .label { font-size: 12px; color: var(--fg-muted); }
.summary-card .value { font-size: 20px; font-weight: 600; margin-top: 4px; }
.summary-card .value.win { color: var(--green); }
.summary-card .value.loss { color: var(--red); }

/* ============= ACTIVE TRADES ============= */
.trade-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.trade-card.green { border-left: 4px solid var(--green); }
.trade-card.green-blink { border-left: 4px solid var(--green); animation: card-blink 1.2s ease-in-out infinite; }
.trade-card.lightgreen { border-left: 4px solid #7fdc8c; }
.trade-card.yellow { border-left: 4px solid var(--yellow); }
.trade-card.red { border-left: 4px solid var(--red); }
.trade-card.gray { border-left: 4px solid var(--fg-muted); }

@keyframes card-blink {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 0 18px 2px rgba(60, 200, 110, 0.6); }
}

.trade-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.trade-title { font-size: 16px; font-weight: 600; }
.trade-id { color: var(--fg-muted); font-size: 13px; }

.profit-badge {
  padding: 8px 16px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 18px;
  min-width: 80px;
  text-align: center;
}
.profit-badge.green { background: var(--green); color: #fff; }
.profit-badge.green-blink { background: var(--green); color: #fff; animation: badge-blink 1.2s ease-in-out infinite; }
.profit-badge.lightgreen { background: #7fdc8c; color: #0a3a14; }
.profit-badge.yellow { background: var(--yellow); color: #000; }
.profit-badge.red { background: var(--red); color: #fff; }
.profit-badge.gray { background: var(--bg-elev2); color: var(--fg-muted); }

@keyframes badge-blink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.65; transform: scale(1.04); }
}

.tp-action {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
}

.trade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}
.trade-field {
  background: var(--bg-elev2);
  padding: 8px 12px;
  border-radius: 4px;
}
.trade-field .label {
  display: block;
  font-size: 11px;
  color: var(--fg-muted);
  text-transform: uppercase;
}
.trade-field .value {
  font-size: 14px;
  font-weight: 600;
  margin-top: 2px;
}
.trade-field .value.win { color: var(--green); }
.trade-field .value.loss { color: var(--red); }

.legs-display {
  background: var(--bg-elev2);
  padding: 8px 12px;
  border-radius: 4px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 12px;
}
.legs-display .leg-row {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}
.legs-display .leg-label { color: var(--fg-muted); }

.trade-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ============= FORM ============= */
form { background: var(--bg-elev); padding: 20px; border-radius: 8px; border: 1px solid var(--border); }

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  margin: 12px 0;
}
fieldset legend { color: var(--accent); padding: 0 8px; font-weight: 600; }

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--fg-muted);
}
label.full { grid-column: 1 / -1; }

input, select, textarea {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}
input:focus, select:focus { outline: none; border-color: var(--accent); }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.btn-primary, .btn-secondary, .btn-danger {
  padding: 10px 20px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  border: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-elev2); color: var(--fg); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--red-dark); color: #fff; }
.btn-danger:hover { background: var(--red); }

.preview {
  flex: 1;
  font-size: 13px;
  color: var(--fg-muted);
  font-family: 'SF Mono', Menlo, monospace;
}

/* ============= SETUP HELPER ============= */
.setup-helper {
  background: var(--bg-elev);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}
.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.setup-item {
  background: var(--bg-elev2);
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
}
.setup-item .label { color: var(--fg-muted); margin-right: 6px; }
.setup-item.full {
  grid-column: 1 / -1;
  background: transparent;
  color: var(--fg-muted);
  font-size: 12px;
}

/* ============= STRATEGY TABLES ============= */
.strategy-section {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.strategy-section h3 { margin-top: 0; color: var(--accent); }
.strategy-section ul { padding-left: 20px; }
.strategy-section table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}
.strategy-section th, .strategy-section td {
  text-align: left;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
}
.strategy-section th {
  background: var(--bg-elev2);
  color: var(--accent);
  font-weight: 600;
}
.strategy-section td.win { color: var(--green); font-weight: 600; }
.strategy-section td.loss { color: var(--red); font-weight: 600; }
.tp-table tr.highlight td { background: rgba(81, 207, 102, 0.1); }
.tp-table tr.warning td { background: rgba(255, 107, 107, 0.1); }

/* Uttag-historik (Stängda CCS-fliken) — utanför .strategy-section så behöver egen styling */
#monthly-withdrawal-history table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}
#monthly-withdrawal-history th,
#monthly-withdrawal-history td {
  padding: 6px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
#monthly-withdrawal-history th {
  background: var(--bg-elev2);
  color: var(--accent);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
/* Höger-justera sifferkolumner (Kontovärde, PnL, Uttag, Reinvest) — header följer värde */
#monthly-withdrawal-history th:nth-child(2),
#monthly-withdrawal-history th:nth-child(3),
#monthly-withdrawal-history th:nth-child(4),
#monthly-withdrawal-history th:nth-child(5),
#monthly-withdrawal-history td:nth-child(2),
#monthly-withdrawal-history td:nth-child(3),
#monthly-withdrawal-history td:nth-child(4),
#monthly-withdrawal-history td:nth-child(5) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
#monthly-withdrawal-history td.win { color: var(--green); font-weight: 600; }
#monthly-withdrawal-history td.loss { color: var(--red); font-weight: 600; }

.note {
  font-size: 13px;
  color: var(--fg-muted);
  margin-top: 8px;
  font-style: italic;
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.dot.green { background: var(--green); }
.dot.yellow { background: var(--yellow); }
.dot.red { background: var(--red); }

code {
  background: var(--bg-elev2);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 12px;
}

.win { color: var(--green); }
.loss { color: var(--red); }

/* ============= MODAL ============= */
.modal {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  max-width: 600px;
  width: 90%;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.modal-content h3 { margin-top: 0; }

/* ============= SL block ============= */
.sl-block {
  font-size: 0.92em;
}
.sl-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.2rem 1rem;
}
.sl-row {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
}
.sl-row span:first-child {
  color: #aab;
}
.sl-value {
  font-weight: 600;
  font-family: 'SF Mono', Menlo, monospace;
}
.sl-action {
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 0.4rem;
}
@media (max-width: 600px) {
  .sl-grid { grid-template-columns: 1fr; }
}

/* ──────────── Översikt — kompakt vy för många trades ──────────── */
.overview-group {
  margin-bottom: 1.5rem;
  background: var(--bg-elev1, #14213a);
  border: 1px solid var(--border, #2a3a5a);
  border-radius: 8px;
  overflow: hidden;
}
.overview-group-header {
  background: rgba(95, 179, 255, 0.1);
  padding: 0.6rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  border-bottom: 1px solid var(--border, #2a3a5a);
  font-size: 0.92em;
}
.overview-group-header .exp-date {
  font-weight: 600;
  color: #fff;
}
.overview-group-header .dte-badge {
  background: rgba(255,255,255,0.1);
  padding: 0.15rem 0.55rem;
  border-radius: 12px;
  font-size: 0.85em;
  font-weight: 500;
}
.overview-group-header .dte-badge.win {
  background: rgba(95, 207, 95, 0.2);
  color: #5fcf5f;
}
.overview-group-header .dte-badge.loss {
  background: rgba(255, 112, 112, 0.2);
  color: #ff7070;
}
.overview-group-header .trade-count {
  margin-left: auto;
  color: #888;
  font-size: 0.85em;
}
.overview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92em;
}
.overview-table th {
  text-align: left;
  padding: 0.45rem 0.7rem;
  font-weight: 500;
  color: #aab;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border, #2a3a5a);
}
.overview-table td {
  padding: 0.55rem 0.7rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.overview-table tbody tr:hover {
  background: rgba(95, 179, 255, 0.05);
}
.overview-table tbody tr:last-child td { border-bottom: none; }
.overview-table .trade-id {
  color: #888;
  font-family: 'SF Mono', Menlo, monospace;
  font-size: 0.88em;
}
.overview-table .strikes {
  font-family: 'SF Mono', Menlo, monospace;
}
.overview-table .status {
  font-size: 0.88em;
}
.overview-table .win { color: var(--profit, #5fcf5f); }
.overview-table .loss { color: var(--loss, #ff7070); }

/* ──────────── Big strike cards (Ny trade-fliken) ──────────── */
.big-strike-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0;
}
.strike-card {
  background: var(--bg-elev2, #1a2a4a);
  border: 2px solid var(--border, #2a3a5a);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  text-align: center;
}
.strike-card-short {
  border-color: rgba(255, 112, 112, 0.5);
  background: linear-gradient(180deg, rgba(255,112,112,0.08), rgba(255,112,112,0.02));
}
.strike-card-long {
  border-color: rgba(95, 207, 95, 0.5);
  background: linear-gradient(180deg, rgba(95,207,95,0.08), rgba(95,207,95,0.02));
}
.strike-card .card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82em;
  margin-bottom: 0.6rem;
}
.strike-card .leg-direction {
  font-weight: 700;
  letter-spacing: 0.05em;
}
.strike-card .leg-short { color: var(--loss, #ff7070); }
.strike-card .leg-long  { color: var(--profit, #5fcf5f); }
.strike-card .card-dte {
  background: rgba(255,255,255,0.06);
  padding: 0.15rem 0.55rem;
  border-radius: 12px;
  color: #aab;
  font-weight: 500;
}
.strike-card .card-strike {
  font-size: 3.4rem;
  font-weight: 700;
  font-family: 'SF Mono', Menlo, monospace;
  margin: 0.4rem 0;
  letter-spacing: -0.02em;
  line-height: 1;
}
.strike-card-short .card-strike { color: var(--loss, #ff7070); }
.strike-card-long  .card-strike { color: var(--profit, #5fcf5f); }
.strike-card .card-meta {
  display: flex;
  justify-content: center;
  gap: 1rem;
  font-size: 0.92em;
  color: #ccd;
  margin-bottom: 0.4rem;
}
.strike-card .card-expiry {
  font-size: 0.85em;
  color: #888;
  margin-top: 0.3rem;
}
.strike-relation {
  text-align: center;
  padding: 0.55rem 0.9rem;
  background: rgba(95,179,255,0.08);
  border: 1px solid rgba(95,179,255,0.3);
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.92em;
  color: #ccd;
}
@media (max-width: 700px) {
  .big-strike-cards { grid-template-columns: 1fr; }
  .strike-card .card-strike { font-size: 2.6rem; }
}

/* ════════════════════════════════════════════════════
   MOBILE-FRIENDLY (added 2026-05-08)
   Tablet-first: < 900px tweaks; Phone: < 600px stack
   ════════════════════════════════════════════════════ */

/* Tablet & smaller — minska padding och flex-wrap */
@media (max-width: 900px) {
  body { font-size: 13px; }

  header {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 10px;
  }
  .header-left { flex-wrap: wrap; gap: 8px; }
  .header-left h1 { font-size: 18px; }
  .strategy-badge {
    font-size: 11px;
    padding: 3px 8px;
    line-height: 1.4;
    white-space: normal;
  }
  .header-right { font-size: 12px; gap: 8px; flex-wrap: wrap; }

  main { padding: 14px; }

  nav.tabs {
    padding: 0 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  nav.tabs::-webkit-scrollbar { display: none; }
  .tab-btn {
    padding: 10px 14px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .signal-bar { padding: 12px 14px; gap: 10px; }
  .signal-icon { font-size: 28px; }
  .signal-text { font-size: 17px; letter-spacing: 0.2px; }
  .signal-main { min-width: 0; gap: 10px; }
  .signal-details { gap: 12px; }

  /* Trade-grid 2 kolumner */
  .trade-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  /* Summary cards 2 per row */
  .summary-bar { gap: 8px; }
  .summary-card {
    min-width: 0;
    flex: 1 1 calc(50% - 4px);
    padding: 10px 12px;
  }
  .summary-card .value { font-size: 17px; }

  /* Trade-card kompaktare */
  .trade-card { padding: 12px; }
  .trade-title { font-size: 15px; }
  .trade-id { font-size: 12px; }
  .profit-badge {
    font-size: 16px;
    padding: 6px 12px;
    min-width: 70px;
  }
  .tp-action { font-size: 11px; }

  /* Tables — horizontell scroll istället för utflöde */
  table.spec-table,
  table.tp-table,
  table.result-table,
  table.year-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    font-size: 12px;
  }
  table.spec-table td,
  table.tp-table td,
  table.result-table td,
  table.year-table td,
  table.spec-table th,
  table.tp-table th,
  table.result-table th,
  table.year-table th {
    padding: 6px 8px;
  }

  /* Form-fält full-width */
  form input[type="text"],
  form input[type="number"],
  form input[type="date"],
  form select {
    width: 100%;
    box-sizing: border-box;
  }

  /* Button större touch-target */
  button {
    min-height: 40px;
    padding: 8px 14px;
  }

  /* Strategy-section padding mindre */
  .strategy-section {
    padding: 12px;
    margin-bottom: 12px;
  }
  h2 { font-size: 19px; }
  h3 { font-size: 15px; }
  h4 { font-size: 14px; }
}

/* Phone — riktigt smal layout < 600px */
@media (max-width: 600px) {
  body { font-size: 13px; }

  header {
    padding: 8px 12px;
    flex-direction: column;
    align-items: flex-start;
  }
  .header-left { width: 100%; }
  .header-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }

  /* Strategy-badge döljs eller mycket liten på phone */
  .strategy-badge {
    font-size: 10px;
    padding: 2px 6px;
    width: 100%;
    line-height: 1.35;
    margin-top: 4px;
  }

  main { padding: 10px; }

  /* Trade-header — profit-badge under titel */
  .trade-header {
    flex-direction: column;
    align-items: stretch;
  }
  .profit-badge {
    align-self: flex-start;
    font-size: 18px;
    padding: 8px 14px;
    width: 100%;
    text-align: center;
  }

  /* Trade-grid 1 kolumn på phone */
  .trade-grid { grid-template-columns: 1fr; }
  .trade-field { padding: 6px 10px; }
  .trade-field .label { font-size: 10px; }
  .trade-field .value { font-size: 13px; }

  /* Summary cards stack 1 per row men kompakt */
  .summary-card {
    flex: 1 1 100%;
    padding: 8px 12px;
  }
  .summary-card .label { font-size: 11px; }
  .summary-card .value { font-size: 16px; }

  /* Signal-bar — stack vertikalt på phone */
  .signal-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 10px 12px;
  }
  .signal-main {
    align-items: center;
    text-align: center;
    flex-direction: column;
    gap: 4px;
  }
  .signal-icon { font-size: 32px; }
  .signal-text { font-size: 15px; line-height: 1.3; }
  .signal-details {
    flex-direction: column;
    gap: 6px;
    width: 100%;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: 4px;
  }
  .signal-item { flex-direction: row; justify-content: space-between; align-items: baseline; }
  .signal-item span:last-child { font-size: 13px; }

  /* Signal-bar i HTML har också inline display flex som vi måste accept */
  .signal-item .signal-label { font-size: 10px; }

  /* Setup-helper grid 1 col */
  .setup-grid { grid-template-columns: 1fr; }

  /* Strategy-section: bredare scroll-area men inte break-out */
  .strategy-section { padding: 10px; }

  /* Tab-content padding */
  .tab-content > h2 { font-size: 17px; margin-bottom: 12px; }

  /* Aktiva-trades summary-bar */
  .summary-card .value { font-size: 15px; }

  /* TP-action ska bryta */
  .tp-action {
    white-space: normal;
    line-height: 1.3;
  }

  /* Profit-badge: större touch-area + tydlig */
  .profit-badge { font-size: 17px; min-width: 0; }

  /* H-headings mindre på phone */
  h2 { font-size: 17px; margin: 0 0 12px 0; }
  h3 { font-size: 15px; margin: 12px 0 6px 0; }
  h4 { font-size: 13px; margin: 10px 0 4px 0; }

  /* Refresh-knapp större */
  #refresh-btn { padding: 8px 14px; font-size: 16px; }

  /* Modal (edit-trade) tar upp mer skärm */
  .modal-content {
    width: 95vw;
    max-width: none;
    padding: 16px;
    max-height: 90vh;
    overflow-y: auto;
  }

  /* Notes och long-text wrapping */
  .note { font-size: 12px; line-height: 1.45; }
  ul, ol { padding-left: 20px; }
  li { font-size: 13px; }
}

/* Extra-tight phone (< 380px) — minimera padding */
@media (max-width: 380px) {
  main { padding: 8px; }
  .trade-card { padding: 10px; }
  .summary-card { padding: 8px 10px; }
  .strategy-badge { display: none; }  /* Spara plats */
  .tab-btn { padding: 8px 10px; font-size: 12px; }
  h1 { font-size: 16px !important; }
}

/* Touch-friendly: större checkboxar och radios */
@media (pointer: coarse) {
  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
  }
  button, .tab-btn { min-height: 44px; }  /* Apple HIG: 44px touch-target */
}

/* ============= MOBILE: Ny trade + Stäng modal (kritisk när Mat är borta från dator) ============= */
@media (max-width: 600px) {
  /* Modal blir full-screen så hela formuläret syns + scrolla utan att fönster känns trångt */
  .modal-content {
    max-width: 100% !important;
    width: 100% !important;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    overflow-y: auto;
    padding: 16px 14px 80px 14px;
  }
  .modal { padding: 0; align-items: flex-start; }

  /* Inputs >= 16px font för att iOS Safari inte ska auto-zooma + större touch-höjd */
  input[type="text"],
  input[type="number"],
  input[type="date"],
  select,
  textarea {
    font-size: 16px;
    min-height: 44px;
    padding: 10px 12px;
  }
  label { font-size: 14px; }
  fieldset legend { font-size: 14px; font-weight: 600; }

  /* Knappar: större touch + tydlig hierarki */
  .btn-primary, .btn-secondary, .btn-danger {
    padding: 14px 20px;
    font-size: 15px;
    min-height: 50px;
    width: 100%;
  }

  /* Form-actions: stackade, primary överst, sticky på botten av modal */
  .form-actions {
    flex-direction: column-reverse;
    gap: 10px;
    margin-top: 20px;
    position: sticky;
    bottom: 0;
    background: var(--bg-elev, #14213a);
    padding: 12px 0;
    margin-left: -14px;
    margin-right: -14px;
    padding-left: 14px;
    padding-right: 14px;
    border-top: 1px solid var(--border, #2a3a5a);
  }

  /* Strike-card grid stackar (en under den andra) */
  .big-strike-cards { grid-template-columns: 1fr !important; gap: 12px; }
  .strike-card .card-strike { font-size: 2.4rem; }

  /* Setup-grid stackad */
  .setup-grid { grid-template-columns: 1fr !important; }

  /* Tab-buttons: horizontal scroll på smal skärm */
  .tab-list, .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    scrollbar-width: none;
  }
  .tab-list::-webkit-scrollbar, .tabs::-webkit-scrollbar { display: none; }
  .tab-btn {
    flex-shrink: 0;
    min-height: 48px;
    padding: 10px 14px;
    font-size: 14px;
  }

  /* Close-modal leg-info: större ticker-display */
  .close-leg-info { font-size: 14px !important; padding: 10px 12px !important; }
  .close-leg-info strong { font-size: 16px; }
}
