/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&family=Oswald:wght@400;700&display=swap');

/* Theme Variables */
:root {
  --bg: #101010;
  --panel-bg: #1b1b1b;
  --card-bg: #1f1f1f;
  --fg: #FFFFFF;
  --border: #2c2c2c;
  --input-bg: #2a2a2a;
  --input-border: #3a3a3a;
  --btn-bg: #282828;
  --btn-hover: #383838;
  --accent: #00e676;
  --negative: #ff5252;
  --muted: #aaaaaa;
  --jelly: #7719a0;
}

/* Hidden Attribute */
[hidden], .modal-overlay[hidden], .donation-modal[hidden], .hidden-panel {
  display: none !important;
}

/* Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Roboto', sans-serif;
  line-height: 1.4;
}

/* Layout Containers */
.container, #app {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 10px;
}

/* Add consistent spacing between sections in main */
main > section,
main > div {
  margin-bottom: 16px;
}
main > section:last-child,
main > div:last-child {
  margin-bottom: 0;
}

/* Header */
header {
  background: var(--panel-bg);
  position: relative;
  margin-bottom: 8px; /* Reduced from 16px to match the gap below .export-controls */
}
header .container {
  display: flex;
  align-items: center;
  height: 60px;
}
.oddsomatic-logo {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  font-size: 2.5rem;
}
.oddsomatic-logo .odds { color: #fff; }
.oddsomatic-logo .omatic { color: var(--jelly); }
.header-controls {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1px;
}
.settings-btn, .help-button, .donate-button, .contact-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--fg);
  cursor: pointer;
  padding: 4px;
  transition: color .2s;
}
.settings-btn:hover, .help-button:hover, .donate-button:hover, .contact-btn:hover {
  color: var(--accent);
}

/* Form Controls */
input, select, button {
  font-family: inherit;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 4px;
  color: var(--fg);
}
input::placeholder, select::placeholder { color: var(--muted); }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; }
button {
  cursor: pointer;
  transition: background .2s;
  background: var(--btn-bg);
}
button:hover {
  background: var(--btn-hover);
}

/* Inputs Section */
#inputs {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-bottom: 8px;
}

@media (max-width: 600px) {
  #inputs {
    flex-direction: column;
  }
}

/* Bet Side Panels */
.bet-side {
  flex: 1;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px;
}

/* Straight Mode Adjustments */
#inputs.mode-straight .bet-side.hedge-panel {
    display: none !important;
}

#inputs.mode-straight .bet-side.cashout-panel {
    display: block !important;
    flex: 1 !important;
}

/* Non-Straight Mode Adjustments */
#inputs:not(.mode-straight) .bet-side.cashout-panel {
    display: none !important;
}

#inputs:not(.mode-straight) .bet-side:not(.hedge-panel):not(.cashout-panel),
#inputs:not(.mode-straight) .bet-side.hedge-panel {
    display: block !important;
    flex: 1 !important;
}

/* Ensure Bet pane maintains full width in straight mode */
#inputs.mode-straight .bet-side:not(.hedge-panel):not(.cashout-panel) {
    flex: 1 !important;
}

/* Panel Header */
.panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
}
.panel-header h2 {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
.panel-header input.best-odds {
  margin-left: auto;
  width: 80px;
  padding: 4px;
  text-transform: uppercase;
  text-align: center;
}
.panel-header button {
  padding: 4px 6px;
  font-size: .8rem;
  text-transform: uppercase;
}

/* Bet-row */
.bet-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0;
  padding: 18px 14px 14px 6px; /* Adjusted top/right padding for larger button */
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  position: relative; /* Context for absolute positioning */
}

.icon-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

/* BOOK selector */
.book-select {
  position: relative;
  width: 32px;
  height: 32px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Oswald', sans-serif;
  font-size: .6rem;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
}
.book-select::before { content: "BOOK"; }
.book-select img { display: none; }
.book-select img.selected {
  display: block !important;
  position: absolute !important;
  inset: 0 !important;
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  z-index: 2;
}
.book-select:hover, .book-select:focus {
  border-color: var(--accent);
}

