:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-alt: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --bid: #238636;
  --bid-hover: #2ea043;
  --bid-text: #3fb950;
  --offer: #8a1c1c;
  --offer-hover: #b62324;
  --offer-text: #f85149;
  --accent: #f0b429;
  --accent-hover: #e5a726;
  --danger: #b62324;
  --danger-hover: #da3633;
  --primary: #1f6feb;
  --primary-hover: #388bfd;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  font-size: 32px;
  line-height: 1;
}

.header-left h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: -0.3px;
}

.subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.user-label {
  font-size: 13px;
  color: var(--muted);
  margin-right: 4px;
}

/* Main */
.main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 24px 16px;
}

.toolbar {
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pot-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
}

.pot-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  white-space: nowrap;
}

.pot-input {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
  width: 110px;
  text-align: right;
  padding: 0;
}

.pot-input:focus { outline: none; }
.pot-input::-webkit-outer-spin-button,
.pot-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.pot-input[type=number] { -moz-appearance: textfield; }

/* Table */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.markets-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.markets-table thead th {
  background: var(--surface-alt);
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.markets-table th.col-bid,
.markets-table th.col-offer,
.markets-table th.col-size {
  text-align: center;
}

.markets-table tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}

.markets-table tbody tr:last-child {
  border-bottom: none;
}

.markets-table tbody tr:hover {
  background: var(--surface-alt);
}

.markets-table td {
  padding: 0;
  vertical-align: middle;
}

.cell-team {
  padding: 14px 16px;
  font-weight: 500;
  font-size: 14px;
}

.col-position { text-align: center; }

.cell-position {
  text-align: center;
  padding: 14px 12px;
  font-weight: 600;
  font-size: 13px;
  width: 80px;
}

.pos-long  { color: var(--bid-text); }
.pos-short { color: var(--offer-text); }
.pos-flat  { color: var(--muted); }

.cell-odds {
  text-align: center;
  padding: 14px 12px;
  color: var(--muted);
  font-size: 13px;
  width: 80px;
  white-space: nowrap;
}

.col-odds { text-align: center; }

.inline-text {
  width: 72px;
  font-weight: 500;
  font-size: 13px;
  color: var(--muted);
}

.cell-bid,
.cell-offer {
  text-align: center;
  width: 110px;
  min-width: 90px;
}

.cell-size {
  text-align: center;
  padding: 14px 16px;
  color: var(--muted);
  width: 90px;
}

.cell-mid,
.cell-bidoffer {
  text-align: center;
  padding: 6px 8px;
  width: 100px;
}

.col-mid,
.col-bidoffer {
  text-align: center;
}

.inline-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
  width: 80px;
  text-align: center;
  padding: 6px 4px;
  transition: border-color 0.15s, background 0.15s;
}

.inline-input:hover {
  border-color: var(--border);
  background: var(--surface-alt);
}

.inline-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg);
}

.inline-input::-webkit-outer-spin-button,
.inline-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.inline-input[type=number] { -moz-appearance: textfield; }

/* Price buttons */
.price-btn {
  display: block;
  width: 100%;
  padding: 14px 8px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.3px;
  transition: background 0.15s, color 0.15s;
}

.price-btn.bid {
  background: var(--bid);
  color: var(--bid-text);
}

.price-btn.bid:hover {
  background: var(--bid-hover);
}

.price-btn.offer {
  background: var(--offer);
  color: var(--offer-text);
}

.price-btn.offer:hover {
  background: var(--offer-hover);
}

.price-btn.disabled {
  background: var(--surface-alt);
  color: var(--border);
  cursor: default;
}

.price-btn.clickable {
  cursor: pointer;
}

.price-btn.clickable:active {
  opacity: 0.85;
}

.price-label {
  display: block;
  padding: 14px 8px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* Empty state */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 15px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover { background: var(--surface-alt); }

.btn-accent {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}

.btn-accent:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }

.btn-icon {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-icon:hover { background: var(--surface-alt); color: var(--text); }

.btn-icon.del:hover { border-color: var(--danger); color: var(--offer-text); }

/* Modals */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
}

.modal-sm { max-width: 360px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}

.close-btn:hover { color: var(--text); }

.modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-footer {
  padding: 0 24px 20px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* Form fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 14px;
  width: 100%;
  transition: border-color 0.15s;
}

.field input:focus {
  outline: none;
  border-color: var(--primary);
}

.field input::placeholder { color: var(--muted); }

.field-row {
  display: flex;
  gap: 12px;
}

.field-row .field { flex: 1; }

.form-error {
  color: var(--offer-text);
  font-size: 13px;
  padding: 8px 12px;
  background: rgba(248, 81, 73, 0.1);
  border-radius: 6px;
  border: 1px solid rgba(248, 81, 73, 0.3);
}

.muted { color: var(--muted); }

/* Trade summary */
.trade-summary {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.trade-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.trade-label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.trade-value {
  font-weight: 600;
  font-size: 14px;
}

.trade-value.bid-val { color: var(--bid-text); }
.trade-value.offer-val { color: var(--offer-text); }

/* Two-column layout */
.app-layout {
  display: flex;
  gap: 20px;
  align-items: flex-start;
}

.markets-panel {
  flex: 1;
  min-width: 0;
}

.history-panel {
  width: 380px;
  flex-shrink: 0;
}

.history-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

/* History table columns */
.hist-th-time, .hist-td-time { width: 110px; padding: 10px 12px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.hist-th-team, .hist-td-team { padding: 10px 12px; font-size: 13px; }
.hist-th-dir,  .hist-td-dir  { width: 80px;  padding: 10px 12px; text-align: center; }
.hist-th-num,  .hist-td-num  { width: 70px;  padding: 10px 12px; text-align: right; font-size: 13px; }

.direction-bid   { color: var(--bid-text);   font-weight: 600; }
.direction-offer { color: var(--offer-text); font-weight: 600; }

/* Toast */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}

.toast {
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  max-width: 320px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: slide-in 0.2s ease;
}

.toast.success {
  background: #1a3a24;
  border: 1px solid var(--bid);
  color: var(--bid-text);
}

.toast.error {
  background: #3a1a1a;
  border: 1px solid var(--danger);
  color: var(--offer-text);
}

.toast.info {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
}

@keyframes slide-in {
  from { transform: translateX(24px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
