/* ================================================================
   PRAYAS EXAMPORTAL — Global Stylesheet
   Clean, professional, hand-crafted design
   Dark mode default + Light mode toggle
   Mobile-first, accessible, no emoji
   ================================================================ */

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

/* ----------------------------------------------------------------
   CSS Custom Properties
   ---------------------------------------------------------------- */
:root {
  /* Brand */
  --brand:        #4f6ef7;
  --brand-hover:  #3d5ce6;
  --brand-light:  rgba(79, 110, 247, 0.12);
  --brand-border: rgba(79, 110, 247, 0.28);
  --teal:         #0ea5b0;
  --teal-light:   rgba(14, 165, 176, 0.12);
  --success:      #22c55e;
  --success-light:rgba(34, 197, 94, 0.12);
  --warning:      #f59e0b;
  --warning-light:rgba(245, 158, 11, 0.12);
  --danger:       #ef4444;
  --danger-light: rgba(239, 68, 68, 0.12);

  /* Dark mode (default) */
  --bg:           #0d1117;
  --bg-2:         #161b22;
  --bg-3:         #21262d;
  --surface:      #1c2128;
  --surface-2:    #252b33;
  --border:       #30363d;
  --border-2:     #3d444d;
  --text:         #e6edf3;
  --text-2:       #9ca9b5;
  --text-3:       #6e7681;
  --shadow:       0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.3);
  --shadow-lg:    0 4px 6px rgba(0,0,0,0.5), 0 10px 40px rgba(0,0,0,0.4);

  /* Dimensions */
  --sidebar-w:    240px;
  --topbar-h:     56px;
  --radius:       8px;
  --radius-lg:    12px;
  --radius-sm:    5px;

  /* Transitions */
  --trans:        150ms ease;
  --trans-md:     250ms ease;
}

/* Light mode */
[data-theme="light"] {
  --bg:           #f0f2f5;
  --bg-2:         #ffffff;
  --bg-3:         #f6f8fa;
  --surface:      #ffffff;
  --surface-2:    #f6f8fa;
  --border:       #d0d7de;
  --border-2:     #b1bac4;
  --text:         #1f2328;
  --text-2:       #57606a;
  --text-3:       #8b949e;
  --shadow:       0 1px 3px rgba(0,0,0,0.08), 0 2px 8px rgba(0,0,0,0.06);
  --shadow-lg:    0 4px 12px rgba(0,0,0,0.1), 0 8px 32px rgba(0,0,0,0.08);
}

