/* ==========================================================================
   Running Admin — Design System
   Modern SaaS theme (light + dark), Indigo/Violet accent.
   Load AFTER styles.min.css. Har page ye file use karta hai.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* --------------------------------------------------------------------------
   1. Tokens — Light
   -------------------------------------------------------------------------- */
:root {
  --app-bg:        #F5F6FA;
  --surface:       #FFFFFF;
  --surface-2:     #F8FAFC;
  --surface-3:     #F1F5F9;
  --border:        #E4E8F0;
  --border-strong: #CBD5E1;

  --text:          #0F172A;
  --text-2:        #475569;
  --text-muted:    #7C889C;

  --primary:       #6366F1;
  --primary-hover: #4F46E5;
  --primary-soft:  #EEF0FE;
  --primary-ring:  rgba(99, 102, 241, .28);
  --on-primary:    #FFFFFF;

  --success:       #10B981;
  --success-soft:  #E7F8F1;
  --warning:       #F59E0B;
  --warning-soft:  #FEF4E4;
  --danger:        #EF4444;
  --danger-soft:   #FDECEC;
  --info:          #0EA5E9;
  --info-soft:     #E6F5FD;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, .05);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .07), 0 1px 2px rgba(15, 23, 42, .04);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, .07), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .10), 0 2px 8px rgba(15, 23, 42, .05);

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;

  --sidebar-w: 262px;
  --header-h: 68px;

  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* --------------------------------------------------------------------------
   2. Tokens — Dark
   -------------------------------------------------------------------------- */
[data-theme="dark"] {
  --app-bg:        #0A0F1C;
  --surface:       #111827;
  --surface-2:     #161F31;
  --surface-3:     #1E293B;
  --border:        #232F44;
  --border-strong: #334155;

  --text:          #E8EDF5;
  --text-2:        #B4C0D2;
  --text-muted:    #8494AC;

  --primary:       #818CF8;
  --primary-hover: #6366F1;
  --primary-soft:  #1E2340;
  --primary-ring:  rgba(129, 140, 248, .32);
  --on-primary:    #0A0F1C;

  --success:       #34D399;
  --success-soft:  #10261F;
  --warning:       #FBBF24;
  --warning-soft:  #2A2010;
  --danger:        #F87171;
  --danger-soft:   #2C1416;
  --info:          #38BDF8;
  --info-soft:     #0C2231;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .35);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, .45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
}

/* Bootstrap ko hamare tokens par map karein taake template ki CSS bhi follow kare */
:root,
[data-theme] {
  --bs-body-bg:       var(--app-bg);
  --bs-body-color:    var(--text);
  --bs-border-color:  var(--border);
  --bs-primary:       var(--primary);
  --bs-primary-rgb:   99, 102, 241;
  --bs-secondary-color: var(--text-muted);
  --bs-emphasis-color:  var(--text);
  --bs-heading-color:   var(--text);
  --bs-link-color:      var(--primary);
  --bs-link-hover-color: var(--primary-hover);
  --bs-font-sans-serif: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* --------------------------------------------------------------------------
   3. Base
   -------------------------------------------------------------------------- */
* { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--app-bg) !important;
  color: var(--text) !important;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -0.005em;
}

h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.02em;
}

a { text-decoration: none; }
hr { border-color: var(--border); opacity: 1; }

.text-muted, .card-subtitle { color: var(--text-muted) !important; }
.text-body, .text-black, .text-dark { color: var(--text) !important; }
.bg-white { background: var(--surface) !important; }

::selection { background: var(--primary-ring); color: var(--text); }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* --------------------------------------------------------------------------
   4. Layout shell
   -------------------------------------------------------------------------- */
.page-wrapper { background: var(--app-bg); }

.left-sidebar {
  width: var(--sidebar-w) !important;
  background: var(--surface) !important;
  border-right: 1px solid var(--border) !important;
  display: flex;
  flex-direction: column;
}
.left-sidebar > div { display: flex; flex-direction: column; height: 100%; min-height: 0; }