/* BONUS toggle */
.bonus-row { position: relative; }
.bonus-checkbox {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.bonus-select {
  width: 32px;
  height: 32px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: 'Oswald', sans-serif;
  font-size: .6rem;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bonus-select::before { content: "BONUS"; }
.bonus-checkbox:checked + .bonus-select {
  background: var(--accent);
  border-color: var(--accent);
  color: #101010;
}
.bonus-select:hover, .bonus-select:focus, .bonus-row:hover .bonus-select {
  border-color: var(--accent);
}

/* Odds/Stake columns */
.field-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.field-col label {
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
  text-align: center;
}
.field-col input { width: 70px; padding: 6px; font-size: 1rem; }
.input-prefix { display: flex; align-items: center; }
.input-prefix span { margin-right: 2px; font-size: 1.25rem; }
.remove-container { flex: 0 0 auto; }
.remove-container button {
  background: transparent;
  border: none;
  color: var(--negative);
  font-size: 1.2rem;
  cursor: pointer;
  transition: color .15s;
}
.remove-container button:hover { color: #ff0000; }
.fields-wrapper { display: flex; gap: 6px; margin: 0 auto; }
.bet-row .field-col:nth-child(3),
.bet-row .field-col:nth-child(4) { flex: 0 0 auto !important; }

/* Close button for bet rows */
.bet-row .remove {
  position: absolute;
  top: 6px;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--negative); /* #ff5252, matches .donation-close */
  font-size: 1.2rem; /* Matches .donation-close */
  cursor: pointer;
  line-height: 1;
  padding: 0; /* Minimal padding */
  z-index: 1; /* Above other content */
  transition: color 0.15s;
}
.bet-row .remove:hover {
  color: #ff0000; /* Brighter red */
}
.bet-row .remove:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  visibility:hidden;
}

/* Cash Out Panel */
.cashout-panel {
  flex: 1;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px;
  box-sizing: border-box;
}

/* Cash Out Row */
.cashout-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0;
  padding: 18px 14px 14px 6px; /* Match .bet-row padding */
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  position: relative;
  width: 100%;
  min-height: 86px; /* Adjust based on Developer Tools measurement */
  box-sizing: border-box;
}

/* Mimic .icon-container exactly */
.cashout-row .icon-container.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 32px;
  flex: 0 0 32px;
}

.cashout-row .icon-container .book-select.placeholder,
.cashout-row .icon-container .bonus-row.placeholder {
  width: 32px;
  height: 32px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  visibility: hidden;
}

/* Field Column in Cash Out Row */
.cashout-row .field-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 70px;
}

/* Placeholder for Stake field */
.cashout-row .field-col.placeholder {
  flex: 1;
  max-width: 70px;
}

.cashout-row .field-col.placeholder label,
.cashout-row .field-col.placeholder input {
  visibility: hidden;
}

/* Cash Out Amount Label */
.cashout-row .field-col label {
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 700;
  text-align: center;
  width: 100%;
}

/* Cash Out Amount Input */
.cashout-row .cashout-amount {
  width: 70px;
  padding: 6px;
  font-size: 1rem;
  box-sizing: border-box;
}

/* Input Prefix for Cash Out Amount */
.cashout-row .input-prefix {
  display: flex;
  align-items: center;
  width: 100%;
}

.cashout-row .input-prefix span {
  margin-right: 2px;
  font-size: 1.25rem;
}

/* Placeholder for remove-container */
.cashout-row .remove-container.placeholder {
  flex: 0 0 auto;
}

.cashout-row .remove-container.placeholder .remove.placeholder {
  visibility: hidden;
}

/* Cash Out Button Container */
.cashout-row .cashout-btn-container {
  flex: 0 0 auto;
  position: absolute;
  top: 6px;
  right: 6px;
}