/* ----------------------------------------------------------------
   Reset
   ---------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--trans-md), color var(--trans-md);
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

img { max-width: 100%; display: block; }

button { font-family: inherit; cursor: pointer; }

input, select, textarea {
  font-family: inherit;
  font-size: 0.9rem;
}

/* ----------------------------------------------------------------
   Layout
   ---------------------------------------------------------------- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ----------------------------------------------------------------
   Sidebar
   ---------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--trans-md), background var(--trans-md);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
  flex-shrink: 0;
}

.sidebar-logo-img {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  flex-shrink: 0;
}

.sidebar-logo-placeholder {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-placeholder svg {
  color: #fff;
}

.sidebar-brand-text {
  overflow: hidden;
}

.sidebar-brand-name {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: -0.01em;
}

.sidebar-brand-tag {
  font-size: 0.68rem;
  color: var(--text-3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 8px;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 4px;
}

.nav-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 10px 5px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--trans), color var(--trans);
  margin-bottom: 1px;
}

.nav-link:hover {
  background: var(--bg-3);
  color: var(--text);
  text-decoration: none;
}

.nav-link.active {
  background: var(--brand-light);
  color: var(--brand);
  border-left: 2px solid var(--brand);
  padding-left: 8px;
}

.nav-link svg { flex-shrink: 0; opacity: 0.8; }
.nav-link.active svg { opacity: 1; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-3);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.user-name {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-label {
  font-size: 0.7rem;
  color: var(--text-3);
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--trans), color var(--trans);
}

.icon-btn:hover {
  background: var(--border);
  color: var(--text);
}

/* ----------------------------------------------------------------
   Main Content
   ---------------------------------------------------------------- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-menu-btn {
  display: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-2);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.topbar-title {
  flex: 1;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-content {
  padding: 24px;
  flex: 1;
}

/* ----------------------------------------------------------------
   Page Header
   ---------------------------------------------------------------- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-header-left h1 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.page-header-left p {
  font-size: 0.85rem;
  color: var(--text-2);
  margin-top: 3px;
}

/* ----------------------------------------------------------------
   Cards
   ---------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.card-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.card-body { padding: 20px; }

.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-3);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ----------------------------------------------------------------
   Stats Grid
   ---------------------------------------------------------------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue   { background: var(--brand-light); color: var(--brand); }
.stat-icon.teal   { background: var(--teal-light); color: var(--teal); }
.stat-icon.green  { background: var(--success-light); color: var(--success); }
.stat-icon.amber  { background: var(--warning-light); color: var(--warning); }
.stat-icon.red    { background: var(--danger-light); color: var(--danger); }

.stat-val {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat-label {
  font-size: 0.77rem;
  color: var(--text-3);
  margin-top: 3px;
}

/* ----------------------------------------------------------------
   Buttons
   ---------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--trans), border-color var(--trans), color var(--trans), opacity var(--trans);
  white-space: nowrap;
  line-height: 1.4;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); border-color: var(--brand-hover); }

.btn-secondary {
  background: var(--bg-3);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--border); }

.btn-outline {
  background: transparent;
  color: var(--text-2);
  border-color: var(--border);
}
.btn-outline:hover:not(:disabled) { background: var(--bg-3); color: var(--text); border-color: var(--border-2); }

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: rgba(239,68,68,0.3);
}
.btn-danger:hover:not(:disabled) { background: var(--danger); color: #fff; }

.btn-success {
  background: var(--success-light);
  color: var(--success);
  border-color: rgba(34,197,94,0.3);
}
.btn-success:hover:not(:disabled) { background: var(--success); color: #fff; }

.btn-teal {
  background: var(--teal-light);
  color: var(--teal);
  border-color: rgba(14,165,176,0.3);
}
.btn-teal:hover:not(:disabled) { background: var(--teal); color: #fff; }

.btn-sm {
  padding: 4px 10px;
  font-size: 0.78rem;
  gap: 5px;
}

.btn-lg {
  padding: 10px 20px;
  font-size: 0.93rem;
}

.btn-block {
  width: 100%;
  justify-content: center;
}

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
}

.btn-whatsapp {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  background: #22c55e;
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background var(--trans);
}
.btn-whatsapp:hover { background: #16a34a; }

.btn-mail {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  background: var(--brand-light);
  color: var(--brand);
  border: 1px solid var(--brand-border);
  cursor: pointer;
  transition: background var(--trans);
}
.btn-mail:hover { background: var(--brand); color: #fff; }

/* ----------------------------------------------------------------
   Forms
   ---------------------------------------------------------------- */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.88rem;
  transition: border-color var(--trans), box-shadow var(--trans);
  outline: none;
}

.form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(79,110,247,0.15);
}

.form-control::placeholder { color: var(--text-3); }
.form-control:disabled { opacity: 0.5; cursor: not-allowed; }

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236e7681' stroke-width='2.5' stroke-linecap='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-3);
  margin-top: 4px;
}

.form-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 5px;
  display: none;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.input-group {
  display: flex;
  gap: 8px;
}

.input-group .form-control { flex: 1; }

.input-icon-wrap {
  position: relative;
}

.input-icon-wrap .input-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.input-icon-wrap .form-control { padding-left: 34px; }

.input-icon-wrap .input-icon-right {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.input-icon-wrap.has-right .form-control { padding-right: 36px; }

/* ----------------------------------------------------------------
   Tables
   ---------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.87rem;
}

thead th {
  text-align: left;
  padding: 10px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--bg-3);
}

thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--bg-3); }

/* ----------------------------------------------------------------
   Badges
   ---------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-blue   { background: var(--brand-light); color: var(--brand); }
.badge-green  { background: var(--success-light); color: var(--success); }
.badge-red    { background: var(--danger-light); color: var(--danger); }
.badge-amber  { background: var(--warning-light); color: var(--warning); }
.badge-teal   { background: var(--teal-light); color: var(--teal); }
.badge-gray   { background: var(--bg-3); color: var(--text-3); border: 1px solid var(--border); }

/* ----------------------------------------------------------------
   Chips / Tags
   ---------------------------------------------------------------- */
.chips-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  background: var(--brand-light);
  color: var(--brand);
  border: 1px solid var(--brand-border);
  border-radius: 100px;
  font-size: 0.77rem;
  font-weight: 500;
}

.chip-remove {
  width: 14px;
  height: 14px;
  border: none;
  background: transparent;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0.7;
  transition: opacity var(--trans);
}
.chip-remove:hover { opacity: 1; }

/* ----------------------------------------------------------------
   Search Bar
   ---------------------------------------------------------------- */
.search-wrap {
  position: relative;
}

.search-wrap .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.search-wrap input {
  padding-left: 34px;
}

/* ----------------------------------------------------------------
   Filters Bar
   ---------------------------------------------------------------- */
.filters-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.filters-bar .search-wrap {
  flex: 1;
  min-width: 200px;
}

