/* ====================================================
   1. VARIABLES & THEMING
   ==================================================== */
:root {
  --bg:        #0d0d11;
  --surface:   #141419;
  --surface-2: #1b1b23;
  --surface-3: #23232e;
  --border:    #2c2c3c;
  --text:      #e4e4f0;
  --text-sub:  #9a9ab8;
  --text-muted:#5a5a78;
  --blue:      #4f9eff;
  --blue-bg:   rgba(79,158,255,.10);
  --green:     #22c55e;
  --green-bg:  rgba(34,197,94,.10);
  --amber:     #f59e0b;
  --amber-bg:  rgba(245,158,11,.10);
  --red:       #f43f5e;
  --red-bg:    rgba(244,63,94,.10);
  --purple:    #a855f7;
  
  --r:  8px;
  --rl: 12px;
  --sidebar-w: 220px;
  --header-h:  52px;
  --transition: 0.2s cubic-bezier(.4,0,.2,1);
}

/* ====================================================
   2. RESET & BASE ELEMENTS
   ==================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html, body {
  height: 100%;
  overflow: hidden;
}
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
}
button {
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}
input, textarea, select {
  font-family: inherit;
  color: var(--text);
  background: none;
  border: none;
  outline: none;
}

/* Lucide Icon override */
[data-lucide] {
  width: 15px;
  height: 15px;
  stroke-width: 1.8;
  flex-shrink: 0;
}

/* ====================================================
   3. UNIVERSAL COMPONENTS
   ==================================================== */

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r);
  font-weight: 500;
  cursor: pointer;
  font-size: 13px;
  transition: background var(--transition), opacity var(--transition);
}
.btn-primary {
  background: var(--blue);
  color: #fff;
}
.btn-primary:hover {
  background: #60aaff;
}
.btn-secondary {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-sub);
}
.btn-secondary:hover {
  background: var(--surface-3);
  color: var(--text);
}
.btn-danger {
  background: var(--red-bg);
  border: 1px solid rgba(244,63,94,.2);
  color: var(--red);
}
.btn-danger:hover {
  background: rgba(244,63,94,.2);
}
.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
}
.btn-xs {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: 5px;
}

/* --- Badges --- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.bdg-blue   { background: var(--blue-bg);   color: var(--blue);   border: 1px solid rgba(79,158,255,.2); }
.bdg-green  { background: var(--green-bg);  color: var(--green);  border: 1px solid rgba(34,197,94,.2); }
.bdg-amber  { background: var(--amber-bg);  color: var(--amber);  border: 1px solid rgba(245,158,11,.2); }
.bdg-red    { background: var(--red-bg);    color: var(--red);    border: 1px solid rgba(244,63,94,.2); }
.bdg-gray   { background: rgba(255,255,255,.05); color: var(--text-sub); border: 1px solid var(--border); }
.bdg-purple { background: rgba(168,85,247,.1);  color: var(--purple); border: 1px solid rgba(168,85,247,.2); }
.bdg-dot::before {
  content: '';
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

/* --- Avatar --- */
.av {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.av-sm { width: 26px; height: 26px; font-size: 10px; }
.av-md { width: 32px; height: 32px; font-size: 12px; }
.av-lg { width: 40px; height: 40px; font-size: 15px; }

/* --- General Card --- */
.card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--rl);
  padding: 16px;
  position: relative;
}
.card-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--text);
}
.card-title [data-lucide] {
  color: var(--text-muted);
}
.card-lock-hint {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 11px;
}

/* --- Page Header --- */
.pg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.pg-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.5px;
}

/* --- Tabs --- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab {
  padding: 8px 16px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}
.tab:hover {
  color: var(--text-sub);
}
.tab.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
}

/* --- Breadcrumbs --- */
.tb-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-sub);
  font-size: 13px;
}
.tb-breadcrumb .current {
  color: var(--text);
  font-weight: 600;
}
.tb-crumb-link {
  cursor: pointer;
  transition: color var(--transition);
}
.tb-crumb-link:hover {
  color: var(--blue);
}

/* --- General Scrollbar Utility --- */
.scroll-y {
  overflow-y: auto;
  flex: 1;
}
.scroll-y::-webkit-scrollbar {
  width: 4px;
}
.scroll-y::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.scroll-y::-webkit-scrollbar-track {
  background: transparent;
}

/* ====================================================
   4. SYSTEM MODAL
   ==================================================== */
#modal-wrap {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .65);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
#modal-wrap.hidden {
  display: none;
}
#modal-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: 420px;
  max-width: 92vw;
  box-shadow: 0 24px 80px rgba(0, 0, 0, .7);
  overflow: hidden;
}
#modal-hd {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border);
}
#modal-title {
  font-size: 15px;
  font-weight: 600;
}
#modal-body {
  padding: 20px;
  font-size: 13px;
  color: var(--text-sub);
  line-height: 1.65;
}
#modal-body label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
}
#modal-body .form-group {
  margin-bottom: 12px;
}
#modal-body .form-group:last-child {
  margin-bottom: 0;
}
#modal-body input, #modal-body select, #modal-body textarea {
  width: 100%;
  background: var(--surface-3);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 8px 12px;
  font-size: 13px;
}
#modal-body textarea {
  resize: vertical;
  height: 80px;
}
#modal-ft {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.modal-x {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: background var(--transition);
}
.modal-x:hover {
  background: var(--surface-3);
}

/* ====================================================
   5. DESIGN SWITCHER FAB
   ==================================================== */
#dswitch-wrap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}
#dswitch-fab {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(79, 158, 255, .45);
  transition: transform .2s, box-shadow .2s;
}
#dswitch-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(79, 158, 255, .6);
}
#dswitch-fab [data-lucide] {
  width: 18px;
  height: 18px;
}
#dswitch-panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 13px;
  padding: 16px;
  width: 220px;
  box-shadow: 0 16px 60px rgba(0,0,0,.55);
}
#dswitch-panel.hidden {
  display: none;
}
.sp-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.sp-sec {
  margin-bottom: 12px;
}
.sp-sec:last-child {
  margin-bottom: 0;
}
.sp-sec-lbl {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-sub);
  margin-bottom: 6px;
}
.sp-opts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}
.sp-opt {
  padding: 6px 2px;
  border-radius: 7px;
  font-size: 10px;
  font-weight: 600;
  background: var(--surface-3);
  border: 1px solid var(--border);
  color: var(--text-sub);
  text-align: center;
  transition: all var(--transition);
}
.sp-opt:hover {
  color: var(--text);
}
.sp-opt.active {
  background: var(--blue-bg);
  border-color: var(--blue);
  color: var(--blue);
}
.empty-state {
  text-align: center;
  padding: 50px;
  color: var(--text-muted);
}