/* Cash Out Button */
.cashout-row .cashout-btn-container .btn-cashout {
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--fg);
  font-family: 'Oswald', sans-serif;
  font-size: 0.8rem;
  text-transform: uppercase;
  cursor: pointer;
  line-height: 1;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.cashout-row .cashout-btn-container .btn-cashout:hover,
.cashout-row .cashout-btn-container .btn-cashout:focus {
  background: var(--btn-hover);
  border-color: var(--accent);
  color: var(--accent);
}

.cashout-row .cashout-btn-container .btn-cashout:active {
  background: var(--accent);
  color: var(--bg);
}

/* Shared flex rows */
.field-group.main, .field-group.export {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin: 8px 0; /* Reduced from 16px to match the gap below .export-controls */
}

/* Ensure field sizes and alignment */
.field-group.main > #bet-date,
.field-group.export > #history-date {
  flex: 0 0 110px;
  padding: 6px;
  font-size: 0.85rem; /* Match #history-date */
}

.field-group.main > #bet-desc {
  flex: 1;
  padding: 6px;
  font-size: 0.85rem; /* Match #bet-date */
}

/* Ensure consistent styling for all inputs in these sections */
.field-group.main > #bet-date,
.field-group.main > #bet-desc,
.field-group.export > #history-date {
  box-sizing: border-box;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--fg);
  font-family: 'Roboto', sans-serif; /* Explicitly set to match body */
}

/* Placeholder styling */
input::placeholder, select::placeholder {
  color: var(--muted);
}

/* Results & chart */
#results-container { }
.highlight, #suggestion {
  font-family: 'Oswald', sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
  font-size: 1.5rem;
  margin-bottom: 10px;
}
#results-flex {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
#results-text p { margin: 2px 0; font-size: .95rem; }
.chart-container {
  width: 100%;
  max-height: 140px;
  margin: 0 auto;
}
#profit-chart { width: 100% !important; height: 120px !important; }

/* History container wrapper */
.history-container {
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  overflow-x: auto;
  width: 100%; /* Spans the full width (700px after #app's padding) */
}

/* History Table Panel */
#history-table {
  width: 100%; /* Spans the full width of its parent (700px after #app's padding) */
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

#history-table .desc-cell {
  padding: 4px 8px;
  font-size: 0.65rem;
  color: var(--muted);
  border-bottom: 1px solid rgba(255,255,255,.15);
}

#history-table .desc-entry {
  display: block;
  margin-bottom: 2px;
}

#history-table .desc-entry:last-child {
  margin-bottom: 0;
}

#history-table .desc-label {
  font-style: normal;
  font-weight: 500;
  color: var(--accent);
  margin-right: 4px;
  text-transform: capitalize;
}

#history-table .desc-text {
  font-weight: 400;
  margin-right: 8px;
}

#history-table .desc-text strong {
  color: var(--fg);
}

#history-table tbody td.empty-state {
  text-align: center;
  padding: 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

