/* Base Styles */
html, body { 
  height: 100%; 
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
}

.app {
  display: grid;
  grid-template-rows: 56px 1fr; /* Top bar and content only - removed footer */
  height: 100vh;
}

/* Top Bar */
.topbar {
  position: sticky; 
  top: 0; 
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) auto auto; /* logo, search, notification, profile */
  gap: 12px;
  align-items: center;
  padding: 8px 12px;
  background: #061674;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
  height: 40px;
  padding: 0 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

.logo img {
  height: 100%;
  width: auto;
}

.iconbtn, .quick { 
  height: 40px; 
  min-width: 40px; 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  border-radius: 12px; 
  border: 1px solid var(--border);
  background: var(--chip-bg);
  color: var(--text);
  cursor: pointer; 
  user-select: none;
  transition: transform .08s ease, background-color .2s ease, border-color .2s ease;
}

.iconbtn:hover, .quick:hover { 
  transform: translateY(-1px); 
}

.iconbtn:active, .quick:active { 
  transform: translateY(1px); 
}

/* Header icon buttons with dark background */
.topbar .iconbtn {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  color: white;
}

.topbar .iconbtn:hover {
  background: rgba(255,255,255,0.2);
}

.badge { 
  background: var(--danger); 
  color: white; 
  font-size: 11px; 
  padding: 2px 6px; 
  border-radius: 999px; 
  margin-left: 6px;
}

