:root {
  --rt-dark:      #0a0e1a;
  --rt-darker:    #060910;
  --rt-panel:     #0f1629;
  --rt-card:      #131d35;
  --rt-border:    #1e2d4f;
  --rt-accent:    #00b4d8;
  --rt-accent2:   #0077b6;
  --rt-yellow:    #ffd60a;
  --rt-green:     #06d6a0;
  --rt-red:       #ef233c;
  --rt-text:      #e0e6f0;
  --rt-muted:     #7a8bad;
}

* { box-sizing: border-box; }

body {
  background: var(--rt-dark);
  color: var(--rt-text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

/* NAVBAR */
.rt-navbar {
  background: linear-gradient(90deg, #060c1f 0%, #0a1628 100%);
  border-bottom: 2px solid var(--rt-accent2);
  padding: 10px 0;
}
.rt-navbar .nav-link {
  color: var(--rt-muted) !important;
  font-size: .88rem;
  font-weight: 500;
  padding: 6px 14px !important;
  border-radius: 6px;
  transition: all .2s;
}
.rt-navbar .nav-link:hover, .rt-navbar .nav-link.active {
  color: var(--rt-accent) !important;
  background: rgba(0,180,216,.08);
}
.rt-navbar .navbar-brand span { color: var(--rt-accent); font-size: 1.1rem; }

.rt-badge-live {
  background: rgba(6,214,160,.15);
  color: var(--rt-green);
  border: 1px solid var(--rt-green);
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .5px;
}
.blink { animation: blink 1.2s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* CARDS */
.rt-card {
  background: var(--rt-card);
  border: 1px solid var(--rt-border);
  border-radius: 12px;
  padding: 20px;
  transition: border-color .2s, transform .15s;
}
.rt-card:hover { border-color: var(--rt-accent2); }

.stat-card {
  background: var(--rt-card);
  border: 1px solid var(--rt-border);
  border-radius: 12px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color .2s, box-shadow .2s;
}
.stat-card:hover {
  border-color: var(--rt-accent);
  box-shadow: 0 0 20px rgba(0,180,216,.12);
}
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.blue  { background: rgba(0,119,182,.2); color: var(--rt-accent); }
.stat-icon.green { background: rgba(6,214,160,.2); color: var(--rt-green); }
.stat-icon.yellow{ background: rgba(255,214,10,.2); color: var(--rt-yellow); }
.stat-icon.red   { background: rgba(239,35,60,.2);  color: var(--rt-red); }
.stat-icon.teal  { background: rgba(0,180,216,.2);  color: var(--rt-accent); }

.stat-label { font-size: .78rem; color: var(--rt-muted); text-transform: uppercase; letter-spacing: .8px; }
.stat-value { font-size: 1.8rem; font-weight: 700; line-height: 1.1; color: var(--rt-text); }
.stat-sub   { font-size: .78rem; color: var(--rt-muted); }

/* PAGE TITLE */
.page-header {
  border-bottom: 1px solid var(--rt-border);
  padding-bottom: 14px;
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--rt-text);
  margin: 0;
}
.page-header .breadcrumb { margin:0; }
.breadcrumb-item a { color: var(--rt-accent); text-decoration: none; }
.breadcrumb-item.active { color: var(--rt-muted); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--rt-muted); }

/* TABLES */
.table-dark-rt {
  --bs-table-bg: transparent;
  --bs-table-color: var(--rt-text);
  --bs-table-border-color: var(--rt-border);
  --bs-table-striped-bg: rgba(255,255,255,.02);
  --bs-table-hover-bg: rgba(0,180,216,.06);
  width: 100% !important;
  table-layout: fixed;
  font-size: .78rem;
}
.table-dark-rt thead th {
  background: var(--rt-panel);
  color: var(--rt-muted);
  font-size: .66rem;
  text-transform: uppercase;
  letter-spacing: .35px;
  border-bottom: 2px solid var(--rt-border);
  padding: 8px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-dark-rt tbody td {
  padding: 7px 6px;
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-dark-rt tbody tr:hover td { background: rgba(0,180,216,.05); }
.table-dark-rt td .small,
.table-dark-rt td a,
.table-dark-rt td span {
  min-width: 0;
}
.table-dark-rt td a,
.table-dark-rt td .text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-dark-rt td .d-flex {
  min-width: 0;
}
.table-dark-rt td .btn-sm {
  padding: 4px 7px;
  line-height: 1.1;
}
.table-dark-rt td .form-select-sm {
  min-height: 28px;
  padding-top: 3px;
  padding-bottom: 3px;
  font-size: .72rem;
}
#entriesTable .entry-status {
  max-width: 76px;
  padding-left: 5px;
  padding-right: 20px;
}
.table-responsive {
  overflow-x: visible;
}

/* Compact column maps */
#entriesTable th:nth-child(1), #entriesTable td:nth-child(1) { width: 56px !important; }
#entriesTable th:nth-child(2), #entriesTable td:nth-child(2) { width: 46px !important; }
#entriesTable th:nth-child(3), #entriesTable td:nth-child(3) { width: 15% !important; }
#entriesTable th:nth-child(4), #entriesTable td:nth-child(4) { width: 82px !important; }
#entriesTable th:nth-child(5), #entriesTable td:nth-child(5) { width: 11% !important; }
#entriesTable th:nth-child(6), #entriesTable td:nth-child(6) { width: 44px !important; }
#entriesTable th:nth-child(7), #entriesTable td:nth-child(7) { width: 15% !important; }
#entriesTable th:nth-child(8), #entriesTable td:nth-child(8) { width: 46px !important; }
#entriesTable th:nth-child(9), #entriesTable td:nth-child(9) { width: 50px !important; }
#entriesTable th:nth-child(10), #entriesTable td:nth-child(10) { width: 78px !important; }
#entriesTable th:nth-child(11), #entriesTable td:nth-child(11) { width: 58px !important; }

#horsesTable th:nth-child(1), #horsesTable td:nth-child(1) { width: 62px !important; }
#horsesTable th:nth-child(2), #horsesTable td:nth-child(2) { width: 44px !important; }
#horsesTable th:nth-child(3), #horsesTable td:nth-child(3) { width: 15% !important; }
#horsesTable th:nth-child(4), #horsesTable td:nth-child(4) { width: 13% !important; }
#horsesTable th:nth-child(5), #horsesTable td:nth-child(5) { width: 13% !important; }
#horsesTable th:nth-child(6), #horsesTable td:nth-child(6) { width: 54px !important; }
#horsesTable th:nth-child(7), #horsesTable td:nth-child(7) { width: 50px !important; }
#horsesTable th:nth-child(8), #horsesTable td:nth-child(8) { width: 72px !important; }
#horsesTable th:nth-child(9), #horsesTable td:nth-child(9) { width: 82px !important; }
#horsesTable th:nth-child(10), #horsesTable td:nth-child(10) { width: 58px !important; }
#horsesTable th:nth-child(11), #horsesTable td:nth-child(11) { width: 70px !important; }
#horsesTable th:nth-child(12), #horsesTable td:nth-child(12) { width: 58px !important; }

#syncTable th:nth-child(1), #syncTable td:nth-child(1) { width: 34px !important; }
#syncTable th:nth-child(2), #syncTable td:nth-child(2) { width: 48px !important; }
#syncTable th:nth-child(3), #syncTable td:nth-child(3) { width: 18% !important; }
#syncTable th:nth-child(4), #syncTable td:nth-child(4) { width: 52px !important; }
#syncTable th:nth-child(5), #syncTable td:nth-child(5) { width: 64px !important; }
#syncTable th:nth-child(6), #syncTable td:nth-child(6) { width: 82px !important; }
#syncTable th:nth-child(7), #syncTable td:nth-child(7) { width: 94px !important; }
#syncTable th:nth-child(8), #syncTable td:nth-child(8) { width: 86px !important; }
#syncTable th:nth-child(9), #syncTable td:nth-child(9) { width: 44px !important; }

/* DataTables overrides */
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
  background: var(--rt-panel) !important;
  color: var(--rt-text) !important;
  border: 1px solid var(--rt-border) !important;
  border-radius: 6px;
  padding: 4px 10px;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label { color: var(--rt-muted) !important; }
.dataTables_wrapper .paginate_button { color: var(--rt-muted) !important; }
.dataTables_wrapper .paginate_button.current {
  background: var(--rt-accent2) !important;
  border-color: var(--rt-accent2) !important;
  color: #fff !important;
  border-radius: 6px !important;
}
.dataTables_wrapper .paginate_button:hover {
  background: rgba(0,180,216,.15) !important;
  border-color: var(--rt-accent) !important;
  color: var(--rt-accent) !important;
  border-radius: 6px !important;
}

/* HIP BADGE */
.hip-badge {
  display: inline-flex;
  align-items: center; justify-content: center;
  width: 28px; height: 28px;
  background: var(--rt-accent2);
  color: #fff;
  font-weight: 700;
  font-size: .68rem;
  border-radius: 7px;
  flex-shrink: 0;
}

/* SCORE BAR */
.score-bar {
  display: flex; align-items: center; gap: 8px;
}
.score-fill {
  height: 6px; border-radius: 3px;
  background: linear-gradient(90deg, var(--rt-accent2), var(--rt-accent));
}
.score-num { font-weight: 700; color: var(--rt-accent); min-width: 32px; }

/* FORMS */
.form-control, .form-select {
  background: var(--rt-panel) !important;
  color: var(--rt-text) !important;
  border: 1px solid var(--rt-border) !important;
  border-radius: 8px;
}
.form-control:focus, .form-select:focus {
  border-color: var(--rt-accent) !important;
  box-shadow: 0 0 0 3px rgba(0,180,216,.15) !important;
}
.form-label { color: var(--rt-muted); font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.input-group-text {
  background: var(--rt-border) !important;
  color: var(--rt-muted) !important;
  border-color: var(--rt-border) !important;
}

/* BUTTONS */
.btn-rt-primary {
  background: linear-gradient(135deg, var(--rt-accent2), var(--rt-accent));
  border: none; color: #fff; font-weight: 600; border-radius: 8px; padding: 8px 20px;
  transition: all .2s;
}
.btn-rt-primary:hover { filter: brightness(1.15); color: #fff; transform: translateY(-1px); }

.btn-rt-outline {
  background: transparent;
  border: 1px solid var(--rt-border);
  color: var(--rt-muted);
  font-weight: 600; border-radius: 8px; padding: 8px 20px;
  transition: all .2s;
}
.btn-rt-outline:hover { border-color: var(--rt-accent); color: var(--rt-accent); background: rgba(0,180,216,.06); }

/* HORSE CARD (detail) */
.horse-header {
  background: linear-gradient(135deg, var(--rt-panel) 0%, #0d1b3a 100%);
  border: 1px solid var(--rt-border);
  border-radius: 14px;
  padding: 24px;
}
.horse-hip-big {
  background: var(--rt-accent2);
  color: #fff;
  font-size: 1.4rem; font-weight: 800;
  width: 60px; height: 60px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.horse-name { font-size: 1.6rem; font-weight: 700; color: var(--rt-text); }
.horse-meta span {
  font-size: .82rem; color: var(--rt-muted);
  margin-right: 16px;
}
.horse-meta .val { color: var(--rt-text); font-weight: 600; }

/* RACE HISTORY */
.race-row { transition: background .15s; }
.pos-1 td:first-child { border-left: 3px solid var(--rt-yellow) !important; }
.pos-2 td:first-child { border-left: 3px solid var(--rt-accent) !important; }
.pos-3 td:first-child { border-left: 3px solid var(--rt-green) !important; }

/* FILTER BAR */
.filter-bar {
  background: var(--rt-card);
  border: 1px solid var(--rt-border);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
}

/* PROGRESS / SYNC */
.sync-progress { display: none; }
.sync-progress.active { display: block; }
.progress { background: var(--rt-panel); border-radius: 8px; height: 10px; }
.progress-bar { background: linear-gradient(90deg, var(--rt-accent2), var(--rt-accent)); }

/* ALERTS */
.alert-rt {
  border-radius: 10px;
  border-left: 4px solid var(--rt-accent);
  background: rgba(0,180,216,.08);
  color: var(--rt-text);
  border-top: none; border-right: none; border-bottom: none;
}

/* TABS */
.nav-tabs-rt {
  border-bottom: 2px solid var(--rt-border);
  margin-bottom: 20px;
}
.nav-tabs-rt .nav-link {
  color: var(--rt-muted);
  background: transparent;
  border: none;
  padding: 10px 20px;
  font-weight: 600;
  font-size: .88rem;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all .2s;
}
.nav-tabs-rt .nav-link:hover { color: var(--rt-accent); }
.nav-tabs-rt .nav-link.active {
  color: var(--rt-accent);
  border-bottom-color: var(--rt-accent);
  background: transparent;
}

/* NAVBAR DROPDOWN */
.rt-navbar .dropdown-item:hover, .rt-navbar .dropdown-item:focus {
  background: rgba(0,180,216,.1) !important;
  color: var(--rt-accent) !important;
}
.rt-navbar .dropdown-item.active {
  background: rgba(0,119,182,.2) !important;
  color: var(--rt-accent) !important;
}
.rt-navbar .dropdown-menu { margin-top: 4px !important; }

/* MODAL */
.modal-content {
  background: var(--rt-card);
  border: 1px solid var(--rt-border);
  border-radius: 14px;
}
.modal-header {
  border-bottom: 1px solid var(--rt-border);
  background: var(--rt-panel);
  border-radius: 14px 14px 0 0;
}
.modal-title { color: var(--rt-text); font-weight: 700; }
.btn-close { filter: invert(1); }
.modal-footer { border-top: 1px solid var(--rt-border); }

/* COST DISPLAY */
.cost-green { color: var(--rt-green); font-weight: 700; }
.cost-red   { color: var(--rt-red);   font-weight: 700; }
.cost-blue  { color: var(--rt-accent); font-weight: 700; }
.sale-code-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 58px;
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(255,214,10,.12);
  color: var(--rt-yellow);
  border: 1px solid rgba(255,214,10,.28);
  font-size: .62rem;
  font-weight: 800;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* SECTION TITLE */
.section-title {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--rt-muted);
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--rt-border);
}

/* PAGINATION */
.rt-page-link {
  background: var(--rt-panel) !important;
  border: 1px solid var(--rt-border) !important;
  color: var(--rt-muted) !important;
  border-radius: 6px !important;
  padding: 5px 10px;
  font-size: .82rem;
  transition: all .15s;
}
.rt-page-link:hover {
  background: rgba(0,180,216,.12) !important;
  border-color: var(--rt-accent) !important;
  color: var(--rt-accent) !important;
}
.page-item.active .rt-page-link {
  background: var(--rt-accent2) !important;
  border-color: var(--rt-accent2) !important;
  color: #fff !important;
  font-weight: 700;
}
.page-item.disabled .rt-page-link {
  opacity: .35;
  pointer-events: none;
}

/* SCROLLBAR */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--rt-darker); }
::-webkit-scrollbar-thumb { background: var(--rt-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--rt-accent2); }

/* TOAST */
.toast-container { z-index: 9999; }
.rt-toast { background: var(--rt-card); border: 1px solid var(--rt-border); color: var(--rt-text); }

/* RESPONSIVE */
@media (max-width: 768px) {
  .stat-card { padding: 14px; }
  .stat-value { font-size: 1.4rem; }
  .horse-name { font-size: 1.2rem; }
}