#history-table thead { background: var(--card-bg); }
#history-table thead th {
  padding: 8px 6px;
  text-transform: uppercase;
  font-size: .75rem;
  letter-spacing: .02em;
  color: var(--fg);
  border-bottom: 1px solid rgba(255,255,255,.15);
}
#history-table thead th:nth-child(6),
#history-table thead th:nth-child(7),
#history-table thead th:nth-child(8),
#history-table thead th:nth-child(9) { text-align: right; }
#history-table tbody td {
  padding: 4px 6px;
  font-size: .75rem;
  color: var(--fg);
  border-bottom: 1px solid rgba(255,255,255,.15);
  border-right: 1px solid rgba(255,255,255,.15);
  display: table-cell !important;
  vertical-align: middle;
}
#history-table tbody td:last-child { border-right: none; }
#history-table thead th:first-child { border-top-left-radius: 6px; }
#history-table thead th:last-child { border-top-right-radius: 6px; }
#history-table tbody tr:last-child td:first-child { border-bottom-left-radius: 6px; }
#history-table tbody tr:last-child td:last-child { border-bottom-right-radius: 6px; }
#history-table tbody tr:nth-child(4n+1),
#history-table tbody tr:nth-child(4n+2) { background: #1e1e1e; }
#history-table tbody tr:nth-child(4n+3),
#history-table tbody tr:nth-child(4n+4) { background: #2a2a2a; }
#history-table tbody tr:hover td { background: rgba(255,255,255,.1); }
#history-table tbody tr.hist-desc td.desc-cell {
  padding: 2px 8px;
  font-size: .65rem;
  color: var(--muted);
  border-bottom: 1px solid rgba(255,255,255,.15);
}
#history-table .desc-label {
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
  margin-right: 4px;
  text-transform: capitalize;
}
#history-table .desc-text { font-weight: 400; }
#history-table tbody tr:not(.hist-desc):first-child,
#history-table tbody tr:not(.hist-desc) + tr.hist-desc + tr:not(.hist-desc) {
  border-top: 2px solid var(--border);
}
#history-table td.history-result-cell,
#history-table td:nth-child(4),
#history-table td:nth-child(5),
#history-table td:nth-child(10) { text-align: center; }
#history-table td:nth-child(6),
#history-table td:nth-child(7),
#history-table td:nth-child(8),
#history-table td:nth-child(9) { text-align: right; }
#history-table td.positive,
#history-table td.negative { color: var(--accent); }
#history-table td.negative { color: var(--negative); }
#history-table td img {
  display: inline-block;
  vertical-align: middle;
  margin: 0;
}
.history-result-cell.pending-cell {
  background: orange;
  color: #000;
  font-weight: bold;
}
.hist-main:hover .history-result-cell.pending-cell,
.history-result-cell.pending-cell {
  background: #ff9800 !important;
  color: #000 !important;
}
.history-result-cell.arb-cell {
  background: transparent;
  color: inherit;
  font-weight: normal;
}
.history-result-cell.cashed-out-cell {
  background: #ffd700; /* Gold for cash-out */
  color: #000;
  font-weight: bold;
}
.hist-main:hover .history-result-cell.cashed-out-cell {
  background: #ffca28 !important; /* Slightly darker gold on hover */
  color: #000 !important;
}

/* Style for profit and ROI ranges in history table */
#history-table tbody td.profit-range,
#history-table tbody td.roi-range {
  white-space: nowrap;
  font-size: 0.75rem; /* Match existing table font */
  color: var(--fg);
}

#history-table tbody td.profit-range.positive,
#history-table tbody td.roi-range.positive {
  color: var(--accent);
}

#history-table tbody td.profit-range.negative,
#history-table tbody td.roi-range.negative {
  color: var(--negative);
}

/* Center-align sportsbook icons in Bet and Hedge columns */
#history-table tbody td:nth-child(2),
#history-table tbody td:nth-child(3) {
  text-align: center;
}

/* Highlight style for history table */
#history-table tbody tr.highlight-row {
  border: 2px solid var(--accent);
  background: rgba(0, 230, 118, 0.1);
  transition: border 0.3s ease, background 0.3s ease;
}

/* Sticky Actions Column */
#history-table th:last-child,
#history-table td:last-child {
  position: sticky;
  right: 0;
  z-index: 1;
  border-left: 1px solid var(--border); /* Maintain separation */
}

/* Daily Summary Panel */
#daily-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px;
  font-size: .9rem;
  width: 100%; /* Spans the full width (700px after #app's padding) */
}
#daily-summary .summary-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#daily-summary .summary-item + .summary-item { margin-left: 8px; }
#daily-summary .summary-item .label { font-size: .85rem; color: var(--muted); }
#daily-summary .summary-item .value { margin-top: 4px; font-weight: 700; }
#daily-summary .value.positive { color: var(--accent); }
#daily-summary .value.negative { color: var(--negative); }

/* Base styles for all values in daily-summary */
#daily-summary .summary-item .value {
  font-weight: bold;
  font-size: 1rem;
  color: var(--fg);
}

