/* ==========================================================================
   RedDevonix Licensing Platform — Enterprise Design System (v2.0)
   Designed for Senior SaaS UI/UX Standards
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design Tokens & CSS Variables
   -------------------------------------------------------------------------- */
:root {
  /* Brand Theme Overrides (Defaults) */
  --primary: #0f172a;
  --secondary: #334155;
  --accent: #e11d48;
  --accent-rgb: 225, 29, 72;
  --accent-soft: rgba(225, 29, 72, 0.10);
  --accent-hover: #be123c;

  /* Surfaces & Canvas */
  --bg: #f8fafc;
  --bg-subtle: #f1f5f9;
  --card: #ffffff;
  --card-2: #f8fafc;
  --card-elevated: #ffffff;
  --surface-border: #e2e8f0;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  /* Typography Colors */
  --text: #0f172a;
  --text-secondary: #475569;
  --muted: #64748b;
  --muted-light: #94a3b8;

  /* Sidebar Tokens (Navy Default) */
  --sidebar-bg: #0b1329;
  --sidebar-bg-glass: rgba(11, 19, 41, 0.95);
  --sidebar-surface: rgba(255, 255, 255, 0.04);
  --sidebar-surface-hover: rgba(255, 255, 255, 0.08);
  --sidebar-text: #e2e8f0;
  --sidebar-text-secondary: #94a3b8;
  --sidebar-muted: #64748b;
  --sidebar-border: rgba(255, 255, 255, 0.07);
  --sidebar-active: rgba(225, 29, 72, 0.16);
  --sidebar-active-text: #ffffff;
  --sidebar-active-border: var(--accent);

  /* Status Tokens */
  --ok: #10b981;
  --ok-bg: #ecfdf5;
  --ok-border: rgba(16, 185, 129, 0.25);
  --ok-text: #047857;

  --warn: #f59e0b;
  --warn-bg: #fffbeb;
  --warn-border: rgba(245, 158, 11, 0.25);
  --warn-text: #b45309;

  --bad: #ef4444;
  --bad-bg: #fef2f2;
  --bad-border: rgba(239, 68, 68, 0.25);
  --bad-text: #b91c1c;

  --info: #3b82f6;
  --info-bg: #eff6ff;
  --info-border: rgba(59, 130, 246, 0.25);
  --info-text: #1d4ed8;

  --purple: #8b5cf6;
  --purple-bg: #f5f3ff;
  --purple-border: rgba(139, 92, 246, 0.25);
  --purple-text: #6d28d9;

  /* Geometry & Elevation */
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-xs: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 1px 3px 0 rgba(15, 23, 42, 0.06), 0 1px 2px -1px rgba(15, 23, 42, 0.06);
  --shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 25px -4px rgba(15, 23, 42, 0.08), 0 4px 8px -4px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 35px -6px rgba(15, 23, 42, 0.12), 0 8px 12px -6px rgba(15, 23, 42, 0.06);

  /* Topbar */
  --topbar-bg: rgba(255, 255, 255, 0.85);
  --topbar-border: rgba(226, 232, 240, 0.8);
}

/* --------------------------------------------------------------------------
   2. Dark Mode Overrides
   -------------------------------------------------------------------------- */
body.mode-dark {
  --bg: #080d1a;
  --bg-subtle: #0f172a;
  --card: #0f172a;
  --card-2: #162036;
  --card-elevated: #1a253f;
  --surface-border: #1e293b;
  --border: #1e293b;
  --border-light: #162036;

  --text: #f8fafc;
  --text-secondary: #cbd5e1;
  --muted: #94a3b8;
  --muted-light: #64748b;

  --topbar-bg: rgba(15, 23, 42, 0.85);
  --topbar-border: rgba(30, 41, 59, 0.8);

  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.2);
  --shadow-sm: 0 2px 4px 0 rgba(0, 0, 0, 0.25);
  --shadow: 0 4px 20px 0 rgba(0, 0, 0, 0.4);
  --shadow-md: 0 12px 30px 0 rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 24px 50px 0 rgba(0, 0, 0, 0.55);

  --ok-bg: rgba(16, 185, 129, 0.14);
  --ok-text: #34d399;
  --warn-bg: rgba(245, 158, 11, 0.14);
  --warn-text: #fbbf24;
  --bad-bg: rgba(239, 68, 68, 0.14);
  --bad-text: #f87171;
  --info-bg: rgba(59, 130, 246, 0.14);
  --info-text: #60a5fa;
  --purple-bg: rgba(139, 92, 246, 0.14);
  --purple-text: #a78bfa;
}