/* Main Workspace */
.workspace { 
  padding: 16px; 
  height: 100%; 
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Admin interface fills workspace */
.workspace .app-container {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
}

.card {
  border-radius: 16px; 
  border: 1px solid var(--border); 
  background: var(--bg-elev);
  padding: 14px; 
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.grid { 
  display: grid; 
  grid-template-columns: repeat(12, 1fr); 
  gap: 12px; 
}

.col-4 { grid-column: span 4; }
.col-8 { grid-column: span 8; }
.col-6 { grid-column: span 6; }
.col-12 { grid-column: span 12; }

.list { 
  display: grid; 
  gap: 8px; 
}

.row { 
  display: grid; 
  grid-template-columns: 1fr auto; 
  gap: 8px; 
  align-items: center; 
  padding: 10px; 
  border: 1px solid var(--border); 
  border-radius: 12px; 
  background: var(--panel); 
}

.row .meta { 
  color: var(--muted); 
  font-size: 12px; 
}

.row .btn { 
  padding: 6px 10px; 
  border: 1px solid var(--border); 
  border-radius: 10px; 
  background: var(--chip-bg); 
  cursor: pointer; 
}

/* Accessibility helpers */
.sr-only { 
  position: absolute; 
  width: 1px; 
  height: 1px; 
  padding: 0; 
  margin: -1px; 
  overflow: hidden; 
  clip: rect(0,0,0,0); 
  white-space: nowrap; 
  border: 0; 
}

@media (max-width: 1000px) {
  .layout { 
    grid-template-columns: 64px 1fr; 
  }
  .label, .group-title { 
    display: none; 
  }
}

/* ---------- Top Bar ---------- */
    .topbar {
      position: sticky; top: 0; z-index: 20;
      display: grid;
      grid-template-columns: auto minmax(260px, 1fr) auto auto; /* logo, search, notification, profile */
      gap: 12px;
      align-items: center;
      padding: 8px 12px;
      background: #061674;
      border-bottom: 1px solid rgba(255,255,255,0.1);
    }
    .logo {
      height: 40px;
      padding: 0 8px;
      cursor: pointer;
      display: inline-flex;
      align-items: center;
    }
    .logo img {
      height: 100%;
      width: auto;
    }
    .iconbtn, .quick { 
      height: 40px; min-width: 40px; 
      display: inline-flex; align-items: center; justify-content: center; 
      border-radius: 12px; border: 1px solid var(--border);
      background: var(--chip-bg);
      color: var(--text);
      cursor: pointer; 
      user-select: none;
      transition: transform .08s ease, background-color .2s ease, border-color .2s ease;
    }
    .iconbtn:hover, .quick:hover { transform: translateY(-1px); }
    .iconbtn:active, .quick:active { transform: translateY(1px); }
    
    /* Header icon buttons with dark background */
    .topbar .iconbtn {
      background: rgba(255,255,255,0.1);
      border-color: rgba(255,255,255,0.2);
      color: white;
    }
    .topbar .iconbtn:hover {
      background: rgba(255,255,255,0.2);
    }.search {
      position: relative;
      display: flex; align-items: center; gap: 8px; 
      background: rgba(255,255,255,0.15);
      border: 1px solid rgba(255,255,255,0.2);
      border-radius: 14px; 
      height: 40px; padding: 0 12px;
      min-width: 0; width: 100%; max-width: 600px;
    }
    .search svg {
      color: rgba(255,255,255,0.8);
    }
    .search input {
      flex: 1; height: 100%; border: 0; outline: 0; background: transparent; 
      color: white;
      font-size: 14px;
    }
    .search input::placeholder {
      color: rgba(255,255,255,0.6);
    }
    .search-config-btn {
      flex-shrink: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      height: 28px;
      padding: 0 10px;
      border-radius: 8px;
      border: 1px solid rgba(255,255,255,0.2);
      background: rgba(255,255,255,0.1);
      color: rgba(255,255,255,0.85);
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s ease;
    }
    .search-config-btn:hover,
    .search-config-btn[aria-expanded="true"] {
      background: rgba(255,255,255,0.2);
      color: white;
      border-color: rgba(255,255,255,0.35);
    }
    .search-results {
      position: absolute;
      top: 44px;
      left: 0;
      right: 0;
      background: var(--panel);
      border: 1px solid var(--border);
      border-radius: 12px;
      box-shadow: 0 12px 32px rgba(15,23,42,0.25);
      padding: 8px 0;
      z-index: 50;
      display: none;
      max-height: 360px;
      overflow-y: auto;
    }
    .search-results.visible {
      display: block;
    }
    .search-config-menu {
      position: absolute;
      top: 44px;
      right: 0;
      width: 240px;
      background: var(--panel);
      border: 1px solid var(--border);
      border-radius: 12px;
      box-shadow: 0 12px 32px rgba(15,23,42,0.25);
      padding: 14px;
      z-index: 60;
      display: none;
    }
    .search-config-menu.visible {
      display: block;
    }
    .search-config-title {
      font-size: 12px;
      font-weight: 700;
      text-transform: uppercase;
      color: var(--muted);
      letter-spacing: 0.05em;
      margin-bottom: 10px;
    }
    .search-config-option {
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 6px;
      border-radius: 8px;
      cursor: pointer;
      font-size: 13px;
      color: var(--text);
    }
    .search-config-option:hover {
      background: var(--chip-bg);
    }
    .search-config-option input {
      width: 16px;
      height: 16px;
      margin: 0;
      accent-color: var(--accent);
      cursor: pointer;
    }
    .search-result {
      padding: 10px 14px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      color: var(--text);
      text-decoration: none;
    }
    .search-result.empty {
      cursor: default;
      color: var(--muted);
    }
    .search-result-main {
      display: flex;
      flex-direction: column;
      gap: 4px;
      flex: 1;
      min-width: 0;
    }
    .search-result:hover,
    .search-result.active {
      background: var(--chip-bg);
    }
    .search-result.empty:hover {
      background: none;
    }
    .search-result-name {
      font-size: 14px;
      font-weight: 600;
      color: var(--text);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .search-result-meta {
      font-size: 12px;
      color: var(--muted);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .search-result-actions {
      display: inline-flex;
      align-items: center;
      gap: 8px;
    }
    .search-result-action {
      border-radius: 999px;
      border: 1px solid var(--border);
      background: var(--chip-bg);
      color: var(--text);
      padding: 4px 10px;
      font-size: 12px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.2s ease;
    }
    .search-result-action:hover {
      background: var(--accent);
      border-color: var(--accent);
      color: #ffffff;
      transform: translateY(-1px);
    }
    .badge { 
      background: var(--danger); color: white; font-size: 11px; 
      padding: 2px 6px; border-radius: 999px; margin-left: 6px;
    }:root {
      --bg: #0f172a;            /* slate-900 */
      --bg-elev: #111827;       /* gray-900 */
      --panel: #111827;
      --text: #e5e7eb;          /* gray-200 */
      --muted: #9ca3af;         /* gray-400 */
      --accent: #60a5fa;        /* blue-400 */
      --accent-2: #34d399;      /* emerald-400 */
      --warning: #f59e0b;       /* amber-500 */
      --danger: #ef4444;        /* red-500 */
      --border: #1f2937;        /* gray-800 */
      --chip-bg: #1f2937;
    }
    .light {
      --bg: #ffffff;            /* white background */
      --bg-elev: #f8fafc;       /* very light gray for elevated elements */
      --panel: #ffffff;         /* white panels */
      --text: #1e293b;          /* slate-800 for readable dark text */
      --muted: #475569;         /* slate-600 for muted text */
      --accent: #2d3e9f;        /* deep blue matching logo */
      --accent-2: #059669;      /* emerald-600 */
      --warning: #d97706;       /* amber-600 */
      --danger: #dc2626;        /* red-600 */
      --border: #cbd5e1;        /* slate-300 for borders */
      --chip-bg: #f1f5f9;       /* slate-100 */
      --card: #ffffff;          /* white cards */
      --sidebar-bg: #2d3e9f;    /* matching logo purple-blue */
      --sidebar-text: #ffffff;
      --sidebar-hover: #3d4eb0;
      --sidebar-active: #4d5ec0;
    }

    /* Base */
    html, body { height: 100%; }
    body {
      margin: 0;
      font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
      color: var(--text);
      background: var(--bg);
    }
    .app {
      display: grid;
      grid-template-rows: 56px 1fr; /* Top bar and content only - removed footer */
      height: 100vh;
    }