/* Range-specific styles (only handle nowrap and color) */
#daily-summary .summary-item .profit-range,
#daily-summary .summary-item .roi-range {
  white-space: nowrap;
}

#daily-summary .summary-item .profit-range.positive,
#daily-summary .summary-item .roi-range.positive {
  color: var(--accent);
}

#daily-summary .summary-item .profit-range.negative,
#daily-summary .summary-item .roi-range.negative {
  color: var(--negative);
}

/* Adjust the gap between #daily-summary and #history */
#daily-summary:has(+ #history) {
  margin-bottom: 8px; /* Match the gap below .export-controls */
}

/* History Section */
#history {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0; /* Remove nested padding; parent #app already has padding: 0 10px */
}

/* Container for the history date picker and export buttons */
#history .export-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%; /* Spans the full width of #history */
  margin-bottom: 8px;
  margin-top: 8px;
}

/* Date picker styling */
#history-date {
  flex: 0 0 110px;
  padding: 6px;
  box-sizing: border-box;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Container for the export buttons within the flex layout */
#history .export-buttons {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

/* Styling for export buttons */
#btn-export, #btn-export-month, #btn-export-all {
  width: 100%;
  box-sizing: border-box;
  height: 1.9rem;
  padding: 6px 0;
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  font-family: 'Oswald', sans-serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hover/focus effect for export buttons */
#btn-export:hover, #btn-export:focus,
#btn-export-month:hover, #btn-export-month:focus,
#btn-export-all:hover, #btn-export-all:focus {
  background: var(--btn-hover);
  border-color: var(--accent);
}

/* Responsive behavior: Stack vertically on smaller screens */
@media (max-width: 600px) {
  #history .export-controls {
    flex-direction: column;
    align-items: stretch;
  }
  #history-date {
    flex: 1;
  }
  #history .export-buttons {
    grid-template-columns: 1fr;
  }
}

/* Book-picker pop-up */
.book-picker {
  position: absolute;
  display: inline-grid;
  grid-template-columns: repeat(3,32px);
  grid-auto-rows: 32px;
  gap: 4px;
  padding: 4px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0,0,0,.5);
  z-index: 1001;
}
.book-picker img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: pointer;
}

/* Pill-style “Straight Bet” toggle */
#straight-only {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}
label[for="straight-only"] {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.8rem;
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
label[for="straight-only"]::before {
  content: "⇄";
  display: inline-block;
  font-size: 1rem;
  line-height: 1;
}
label[for="straight-only"]:hover,
label[for="straight-only"]:focus-within {
  background: var(--btn-hover);
  border-color: var(--accent);
}
label[for="straight-only"].active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* Mode buttons (Arbitrage & Middle) */
.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.4rem 0.8rem;
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: 'Oswald', sans-serif;
  color: var(--fg);
  font-size: 0.8rem;
  text-transform: uppercase;
  line-height: 1.2;
}
#straight-label::before {
  content: "⇄";
  display: inline-block;
  font-size: 1rem;
  line-height: 1;
}
.mode-btn:hover, .mode-btn:focus {
  background: var(--btn-hover);
  border-color: var(--accent);
}
.mode-btn.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}
label[for="straight-only"]::before { content: none !important; }

/* Uppercase “Result:” label & dropdown text */
#result-label {
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  font-size: 0.8rem;
  color: var(--fg);
  margin-left: 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
#result-select {
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  font-size: 0.8rem;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 4px;
  padding: 4px 6px;
}
#result-select option { text-transform: uppercase; }
#result-label[hidden] { display: none !important; }
#result-label:not([hidden]) {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
}

/* Button Group Container */
.button-group {
  display: flex;
  flex-direction: column;
  gap: 8px !important;
  margin-bottom: 8px; /* Reduced from 16px to match the gap below .export-controls */
}

/* Specific reset for sections inside button-group */
.button-group > section {
  margin: 0 !important;
}

