/* ============================================================
   Shups Admin — Standalone Modern Design System
   No external framework dependencies. Pure custom CSS.
   GitHub-dark-inspired palette with smooth animations.
   ============================================================ */

/* ---------- Reset & Base ---------- */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-primary);
}

/* ---------- CSS Custom Properties ---------- */

:root {
  /* Palette — GitHub dark inspired */
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-canvas: #010409;
  --bg-hover: #30363d;
  --bg-active: #21262d;

  --border-color: #30363d;
  --border-light: #21262d;

  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #8b949e;
  --text-link: #58a6ff;

  --brand: #58a6ff;
  --brand-hover: #79c0ff;
  --brand-bg: rgba(56, 139, 253, 0.15);

  --success: #3fb950;
  --success-bg: rgba(63, 185, 80, 0.15);
  --danger: #f85149;
  --danger-bg: rgba(248, 81, 73, 0.15);
  --warning: #d29922;
  --warning-bg: rgba(210, 153, 34, 0.15);
  --info: #58a6ff;
  --info-bg: rgba(88, 166, 255, 0.15);
  --purple: #a371f7;
  --purple-bg: rgba(163, 113, 247, 0.15);

  /* Typography */
  --font-mono: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;

  /* Radii */
  --radius-sm: 0.25rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 3px 8px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 0 0.25rem rgba(88, 166, 255, 0.15);

  /* Transitions */
  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Layout */
  --sidebar-w: 260px;
  --topbar-h: 56px;
}

/* ---------- Scrollbar ---------- */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-hover);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ---------- Selection ---------- */

::selection {
  background: rgba(56, 139, 253, 0.3);
  color: var(--text-primary);
}

/* ---------- Focus ---------- */

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ============================================================
   LAYOUT
   ============================================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  min-height: 100vh;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  flex-shrink: 0;
  z-index: 1040;
  transition: transform 0.25s ease;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  margin: 0.5rem;
  transition: color var(--transition), background-color var(--transition);
}

.sidebar-brand:hover {
  color: var(--brand);
  background-color: var(--bg-tertiary);
}

.sidebar-section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 1rem 1rem 0.25rem;
  font-weight: 600;
}

.sidebar-nav {
  list-style: none;
  padding: 0;
  margin: 0;
}

.sidebar .nav-link {
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color var(--transition), color var(--transition);
  text-decoration: none;
  margin: 0.125rem 0.5rem;
  font-weight: 400;
}

.sidebar .nav-link:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.sidebar .nav-link.active {
  background-color: var(--brand-bg);
  color: var(--brand);
  font-weight: 500;
}

.sidebar .nav-link svg {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-width: 0;
}

.main-content {
  padding: 2rem;
  max-width: 1400px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-header h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* ============================================================
   GRID SYSTEM
   ============================================================ */

.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -0.5rem;
}

.col {
  flex: 1 0 0%;
  min-width: 0;
  padding: 0 0.5rem;
}

/* Individual column widths */
.col-auto { flex: 0 0 auto; width: auto; }
.col-1  { flex: 0 0 auto; width: 8.333333%; }
.col-2  { flex: 0 0 auto; width: 16.666667%; }
.col-3  { flex: 0 0 auto; width: 25%; }
.col-4  { flex: 0 0 auto; width: 33.333333%; }
.col-5  { flex: 0 0 auto; width: 41.666667%; }
.col-6  { flex: 0 0 auto; width: 50%; }
.col-7  { flex: 0 0 auto; width: 58.333333%; }
.col-8  { flex: 0 0 auto; width: 66.666667%; }
.col-9  { flex: 0 0 auto; width: 75%; }
.col-10 { flex: 0 0 auto; width: 83.333333%; }
.col-11 { flex: 0 0 auto; width: 91.666667%; }
.col-12 { flex: 0 0 auto; width: 100%; }

/* Gap utilities */
.g-2 { margin: 0 -0.5rem; }
.g-2 > .col { padding: 0 0.5rem; }
.g-3 { margin: 0 -0.75rem; }
.g-3 > .col { padding: 0 0.75rem; }
.g-4 { margin: 0 -1rem; }
.g-4 > .col { padding: 0 1rem; }