@media (min-width: 1200px) {
  #main-wrapper[data-layout=vertical][data-sidebartype=full] .body-wrapper { margin-left: var(--sidebar-w); }
  #main-wrapper[data-layout=vertical][data-header-position=fixed] .app-header { width: calc(100% - var(--sidebar-w)); }
}

.body-wrapper { border-radius: 0 !important; background: var(--app-bg); }
.body-wrapper .body-wrapper-inner { min-height: calc(100vh - var(--header-h)); }
.body-wrapper .container-fluid { padding: 24px 28px; max-width: 1560px; }

/* Header fixed hai — content ko uske neeche se shuru karein.
   Template ka rule sirf .body-wrapper ke direct child par lagta tha, hamare
   markup me container-fluid ek level andar hai, isliye yahan dobara. */
#main-wrapper[data-header-position=fixed] .body-wrapper-inner { padding-top: var(--header-h); }

@media (max-width: 767px) {
  .body-wrapper .container-fluid { padding: 16px; }
}

/* --------------------------------------------------------------------------
   5. Sidebar — brand
   -------------------------------------------------------------------------- */
.brand-logo {
  height: var(--header-h);
  padding: 0 20px !important;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.brand-logo .brand-mark {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary) 0%, #A855F7 100%);
  color: #fff;
  font-size: 19px;
  box-shadow: 0 4px 12px var(--primary-ring);
  flex-shrink: 0;
}
.brand-logo .brand-text { line-height: 1.15; }
.brand-logo .brand-name {
  font-size: 15px; font-weight: 700; color: var(--text);
  letter-spacing: -0.02em; display: block;
}
.brand-logo .brand-sub {
  font-size: 10.5px; font-weight: 500; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .09em; display: block;
}

/* --------------------------------------------------------------------------
   6. Sidebar — navigation
   -------------------------------------------------------------------------- */
.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px 12px 8px;
}
#sidebarnav { list-style: none; margin: 0; padding: 0; }

.nav-small-cap {
  display: flex; align-items: center;
  padding: 16px 10px 7px;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-muted);
}
.nav-small-cap:first-child { padding-top: 4px; }

.sidebar-item { margin-bottom: 2px; }

.sidebar-item .sidebar-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 13.5px; font-weight: 500;
  transition: background .15s var(--ease), color .15s var(--ease);
  position: relative;
}
.sidebar-item .sidebar-link i,
.sidebar-item .sidebar-link .nav-ico {
  font-size: 19px; width: 20px; flex-shrink: 0;
  display: grid; place-items: center;
  color: var(--text-muted);
  transition: color .15s var(--ease);
}
.sidebar-item .sidebar-link:hover {
  background: var(--surface-3);
  color: var(--text);
}
.sidebar-item .sidebar-link:hover i { color: var(--text-2); }

.sidebar-item .sidebar-link.active,
.sidebar-item .sidebar-link.aactive {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}
.sidebar-item .sidebar-link.active i { color: var(--primary); }
.sidebar-item .sidebar-link.active::before {
  content: '';
  position: absolute; left: -12px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}