/* Mode Toggle */
#mode-toggle {
  display: flex;
  gap: 8px;
}
#mode-toggle .mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0;
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  font-family: 'Oswald', sans-serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#mode-toggle .mode-btn:hover, #mode-toggle .mode-btn:focus {
  background: var(--btn-hover);
  border-color: var(--accent);
}
#mode-toggle .mode-btn.active {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
}

/* Action Buttons */
.action-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}
.action-buttons button {
  width: 100%;
  box-sizing: border-box;
  height: 1.9rem;
  padding: 6px 0;
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  font-family: 'Oswald', sans-serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.action-buttons button:hover, .action-buttons button:focus,
#add-fav:hover, #add-fav:focus, #add-und:hover, #add-und:focus {
  background: var(--btn-hover);
  border-color: var(--accent);
}

/* Track Message */
#track-msg {
  grid-column: 1 / -1;
  text-align: center;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.2;
  color: inherit;
  margin-top: 0;
  display: none;
}
#track-msg:not(:empty) {
  display: block;
  margin-top: 8px;
}

/* Settings panel */
.settings-panel {
  position: absolute;
  top: 60px;
  right: 10px;
  width: 220px;
  max-width: calc(100% - 20px);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 12px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.3);
  display: none;
  z-index: 1000;
}
.settings-panel.open { display: block; }
.settings-panel h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.setting-group { margin-bottom: 12px; }
.setting-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
}
.setting-items label {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
  font-size: 0.9rem;
}
.setting-items input[type="checkbox"] { margin-right: 8px; }
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 8px;
  padding: 4px 0;
}
.settings-icon {
  width: 32px;
  height: 32px;
  cursor: pointer;
  transition: filter 0.2s, opacity 0.2s;
}
.settings-icon.disabled {
  filter: grayscale(100%);
  opacity: 0.5;
}
.settings-panel { position: relative; }
.settings-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: #e74c3c;
  font-size: 1.25rem;
  cursor: pointer;
}
.settings-icon {
  transition: all .2s ease;
  border: 2px solid transparent;
}
.settings-icon.disabled { filter: grayscale(100%); opacity: 0.4; }
.settings-icon.enabled {
  filter: none;
  opacity: 1;
  border-color: var(--accent);
}
#sportsbook-settings {
  max-height: 300px;
  overflow-y: auto;
}
.settings-panel .setting-group + .setting-group {
  border-top: 1px solid var(--border);
  margin-top: 0.75rem;
  padding-top: 0.75rem;
}
#sb-group .settings-close {
  position: absolute;
  top: 6px;
  right: 6px;
  background: transparent;
  border: none;
  color: var(--fg);
  font-size: 1rem;
  cursor: pointer;
  padding: 0;
}

/* Donation Modal */
.donation-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}
.donation-content {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  max-width: 320px;
  width: 90%;
  text-align: center;
  color: var(--fg);
  position: relative;
}
.donation-content h2 {
  margin-bottom: 12px;
  font-family: 'Oswald', sans-serif;
}
.donation-content p { margin-bottom: 16px; }
.donation-close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: none;
  border: none;
  color: var(--negative);
  font-size: 1.2rem;
  cursor: pointer;
}
.donation-close:hover, .donation-close:focus { color: var(--negative); }
.donation-link .btn {
  background: var(--accent);
  border: none;
  padding: 8px 16px;
  border-radius: 4px;
  color: var(--bg);
  font-family: inherit;
  cursor: pointer;
}
.donation-link .btn:hover { background: var(--btn-hover); }