/* Responsive column breakpoints */
@media (min-width: 576px) {
  .col-sm-1  { flex: 0 0 auto; width: 8.333333%; }
  .col-sm-2  { flex: 0 0 auto; width: 16.666667%; }
  .col-sm-3  { flex: 0 0 auto; width: 25%; }
  .col-sm-4  { flex: 0 0 auto; width: 33.333333%; }
  .col-sm-6  { flex: 0 0 auto; width: 50%; }
  .col-sm-8  { flex: 0 0 auto; width: 66.666667%; }
  .col-sm-12 { flex: 0 0 auto; width: 100%; }
}

@media (min-width: 768px) {
  .col-md-1  { flex: 0 0 auto; width: 8.333333%; }
  .col-md-2  { flex: 0 0 auto; width: 16.666667%; }
  .col-md-3  { flex: 0 0 auto; width: 25%; }
  .col-md-4  { flex: 0 0 auto; width: 33.333333%; }
  .col-md-5  { flex: 0 0 auto; width: 41.666667%; }
  .col-md-6  { flex: 0 0 auto; width: 50%; }
  .col-md-7  { flex: 0 0 auto; width: 58.333333%; }
  .col-md-8  { flex: 0 0 auto; width: 66.666667%; }
  .col-md-9  { flex: 0 0 auto; width: 75%; }
  .col-md-10 { flex: 0 0 auto; width: 83.333333%; }
  .col-md-12 { flex: 0 0 auto; width: 100%; }
}

@media (min-width: 992px) {
  .col-lg-1  { flex: 0 0 auto; width: 8.333333%; }
  .col-lg-2  { flex: 0 0 auto; width: 16.666667%; }
  .col-lg-3  { flex: 0 0 auto; width: 25%; }
  .col-lg-4  { flex: 0 0 auto; width: 33.333333%; }
  .col-lg-5  { flex: 0 0 auto; width: 41.666667%; }
  .col-lg-6  { flex: 0 0 auto; width: 50%; }
  .col-lg-7  { flex: 0 0 auto; width: 58.333333%; }
  .col-lg-8  { flex: 0 0 auto; width: 66.666667%; }
  .col-lg-9  { flex: 0 0 auto; width: 75%; }
  .col-lg-10 { flex: 0 0 auto; width: 83.333333%; }
  .col-lg-12 { flex: 0 0 auto; width: 100%; }
}

@media (min-width: 1200px) {
  .col-xl-1  { flex: 0 0 auto; width: 8.333333%; }
  .col-xl-2  { flex: 0 0 auto; width: 16.666667%; }
  .col-xl-3  { flex: 0 0 auto; width: 25%; }
  .col-xl-4  { flex: 0 0 auto; width: 33.333333%; }
  .col-xl-5  { flex: 0 0 auto; width: 41.666667%; }
  .col-xl-6  { flex: 0 0 auto; width: 50%; }
  .col-xl-7  { flex: 0 0 auto; width: 58.333333%; }
  .col-xl-8  { flex: 0 0 auto; width: 66.666667%; }
  .col-xl-9  { flex: 0 0 auto; width: 75%; }
  .col-xl-10 { flex: 0 0 auto; width: 83.333333%; }
  .col-xl-12 { flex: 0 0 auto; width: 100%; }
}

/* ============================================================
   FLEXBOX UTILITIES
   ============================================================ */

.d-flex  { display: flex !important; }
.d-inline-flex { display: inline-flex !important; }
.flex-column  { flex-direction: column !important; }
.flex-row  { flex-direction: row !important; }
.flex-wrap  { flex-wrap: wrap !important; }
.flex-nowrap  { flex-wrap: nowrap !important; }
.flex-grow-1  { flex-grow: 1 !important; }
.flex-shrink-0 { flex-shrink: 0 !important; }
.flex-fill  { flex: 1 1 auto !important; }

.align-items-start  { align-items: flex-start !important; }
.align-items-center  { align-items: center !important; }
.align-items-end  { align-items: flex-end !important; }
.align-items-stretch { align-items: stretch !important; }
.align-items-baseline { align-items: baseline !important; }

.justify-content-start  { justify-content: flex-start !important; }
.justify-content-end  { justify-content: flex-end !important; }
.justify-content-center  { justify-content: center !important; }
.justify-content-between { justify-content: space-between !important; }
.justify-content-around  { justify-content: space-around !important; }
.justify-content-evenly  { justify-content: space-evenly !important; }