.sidebar-link .nav-badge {
  margin-left: auto;
  font-size: 10.5px; font-weight: 600;
  padding: 1px 7px; border-radius: 99px;
  background: var(--surface-3); color: var(--text-muted);
}
.sidebar-link.active .nav-badge { background: var(--primary); color: #fff; }

.sidebar-divider {
  display: block; height: 1px; margin: 12px 10px;
  background: var(--border);
}

/* Sidebar footer card */
.sidebar-foot {
  flex-shrink: 0;
  padding: 12px;
  border-top: 1px solid var(--border);
}
.sidebar-foot .who {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.sidebar-foot .who .meta { min-width: 0; }
.sidebar-foot .who .n {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-foot .who .e {
  font-size: 11.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

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

/* --------------------------------------------------------------------------
   7. Header / topbar
   -------------------------------------------------------------------------- */
.app-header {
  background: color-mix(in srgb, var(--surface) 86%, transparent) !important;
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: none !important;
}
.app-header .navbar {
  min-height: var(--header-h);
  padding: 0 28px;
  display: flex; align-items: center; gap: 16px;
  flex-wrap: nowrap;
  overflow: hidden;   /* navbar kabhi page ko chaura na kare */
}
@media (max-width: 767px) { .app-header .navbar { padding: 0 16px; } }

.topbar-title { min-width: 0; flex: 1 1 auto; }
.topbar-title h1 {
  font-size: 17px; font-weight: 650; margin: 0;
  color: var(--text); letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-crumb {
  font-size: 12px; color: var(--text-muted);
  display: flex; align-items: center; gap: 6px; margin-top: 1px;
}
.topbar-crumb a { color: var(--text-muted); }
.topbar-crumb a:hover { color: var(--primary); }
.topbar-crumb .sep { opacity: .5; }

/* Icon button */
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: inline-grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-2);
  font-size: 19px;
  cursor: pointer;
  transition: all .15s var(--ease);
  position: relative;
}
.icon-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border);
}
.icon-btn .dot {
  position: absolute; top: 8px; right: 9px;
  width: 7px; height: 7px; border-radius: 99px;
  background: var(--danger);
  border: 2px solid var(--surface);
}

/* Topbar search.
   Sidebar 262px kha jata hai, isliye viewport 1200 par bhi jagah tang hoti hai —
   search sirf 1300px se upar dikhta hai warna navbar overflow karta tha. */
.topbar-search { position: relative; width: clamp(170px, 18vw, 260px); flex-shrink: 0; }
.topbar-search i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 17px; pointer-events: none;
}
.topbar-search input {
  width: 100%; height: 38px;
  padding: 0 12px 0 36px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  transition: all .15s var(--ease);
}
.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
@media (max-width: 1299px) { .topbar-search { display: none; } }

/* Avatar */
.avatar {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary) 0%, #A855F7 100%);
  color: #fff; font-weight: 600; font-size: 13px;
  flex-shrink: 0; letter-spacing: .02em;
}
.avatar.sm { width: 30px; height: 30px; border-radius: 8px; font-size: 11.5px; }
.avatar.lg { width: 44px; height: 44px; border-radius: 12px; font-size: 15px; }

/* --------------------------------------------------------------------------
   8. Dropdowns
   -------------------------------------------------------------------------- */
.dropdown-menu {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  min-width: 220px;
  color: var(--text);
}
.dropdown-item {
  border-radius: var(--r-sm);
  padding: 8px 10px;
  font-size: 13.5px;
  color: var(--text-2);
  display: flex; align-items: center; gap: 10px;
}
.dropdown-item i { font-size: 17px; color: var(--text-muted); }
.dropdown-item:hover, .dropdown-item:focus {
  background: var(--surface-3); color: var(--text);
}
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger i { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-soft); color: var(--danger); }
.dropdown-divider { border-color: var(--border); margin: 5px 0; }
.dropdown-head {
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 5px;
}

/* --------------------------------------------------------------------------
   9. Cards
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  margin-bottom: 24px;
  overflow: hidden;
}
.card-body { padding: 22px; }
.card .card { box-shadow: none; margin-bottom: 0; }

/* Vertical rhythm.
   Bootstrap ke `g-*` gutters row par negative margin-top lagate hain, jo pichhli
   row ke card ka margin-bottom kha jata hai aur cards ek dusre se chipak jate hain.
   Isliye grid ke andar spacing rows khud sambhalti hain, cards nahi. */
.body-wrapper .row { margin-top: 0; row-gap: 24px; margin-bottom: 24px; }
.body-wrapper .row > [class*="col"] { padding-top: 0; }
.body-wrapper .row > [class*="col"] > .card,
.body-wrapper .row > [class*="col"] > .stat { margin-bottom: 0; }
.body-wrapper .row:last-child { margin-bottom: 24px; }
/* Nested rows (forms ke andar) apni spacing khud rakhte hain */
.body-wrapper .card .row { margin-bottom: 0; }

.card-title { font-size: 15.5px; font-weight: 600; margin: 0; color: var(--text); }
.card-subtitle { font-size: 13px; color: var(--text-muted); margin: 3px 0 0; }