/* --------------------------------------------------------------------------
   3. Theme Variations (Look, Shape, Sidebar)
   -------------------------------------------------------------------------- */
body.shape-squared {
  --radius: 4px;
  --radius-sm: 3px;
  --radius-lg: 6px;
  --radius-xl: 8px;
}

body.shape-glass .card,
body.shape-glass .kpi-card,
body.shape-glass .topbar {
  background: color-mix(in srgb, var(--card) 85%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

body.sidebar-theme {
  --sidebar-bg: var(--primary);
  --sidebar-bg-glass: color-mix(in srgb, var(--primary) 95%, transparent);
  --sidebar-active: color-mix(in srgb, var(--accent) 24%, var(--primary));
  --sidebar-active-border: var(--accent);
}

body.sidebar-light {
  --sidebar-bg: #ffffff;
  --sidebar-bg-glass: rgba(255, 255, 255, 0.95);
  --sidebar-surface: #f8fafc;
  --sidebar-surface-hover: #f1f5f9;
  --sidebar-text: #0f172a;
  --sidebar-text-secondary: #475569;
  --sidebar-muted: #64748b;
  --sidebar-border: #e2e8f0;
  --sidebar-active: rgba(225, 29, 72, 0.08);
  --sidebar-active-text: var(--accent);
  --sidebar-active-border: var(--accent);
}

body.look-classic .card-head {
  background: var(--primary);
  color: #fff;
  margin: -20px -22px 18px;
  padding: 14px 22px;
  border-radius: var(--radius) var(--radius) 0 0;
}
body.look-classic .card-head .muted { color: #cbd5e1; }

/* --------------------------------------------------------------------------
   4. Global Reset & Typography
   -------------------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  font-size: 14px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Elegant Global Custom Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
}
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.3);
  border-radius: 9999px;
  transition: background 0.2s;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.55);
}

a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover {
  color: var(--accent-hover);
  text-decoration: none;
}

/* --------------------------------------------------------------------------
   5. App Shell & Layout
   -------------------------------------------------------------------------- */
.shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  position: relative;
}

/* --------------------------------------------------------------------------
   6. Sidebar Architecture (Ultra-Polished & Zero White Scrollbar)
   -------------------------------------------------------------------------- */
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden; /* Ensures sidebar itself never creates an outer scrollbar */
}

/* Sidebar Brand Header */
.sb-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sb-brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.sb-brand-text {
  min-width: 0;
  flex: 1;
}
.sb-brand-title {
  display: flex;
  align-items: center;
  gap: 6px;
}
.sb-brand-title strong {
  font-size: 14.5px;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -0.01em;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
body.sidebar-light .sb-brand-title strong {
  color: var(--text);
}
.sb-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  flex-shrink: 0;
  display: inline-block;
}
.sb-brand-subtitle {
  color: var(--sidebar-muted);
  font-size: 11px;
  font-weight: 500;
  display: block;
  margin-top: 1px;
}

/* Sidebar Quick Search Button */
.sb-search-btn {
  margin: 12px 14px 6px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--sidebar-border);
  background: var(--sidebar-surface);
  color: var(--sidebar-text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 12.5px;
  font-family: inherit;
  transition: all 0.15s ease;
  flex-shrink: 0;
}
.sb-search-btn:hover {
  background: var(--sidebar-surface-hover);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}
body.sidebar-light .sb-search-btn {
  background: var(--sidebar-surface);
  border-color: var(--border);
  color: var(--muted);
}
body.sidebar-light .sb-search-btn:hover {
  background: var(--sidebar-surface-hover);
  color: var(--text);
}
.sb-search-btn .sb-search-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.sb-search-btn svg {
  width: 14px;
  height: 14px;
  opacity: 0.7;
}
.sb-search-btn kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--sidebar-muted);
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  padding: 1px 5px;
  border-radius: 4px;
  font-weight: 600;
}
body.sidebar-light .sb-search-btn kbd {
  background: #ffffff;
  border-color: var(--border);
  color: var(--muted);
}

/* Sidebar Navigation Items & Scrollbar */
.sb-nav {
  padding: 10px 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  /* Premium Dark Scrollbar for Sidebar */
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}
.sb-nav::-webkit-scrollbar {
  width: 4px;
}
.sb-nav::-webkit-scrollbar-track {
  background: transparent;
}
.sb-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 9999px;
}
.sb-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.28);
}
body.sidebar-light .sb-nav {
  scrollbar-color: rgba(0, 0, 0, 0.12) transparent;
}
body.sidebar-light .sb-nav::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
}

.sb-group {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-muted);
  padding: 14px 10px 6px;
  font-weight: 700;
}
.sb-group:first-child {
  padding-top: 4px;
}

.sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text-secondary);
  font-weight: 500;
  font-size: 13px;
  margin-bottom: 2px;
  transition: all 0.15s ease;
  position: relative;
  text-decoration: none;
}
.sb-link svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
  opacity: 0.75;
  transition: opacity 0.15s, transform 0.15s;
}
.sb-link:hover {
  background: var(--sidebar-surface-hover);
  color: #ffffff;
  text-decoration: none;
}
.sb-link:hover svg {
  opacity: 1;
  transform: scale(1.05);
}
body.sidebar-light .sb-link:hover {
  background: var(--sidebar-surface-hover);
  color: var(--text);
}

.sb-link.active {
  background: var(--sidebar-active);
  color: var(--sidebar-active-text);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--sidebar-active-border);
}
.sb-link.active svg {
  opacity: 1;
  color: var(--accent);
}
body.sidebar-light .sb-link.active {
  background: rgba(225, 29, 72, 0.08);
  color: var(--accent);
  box-shadow: inset 3px 0 0 var(--accent);
}

.sb-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  line-height: 1.4;
  box-shadow: 0 2px 6px rgba(225, 29, 72, 0.35);
}

/* --------------------------------------------------------------------------
   7. Sidebar Footer (Sleek Senior Designer Redesign)
   -------------------------------------------------------------------------- */
.sb-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--sidebar-border);
  background: rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
}
body.sidebar-light .sb-foot {
  background: #fafbfc;
  border-top-color: var(--border);
}

.sb-user-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sb-user-main {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 2px 2px;
}

.avatar-wrap {
  position: relative;
  flex-shrink: 0;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  background: linear-gradient(135deg, var(--accent), #be123c);
  color: #ffffff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.status-indicator {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 2px solid var(--sidebar-bg);
}
.status-indicator.online {
  background: #10b981;
}

.sb-user-info {
  flex: 1;
  min-width: 0;
}
.sb-user-name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}
body.sidebar-light .sb-user-name {
  color: var(--text);
}
.sb-user-role {
  display: inline-block;
  font-size: 10.5px;
  color: var(--sidebar-muted);
  font-weight: 500;
  line-height: 1.2;
}

/* Elegant Quick Action Toolbar */
.sb-foot-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
body.sidebar-light .sb-foot-actions {
  background: #ffffff;
  border-color: var(--border);
}

.sb-action-form {
  margin: 0;
  display: contents;
}

.sb-foot-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border-radius: 6px;
  background: transparent;
  color: var(--sidebar-text-secondary);
  border: 0;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  text-decoration: none;
}
.sb-foot-btn svg {
  width: 15px;
  height: 15px;
  opacity: 0.8;
  transition: all 0.15s;
}
.sb-foot-btn:hover {
  background: var(--sidebar-surface-hover);
  color: #ffffff;
  text-decoration: none;
}
.sb-foot-btn:hover svg {
  opacity: 1;
  transform: scale(1.1);
}
body.sidebar-light .sb-foot-btn {
  color: var(--muted);
}
body.sidebar-light .sb-foot-btn:hover {
  background: #f1f5f9;
  color: var(--text);
}

.sb-foot-btn-danger:hover {
  background: rgba(239, 68, 68, 0.15) !important;
  color: #f87171 !important;
}

/* --------------------------------------------------------------------------
   8. Main Content & Sticky Glass Topbar
   -------------------------------------------------------------------------- */
.main-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--topbar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--topbar-border);
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 30;
  transition: background 0.2s, border-color 0.2s;
}

.tb-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.menu-toggle {
  display: none;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  cursor: pointer;
  color: var(--text);
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.menu-toggle:hover {
  background: var(--card-2);
}
.menu-toggle svg {
  width: 18px;
  height: 18px;
}

.page-title-bar h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
}
.breadcrumb {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 500;
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb span {
  opacity: 0.6;
}

.tb-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tb-search {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  width: 270px;
  cursor: pointer;
  color: var(--muted);
  font-size: 13px;
  font-family: inherit;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-xs);
}
.tb-search:hover {
  border-color: var(--muted-light);
  color: var(--text);
  background: var(--card-2);
}
.tb-search svg {
  width: 15px;
  height: 15px;
  opacity: 0.65;
  flex-shrink: 0;
}
.tb-search span {
  flex: 1;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-search kbd {
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, monospace;
  color: var(--muted);
  font-weight: 600;
}

/* Modern Icon Buttons in Topbar */
.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text-secondary);
  display: grid;
  place-items: center;
  position: relative;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-xs);
  text-decoration: none;
}
.icon-btn svg {
  width: 17px;
  height: 17px;
  transition: transform 0.15s;
}
.icon-btn:hover {
  background: var(--card-2);
  color: var(--text);
  border-color: var(--muted-light);
  text-decoration: none;
}
.icon-btn:hover svg {
  transform: scale(1.08);
}
.icon-btn .dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}