/* ----------------------------------------------------------------
   Empty State
   ---------------------------------------------------------------- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}

.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  color: var(--text-3);
}

.empty-state h3 {
  font-size: 0.95rem;
  color: var(--text-2);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 0.83rem;
  margin-bottom: 16px;
}

/* ----------------------------------------------------------------
   Inline Edit Panel (replaces popups)
   ---------------------------------------------------------------- */
.edit-panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  overflow: hidden;
  animation: slideDown 0.2s ease;
}

.edit-panel.open { display: block; }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.edit-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3);
}

.edit-panel-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.edit-panel-body { padding: 20px; }

.edit-panel-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: var(--bg-3);
}

/* ----------------------------------------------------------------
   Credential Box
   ---------------------------------------------------------------- */
.cred-box {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.cred-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

.cred-row:last-child { border-bottom: none; }

.cred-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  width: 72px;
  flex-shrink: 0;
}

.cred-val {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.83rem;
  color: var(--text);
  flex: 1;
  word-break: break-all;
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.72rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--trans), color var(--trans);
  flex-shrink: 0;
}
.copy-btn:hover { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ----------------------------------------------------------------
   Tabs
   ---------------------------------------------------------------- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
  transition: color var(--trans), border-color var(--trans);
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--brand); border-color: var(--brand); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ----------------------------------------------------------------
   Login Page
   ---------------------------------------------------------------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

.login-brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo-wrap {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
  overflow: hidden;
}

.login-logo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.login-logo-wrap svg { color: #fff; }

.login-brand h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
}

.login-brand p {
  font-size: 0.83rem;
  color: var(--text-3);
  margin-top: 3px;
}

.role-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 24px;
}

.role-btn {
  padding: 9px;
  border: none;
  background: transparent;
  color: var(--text-2);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--trans), color var(--trans);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.role-btn.active {
  background: var(--brand);
  color: #fff;
}

.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.75rem;
  color: var(--text-3);
}

.theme-toggle-login {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--trans), color var(--trans);
}
.theme-toggle-login:hover { background: var(--bg-3); color: var(--text); }

/* ----------------------------------------------------------------
   Toast
   ---------------------------------------------------------------- */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  color: var(--text);
  max-width: 320px;
  animation: toastIn 0.2s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast-icon { flex-shrink: 0; }
.toast.success .toast-icon { color: var(--success); }
.toast.error   .toast-icon { color: var(--danger); }
.toast.info    .toast-icon { color: var(--brand); }

/* ----------------------------------------------------------------
   Loader
   ---------------------------------------------------------------- */
.loader {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

.loader-dark {
  border-color: rgba(79,110,247,0.2);
  border-top-color: var(--brand);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ----------------------------------------------------------------
   Import Zone / Drop Area
   ---------------------------------------------------------------- */
.drop-zone {
  border: 2px dashed var(--border-2);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--trans-md), background var(--trans-md);
  position: relative;
}

.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--brand);
  background: var(--brand-light);
}

.drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.drop-zone-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
  color: var(--text-3);
}

.drop-zone h4 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 4px;
}

.drop-zone p { font-size: 0.8rem; color: var(--text-3); }

/* ----------------------------------------------------------------
   Code block (JSON preview)
   ---------------------------------------------------------------- */
.code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 0.78rem;
  color: var(--teal);
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-all;
  display: none;
}

/* ----------------------------------------------------------------
   Exam-taking UI
   ---------------------------------------------------------------- */
.exam-shell {
  max-width: 720px;
  margin: 0 auto;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 16px;
  display: none;
}

.question-card.active { display: block; animation: slideDown 0.2s ease; }

.question-number {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.question-text {
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.6;
  margin-bottom: 16px;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 0.88rem;
  font-family: inherit;
  transition: border-color var(--trans), background var(--trans);
}

.option-btn:hover { border-color: var(--brand); background: var(--brand-light); }
.option-btn.selected { border-color: var(--brand); background: var(--brand-light); }
.option-btn.correct  { border-color: var(--success); background: var(--success-light); }
.option-btn.wrong    { border-color: var(--danger); background: var(--danger-light); }

.option-indicator {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: border-color var(--trans), background var(--trans), color var(--trans);
}

.option-btn.selected .option-indicator { border-color: var(--brand); background: var(--brand); color: #fff; }
.option-btn.correct  .option-indicator { border-color: var(--success); background: var(--success); color: #fff; }
.option-btn.wrong    .option-indicator { border-color: var(--danger); background: var(--danger); color: #fff; }

.progress-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 20px;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--teal));
  border-radius: 2px;
  transition: width 0.3s ease;
}

.timer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 100px;
  background: var(--warning-light);
  border: 1px solid rgba(245,158,11,0.3);
  color: var(--warning);
  font-size: 0.8rem;
  font-weight: 600;
}