.card-head {
  display: flex; align-items: center; gap: 16px;
  padding: 17px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.card-head .card-head-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.card-flush .card-body { padding-top: 0; }

/* --------------------------------------------------------------------------
   10. Page header
   -------------------------------------------------------------------------- */
.page-head {
  display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.page-head .page-h1 {
  font-size: 22px; font-weight: 650; margin: 0;
  letter-spacing: -0.025em; color: var(--text);
}
.page-head .page-sub { font-size: 13.5px; color: var(--text-muted); margin: 4px 0 0; }
.page-head .page-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   11. Stat cards
   -------------------------------------------------------------------------- */
.stat {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  height: 100%;
  transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.stat:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat .stat-ico {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  font-size: 22px; flex-shrink: 0;
}
.stat .stat-label {
  font-size: 12px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.stat .stat-value {
  font-size: 27px; font-weight: 700; color: var(--text);
  letter-spacing: -0.03em; line-height: 1.2; margin-top: 3px;
}
.stat .stat-foot { font-size: 12.5px; color: var(--text-muted); margin-top: 5px; }
.stat .trend { font-weight: 600; }
.trend.up   { color: var(--success); }
.trend.down { color: var(--danger); }

.ico-primary { background: var(--primary-soft); color: var(--primary); }
.ico-success { background: var(--success-soft); color: var(--success); }
.ico-warning { background: var(--warning-soft); color: var(--warning); }
.ico-danger  { background: var(--danger-soft);  color: var(--danger); }
.ico-info    { background: var(--info-soft);    color: var(--info); }

/* --------------------------------------------------------------------------
   12. Buttons
   -------------------------------------------------------------------------- */
.btn {
  --bs-btn-focus-box-shadow: 0 0 0 3px var(--primary-ring);
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 550;
  padding: 8.5px 16px;
  border: 1px solid transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: all .15s var(--ease);
  letter-spacing: -0.005em;
  line-height: 1.35;
}
.btn i { font-size: 17px; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-ring); }

.btn-primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background: var(--primary-hover) !important;
  border-color: var(--primary-hover) !important;
  color: #fff !important;
}

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

.btn-light, .btn-secondary, .btn-ghost {
  background: var(--surface); border-color: var(--border); color: var(--text-2);
}
.btn-light:hover, .btn-secondary:hover, .btn-ghost:hover {
  background: var(--surface-3) !important; border-color: var(--border-strong) !important; color: var(--text) !important;
}

.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover, .btn-danger:focus { background: #DC2626 !important; border-color: #DC2626 !important; color: #fff !important; }

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

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

.btn:disabled, .btn.disabled, fieldset:disabled .btn {
  opacity: .45;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
}

.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-sm i { font-size: 15px; }
.btn-lg { padding: 11px 20px; font-size: 15px; border-radius: 12px; }

/* Square action button used in tables */
.btn-act {
  width: 32px; height: 32px; padding: 0;
  border-radius: 8px;
  display: inline-grid; place-items: center;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  transition: all .15s var(--ease);
}
.btn-act i { font-size: 16px; }
.btn-act:hover { background: var(--surface-3); color: var(--text); border-color: var(--border-strong); }
.btn-act.view:hover  { background: var(--info-soft); color: var(--info); border-color: var(--info); }
.btn-act.edit:hover  { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }
.btn-act.del:hover   { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }

/* --------------------------------------------------------------------------
   13. Forms
   -------------------------------------------------------------------------- */
.form-label {
  font-size: 13px; font-weight: 550; color: var(--text-2);
  margin-bottom: 6px; letter-spacing: -0.005em;
}
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control, .form-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13.5px;
  padding: 9px 13px;
  min-height: 40px;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus, .form-select:focus {
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-ring);
  color: var(--text);
}
.form-control:disabled, .form-control[readonly] {
  background: var(--surface-3); color: var(--text-muted);
}
textarea.form-control { min-height: 110px; line-height: 1.6; }
.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='%237C889C' 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 12px center;
  background-size: 15px 15px;
  padding-right: 36px;
  -webkit-appearance: none;
  appearance: none;
}
.form-text { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

.form-check-input {
  border-color: var(--border-strong);
  background-color: var(--surface);
  width: 17px; height: 17px; margin-top: .18em;
}
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-ring); }
.form-check-label { font-size: 13.5px; color: var(--text-2); }

