:root{
  /* Light theme (default) */
  --bg:#e8eef5; --surface:#fff; --primary:#1a1a2e; --primary-light:#16213e;
  --accent:#4a6fa5; --accent-light:#6b8cbe;
  --text:#1a1a2e; --muted:#5a6578; --border:#d0d9e6; --radius:12px;
  --row-hover:#eef3fa; --th-bg:#f5f8fc; --shadow:0 8px 24px rgba(26,26,46,.08);
  --sidebar-width: 280px;
  /* Additional light theme variables */
  --input-bg:#fff; --input-border:#d0d9e6;
  --card-bg:#fff; --card-border:#d0d9e6;
  --table-stripe:#f9fafb; --table-hover:#eef3fa;
  --success:#22c55e; --warning:#f59e0b; --danger:#ef4444;
  --header-gradient: linear-gradient(135deg, #2d5a8a 0%, #3d6a9a 100%);
}

/* Dark theme */
[data-theme="dark"] {
  --bg:#0f0f1a; --surface:#1a1a2e; --primary:#e8eef5; --primary-light:#d0d9e6;
  --accent:#6b8cbe; --accent-light:#8aa8d4;
  --text:#e8eef5; --muted:#9ca3af; --border:#2d2d44; --radius:12px;
  --row-hover:#252540; --th-bg:#1f1f35; --shadow:0 8px 24px rgba(0,0,0,.3);
  --input-bg:#1f1f35; --input-border:#3d3d5c;
  --card-bg:#1a1a2e; --card-border:#2d2d44;
  --table-stripe:#1f1f35; --table-hover:#252540;
  --header-gradient: linear-gradient(135deg, #1a1a2e 0%, #252545 100%);
}

/* Dark mode specific overrides */
[data-theme="dark"] .top-bar {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .page-header {
  background: var(--header-gradient);
}

[data-theme="dark"] .content-card,
[data-theme="dark"] .card {
  background: var(--card-bg);
  border-color: var(--card-border);
}

[data-theme="dark"] .content-card-header {
  background: linear-gradient(to bottom, #1f1f35, #1a1a2e);
  border-color: var(--border);
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--input-bg);
  border-color: var(--input-border);
  color: var(--text);
}

[data-theme="dark"] input::placeholder,
[data-theme="dark"] textarea::placeholder {
  color: var(--muted);
}

[data-theme="dark"] table th {
  background: var(--th-bg);
}

[data-theme="dark"] table tr:nth-child(even) {
  background: var(--table-stripe);
}

[data-theme="dark"] table tr:hover {
  background: var(--table-hover);
}

[data-theme="dark"] .info-box {
  background: linear-gradient(135deg, #1f1f35 0%, #252540 100%);
}

[data-theme="dark"] .info-box.success {
  background: linear-gradient(135deg, #052e16 0%, #064e3b 100%);
}

[data-theme="dark"] .info-box.warning {
  background: linear-gradient(135deg, #451a03 0%, #713f12 100%);
}

[data-theme="dark"] .info-box.danger {
  background: linear-gradient(135deg, #450a0a 0%, #7f1d1d 100%);
}

[data-theme="dark"] .btn-link {
  background: rgba(107,140,190,0.15);
  border-color: rgba(107,140,190,0.3);
}

[data-theme="dark"] .modal,
[data-theme="dark"] .modal-overlay .modal,
[data-theme="dark"] .modal-content {
  background: var(--surface);
  color: var(--text);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
  border-color: var(--border);
}

/* Smooth transition for theme changes */
body, .top-bar, .page-header, .content-card, .card, input, select, textarea, table, .info-box, .modal {
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

*{box-sizing:border-box}
html,body{height:100%;overflow-x:hidden}
body{margin:0;background:var(--bg);color:var(--text);font-family:'Segoe UI',system-ui,sans-serif}
a{color:inherit}

/* ============================================
   TOP BAR (minimal header with menu toggle)
   ============================================ */
.top-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(26,26,46,0.06);
}

.menu-toggle {
  width: 40px;
  height: 40px;
  border: none;
  background: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: all 0.2s ease;
  color: var(--text);
}

.menu-toggle:hover {
  background: var(--row-hover);
}

.menu-toggle svg {
  width: 22px;
  height: 22px;
}

.top-bar-title {
  margin-left: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.top-bar-title img {
  height: 24px;
}

.top-bar-title span {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

/* ============================================
   SIDEBAR NAVIGATION
   ============================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, #1a1a2e 0%, #16213e 100%);
  color: #fff;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  overflow-x: hidden;
}

.sidebar.open {
  opacity: 1;
  visibility: visible;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,26,46,0.4);
  backdrop-filter: blur(2px);
  z-index: 150;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

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

/* Sidebar Header */
.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-logo img {
  height: 28px;
  filter: brightness(0) invert(1);
}

.sidebar-logo span {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}

.sidebar-close {
  width: 32px;
  height: 32px;
  border: none;
  background: rgba(255,255,255,0.1);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.sidebar-close:hover {
  background: rgba(255,255,255,0.2);
}

.sidebar-close svg {
  width: 18px;
  height: 18px;
}

/* Sidebar Navigation */
.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* Custom scrollbar for sidebar - blends with dark theme */
.sidebar-nav::-webkit-scrollbar {
  width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* Firefox scrollbar styling */
.sidebar-nav {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.nav-section {
  margin-bottom: 24px;
  width: 100%;
  display: block;
}

.nav-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255,255,255,0.4);
  padding: 0 12px;
  margin-bottom: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: rgba(255,255,255,0.75);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  margin-bottom: 4px;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.nav-link:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.nav-link.active {
  background: rgba(74,111,165,0.3);
  color: #fff;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.8;
}

.nav-link.active svg {
  opacity: 1;
}

/* Workspace Submenu */
.nav-submenu {
  margin-left: 32px;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,0.15);
  margin-top: 4px;
  display: none;
}

.nav-submenu.open {
  display: block;
}

.nav-submenu .nav-link {
  padding: 10px 12px;
  font-size: 13px;
}

.nav-link-expandable {
  cursor: pointer;
}

.nav-link-expandable .nav-caret {
  margin-left: auto;
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.nav-link-expandable.expanded .nav-caret {
  transform: rotate(180deg);
}

/* Sidebar Footer (User Info + Logout) */
.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.1);
  background: rgba(0,0,0,0.15);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px;
  margin-bottom: 12px;
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: #fff;
}

.user-details {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
}

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  border: none;
  background: rgba(220, 38, 38, 0.15);
  color: #fca5a5;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background: rgba(220, 38, 38, 0.25);
  color: #fecaca;
}

.logout-btn svg {
  width: 18px;
  height: 18px;
}

/* ============================================
   PAGE LAYOUT WITH SIDEBAR
   ============================================ */
.page-wrapper {
  padding-top: 56px;
  min-height: 100vh;
}

/* Legacy header support (hidden when using sidebar) */
header{
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color:#fff;
  padding:0 32px;
  height:60px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
header .logo{
  display:flex;
  align-items:center;
  gap:14px;
  font-weight:600;
  font-size:15px;
  letter-spacing: 0.3px;
}
header .logo img{
  filter: brightness(0) invert(1);
}
nav{display:flex;align-items:center;gap:4px}
nav a{
  color:rgba(255,255,255,0.85);
  text-decoration:none;
  padding: 8px 14px;
  font-size:13px;
  font-weight: 500;
  border-radius: 8px;
  transition: all 0.2s ease;
}
nav a:hover{
  background: rgba(255,255,255,0.1);
  color: #fff;
}
nav a.active{
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* Workspace dropdown (legacy) */
.dropdown{position:relative}
.trigger{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:8px 14px;
  border-radius:8px;
  line-height:1;
  color:rgba(255,255,255,0.85);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}
.trigger:hover{
  background: rgba(255,255,255,0.1);
  color: #fff;
}
.caret{
  width:8px;
  height:8px;
  display:inline-block;
  transform:rotate(45deg);
  border:solid rgba(255,255,255,0.7);
  border-width:0 2px 2px 0;
  margin-left:4px;
  margin-top: -2px;
}
.menu{
  position:absolute;
  top:50px;
  right:0;
  min-width:280px;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border:1px solid rgba(255,255,255,0.1);
  border-radius:12px;
  box-shadow:0 18px 40px rgba(0,0,0,.35);
  padding:8px;
  display:none;
  z-index:30;
}
.dropdown.open .menu{display:block}
@media(hover:hover) and (pointer:fine){ .dropdown:hover .menu{display:block} }
.menu a{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  text-decoration:none;
  color:rgba(255,255,255,0.85);
  padding:12px 14px;
  border-radius:10px;
  transition: all 0.2s ease;
}
.menu a:hover{
  background:rgba(255,255,255,0.1);
  color:#fff;
}
.menu a.current{
  background:rgba(74,111,165,0.3);
  border:1px solid rgba(74,111,165,0.5);
  color:#fff;
}
.menu small{
  color:rgba(255,255,255,0.5);
  font-size:12px;
}

/* Shared helpers */
.container{max-width:none;margin:0;padding:24px 32px}
.btn{
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color:#fff;
  border:none;
  border-radius:10px;
  padding:10px 14px;
  cursor:pointer;
  font-weight:600;
  transition:all .2s ease;
}
.btn:hover{
  background: linear-gradient(135deg, #252547 0%, #1e2d4d 100%);
  box-shadow:0 4px 12px rgba(26,26,46,.2);
  transform: translateY(-1px);
}
.btn:active{transform:translateY(1px)}
.btn.small{padding:6px 10px;font-size:12px;border-radius:8px}
.btn.secondary{background:#5a6578}
.btn.secondary:hover{background:#6b7689}
.btn.danger{background:#dc3545}
.btn.danger:hover{background:#c82333}
.btn-link{
  display:inline-block;
  padding:8px 10px;
  background:rgba(74,111,165,0.1);
  border:1px solid rgba(74,111,165,0.3);
  border-radius:10px;
  text-decoration:none;
  color:var(--accent);
}
.btn-link:hover{
  background:rgba(74,111,165,0.2);
}
select,input{font-family:inherit}

/* ============================================
   PAGE HEADER - Distinctive section headers
   ============================================ */
.page-header {
  background: linear-gradient(135deg, #2d5a8a 0%, #3d6a9a 100%);
  color: #fff;
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: 0 4px 12px rgba(45,90,138,0.3);
}

.page-header h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.page-header h1 svg {
  width: 28px;
  height: 28px;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}

.page-header .subtitle {
  font-size: 15px;
  color: #fff;
  opacity: 1;
  margin-top: 6px;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  font-weight: 500;
}

/* Breadcrumb navigation */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  padding: 12px 0;
  margin-bottom: 8px;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb a:hover {
  color: var(--primary);
  text-decoration: underline;
}

.breadcrumb .separator {
  color: var(--border);
}

.breadcrumb .current {
  color: var(--text);
  font-weight: 500;
}

/* ============================================
   CONTENT CARDS - Better visual separation
   ============================================ */
.content-card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.content-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, #fafbfc, #f5f8fc);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.content-card-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}

.content-card-header h2 svg {
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.content-card-body {
  padding: 20px;
}

/* Section dividers for long pages */
.section-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border), transparent);
  margin: 32px 0;
}

/* Stats/info boxes for dashboards */
.info-box {
  background: linear-gradient(135deg, #f8fafc 0%, #eef3fa 100%);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
}

.info-box.success {
  border-left-color: #22c55e;
  background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%);
}

.info-box.warning {
  border-left-color: #f59e0b;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
}

.info-box.danger {
  border-left-color: #ef4444;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
}

.info-box-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin-bottom: 4px;
}

.info-box-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}