/* Welcome Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3000;
}
.modal-content {
  background: var(--panel-bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  text-align: left;
  font-family: 'Roboto', sans-serif;
}
.modal-content h2 {
  font-family: 'Oswald', sans-serif;
  margin-bottom: 12px;
}
.modal-content ul { margin: 12px 0; padding-left: 1.2em; }
.modal-content li { margin-bottom: 6px; }
.modal-checkbox {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
}
.modal-checkbox input { margin-right: 6px; }
#welcome-close.btn {
  background: var(--accent);
  border: none;
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
}
#welcome-close.btn:hover { background: var(--btn-hover); }

/* Intro.js Overrides */
.introjs-tooltip {
  background: var(--panel-bg) !important;
  border: 2px solid var(--jelly) !important;
  color: var(--fg) !important;
  font-family: 'Oswald', sans-serif !important;
}
.introjs-tooltip:after { border-top-color: var(--jelly) !important; }
.introjs-tooltiptext { font-family: 'Roboto', sans-serif !important; }
.introjs-tooltipheader, .introjs-tooltiptext { color: var(--fg) !important; }
.introjs-tooltipbuttons a {
  background: transparent !important;
  border: 1px solid var(--jelly) !important;
  color: #fff !important;
  font-weight: 700 !important;
  text-shadow: none !important;
}
.introjs-tooltipbuttons a:hover {
  background: var(--jelly) !important;
  color: #fff !important;
}
.introjs-progress { background: var(--border) !important; }
.introjs-progressbar { background-color: var(--jelly) !important; }
.introjs-helperLayer { background: var(--jelly) !important; }
.introjs-helperElement {
  box-shadow: 0 0 0 4px rgba(128,0,128,0.9), 0 0 10px 6px rgba(128,0,128,0.5);
}
.my-intro-highlight {
  background: #ffa600 !important;
  box-shadow: 0 0 0 4px rgba(255,165,0,0.8) !important;
}
.introjs-skipbutton {
  color: var(--negative) !important;
  background: none !important;
  border: none !important;
  font-family: inherit !important;
  font-size: 1.25rem !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  padding: 0.25em !important;
}

/* Contact Panel */
#contact-panel a {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--accent);
  background: rgba(0, 230, 118, 0.1);
  border: 1px solid var(--accent);
  border-radius: 0.25rem;
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
#contact-panel a:hover {
  background: var(--accent);
  color: var(--bg);
}

/* Highlight suggested bet row */
.bet-row.suggested {
  border: 2px solid #00e676; /* Green border to indicate the suggestion */
  background-color: rgba(0, 230, 118, 0.1); /* Light green background for visibility */
  transition: border 0.3s ease, background-color 0.3s ease;
}

/* Hide profit-und in straight mode */
.mode-straight #profit-und {
  display: none;
}

/* 1) Give every panel the same header height */
.bet-side .panel-header {
  min-height: 32px;    /* match the Bet panel's rendered header – tweak as needed */
}

/* 2) Re-order the Cash Out row so its amount sits in the same “Stake” column */
.cashout-row {
  display: flex;
  align-items: center;
  position: relative;  /* for your absolutely-positioned button */
}
.cashout-row .field-col.placeholder {
  /* this is the invisible “Stake” placeholder column */
  order: 1;
  flex: 0 0 70px;      /* match your actual stake‐input width */
}
.cashout-row .field-col:not(.placeholder) {
  /* this is the real “Cash Out Amount” column */
  order: 2;
  flex: 0 0 70px;
}
.cashout-row .remove-container.placeholder {
  /* reserve the remove-button column */
  order: 3;
}

/* 3) (Optional) if you want the Cash Out button up in the header to perfectly mirror the Bet panel: */
/*
HTML:

<header class="panel-header">
  <h2>Cash Out</h2>
  <button id="cashout-btn" class="btn-cashout">💸 CASH OUT</button>
</header>

CSS:

.cashout-panel .btn-cashout {
  margin-left: auto;
}
*/


/* 1) Force all panel-headers to match height & prevent wrapping */
.bet-side .panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;        /* never wrap */
  min-height: 40px;         /* tweak this until it exactly matches your Bet header */
}

/* 2) Push the button to the far right and keep it on one line */
.cashout-panel .panel-header .btn-cashout {
  margin-left: auto;
  white-space: nowrap;
}

/* 3) Hide the old row-level cashout button (we’re doing it in the header now) */
.cashout-row .cashout-btn-container {
  display: none;
}