/* User pill in topbar */
.tb-user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-xs);
}
.tb-user-pill:hover {
  background: var(--card-2);
  border-color: var(--muted-light);
  text-decoration: none;
}
.tb-user-pill .avatar {
  width: 26px;
  height: 26px;
  font-size: 11px;
  border-radius: 50%;
}
.tb-user-pill .tb-user-role-badge {
  background: var(--card-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 10.5px;
  padding: 1px 6px;
  border-radius: var(--radius-full);
  font-weight: 500;
}

.content {
  padding: 24px 28px 48px;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
}

/* --------------------------------------------------------------------------
   9. Cards, Panels & Grid System
   -------------------------------------------------------------------------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.card-head h2,
.card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.muted { color: var(--muted); }
.small { font-size: 12px; }

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 20px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
}
.grid-eq-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
}
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* --------------------------------------------------------------------------
   10. High-End KPI Stats Cards
   -------------------------------------------------------------------------- */
.kpi-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px 0;
  box-shadow: var(--shadow);
  overflow: hidden;
  position: relative;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s, border-color 0.2s;
  display: flex;
  flex-direction: column;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--muted-light);
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.kpi-val {
  font-size: 30px;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.03em;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.kpi-lbl {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-top: 4px;
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.kpi-card:hover .kpi-icon {
  transform: scale(1.06);
}
.kpi-icon svg {
  width: 22px;
  height: 22px;
}

.kpi-ok {
  background: var(--ok-bg);
  color: var(--ok-text);
  border: 1px solid var(--ok-border);
}
.kpi-neutral {
  background: var(--info-bg);
  color: var(--info-text);
  border: 1px solid var(--info-border);
}
.kpi-warn {
  background: var(--warn-bg);
  color: var(--warn-text);
  border: 1px solid var(--warn-border);
}
.kpi-bad {
  background: var(--bad-bg);
  color: var(--bad-text);
  border: 1px solid var(--bad-border);
}

.kpi-foot {
  margin: auto -20px 0;
  padding: 10px 20px;
  font-size: 12px;
  font-weight: 600;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-2);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all 0.15s ease;
}
.kpi-foot svg {
  width: 14px;
  height: 14px;
  transition: transform 0.15s ease;
}
.kpi-card:hover .kpi-foot {
  color: var(--accent);
  background: var(--card);
  text-decoration: none;
}
.kpi-card:hover .kpi-foot svg {
  transform: translateX(3px);
}

/* --------------------------------------------------------------------------
   11. Quota & Progress Bars
   -------------------------------------------------------------------------- */
.quota-bar {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 14px 20px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow);
}
.quota-bar b {
  font-size: 14px;
  display: block;
  color: var(--text);
}
.progress-track {
  flex: 1;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--border);
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #f43f5e);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

/* --------------------------------------------------------------------------
   12. Pipeline Tabs (Segmented Control Filters)
   -------------------------------------------------------------------------- */
.pipeline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  background: var(--card-2);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  width: fit-content;
}
.pipe-tab {
  padding: 6px 12px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
}
.pipe-tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.4);
  text-decoration: none;
}
body.mode-dark .pipe-tab:hover {
  background: rgba(255, 255, 255, 0.05);
}
.pipe-tab.active {
  background: var(--card);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}
.pipe-tab .cnt {
  background: var(--border);
  color: var(--muted);
  padding: 1px 7px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
}
.pipe-tab.active .cnt {
  background: var(--accent-soft);
  color: var(--accent);
}

/* --------------------------------------------------------------------------
   13. Badges & Status Indicators
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.01em;
  border: 1px solid transparent;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.b-active {
  background: var(--ok-bg);
  color: var(--ok-text);
  border-color: var(--ok-border);
}
.b-active::before {
  background: var(--ok);
  box-shadow: 0 0 6px var(--ok);
}

.b-not_used {
  background: var(--info-bg);
  color: var(--info-text);
  border-color: var(--info-border);
}
.b-not_used::before {
  background: var(--info);
}

.b-ending_soon,
.b-paused {
  background: var(--warn-bg);
  color: var(--warn-text);
  border-color: var(--warn-border);
}
.b-ending_soon::before,
.b-paused::before {
  background: var(--warn);
}

.b-expired,
.b-cancelled,
.b-device_removed,
.b-suspended {
  background: var(--bad-bg);
  color: var(--bad-text);
  border-color: var(--bad-border);
}
.b-expired::before,
.b-cancelled::before,
.b-device_removed::before,
.b-suspended::before {
  background: var(--bad);
}

.b-admin {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(225, 29, 72, 0.2);
}
.b-admin::before {
  background: var(--accent);
}

.b-reseller {
  background: var(--purple-bg);
  color: var(--purple-text);
  border-color: var(--purple-border);
}
.b-reseller::before {
  background: var(--purple);
}

/* --------------------------------------------------------------------------
   14. Buttons & Form Controls
   -------------------------------------------------------------------------- */