/* Gap utilities */
.gap-1 { gap: 0.25rem !important; }
.gap-2 { gap: 0.5rem !important; }
.gap-3 { gap: 1rem !important; }
.gap-4 { gap: 1.5rem !important; }

/* ============================================================
   DISPLAY UTILITIES
   ============================================================ */

.d-none  { display: none !important; }
.d-inline  { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-block  { display: block !important; }
.d-table  { display: table !important; }
.d-table-row  { display: table-row !important; }
.d-table-cell  { display: table-cell !important; }

.w-25  { width: 25% !important; }
.w-50  { width: 50% !important; }
.w-75  { width: 75% !important; }
.w-100 { width: 100% !important; }
.w-auto { width: auto !important; }
.h-25  { height: 25% !important; }
.h-50  { height: 50% !important; }
.h-75  { height: 75% !important; }
.h-100 { height: 100% !important; }
.h-auto { height: auto !important; }
.min-vh-100 { min-height: 100vh !important; }

/* ============================================================
   SPACING UTILITIES
   ============================================================ */

/* Scale: 0=0, 1=0.25rem, 2=0.5rem, 3=1rem, 4=1.5rem, 5=3rem */
.m-0  { margin: 0 !important; }
.m-1  { margin: 0.25rem !important; }
.m-2  { margin: 0.5rem !important; }
.m-3  { margin: 1rem !important; }
.m-4  { margin: 1.5rem !important; }
.m-5  { margin: 3rem !important; }
.m-auto { margin: auto !important; }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-2 { margin-top: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mt-4 { margin-top: 1.5rem !important; }
.mt-5 { margin-top: 3rem !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mb-5 { margin-bottom: 3rem !important; }

.ms-0 { margin-left: 0 !important; }
.ms-1 { margin-left: 0.25rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-3 { margin-left: 1rem !important; }
.ms-4 { margin-left: 1.5rem !important; }

.me-0 { margin-right: 0 !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
.me-4 { margin-right: 1.5rem !important; }

.mx-auto { margin-left: auto !important; margin-right: auto !important; }

.p-0  { padding: 0 !important; }
.p-1  { padding: 0.25rem !important; }
.p-2  { padding: 0.5rem !important; }
.p-3  { padding: 1rem !important; }
.p-4  { padding: 1.5rem !important; }
.p-5  { padding: 3rem !important; }

.pt-0 { padding-top: 0 !important; }
.pt-1 { padding-top: 0.25rem !important; }
.pt-2 { padding-top: 0.5rem !important; }
.pt-3 { padding-top: 1rem !important; }
.pt-4 { padding-top: 1.5rem !important; }

.pb-0 { padding-bottom: 0 !important; }
.pb-1 { padding-bottom: 0.25rem !important; }
.pb-2 { padding-bottom: 0.5rem !important; }
.pb-3 { padding-bottom: 1rem !important; }
.pb-4 { padding-bottom: 1.5rem !important; }

.ps-0 { padding-left: 0 !important; }
.ps-1 { padding-left: 0.25rem !important; }
.ps-2 { padding-left: 0.5rem !important; }
.ps-3 { padding-left: 1rem !important; }
.ps-4 { padding-left: 1.5rem !important; }

.pe-0 { padding-right: 0 !important; }
.pe-1 { padding-right: 0.25rem !important; }
.pe-2 { padding-right: 0.5rem !important; }
.pe-3 { padding-right: 1rem !important; }
.pe-4 { padding-right: 1.5rem !important; }

.px-0 { padding-left: 0 !important; padding-right: 0 !important; }
.px-1 { padding-left: 0.25rem !important; padding-right: 0.25rem !important; }
.px-2 { padding-left: 0.5rem !important; padding-right: 0.5rem !important; }
.px-3 { padding-left: 1rem !important; padding-right: 1rem !important; }
.px-4 { padding-left: 1.5rem !important; padding-right: 1.5rem !important; }

.py-0 { padding-top: 0 !important; padding-bottom: 0 !important; }
.py-1 { padding-top: 0.25rem !important; padding-bottom: 0.25rem !important; }
.py-2 { padding-top: 0.5rem !important; padding-bottom: 0.5rem !important; }
.py-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
.py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }

/* ============================================================
   TEXT UTILITIES
   ============================================================ */

.text-start  { text-align: left !important; }
.text-center  { text-align: center !important; }
.text-end  { text-align: right !important; }

.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-muted  { color: var(--text-muted) !important; }
.text-body-secondary { color: var(--text-secondary) !important; }
.text-link  { color: var(--text-link) !important; }
.text-brand  { color: var(--brand) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-info  { color: var(--info) !important; }
.text-white  { color: #fff !important; }
.text-monospace { font-family: var(--font-mono) !important; }

.fw-bold  { font-weight: 700 !important; }
.fw-semibold { font-weight: 600 !important; }
.fw-normal { font-weight: 400 !important; }
.fw-light  { font-weight: 300 !important; }

.fs-sm { font-size: 0.75rem !important; }
.fs-base { font-size: 0.875rem !important; }
.fs-lg { font-size: 1.125rem !important; }
.fs-xl { font-size: 1.5rem !important; }

.small  { font-size: 0.875em !important; }
.h1, h1 { font-size: 2rem; font-weight: 600; line-height: 1.2; }
.h2, h2 { font-size: 1.5rem; font-weight: 600; line-height: 1.3; }
.h3, h3 { font-size: 1.25rem; font-weight: 600; line-height: 1.4; }
.h4, h4 { font-size: 1.125rem; font-weight: 600; line-height: 1.4; }
.h5, h5 { font-size: 1rem; font-weight: 600; line-height: 1.5; }
.h6, h6 { font-size: 0.875rem; font-weight: 600; line-height: 1.5; }

.text-uppercase { text-transform: uppercase !important; }
.text-lowercase { text-transform: lowercase !important; }
.text-capitalize { text-transform: capitalize !important; }
.text-wrap  { white-space: normal !important; }
.text-nowrap { white-space: nowrap !important; }
.text-truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cursor-pointer { cursor: pointer !important; }

/* ============================================================
   BACKGROUND UTILITIES
   ============================================================ */

.bg-primary { background-color: var(--bg-primary) !important; }
.bg-secondary { background-color: var(--bg-secondary) !important; }
.bg-tertiary { background-color: var(--bg-tertiary) !important; }
.bg-success, .text-bg-success { background-color: var(--success-bg) !important; color: var(--success) !important; }
.bg-danger, .text-bg-danger  { background-color: var(--danger-bg) !important; color: var(--danger) !important; }
.bg-warning, .text-bg-warning { background-color: var(--warning-bg) !important; color: var(--warning) !important; }
.bg-info, .text-bg-info  { background-color: var(--info-bg) !important; color: var(--info) !important; }
.bg-brand  { background-color: var(--brand-bg) !important; }

.border  { border: 1px solid var(--border-color) !important; }
.border-0  { border: 0 !important; }
.border-bottom { border-bottom: 1px solid var(--border-color) !important; }
.border-top  { border-top: 1px solid var(--border-color) !important; }

.rounded  { border-radius: var(--radius-md) !important; }
.rounded-sm { border-radius: var(--radius-sm) !important; }
.rounded-lg { border-radius: var(--radius-lg) !important; }
.rounded-xl { border-radius: var(--radius-xl) !important; }
.rounded-full { border-radius: var(--radius-full) !important; }

/* ============================================================
   CARDS
   ============================================================ */

.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
  border-color: var(--bg-hover);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 1rem 1.25rem;
  font-weight: 500;
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* ============================================================
   STAT CARDS
   ============================================================ */

.stat-card {
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  border-color: var(--brand);
  box-shadow: var(--shadow-glow);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue  { background: var(--brand-bg); color: var(--brand); }
.stat-icon.green  { background: var(--success-bg); color: var(--success); }
.stat-icon.purple { background: var(--purple-bg); color: var(--purple); }
.stat-icon.orange { background: var(--warning-bg); color: var(--warning); }
.stat-icon.red  { background: var(--danger-bg); color: var(--danger); }

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text-primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
}

/* ============================================================
   TABLES
   ============================================================ */

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  margin: 0;
  border-collapse: collapse;
  color: var(--text-primary);
  font-size: 0.875rem;
}

.table th,
.table td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

.table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  font-weight: 600;
  background-color: var(--bg-tertiary);
  border-bottom-width: 1px;
}

.table-hover tbody tr {
  transition: background-color var(--transition);
}

.table-hover tbody tr:hover {
  background-color: var(--bg-tertiary);
}

.table-sm th,
.table-sm td {
  padding: 0.5rem 0.75rem;
}

/* ============================================================
   FORMS
   ============================================================ */

.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-control,
.form-select {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-family: inherit;
  line-height: 1.5;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:disabled,
.form-control[readonly] {
  background-color: var(--bg-tertiary);
  opacity: 0.6;
  cursor: not-allowed;
}

.form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238b949e' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 12px;
  padding-right: 2rem;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.form-check-input {
  width: 1rem;
  height: 1rem;
  margin: 0;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition);
  flex-shrink: 0;
}

.form-check-input[type="checkbox"] {
  border-radius: var(--radius-sm);
}

.form-check-input[type="radio"] {
  border-radius: 50%;
}

.form-check-input:checked {
  background-color: var(--brand);
  border-color: var(--brand);
}

.form-check-input:checked[type="checkbox"] {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23fff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 70%;
}

.form-check-input:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.form-text {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-control {
  flex: 1 1 auto;
  width: 1%;
}

.input-group .form-control:not(:first-child) {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

.input-group .form-control:not(:last-child) {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group-text {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  white-space: nowrap;
}

.input-group-text:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.input-group-text:last-child {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */

.toggle-switch {
  position: relative;
  width: 2.5em;
  height: 1.25em;
  margin: 0;
  background-color: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition);
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 0.125em;
  left: 0.125em;
  width: calc(1.25em - 0.25em);
  height: calc(1.25em - 0.25em);
  background-color: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}

.toggle-switch:checked {
  background-color: var(--brand);
  border-color: var(--brand);
}

.toggle-switch:checked::after {
  transform: translateX(1.25em);
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.5;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  transition: background-color var(--transition), border-color var(--transition), color var(--transition), box-shadow var(--transition);
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-block {
  display: flex;
  width: 100%;
}

/* Sizes */
.btn-sm {
  padding: 0.25rem 0.625rem;
  font-size: 0.75rem;
}

.btn-lg {
  padding: 0.625rem 1.5rem;
  font-size: 1rem;
}

/* Solid variants */
.btn-primary {
  color: #0d1117;
  background-color: var(--brand);
  border-color: var(--brand);
}
.btn-primary:hover {
  background-color: var(--brand-hover);
  border-color: var(--brand-hover);
}

.btn-secondary {
  color: #fff;
  background-color: var(--bg-hover);
  border-color: var(--bg-hover);
}
.btn-secondary:hover {
  background-color: var(--text-muted);
  border-color: var(--text-muted);
}

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

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

.btn-warning {
  color: #000;
  background-color: var(--warning);
  border-color: var(--warning);
}
.btn-warning:hover {
  background-color: #bb8009;
  border-color: #bb8009;
}

/* Outline variants */
.btn-outline-primary {
  color: var(--brand);
  background-color: transparent;
  border-color: var(--brand);
}
.btn-outline-primary:hover {
  color: #fff;
  background-color: var(--brand);
}

.btn-outline-secondary {
  color: var(--text-secondary);
  background-color: transparent;
  border-color: var(--border-color);
}
.btn-outline-secondary:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

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

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

.btn-outline-warning {
  color: var(--warning);
  background-color: transparent;
  border-color: var(--warning);
}
.btn-outline-warning:hover {
  color: #000;
  background-color: var(--warning);
}

.btn-outline-info {
  color: var(--info);
  background-color: transparent;
  border-color: var(--info);
}
.btn-outline-info:hover {
  color: #fff;
  background-color: var(--info);
}

/* ============================================================
   BADGES
   ============================================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15em 0.5em;
  font-size: 0.75em;
  font-weight: 500;
  letter-spacing: 0.02em;
  border-radius: var(--radius-full);
  white-space: nowrap;
}

.badge.bg-success, .badge.text-bg-success { background-color: var(--success-bg); color: var(--success); }
.badge.bg-danger, .badge.text-bg-danger  { background-color: var(--danger-bg); color: var(--danger); }
.badge.bg-warning, .badge.text-bg-warning { background-color: var(--warning-bg); color: var(--warning); }
.badge.bg-info, .badge.text-bg-info  { background-color: var(--info-bg); color: var(--info); }
.badge.bg-secondary, .badge.text-bg-secondary { background-color: var(--bg-tertiary); color: var(--text-secondary); }

/* ============================================================
   ALERTS
   ============================================================ */

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

.alert-success {
  background-color: var(--success-bg);
  border-color: rgba(63, 185, 80, 0.3);
  color: var(--success);
}

.alert-danger {
  background-color: var(--danger-bg);
  border-color: rgba(248, 81, 73, 0.3);
  color: var(--danger);
}

.alert-warning {
  background-color: var(--warning-bg);
  border-color: rgba(210, 153, 34, 0.3);
  color: var(--warning);
}

.alert-info {
  background-color: var(--info-bg);
  border-color: rgba(88, 166, 255, 0.3);
  color: var(--info);
}

/* ============================================================
   MODAL (Alpine.js compatible)
   ============================================================ */

.modal-backdrop-custom {
  position: fixed;
  inset: 0;
  z-index: 1055;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to  { opacity: 1; }
}

.modal-dialog-custom {
  width: 100%;
  max-width: 500px;
  animation: modalSlideIn 0.2s ease;
}

.modal-dialog-custom.modal-lg { max-width: 700px; }
.modal-dialog-custom.modal-sm { max-width: 350px; }

.modal-dialog-scrollable {
  max-height: 80vh;
  overflow-y: auto;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to  { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-content {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h5,
.modal-header .modal-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-color);
}

.btn-close-custom {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition), background-color var(--transition);
  display: flex;
  align-items: center;
}

.btn-close-custom:hover {
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
}

/* ============================================================
   TOAST
   ============================================================ */

.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast-item {
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  color: #fff;
  box-shadow: var(--shadow-md);
  animation: toastSlideIn 0.3s ease forwards;
  max-width: 360px;
  word-break: break-word;
  pointer-events: auto;
}

.toast-item.success { background: var(--success); }
.toast-item.error  { background: var(--danger); }
.toast-item.info  { background: var(--brand); }
.toast-item.warning { background: var(--warning); color: #000; }

.toast-item.removing {
  animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateY(1rem); }
  to  { opacity: 1; transform: translateY(0); }
}

@keyframes toastSlideOut {
  from { opacity: 1; transform: translateY(0); }
  to  { opacity: 0; transform: translateY(1rem); }
}

/* ============================================================
   SPINNER
   ============================================================ */

.spinner-border {
  display: inline-block;
  width: 1.25rem;
  height: 1.25rem;
  vertical-align: text-bottom;
  border: 0.15em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.spinner-border-sm {
  width: 0.85rem;
  height: 0.85rem;
  border-width: 0.1em;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   SORTABLE TABLE HEADERS
   ============================================================ */

.th-sort {
  cursor: pointer;
  user-select: none;
  transition: color var(--transition);
  position: relative;
}

.th-sort:hover {
  color: var(--brand);
}

.th-sort .sort-icon {
  display: inline-block;
  margin-left: 0.25rem;
  opacity: 0.3;
  font-size: 0.7em;
  transition: opacity var(--transition);
}

.th-sort.active .sort-icon {
  opacity: 1;
  color: var(--brand);
}

/* ============================================================
   INLINE EDIT
   ============================================================ */

.inline-edit {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.inline-edit input,
.inline-edit .form-control {
  display: inline-block;
  width: auto;
  padding: 0.15rem 0.4rem;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.inline-edit input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 0.2rem rgba(88, 166, 255, 0.25);
}

.inline-edit-save {
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
  line-height: 1;
}

.inline-edit-spinner {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border: 0.1em solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ============================================================
   LOADING OVERLAY
   ============================================================ */

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  border-radius: inherit;
}

.loading-overlay .spinner-border {
  width: 2rem;
  height: 2rem;
  color: var(--brand);
}

/* ============================================================
   ROW FLASH
   ============================================================ */

.row-flash {
  animation: rowFlash 0.8s ease;
}

@keyframes rowFlash {
 0%  { background-color: rgba(88, 166, 255, 0.25); }
 100% { background-color: transparent; }
}

/* ============================================================
   ACTIVITY LIST
   ============================================================ */

.activity-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.65rem 0;
  border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--brand);
  flex-shrink: 0;
  margin-top: 0.35rem;
}

.activity-text {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.activity-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ============================================================
   API KEY INDICATOR
   ============================================================ */

.api-key-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
}

.api-key-dot.active { background: var(--success); }
.api-key-dot.none  { background: var(--text-muted); }

/* ============================================================
   TREE VIEW
   ============================================================ */

.tree-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.tree-list .tree-item {
  padding: 0.35rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tree-list .tree-indent {
  display: inline-block;
  width: 1.5rem;
  flex-shrink: 0;
}

.tree-list .tree-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  width: 1.25rem;
  flex-shrink: 0;
  transition: transform var(--transition), color var(--transition);
}

.tree-list .tree-toggle:hover {
  color: var(--text-primary);
}

.tree-list .tree-toggle.expanded {
  transform: rotate(90deg);
}

.tree-list .tree-toggle-placeholder {
  display: inline-block;
  width: 1.25rem;
  flex-shrink: 0;
}

.tree-list .tree-children {
  display: none;
}

.tree-list .tree-children.show {
  display: block;
}

.tree-list .tree-path {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

/* ============================================================
   FILTER BAR
   ============================================================ */

.filter-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.filter-bar .form-control {
  max-width: 320px;
}

/* ============================================================
   EMPTY STATE
   ============================================================ */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state p {
  margin: 0;
  font-size: 0.9375rem;
}

/* ============================================================
   MOBILE TOPBAR
   ============================================================ */

.mobile-topbar,
.topbar {
  display: none;
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  padding: 0 1rem;
  align-items: center;
  gap: 0.75rem;
  position: sticky;
  top: 0;
  z-index: 1035;
}

.topbar-title {
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  font-size: 1rem;
}

.btn-menu-toggle,
.btn-sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background-color var(--transition), color var(--transition);
}

.btn-menu-toggle:hover,
.btn-sidebar-toggle:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ============================================================
   SIDEBAR OVERLAY (mobile)
   ============================================================ */

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1039;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition), visibility var(--transition);
}

.sidebar-overlay.show {
  opacity: 1;
  visibility: visible;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

@media (max-width: 767.98px) {
  .mobile-topbar,
  .topbar {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    padding-top: var(--topbar-h);
  }

  .sidebar.show {
    transform: translateX(0);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .main-content {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.35rem;
  }

  .page-header h1 {
    font-size: 1.35rem;
  }

  .toast-container {
    bottom: 0.75rem;
    right: 0.75rem;
    left: 0.75rem;
  }

  .toast-item {
    max-width: 100%;
  }
}

/* ============================================================
   ALPINE.JS x-cloak
   ============================================================ */

[x-cloak] { display: none !important; }

/* ============================================================
   LOGIN PAGE
   ============================================================ */

.login-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: var(--bg-base);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-light);
  border-radius: 0.5rem;
  padding: 2rem;
}

.login-title {
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

/* ============================================================
   SIDEBAR SEARCH
   ============================================================ */

.sidebar-search {
  position: relative;
  margin: 0.25rem 0.5rem 0.5rem;
}

.sidebar-search-wrapper {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.625rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.sidebar-search-wrapper:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.15);
}

.sidebar-search-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}

.sidebar-search-input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 0.8125rem;
  color: var(--text-primary);
  outline: none;
  font-family: inherit;
  width: 100%;
}

.sidebar-search-input::placeholder {
  color: var(--text-muted);
}

.sidebar-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.25rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-search-result {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
  transition: background-color var(--transition);
  border-bottom: 1px solid var(--border-color);
}

.sidebar-search-result:first-child {
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.sidebar-search-result:last-child {
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  border-bottom: none;
}

.sidebar-search-result:hover {
  background-color: var(--bg-tertiary);
}

.sidebar-search-result-type {
  flex-shrink: 0;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
  background-color: var(--brand-bg);
  color: var(--brand);
  line-height: 1.4;
}

.sidebar-search-result-text {
  flex: 1;
  min-width: 0;
}

.sidebar-search-result-title {
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-search-result-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-search-loading,
.sidebar-search-empty {
  padding: 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8125rem;
}