/* ------------------------------------------
   ↓ NEW STYLES TO FORCE perfect header alignment ↓
   ------------------------------------------ */

/* 1) Force both Bet/Hedge/CashOut headers to same fixed height & nowrap */
.bet-side .panel-header {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  height: 40px;     /* tweak to exactly match your rendered header height */
}

/* 2) Push the header-level Cash Out button to the far right */
.cashout-panel .panel-header .btn-cashout {
  margin-left: auto;
  white-space: nowrap;
}

/* 3) Hide the old in-row Cash Out button container */
.cashout-row .cashout-btn-container {
  display: none !important;
}

/* stack Cash Out label above its $ + input */
.cashout-row .field-col label {
  display: flex;
  flex-direction: column;
  align-items: right;
  margin-bottom: 4px; /* small gap between label text and field */
}

/* ensure the $ + input sit centered under the label */
.cashout-row .input-prefix {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* ──────────────────────────────────────── */
/* Cash-Out row now lives inside the rows */
/* ──────────────────────────────────────── */

/* Stack label above its field, center everything */
.cashout-row .field-col label {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 4px;
}
.cashout-row .input-prefix {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* Make AMOUNT and BUTTON mirror your Bet row slots */
.cashout-row .field-col {
  flex: 1; /* same as your odds column */
}
.cashout-row .button-col {
  flex: 0 0 80px;           /* roughly match your stake column width */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hide the old in-header Cash-Out button (we moved it here) */
.cashout-panel .panel-header .btn-cashout {
  display: none !important;
}

/* ──────────────────────────────────────── */
/*  Cash-Out row uses the same 4 flex slots */
/* ──────────────────────────────────────── */

/* 1) BOOK slot placeholder (32px) */
.cashout-row .icon-container.placeholder {
  flex: 0 0 32px;
  width: 32px;
}

/* 2) Stack Amount label + field exactly like .field-col */
.cashout-row .field-col label {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 4px;
}
.cashout-row .field-col .input-prefix {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* 3) Button slot uses same .field-col logic (nth-child(3)) */
.cashout-row .field-col:nth-child(3) {
  /* matches the Bet-side’s stake column: auto width based on content */
  flex: 0 0 auto !important;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cashout-row .field-col:nth-child(3) .btn-cashout {
  /* Optional: make the button fill that slot */
  max-width: 200px; /* tweak to match your stake-input width */
}

/* 4) remove-slot placeholder stays invisible */
.cashout-row .remove-container.placeholder {
  flex: 0 0 auto;
}

/* Hide the header-level Cash Out button (we moved it into the row) */
.cashout-panel .panel-header .btn-cashout {
  display: none !important;
}


/* 1) Hide the old header-button — we moved it into the row */
.cashout-panel .panel-header .btn-cashout {
  display: none !important;
}

/* 2) Ensure the placeholders stay invisible */
.book-select.placeholder,
.bonus-row.placeholder {
  visibility: hidden;
}


#cashout-btn {
  /* your existing tweaks */
  width: 100px;
  height: 34px;
  margin-top: 18px;
  margin-left: 70px;
  line-height: .75;
  white-space: nowrap;

  /* match Calculate button’s base styles */
  background: var(--btn-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--fg);
  font-family: 'Oswald', sans-serif;
  font-size: 0.85rem;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;

  /* center the icon/text inside */
  display: flex;
  align-items: center;
  justify-content: center;
}

#cashout-btn:hover,
#cashout-btn:focus {
  /* match the Calculate button hover */
  background: var(--btn-hover);
  border-color: var(--accent);
}

/* 1) let the prefix+input container shrink to its contents */
.cashout-row .input-prefix {
  width: auto !important;      /* override your old 100% */
  display: inline-flex;        /* shrink‐to‐fit */
  justify-content: center;     /* center $ and input together */
}

/* 2) let the label shrink to the same width */
.cashout-row .field-col label {
  width: auto !important;      /* no more 70px */
  margin: 0  auto 4px;         /* auto-center in its column */
  text-align: center;          /* center the text */
}