.timer.urgent {
  background: var(--danger-light);
  border-color: rgba(239,68,68,0.3);
  color: var(--danger);
  animation: timerPulse 1s infinite;
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}

/* Score ring */
.score-ring {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.score-ring svg { position: absolute; inset: 0; transform: rotate(-90deg); }

.score-ring-val {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
}

/* ----------------------------------------------------------------
   Exam Cards (Student dashboard)
   ---------------------------------------------------------------- */
.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.exam-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color var(--trans-md), box-shadow var(--trans-md);
  box-shadow: var(--shadow);
}

.exam-card:hover {
  border-color: var(--brand-border);
  box-shadow: var(--shadow-lg);
}

.exam-card-top {
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--teal));
}

.exam-card.completed .exam-card-top {
  background: linear-gradient(90deg, var(--success), var(--teal));
}

.exam-card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.exam-card-title {
  font-size: 0.93rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.exam-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.exam-card-desc {
  font-size: 0.82rem;
  color: var(--text-2);
  line-height: 1.5;
  flex: 1;
}

.exam-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg-3);
  gap: 10px;
}

/* ----------------------------------------------------------------
   Question type badges
   ---------------------------------------------------------------- */
.q-badge-mcq       { background: var(--brand-light); color: var(--brand); }
.q-badge-truefalse { background: var(--teal-light); color: var(--teal); }
.q-badge-short     { background: var(--warning-light); color: var(--warning); }

/* ----------------------------------------------------------------
   Set card
   ---------------------------------------------------------------- */
.set-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  transition: border-color var(--trans-md);
  box-shadow: var(--shadow);
}
.set-card:hover { border-color: var(--brand-border); }

.set-card-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.set-card-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  align-items: center;
}

.set-card-desc {
  font-size: 0.82rem;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 14px;
}

.set-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.active-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--success);
  display: inline-block;
}

/* Q chip */
.q-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 8px;
  font-size: 0.77rem;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--trans);
}
.q-chip:hover { background: var(--brand-light); color: var(--brand); border-color: var(--brand-border); }
.q-chip-remove { color: var(--danger); margin-left: 2px; font-size: 0.9rem; opacity: 0.7; }
.q-chip-remove:hover { opacity: 1; }

/* ----------------------------------------------------------------
   Answer item (result review)
   ---------------------------------------------------------------- */
.ans-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.ans-item.correct { border-color: rgba(34,197,94,0.4); background: var(--success-light); }
.ans-item.wrong   { border-color: rgba(239,68,68,0.4);  background: var(--danger-light); }

.ans-q { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.ans-detail { font-size: 0.8rem; color: var(--text-2); }
.ans-correct-label { color: var(--success); font-weight: 600; }
.ans-wrong-label   { color: var(--danger); font-weight: 600; }

/* ----------------------------------------------------------------
   Divider
   ---------------------------------------------------------------- */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

/* ----------------------------------------------------------------
   Grid helpers
   ---------------------------------------------------------------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

/* ----------------------------------------------------------------
   Utility
   ---------------------------------------------------------------- */
.text-sm   { font-size: 0.82rem; }
.text-xs   { font-size: 0.75rem; }
.text-muted { color: var(--text-2); }
.text-dim  { color: var(--text-3); }
.text-brand { color: var(--brand); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.text-warning { color: var(--warning); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.gap-8 { gap: 8px; }
.flex  { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.hidden { display: none !important; }

/* ----------------------------------------------------------------
   Logo Upload Section
   ---------------------------------------------------------------- */
.logo-upload-area {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.logo-preview {
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-3);
}

.logo-preview img { width: 100%; height: 100%; object-fit: contain; }

/* ----------------------------------------------------------------
   Mobile Responsive
   ---------------------------------------------------------------- */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-240px);
    width: 240px;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
  }
  .sidebar-overlay.show { display: block; }

  .main { margin-left: 0; }

  .topbar-menu-btn { display: flex; }

  .page-content { padding: 16px; }

  .form-row { grid-template-columns: 1fr; }

  .grid-2, .grid-3 { grid-template-columns: 1fr; }

  .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }

  .page-header { gap: 10px; }
  .page-header-left h1 { font-size: 1.2rem; }

  .table-wrap { font-size: 0.8rem; }
  tbody td, thead th { padding: 8px 10px; }

  .exam-grid { grid-template-columns: 1fr; }

  .login-card { padding: 24px 20px; }

  .topbar { padding: 0 16px; }

  .edit-panel-body { padding: 16px; }
  .edit-panel-footer { padding: 12px 16px; }
  .card-body { padding: 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; align-items: stretch; }
  .filters-bar .search-wrap { min-width: unset; }
  .btn-sm { font-size: 0.75rem; padding: 4px 8px; }
}