.input-group-text {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text-muted);
  border-radius: 10px;
  font-size: 13.5px;
}

/* Password reveal */
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 42px; }
.pw-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; border: 0; background: transparent;
  border-radius: 8px; color: var(--text-muted); cursor: pointer;
  display: grid; place-items: center; font-size: 17px;
}
.pw-toggle:hover { background: var(--surface-3); color: var(--text); }

/* Form section */
.form-section { padding: 22px; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: 0; }
.form-section-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.form-section-sub { font-size: 12.5px; color: var(--text-muted); margin-bottom: 18px; }

.form-actions {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 22px;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
}
.form-actions .spacer { margin-left: auto; }

/* Sticky save bar at the bottom of forms */
.form-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 20px;
  margin-top: 4px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
}
.form-bar .hint { font-size: 12.5px; color: var(--text-muted); }
.form-bar .spacer { margin-left: auto; }

/* Image / file picker with preview */
.filedrop {
  position: relative;
  display: block;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface-2);
  padding: 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.filedrop:hover { border-color: var(--primary); background: var(--primary-soft); }
.filedrop input[type=file] {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.filedrop .fd-ico {
  width: 40px; height: 40px; margin: 0 auto 9px;
  border-radius: 11px; display: grid; place-items: center;
  background: var(--surface-3); color: var(--text-muted); font-size: 20px;
}
.filedrop .fd-title { font-size: 13.5px; font-weight: 550; color: var(--text); }
.filedrop .fd-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.filedrop .fd-name {
  font-size: 12.5px; color: var(--primary); font-weight: 550;
  margin-top: 8px; word-break: break-all;
}

.file-preview {
  width: 100%; aspect-ratio: 16 / 10;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--surface-3);
  object-fit: cover;
  display: block;
}
.file-preview-empty {
  width: 100%; aspect-ratio: 16 / 10;
  border-radius: var(--r-md);
  border: 1px dashed var(--border-strong);
  background: var(--surface-2);
  display: grid; place-items: center;
  color: var(--text-muted); font-size: 30px;
}

/* Repeater rows (game sets, and any other add-many form) */
.repeat-row {
  position: relative;
  padding: 16px 16px 16px 46px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface-2);
  margin-bottom: 12px;
}
.repeat-row .repeat-num {
  position: absolute; left: 14px; top: 16px;
  width: 22px; height: 22px; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
  font-size: 11.5px; font-weight: 700;
}
.repeat-row .repeat-remove {
  position: absolute; right: 12px; top: 12px;
  width: 28px; height: 28px; border-radius: 7px;
  display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-muted); cursor: pointer; font-size: 15px;
  transition: all .15s var(--ease);
}
.repeat-row .repeat-remove:hover {
  background: var(--danger-soft); color: var(--danger); border-color: var(--danger);
}
.repeat-empty {
  padding: 26px; text-align: center;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  color: var(--text-muted); font-size: 13.5px;
}

/* Inline field error */
.field-error { font-size: 12.5px; color: var(--danger); margin-top: 5px; }
.form-control.is-invalid, .form-select.is-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 18%, transparent);
}

/* --------------------------------------------------------------------------
   14. Tables
   -------------------------------------------------------------------------- */
.table-wrap { border-radius: var(--r-lg); overflow: hidden; }
.table-responsive { overflow-x: auto; }

.table {
  --bs-table-bg: transparent;
  --bs-table-color: var(--text);
  margin-bottom: 0;
  border-color: var(--border);
  font-size: 13.5px;
  color: var(--text);
}
.table > :not(caption) > * > * { background: transparent; color: var(--text); }

.table thead th {
  background: var(--surface-2) !important;
  color: var(--text-muted) !important;
  font-size: 11.5px !important;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 11px 14px !important;
  border-bottom: 1px solid var(--border);
  border-top: 1px solid var(--border);
  white-space: nowrap;
  vertical-align: middle;
}
.table tbody td {
  padding: 13px 14px !important;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text-2);
  font-size: 13.5px !important;
}
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover > td { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }

.table .cell-strong { color: var(--text); font-weight: 550; }
.table .cell-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; color: var(--text-muted);
}
.table .cell-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--text-muted);
}
.table .cell-actions { text-align: right; white-space: nowrap; }
.table .cell-actions .btn-act + .btn-act { margin-left: 5px; }
.table .cell-clamp {
  max-width: 300px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; display: inline-block; vertical-align: middle;
}
.table .thumb {
  width: 42px; height: 42px; border-radius: 9px; object-fit: cover;
  border: 1px solid var(--border); background: var(--surface-3);
}

/* Toolbar above tables */
.table-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}
.table-toolbar .spacer { margin-left: auto; }
.tbl-search { position: relative; min-width: 240px; }
.tbl-search i {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 17px; pointer-events: none;
}
.tbl-search input { padding-left: 36px; }

/* --------------------------------------------------------------------------
   15. Badges
   -------------------------------------------------------------------------- */
.badge, .chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3.5px 9px;
  border-radius: 7px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1.4;
}
.chip::before {
  content: ''; width: 6px; height: 6px; border-radius: 99px;
  background: currentColor; flex-shrink: 0;
}
.chip-success { background: var(--success-soft); color: var(--success); }
.chip-danger  { background: var(--danger-soft);  color: var(--danger); }
.chip-warning { background: var(--warning-soft); color: var(--warning); }
.chip-info    { background: var(--info-soft);    color: var(--info); }
.chip-primary { background: var(--primary-soft); color: var(--primary); }
.chip-muted   { background: var(--surface-3);    color: var(--text-muted); }
.chip-muted::before { opacity: .6; }

/* --------------------------------------------------------------------------
   16. Pagination
   -------------------------------------------------------------------------- */
.pager {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px 22px;
  border-top: 1px solid var(--border);
}
.pager .pager-info { font-size: 13px; color: var(--text-muted); }
.pager .pagination { margin: 0 0 0 auto; gap: 4px; }

.pagination .page-link {
  min-width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px !important;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px; font-weight: 550;
  padding: 0 10px;
  transition: all .15s var(--ease);
}
.pagination .page-link:hover {
  background: var(--surface-3); color: var(--text);
  border-color: var(--border-strong); z-index: 1;
}
.pagination .page-item.active .page-link {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.pagination .page-item.disabled .page-link {
  background: var(--surface-2); color: var(--text-muted); opacity: .6;
}

/* --------------------------------------------------------------------------
   17. Alerts & toasts
   -------------------------------------------------------------------------- */
.alert {
  border-radius: var(--r-md);
  border: 1px solid transparent;
  font-size: 13.5px;
  padding: 12px 15px;
  display: flex; align-items: flex-start; gap: 10px;
}
.alert i { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 22%, transparent); }
.alert-info    { background: var(--info-soft);    color: var(--info);    border-color: color-mix(in srgb, var(--info) 22%, transparent); }

