/* ── Design System ── */
:root {
  --bg:        #0b0b14;
  --surface:   #13131f;
  --surface-2: #1c1c2e;
  --surface-3: #242438;
  --border:    rgba(99,102,241,0.15);
  --border-2:  rgba(99,102,241,0.28);
  --accent:    #6366f1;
  --accent-lt: #818cf8;
  --text:      #e2e8f0;
  --muted:     #64748b;
  --success:   #10b981;
  --danger:    #ef4444;
  --warning:   #f59e0b;
  --info:      #06b6d4;
  --radius:    10px;
  --radius-lg: 16px;
}

/* ── Base ── */
*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: .9375rem;
  margin: 0;
  min-height: 100vh;
}

a { color: var(--accent-lt); text-decoration: none; }
a:hover { color: #fff; }

code {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: .82em;
  color: #a5b4fc;
  background: rgba(99,102,241,0.1);
  padding: .1em .4em;
  border-radius: 4px;
}

/* ── Navbar ── */
.rh-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 54px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.rh-nav .brand {
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: .3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.rh-nav .nav-links {
  display: flex;
  gap: .15rem;
  flex: 1;
}

.rh-nav .nav-links a {
  color: var(--muted);
  font-size: .84rem;
  font-weight: 500;
  padding: .3rem .7rem;
  border-radius: 6px;
  transition: color .15s, background .15s;
  white-space: nowrap;
}

.rh-nav .nav-links a:hover  { color: var(--text); background: var(--surface-2); }
.rh-nav .nav-links a.active { color: #fff; background: rgba(99,102,241,.2); }

.rh-nav .nav-end { display: flex; gap: .5rem; align-items: center; margin-left: auto; flex-shrink: 0; }

/* ── Page layout ── */
.page    { padding: 2rem; max-width: 1400px; margin: 0 auto; }
.page-sm { max-width: 580px;  margin: 0 auto; padding: 2rem; }
.page-md { max-width: 820px;  margin: 0 auto; padding: 2rem; }

.page-header { margin-bottom: 1.75rem; }
.page-header h1 { font-size: 1.3rem; font-weight: 700; color: #fff; margin: 0 0 .25rem; }
.page-header p  { color: var(--muted); font-size: .875rem; margin: 0; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

.card-title {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: .6rem;
}

/* ── Stat cards ── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.2rem 1.4rem;
  transition: border-color .2s, transform .15s;
}

.stat-card:hover { border-color: var(--border-2); transform: translateY(-2px); }

.stat-card .stat-icon  { font-size: 1.3rem; margin-bottom: .5rem; }
.stat-card .stat-value { font-size: 1.9rem; font-weight: 700; color: #fff; line-height: 1; }
.stat-card .stat-label { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .7px; color: var(--muted); margin-top: .35rem; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .45rem 1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  line-height: 1.4;
  white-space: nowrap;
}

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

.btn-outline { background: transparent; color: var(--text); border-color: var(--border-2); }
.btn-outline:hover { background: var(--surface-2); color: #fff; border-color: var(--accent); }

.btn-danger { background: transparent; color: var(--danger); border-color: rgba(239,68,68,.35); }
.btn-danger:hover { background: rgba(239,68,68,.1); color: var(--danger); }

.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #059669; border-color: #059669; color: #fff; }

.btn-ghost { background: transparent; color: var(--muted); border-color: transparent; }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn-sm { padding: .28rem .65rem; font-size: .78rem; }
.btn-lg { padding: .65rem 1.5rem; font-size: 1rem; }

/* ── Forms ── */
.form-group { margin-bottom: 1.1rem; }

.form-label {
  display: block;
  font-size: .77rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin-bottom: .4rem;
}

.form-control, .form-select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  padding: .55rem .9rem;
  font-size: .9rem;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.18);
  color: var(--text);
}

.form-control::placeholder { color: var(--surface-3); }
textarea.form-control { resize: vertical; min-height: 120px; line-height: 1.6; }

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%2364748b' d='M5 7L0 2h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .8rem center;
  padding-right: 2.2rem;
  cursor: pointer;
}

.form-hint { font-size: .78rem; color: var(--muted); margin-top: .3rem; line-height: 1.5; }

.input-row { display: flex; gap: .5rem; align-items: flex-end; }
.input-row .form-control { flex: 1; }

.form-check { display: flex; align-items: center; gap: .5rem; cursor: pointer; }
.form-check-input {
  width: 15px; height: 15px;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: 4px;
  cursor: pointer;
  accent-color: var(--accent);
  flex-shrink: 0;
  margin: 0;
}
.form-check-label { font-size: .875rem; cursor: pointer; }

/* ── Alerts ── */
.alert { padding: .75rem 1rem; border-radius: var(--radius); font-size: .875rem; margin-bottom: 1rem; display: flex; gap: .5rem; align-items: flex-start; }
.alert-info    { background: rgba(6,182,212,.08);   border: 1px solid rgba(6,182,212,.25);   color: #67e8f9; }
.alert-success { background: rgba(16,185,129,.08);  border: 1px solid rgba(16,185,129,.25);  color: #6ee7b7; }
.alert-danger  { background: rgba(239,68,68,.08);   border: 1px solid rgba(239,68,68,.25);   color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,.08);  border: 1px solid rgba(245,158,11,.25);  color: #fcd34d; }

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: .18em .6em;
  font-size: .7rem;
  font-weight: 600;
  border-radius: 20px;
  letter-spacing: .3px;
}
.badge-success { background: rgba(16,185,129,.12); color: #34d399; border: 1px solid rgba(16,185,129,.2); }
.badge-muted   { background: rgba(100,116,139,.12); color: #94a3b8; border: 1px solid rgba(100,116,139,.18); }
.badge-accent  { background: rgba(99,102,241,.12); color: #a5b4fc; border: 1px solid rgba(99,102,241,.22); }
.badge-info    { background: rgba(99,102,241,.12);  color: #a5b4fc; border: 1px solid rgba(99,102,241,.22); }
.badge-warning { background: rgba(234,179,8,.12);   color: #facc15; border: 1px solid rgba(234,179,8,.22); }
.badge-danger  { background: rgba(239,68,68,.12);   color: #f87171; border: 1px solid rgba(239,68,68,.22); }

/* ── Progress bar ── */
.progress {
  width: 100%;
  height: 7px;
  background: rgba(100,116,139,.18);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 3px;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  border-radius: 20px;
  transition: width .4s ease;
}

/* ── Tables ── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}

.rh-table { width: 100%; border-collapse: collapse; font-size: .875rem; }

.rh-table thead th {
  background: var(--surface-2);
  color: var(--muted);
  font-size: .7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  padding: .7rem 1rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.rh-table tbody td {
  padding: .65rem 1rem;
  border-bottom: 1px solid rgba(99,102,241,.06);
  color: var(--text);
  vertical-align: middle;
}

.rh-table tbody tr:last-child td { border-bottom: none; }
.rh-table tbody tr:hover td { background: rgba(99,102,241,.05); }

/* DataTables overrides */
.dataTables_wrapper { color: var(--text); }

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info {
  padding: .8rem 1rem;
  font-size: .8rem;
  color: var(--muted);
}

.dataTables_wrapper .dataTables_paginate { padding: .75rem 1rem; }

.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius);
  color: var(--text);
  padding: .3rem .65rem;
  margin-left: .4rem;
  font-size: .8rem;
}

.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(99,102,241,.15);
}

.dataTables_wrapper .dataTables_paginate .paginate_button {
  background: transparent !important;
  border: 1px solid var(--border) !important;
  border-radius: 6px !important;
  color: var(--muted) !important;
  margin: 0 2px;
  padding: .25rem .65rem !important;
  font-size: .78rem !important;
  cursor: pointer;
}

.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
  background: var(--surface-2) !important;
  color: #fff !important;
  border-color: var(--border-2) !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.current {
  background: var(--accent) !important;
  border-color: var(--accent) !important;
  color: #fff !important;
}

.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
  opacity: .35;
  cursor: default;
  background: transparent !important;
}

table.dataTable thead th { border-color: var(--border) !important; }
table.dataTable tbody td { border-color: rgba(99,102,241,.06) !important; }
table.dataTable.stripe tbody tr.odd td { background: rgba(99,102,241,.02); }
table.dataTable tbody tr:hover td { background: rgba(99,102,241,.06) !important; }

/* ── Chart card ── */
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 2rem; }
.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
}
.chart-title {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--muted);
  margin-bottom: 1rem;
}

/* ── Divider ── */
.divider { height: 1px; background: var(--border); margin: 1.5rem 0; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

/* ── Utilities ── */
.flex        { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between{ display: flex; align-items: center; justify-content: space-between; }
.gap-2  { gap: .5rem; }  .gap-3 { gap: .75rem; } .gap-4 { gap: 1rem; }
.mt-2 { margin-top: .5rem; }  .mt-3 { margin-top: .75rem; } .mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.5rem; } .mt-6 { margin-top: 2rem; }
.mb-2 { margin-bottom: .5rem; }  .mb-3 { margin-bottom: .75rem; } .mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.5rem; } .mb-6 { margin-bottom: 2rem; }
.text-muted   { color: var(--muted) !important; }
.text-accent  { color: var(--accent-lt); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-sm { font-size: .82rem; } .text-xs { font-size: .72rem; }
.font-bold { font-weight: 700; }
.w-full { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
}
.modal-box {
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-lg);
  max-width: 640px; width: 100%; max-height: 85vh; overflow-y: auto;
  padding: 1.5rem; box-shadow: 0 10px 40px rgba(0,0,0,.4);
}
.modal-box h3 { margin: 0 0 1rem; font-size: 1.1rem; }
.modal-section { margin-bottom: 1.25rem; }
.modal-section:last-child { margin-bottom: 0; }
.modal-section-title {
  font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .7px;
  color: var(--muted); margin-bottom: .5rem;
}
.modal-field { display: flex; justify-content: space-between; gap: 1rem; padding: .4rem 0; border-bottom: 1px solid var(--border); font-size: .88rem; }
.modal-field:last-child { border-bottom: none; }
.modal-field .k { color: var(--muted); flex-shrink: 0; }
.modal-field .v { text-align: right; word-break: break-word; }