.btn, button {
  font-family: inherit;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-xs);
  text-decoration: none;
}
.btn:hover {
  background: var(--card-2);
  border-color: var(--muted-light);
  color: var(--text);
  text-decoration: none;
}
.btn:active {
  transform: scale(0.98);
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.3);
}
.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #ffffff;
}
.btn-dark {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}
.btn-dark:hover {
  background: #1e293b;
  border-color: #1e293b;
  color: #ffffff;
}
.btn-danger {
  background: var(--bad);
  border-color: var(--bad);
  color: #ffffff;
}
.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-shadow: var(--shadow-xs);
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
label.fld {
  display: block;
  margin-bottom: 14px;
}
label.fld > span {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

/* --------------------------------------------------------------------------
   15. High-Precision Modern SaaS Tables
   -------------------------------------------------------------------------- */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}
th, td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  background: var(--card-2);
  font-weight: 700;
  white-space: nowrap;
}
tr:last-child td {
  border-bottom: 0;
}
tr:hover td {
  background: rgba(15, 23, 42, 0.015);
}
body.mode-dark tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Modern Monospace License Key Code Tag */
.key-code {
  font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.02em;
  background: var(--card-2);
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Toolbar & Row */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.toolbar .grow {
  flex: 1;
  min-width: 220px;
}
.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

/* --------------------------------------------------------------------------
   16. Alerts & Notifications
   -------------------------------------------------------------------------- */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 18px;
  font-weight: 500;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-ok {
  background: var(--ok-bg);
  color: var(--ok-text);
  border-color: var(--ok-border);
}
.alert-bad {
  background: var(--bad-bg);
  color: var(--bad-text);
  border-color: var(--bad-border);
}
.alert-info {
  background: var(--info-bg);
  color: var(--info-text);
  border-color: var(--info-border);
}

/* --------------------------------------------------------------------------
   17. Modals & Backdrop Blur
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(11, 19, 41, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 60;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.modal-backdrop.open {
  display: flex;
  opacity: 1;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 24px;
  transform: scale(0.97);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-backdrop.open .modal {
  transform: scale(1);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* --------------------------------------------------------------------------
   18. High-Performance Charts & Legends
   -------------------------------------------------------------------------- */
.chart-wrap {
  width: 100%;
  overflow-x: auto;
}
.donut-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 8px 0;
}
.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 14px;
  font-size: 12px;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 500;
  color: var(--text-secondary);
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  display: inline-block;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   19. Appearance Customization Cards
   -------------------------------------------------------------------------- */
.opt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 14px;
}
.opt-card {
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: pointer;
  display: block;
  background: var(--card);
  transition: all 0.15s ease;
}
.opt-card:hover {
  border-color: var(--muted-light);
  transform: translateY(-1px);
}
.opt-card input[type="radio"] {
  display: none;
}
.opt-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent);
}
.swatches {
  display: flex;
  height: 22px;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.swatches span {
  flex: 1;
}

/* --------------------------------------------------------------------------
   20. Auth & Installer Pages
   -------------------------------------------------------------------------- */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top right, rgba(225, 29, 72, 0.12), transparent 50%),
              radial-gradient(circle at bottom left, rgba(15, 23, 42, 0.1), transparent 50%),
              var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
  position: relative;
}
.auth-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  border-radius: var(--radius-full);
}

/* --------------------------------------------------------------------------
   21. Responsive Design & Mobile Drawer
   -------------------------------------------------------------------------- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 19, 41, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 35;
  opacity: 0;
  transition: opacity 0.25s ease;
}

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-eq-2 { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .sidebar.open + .sidebar-overlay {
    display: block;
    opacity: 1;
  }
  .menu-toggle {
    display: inline-flex;
  }
  .tb-search {
    display: none;
  }
  .grid-4, .grid-3 {
    grid-template-columns: 1fr;
  }
  .content {
    padding: 16px;
  }
  .topbar {
    padding: 12px 16px;
  }
}