#toast-stack {
  position: fixed; top: 18px; right: 18px; z-index: 1080;
  display: flex; flex-direction: column; gap: 10px;
  pointer-events: none;
}
.toast-item {
  pointer-events: auto;
  min-width: 290px; max-width: 380px;
  display: flex; align-items: flex-start; gap: 11px;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px; color: var(--text);
  animation: toast-in .25s var(--ease);
}
.toast-item.ok  { border-left-color: var(--success); }
.toast-item.err { border-left-color: var(--danger); }
.toast-item i { font-size: 19px; flex-shrink: 0; }
.toast-item.ok i  { color: var(--success); }
.toast-item.err i { color: var(--danger); }
.toast-item .x {
  margin-left: auto; border: 0; background: transparent;
  color: var(--text-muted); cursor: pointer; font-size: 17px; line-height: 1;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* --------------------------------------------------------------------------
   18. Modals
   -------------------------------------------------------------------------- */
.modal-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.modal-header, .modal-footer { border-color: var(--border); padding: 16px 20px; }
.modal-body { padding: 20px; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-backdrop.show { opacity: .45; }

/* --------------------------------------------------------------------------
   19. Empty state
   -------------------------------------------------------------------------- */
.empty {
  padding: 56px 24px;
  text-align: center;
}
.empty .empty-ico {
  width: 58px; height: 58px; margin: 0 auto 16px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: 27px;
}
.empty h5 { font-size: 15px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.empty p { font-size: 13.5px; color: var(--text-muted); margin-bottom: 18px; }

/* --------------------------------------------------------------------------
   20. Auth / login page
   -------------------------------------------------------------------------- */
.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  background: var(--app-bg);
}
@media (min-width: 992px) { .auth { grid-template-columns: 1.05fr 1fr; } }

.auth-aside {
  display: none;
  position: relative;
  overflow: hidden;
  padding: 52px;
  color: #fff;
  background:
    radial-gradient(1000px 600px at 12% 8%, rgba(168, 85, 247, .55), transparent 60%),
    radial-gradient(800px 620px at 88% 92%, rgba(56, 189, 248, .38), transparent 60%),
    linear-gradient(150deg, #4338CA 0%, #4F46E5 42%, #312E81 100%);
}
@media (min-width: 992px) { .auth-aside { display: flex; flex-direction: column; } }

.auth-aside::after {
  content: '';
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: radial-gradient(circle at 30% 30%, #000, transparent 78%);
  mask-image: radial-gradient(circle at 30% 30%, #000, transparent 78%);
  pointer-events: none;
}
.auth-aside > * { position: relative; z-index: 1; }

.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand .mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-size: 22px;
  background: rgba(255,255,255,.16);
  border: 1px solid rgba(255,255,255,.24);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}
.auth-brand .name { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }

.auth-aside .headline {
  margin-top: auto;
  font-size: 34px; font-weight: 700; line-height: 1.2;
  letter-spacing: -.03em; max-width: 15ch;
}
.auth-aside .sub {
  margin-top: 14px; font-size: 15px; line-height: 1.65;
  color: rgba(255,255,255,.78); max-width: 42ch;
}
.auth-stats {
  margin-top: 40px; display: flex; gap: 40px;
  padding-top: 26px; border-top: 1px solid rgba(255,255,255,.16);
}
.auth-stats .v { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.auth-stats .k { font-size: 12px; color: rgba(255,255,255,.7); text-transform: uppercase; letter-spacing: .08em; margin-top: 2px; }

.auth-main {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px;
  background: var(--surface);
}
.auth-card { width: 100%; max-width: 396px; }
.auth-card .eyebrow {
  font-size: 11.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--primary); margin-bottom: 10px;
}
.auth-card h2 { font-size: 26px; font-weight: 680; letter-spacing: -.03em; margin-bottom: 7px; }
.auth-card .lead-sub { font-size: 14px; color: var(--text-muted); margin-bottom: 26px; }
.auth-foot { margin-top: 28px; font-size: 12.5px; color: var(--text-muted); text-align: center; }

.auth-mobile-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 30px; }
@media (min-width: 992px) { .auth-mobile-brand { display: none; } }
.auth-mobile-brand .mark {
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center; font-size: 21px; color: #fff;
  background: linear-gradient(135deg, var(--primary) 0%, #A855F7 100%);
}

.auth-theme-btn { position: fixed; top: 18px; right: 18px; z-index: 5; }

/* --------------------------------------------------------------------------
   21. Misc / utilities
   -------------------------------------------------------------------------- */
.soft-divider { height: 1px; background: var(--border); margin: 20px 0; }
.fw-550 { font-weight: 550; }
.fs-13 { font-size: 13px; }
.fs-12 { font-size: 12px; }
.text-primary { color: var(--primary) !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* Template overrides that used hardcoded colors */
.text-bg-light { background: var(--app-bg) !important; color: var(--text) !important; }
.border, .border-top, .border-bottom, .border-start, .border-end { border-color: var(--border) !important; }
.bg-light { background: var(--surface-2) !important; }

/* ApexCharts in dark mode */
[data-theme="dark"] .apexcharts-tooltip {
  background: var(--surface-3) !important;
  border-color: var(--border) !important;
  color: var(--text) !important;
  box-shadow: var(--shadow-lg) !important;
}
[data-theme="dark"] .apexcharts-tooltip-title {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
}
[data-theme="dark"] .apexcharts-text tspan { fill: var(--text-muted); }
[data-theme="dark"] .apexcharts-gridline { stroke: var(--border); }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
