/* =========================================================
   EventTrack — Design System v3
   Dark navy sidebar + emerald accent, inspired by modern
   admin dashboards (card-based, generous whitespace, soft
   shadows, pill badges).
   ========================================================= */
:root {
  /* Accent (brand) — emerald/teal green */
  --green-900: #0b3d2e;
  --green-800: #0f5940;
  --green-700: #12734f;
  --green-600: #159b6b;
  --green-500: #1cb37c;
  --green-400: #3fca94;
  --green-300: #86e0bb;
  --green-100: #e2f7ee;
  --green-50:  #f2fbf7;

  /* Sidebar navy */
  --navy-950: #0a1120;
  --navy-900: #0f1a2e;
  --navy-800: #16233c;
  --navy-700: #202f4a;

  /* Neutrals */
  --ink-900: #101826;
  --ink-700: #3c4657;
  --ink-500: #6b7686;
  --ink-300: #a7b0bd;
  --border:  #e5e9ef;
  --bg-page: #f4f6f9;

  --amber-500: #c9860f;
  --amber-100: #fdf1dc;
  --red-500: #d9432a;
  --red-100: #fbe4df;
  --blue-500: #2f7bd9;
  --blue-100: #e2eefd;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16,24,38,0.04), 0 8px 24px rgba(16,24,38,0.06);
  --shadow-lg: 0 20px 45px rgba(10,17,32,0.16);
  --font-display: 'Poppins', 'Segoe UI', sans-serif;

  /* Alias used by login.php/register.php/index.php inline styles */
  --accent-600: var(--green-600);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font-display);
  background: var(--bg-page);
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
::selection { background: var(--green-300); color: var(--green-900); }

/* ---------- Dark theme overrides ---------- */
html.theme-dark { --bg-page: #0b1220; --border: #223049; --ink-900: #eef2f7; --ink-700: #c3ccd9; --ink-500: #8e99ab; --ink-300: #5b6479; }
html.theme-dark body { background: var(--bg-page); }
html.theme-dark .card, html.theme-dark .topbar, html.theme-dark .dropdown-panel, html.theme-dark .auth-card { background: #101a2c; border-color: var(--border); }
html.theme-dark input, html.theme-dark select, html.theme-dark textarea { background: #0c1524; color: var(--ink-900); border-color: var(--border); }
html.theme-dark tr:hover td { background: #0c1524; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; overflow-x: clip; }

.sidebar {
  width: 258px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900) 60%, var(--navy-950));
  color: #fff;
  display: flex; flex-direction: column;
  padding: 22px 14px;
  position: sticky; top: 0; height: 100vh; z-index: 50;
  transition: transform .2s ease-out;
  will-change: transform;
  backface-visibility: hidden;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 4px 10px 26px; }
.brand-mark {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 11px;
  background: transparent; color: inherit;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
}
.brand-text { min-width: 0; }
.brand-name { font-weight: 700; font-size: 15.5px; color: #fff; line-height: 1.25; }
.brand-sub { font-size: 10px; font-weight: 600; letter-spacing: .5px; color: rgba(255,255,255,0.45); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; overflow-y: auto; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.65); font-size: 14px; font-weight: 500;
  transition: background .15s ease, color .15s ease; position: relative;
}
.side-nav a .icon { flex-shrink: 0; opacity: .8; }
.side-nav a:hover { background: rgba(255,255,255,0.06); color: #fff; }
.side-nav a.active { background: var(--green-600); color: #fff; font-weight: 600; box-shadow: 0 6px 16px rgba(21,155,107,0.35); }
.side-nav a.active .icon { opacity: 1; }
.nav-badge {
  margin-left: auto; background: var(--red-500); color: #fff; font-size: 11px; font-weight: 700;
  min-width: 20px; height: 20px; border-radius: 20px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

.sidebar-footer { margin-top: 10px; }
.term-box {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08); border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 6px;
}
.term-label { font-size: 10px; font-weight: 700; letter-spacing: .5px; color: rgba(255,255,255,0.45); text-transform: uppercase; }
.term-value { font-size: 13px; font-weight: 600; color: #fff; margin-top: 2px; }
.logout-link {
  display: flex; align-items: center; gap: 10px; margin-top: 4px; padding: 11px 14px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.55); font-size: 14px; font-weight: 500;
}
.logout-link:hover { background: rgba(255,255,255,0.06); color: #fff; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.certificate-editor { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 18px; align-items: start; }
.certificate-canvas-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; min-height: 360px; background: #dfe5ed; overflow: hidden; border-radius: var(--radius); }
/* Templates carry their own page ratio (A4, Letter, 16:9, 4:5, square, custom).
   aspect-ratio stays authoritative and only max-width is constrained, so a tall
   portrait page shrinks in width instead of being distorted — the field boxes
   must stay aligned with the PDF underneath. */
.certificate-canvas-wrap.has-ratio { min-height: 0; margin-inline: auto; }
.certificate-canvas-wrap iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; pointer-events: none; background: #fff; }
.certificate-field-layer { position: absolute; inset: 0; z-index: 2; }
.certificate-field { position: absolute; border: 1px dashed var(--green-600); background: rgba(21,155,107,.18); color: var(--ink-900); display: flex; align-items: center; padding: 0 2px; font-size: 12px; line-height: 1.1; cursor: move; user-select: none; touch-action: none; overflow: hidden; box-sizing: border-box; }
.certificate-field > span { display: block; width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.certificate-field[data-locked="1"] { cursor: not-allowed; opacity: .7; }
.certificate-properties { min-width: 0; }
.certificate-field-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 8px 6px; align-items: end; padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 12px; }
.certificate-field-row .field-row-head { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.certificate-field-row label { font-size: 12px; font-weight: 600; }
.certificate-field-row input, .certificate-field-row select { min-width: 0; width: 100%; padding: 6px; font-size: 11px; }
.certificate-field-cell { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.certificate-field-cell > span { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; color: var(--ink-500); }
.certificate-field-toggles { grid-column: span 2; gap: 4px; }
.certificate-field-toggles label { display: flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 500; }
.certificate-field-toggles input[type="checkbox"] { width: auto; }

.certificate-status { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.certificate-status-item { min-width: 0; font-size: 13px; }
.certificate-status-item > div { margin-top: 4px; }
.certificate-actions { border-top: 1px solid var(--border); padding-top: 16px; }

.certificate-upload-form, .certificate-type-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.certificate-type-form { margin-bottom: 4px; }
.certificate-upload-form input, .certificate-upload-form select,
.certificate-type-form input, .certificate-type-form select { width: 100%; min-width: 0; }
.certificate-upload-form button, .certificate-type-form button { white-space: nowrap; }

.certificate-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.certificate-summary-item { display: flex; flex-direction: column; gap: 2px; }
.certificate-summary-item span { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .3px; opacity: .8; }
.certificate-summary-item strong { font-size: 20px; line-height: 1; }
.certificate-summary-errors { margin: 12px 0 0; padding-left: 18px; font-size: 12.5px; }

.certificate-preview-frame { position: relative; width: 100%; height: 78vh; min-height: 420px; background: #dfe5ed; border-radius: var(--radius); overflow: hidden; }
.certificate-preview-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

@media (max-width: 1000px) { .certificate-editor { grid-template-columns: 1fr; } }

/* ---------- Top bar ---------- */
.topbar {
  height: 68px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; justify-content: space-between;
  padding: 0 26px; position: sticky; top: 0; z-index: 40;
}
.topbar-left { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.mobile-menu-btn { display: none; }
.search-box {
  display: flex; align-items: center; gap: 9px; background: var(--bg-page); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 14px; max-width: 360px; width: 100%; color: var(--ink-500);
}
.search-box input { border: none; background: none; padding: 0; font-size: 13.5px; width: 100%; }
.search-box input:focus { box-shadow: none; }
.search-box svg { flex-shrink: 0; }

.topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: none; background: transparent;
  color: var(--ink-700); display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s ease, color .15s ease; position: relative;
}
.icon-btn:hover, .icon-btn[aria-expanded="true"] { background: var(--green-100); color: var(--green-700); }
.notif-dot {
  position: absolute; top: 3px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--red-500); color: #fff; border-radius: 20px; font-size: 10px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}

.profile-trigger {
  display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 5px; border-radius: 12px;
  border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--ink-900);
  transition: background .15s ease, border-color .15s ease;
}
.profile-trigger:hover, .profile-trigger[aria-expanded="true"] { background: var(--bg-page); border-color: var(--border); }
.profile-trigger .profile-text { text-align: left; line-height: 1.2; }
.profile-trigger .user-name { font-size: 13.5px; font-weight: 600; color: var(--ink-900); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.profile-trigger .user-role { font-size: 11.5px; color: var(--ink-500); }

.user-avatar {
  border-radius: 50%; background: var(--green-600); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0;
}
.avatar-img { border-radius: 50%; object-fit: cover; flex-shrink: 0; }

/* ---------- Dropdown panels ---------- */
.dropdown-wrap { position: relative; }
.dropdown-panel {
  position: absolute; top: calc(100% + 10px); right: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(-6px) scale(.98);
  transition: opacity .16s ease, transform .16s ease, visibility .16s;
  z-index: 200;
}
.dropdown-panel.open { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

.dropdown-header { font-size: 14.5px; font-weight: 600; padding: 14px 16px 10px; color: var(--ink-900); }
.dropdown-footer-link {
  display: block; text-align: center; padding: 12px; font-size: 13px; font-weight: 600;
  color: var(--green-600); border-top: 1px solid var(--border);
}
.dropdown-footer-link:hover { background: var(--green-50); }

.menu-section-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
  color: var(--ink-300); padding: 12px 16px 4px;
}
.dropdown-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 9px 16px; font-size: 14px; font-weight: 500; color: var(--ink-700);
  background: none; border: none; cursor: pointer; font-family: inherit;
  transition: background .12s ease, color .12s ease;
}
.dropdown-item:hover { background: var(--green-50); color: var(--green-700); }
.dropdown-item .icon { flex-shrink: 0; opacity: .8; }
.dropdown-item-danger { color: var(--red-500); }
.dropdown-item-danger:hover { background: var(--red-100); color: var(--red-500); }

.notif-panel { width: 340px; max-width: 90vw; padding-bottom: 4px; }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item { padding: 12px 16px; border-top: 1px solid var(--border); }
.notif-item:first-child { border-top: none; }
.notif-item.unread { background: var(--green-50); }
.notif-title { font-size: 13.5px; font-weight: 600; color: var(--ink-900); }
.notif-msg { font-size: 12.5px; color: var(--ink-500); margin: 3px 0; }
.notif-time { font-size: 11px; color: var(--ink-300); }

.profile-panel { width: 280px; padding-bottom: 8px; }
.profile-panel-head { display: flex; align-items: center; gap: 12px; padding: 16px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.profile-panel-name { font-size: 14.5px; font-weight: 600; color: var(--ink-900); }
.profile-panel-role { font-size: 12px; color: var(--green-600); font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }

.content { padding: 28px; flex: 1; max-width: 1360px; margin: 0 auto; width: 100%; }
.content-plain { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.content-plain:has(.auth-shell) { padding: 0; }

.password-field { position: relative; }
.password-field input { padding-right: 76px; width: 100%; }
.password-toggle {
  position: absolute; top: 1px; right: 1px; bottom: 1px;
  min-width: 58px; border: 0; border-left: 1px solid var(--border); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: transparent; color: var(--green-700); cursor: pointer;
  font: inherit; font-size: 12px; font-weight: 700; padding: 0 9px;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, color .15s ease;
}
.password-toggle:hover { background: var(--green-50); color: var(--green-900); }
.password-toggle:focus-visible { outline: 2px solid var(--green-500); outline-offset: 2px; border-radius: 4px; }

@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translate3d(-100%, 0, 0); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translate3d(0, 0, 0); }
  .mobile-menu-btn { display: flex; }
  .search-box { display: none; }
}

/* Desktop collapsible sidebar (toggle with burger on wider screens) */
@media (min-width: 901px) {
  .app-shell { display: grid; grid-template-columns: 258px minmax(0, 1fr); transition: grid-template-columns .2s ease-out; }
  .app-shell.sidebar-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
  .sidebar.collapsed {
    width: 258px !important;
    transform: translate3d(-100%, 0, 0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .app-shell, .sidebar, .side-nav a, .icon-btn { transition: none !important; }
}
@media (max-width: 640px) {
  .profile-trigger .profile-text { display: none; }
  .content { padding: 16px; }
  .dropdown-panel.notif-panel, .dropdown-panel.profile-panel { position: fixed; top: 68px; left: 12px; right: 12px; width: auto; }
}

/* ---------- Cards & grid ---------- */
.card {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 22px; box-shadow: var(--shadow);
}
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1000px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stat-card { display: flex; flex-direction: column; gap: 6px; transition: transform .15s ease, box-shadow .15s ease; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.stat-label { font-size: 11.5px; color: var(--ink-500); font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.stat-value { font-size: 32px; font-weight: 700; color: var(--ink-900); line-height: 1.15; }
.stat-sub { font-size: 12.5px; color: var(--ink-300); }

.stat-card-amber { background: var(--amber-100); border-color: #f3dfb0; }
.stat-card-amber .stat-label { color: #9a6c0d; }
.stat-card-amber .stat-value { color: var(--amber-500); }
.stat-card-red, .stat-card-danger { background: var(--red-100); border-color: #f4c9c0; }
.stat-card-red .stat-label, .stat-card-danger .stat-label { color: #a53a24; }
.stat-card-red .stat-value, .stat-card-danger .stat-value { color: var(--red-500); }
.stat-card-green, .stat-card-success { background: var(--green-100); border-color: var(--green-300); }
.stat-card-green .stat-label, .stat-card-success .stat-label { color: var(--green-700); }
.stat-card-green .stat-value, .stat-card-success .stat-value { color: var(--green-700); }

.page-head { margin-bottom: 20px; }
.page-title { font-size: 24px; font-weight: 700; color: var(--ink-900); }
.page-sub { font-size: 14px; color: var(--ink-500); margin-top: 4px; }

.section-title { font-size: 16px; font-weight: 600; margin: 0 0 14px; color: var(--ink-900); }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 10px; flex-wrap: wrap; }
.event-filters {
  display: grid; grid-template-columns: minmax(220px, 2fr) repeat(5, minmax(120px, 1fr)); gap: 12px;
  padding: 16px; margin-bottom: 10px; background: var(--bg-page); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.event-filter-field, .event-filter-search { min-width: 0; }
.event-filters label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .35px; margin-bottom: 5px; }
.event-filters input, .event-filters select { padding: 9px 10px; font-size: 13px; }
.event-filter-clear { align-self: end; min-height: 39px; white-space: nowrap; }
.event-filter-result { min-height: 18px; margin: 0 2px 8px; font-size: 12px; }
@media (max-width: 1100px) {
  .event-filters { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
  .event-filter-search { grid-column: span 2; }
}
@media (max-width: 640px) {
  .event-filters { grid-template-columns: 1fr; }
  .event-filter-search { grid-column: auto; }
  .event-filter-clear { width: 100%; }
}
.table-filters {
  display: grid; grid-template-columns: minmax(220px, 2fr) repeat(3, minmax(130px, 1fr)); gap: 12px;
  padding: 16px; margin: 0 0 10px; background: var(--bg-page); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.table-filter-search, .table-filter-field { min-width: 0; }
.table-filters label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .35px; margin-bottom: 5px; }
.table-filters input, .table-filters select { padding: 9px 10px; font-size: 13px; }
.table-filter-clear { align-self: end; min-height: 39px; white-space: nowrap; }
.table-filter-result { grid-column: 1 / -1; min-height: 18px; margin: -2px 2px 0; font-size: 12px; }
.user-row-archived { opacity: .48; }
.user-row-archived:hover td { opacity: .8; }
@media (max-width: 1100px) {
  .table-filters { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
  .table-filter-search { grid-column: span 2; }
}
@media (max-width: 640px) {
  .table-filters { grid-template-columns: 1fr; }
  .table-filter-search { grid-column: auto; }
  .table-filter-clear { width: 100%; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px;
  border: 1px solid transparent; cursor: pointer; transition: all .15s ease;
}
.btn-primary { background: var(--green-600); color: #fff; }
.btn-primary:hover { background: var(--green-700); transform: translateY(-1px); box-shadow: 0 8px 16px rgba(21,155,107,0.25); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--ink-700); }
.btn-outline:hover { border-color: var(--green-400); color: var(--green-700); }
.btn-danger { background: var(--red-500); color: #fff; }
.btn-danger:hover { opacity: .9; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-700); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 11px 13px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  font-family: inherit; font-size: 14.5px; color: var(--ink-900); background: #fff; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--green-500); box-shadow: 0 0 0 3px var(--green-100); }
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.help-text { font-size: 12.5px; color: var(--ink-300); margin-top: 4px; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--ink-500); border-bottom: 1px solid var(--border); padding: 11px 12px; font-weight: 700; }
td { padding: 13px 12px; border-bottom: 1px solid var(--border); color: var(--ink-700); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-page); }
.table-scroll { overflow-x: auto; }

/* ---------- Badges ---------- */
.badge { font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 20px; display: inline-block; }
.badge-green { background: var(--green-100); color: var(--green-700); }
.badge-gray  { background: #eef1f5; color: var(--ink-500); }
.badge-blue  { background: var(--blue-100); color: var(--blue-500); }
.badge-dark  { background: var(--ink-900); color: #fff; }
.badge-red   { background: var(--red-100); color: var(--red-500); }
.badge-amber { background: var(--amber-100); color: var(--amber-500); }

.risk-high   { background: var(--red-100); color: var(--red-500); }
.risk-medium { background: var(--amber-100); color: var(--amber-500); }
.risk-low    { background: var(--green-100); color: var(--green-700); }

.auth-shell { position: relative; height: 100vh; display: flex; overflow: hidden; width: 100%; }
.auth-hero {
  position: absolute; inset: 0; width: 100%;
  background: url('../../bpc_bg.png') center / cover no-repeat;
  color: #fff; padding: 48px 80px; display: flex; flex-direction: column; justify-content: center;
  z-index: 0; overflow: hidden;
}
.auth-hero::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(5,16,27,0.52), rgba(5,16,27,0.18) 70%, rgba(5,16,27,0.08)),
        radial-gradient(circle at 25% 25%, rgba(21,155,107,0.28), transparent 55%),
              radial-gradient(circle at 80% 75%, rgba(47,123,217,0.25), transparent 50%);
  pointer-events: none;
}
.auth-hero-brand, .auth-hero-content, .auth-hero-foot { z-index: 1; text-shadow: 0 2px 5px rgba(0,0,0,0.5); }
.auth-hero-content { position: relative; max-width: 720px; display: flex; flex-direction: column; justify-content: center; padding-left: 48px; align-items: flex-start; text-align: left; margin-top: 8px; }
.auth-hero h1 { font-size: 36px; font-weight: 700; line-height: 1.25; margin: 0 0 16px; }
.auth-hero p { font-size: 15px; color: rgba(255,255,255,0.75); line-height: 1.7; }
.auth-hero-brand { position: absolute; top: 28px; left: 48px; display: flex; align-items: center; gap: 14px; }
.auth-hero-brand .brand-mark { width: 61px; height: 61px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 16px; background: transparent; color: inherit; }
.auth-hero-brand .brand-text { display: flex; flex-direction: column; gap: 2px; }
.auth-hero-brand .brand-name { font-size: 16px; font-weight: 800; color: #fff; }
.auth-hero-brand .brand-sub { font-size: 12px; color: #fff; letter-spacing: .4px; }
.auth-hero-title { font-size: 44px; font-weight: 800; line-height: 1.12; margin: 0 0 18px; color: #fff; }
.auth-hero-sub { font-size: 17px; font-weight: 500; color: #fff; line-height: 1.7; max-width: 600px; }
.auth-hero-foot { position: absolute; left: 48px; bottom: 20px; font-size: 13px; color: #fff; z-index: 2; }
.auth-form-side { position: relative; flex: 1; display: flex; align-items: center; justify-content: flex-end; padding: 48px; background: transparent; z-index: 2; }
.auth-hero-footer { position: relative; font-size: 12.5px; color: rgba(255,255,255,0.4); }
.auth-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 32px; background: var(--bg-page); }
@media (max-width: 900px) {
  .auth-shell { min-height: 100vh; height: auto; overflow-y: auto; }
  .auth-hero { display: flex; position: fixed; inset: 0; padding: 28px 20px 18px; justify-content: flex-start; }
  .auth-hero-brand { position: relative; top: auto; left: auto; align-self: center; text-align: left; }
  .auth-hero-content { display: none; }
  .auth-hero-foot { position: relative; left: auto; right: auto; bottom: auto; align-self: center; margin: -48px 18px 24px; text-align: center; }
  .auth-form-side { min-height: 100vh; box-sizing: border-box; padding: 116px 18px 68px; align-items: center; justify-content: center; }
  .auth-card { margin: 0; max-width: 520px; }
  .auth-card .auth-logo { display: none; }
}

/* ---------- Authentication layout on phones ---------- */
@media (max-width: 768px) {
  .auth-shell {
    display: block;
    width: 100%;
    min-height: 100svh;
    height: auto;
    overflow-x: hidden;
    overflow-y: auto;
  }
  .auth-hero {
    position: absolute;
    inset: 0;
    width: 100%;
    min-height: 100%;
    padding: 22px 16px 76px;
    background-position: center center;
  }
  .auth-hero-brand {
    width: min(100%, 360px);
    max-width: 100%;
    gap: 10px;
    align-items: flex-start;
    overflow-wrap: anywhere;
  }
  .auth-hero-brand .brand-mark {
    width: 48px;
    height: 48px;
  }
  .auth-hero-brand .brand-name {
    font-size: clamp(20px, 6vw, 32px);
    line-height: 1.15;
  }
  .auth-hero-brand .brand-sub {
    font-size: clamp(11px, 3.5vw, 15px);
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .auth-form-side {
    position: relative;
    z-index: 2;
    width: 100%;
    min-height: 100svh;
    padding: 132px 16px 78px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
  }
  .auth-card {
    width: min(100%, 360px);
    max-width: 360px;
    margin: 0 auto;
    padding: 26px 22px;
    border-radius: 16px;
  }
  .auth-header-row {
    gap: 10px;
    margin-bottom: 16px;
  }
  .auth-title {
    font-size: clamp(18px, 5.5vw, 20px);
    line-height: 1.2;
  }
  .auth-sub {
    font-size: 13px;
    line-height: 1.45;
  }
  .auth-card label { font-size: 13px; }
  .auth-card input { min-width: 0; }
  .password-field { width: 100%; min-width: 0; }
  .password-field input { padding-right: 70px; }
  .password-toggle { min-width: 54px; padding: 0 7px; }
  .auth-forgot { font-size: 12px; }
  .auth-hero-foot {
    position: absolute;
    left: 16px;
    right: 16px;
    bottom: 18px;
    width: auto;
    margin: 0;
    font-size: 11.5px;
    line-height: 1.4;
    text-align: center;
    overflow-wrap: anywhere;
  }
}

@media (max-width: 480px) {
  .auth-hero { padding-left: 14px; padding-right: 14px; }
  .auth-form-side { padding-left: 16px; padding-right: 16px; }
  .auth-card { padding: 22px 18px; }
}

@media (max-width: 360px) {
  .auth-form-side { padding-top: 124px; padding-bottom: 72px; }
  .auth-card { padding-left: 16px; padding-right: 16px; }
  .auth-hero-foot { left: 12px; right: 12px; font-size: 11px; }
}

.auth-theme-control { display: flex; justify-content: center; margin: -4px 0 18px; }
.theme-icon[hidden] { display: none; }
.auth-theme-toggle { color: var(--ink-500); }
.auth-theme-toggle:hover { color: var(--green-600); }

.auth-card {
  width: 100%; max-width: 520px; background: #fff; border-radius: 18px;
  box-shadow: var(--shadow-lg); padding: 36px 34px; border: 1px solid var(--border);
  position: relative; z-index: 20; /* sit above the gradient */
  margin: 0 64px 0 0; /* push card toward the right with some space from the viewport edge */
}
@media (max-width: 768px) {
  .auth-card {
    width: min(100%, 360px);
    max-width: 360px;
    margin: 0 auto;
  }
}
.auth-header-row { display:flex; align-items:center; gap:14px; margin-bottom:18px; }
.auth-logo { display: flex; align-items: center; gap: 10px; }
.auth-header-text { display:flex; flex-direction:column; }
.auth-title { font-size: 20px; font-weight: 800; margin: 0; }
.auth-sub { font-size: 13.5px; color: var(--ink-500); margin: 6px 0 0; }
.auth-footer { margin-top: 20px; text-align: center; font-size: 13.5px; color: var(--ink-500); }
.auth-footer a { color: var(--green-600); font-weight: 600; }
.auth-forgot { margin-top: 8px; text-align: right; font-size: 12.5px; }
.auth-forgot a { color: var(--green-600); font-weight: 600; }
.auth-forgot a:hover { color: var(--green-800); text-decoration: underline; }

.alert { padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: var(--red-100); color: var(--red-500); }
.alert-success { background: var(--green-100); color: var(--green-700); }
.alert-info { background: var(--blue-100); color: var(--blue-500); }

/* ---------- QR / Scanner ---------- */
.qr-display-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 20px; }
#qr-canvas-holder { background: #fff; padding: 16px; border-radius: var(--radius); border: 1px solid var(--border); }
.qr-timer { font-size: 14px; font-weight: 600; color: var(--green-700); }
#scanner-viewport { width: 100%; max-width: 420px; border-radius: var(--radius); overflow: hidden; border: 2px solid var(--green-400); }
.scan-result-box { padding: 16px; border-radius: var(--radius-sm); font-weight: 600; text-align: center; }

/* ---------- Dashboard widgets ---------- */
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.quick-action {
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
  padding: 18px 12px; border-radius: var(--radius); border: 1px solid var(--border);
  background: #fff; color: var(--ink-700); font-size: 13.5px; font-weight: 600;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.quick-action:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--green-400); color: var(--green-700); }
.quick-action-icon {
  width: 42px; height: 42px; border-radius: 12px; background: var(--green-100); color: var(--green-700);
  display: flex; align-items: center; justify-content: center;
}

.activity-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 34px; height: 34px; border-radius: 50%; background: var(--green-100); color: var(--green-700); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.activity-text { font-size: 13.5px; color: var(--ink-700); }
.activity-time { font-size: 11.5px; color: var(--ink-300); margin-top: 2px; }

.chart-card canvas { max-width: 100%; }

/* ---------- Profile page ---------- */
.profile-header { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.profile-avatar-lg { position: relative; }
.profile-avatar-lg .avatar-img, .profile-avatar-lg .user-avatar { width: 88px; height: 88px; font-size: 34px; }
.avatar-upload-btn {
  position: absolute; bottom: -2px; right: -2px; width: 30px; height: 30px; border-radius: 50%;
  background: var(--green-600); color: #fff; display: flex; align-items: center; justify-content: center;
  border: 3px solid #fff; cursor: pointer;
}
.tab-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tab-nav a { padding: 10px 16px; font-size: 13.5px; font-weight: 600; color: var(--ink-500); border-bottom: 2px solid transparent; }
.tab-nav a:hover { color: var(--green-700); }
.tab-nav a.active { color: var(--green-700); border-color: var(--green-600); }

/* ---------- Empty / error states ---------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-500); }
.empty-state-icon { width: 56px; height: 56px; border-radius: 50%; background: var(--bg-page); color: var(--ink-300); display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; }
.error-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: var(--bg-page); }
.error-page { text-align: center; padding: 70px 20px; }
.error-code { font-size: 84px; font-weight: 800; color: var(--green-600); line-height: 1; }
.error-title { font-size: 20px; font-weight: 700; margin: 10px 0 6px; }
.error-text, .error-msg { color: var(--ink-500); font-size: 14.5px; margin-bottom: 22px; }

/* ---------- Misc ---------- */
.text-muted { color: var(--ink-500); }
.mt-16 { margin-top: 16px; } .mb-16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; gap: 10px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Loading ---------- */
.loading-shell { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: var(--bg-page); }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--green-100); border-top-color: var(--green-600); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Confirmation modal ---------- */
body.modal-open { overflow: hidden; }
.confirm-modal { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; }
.confirm-modal[hidden] { display: none; }
.confirm-modal-backdrop { position: absolute; inset: 0; background: rgba(10,17,32,.62); backdrop-filter: blur(4px); }
.confirm-dialog { position: relative; width: min(100%, 420px); padding: 28px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); text-align: center; }
.confirm-dialog-icon { width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--green-100); color: var(--green-700); }
.confirm-dialog h2 { margin: 0 0 8px; font-size: 18px; color: var(--ink-900); }
.confirm-dialog p { margin: 0; color: var(--ink-500); font-size: 14px; line-height: 1.6; }
.confirm-dialog-actions { display: flex; justify-content: center; gap: 10px; margin-top: 22px; }
.confirm-dialog-actions .btn { min-width: 100px; }
html.theme-dark .confirm-dialog { background: #101a2c; border-color: var(--border); }
@media (max-width: 480px) { .confirm-dialog { padding: 24px 20px; } .confirm-dialog-actions .btn { flex: 1; } }

/* ---------- Authentication modal ---------- */
.auth-modal { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-modal[hidden] { display: none; }
.auth-modal-backdrop { position: absolute; inset: 0; background: rgba(10,17,32,.62); backdrop-filter: blur(4px); }
.auth-modal-dialog { position: relative; width: min(100%, 440px); max-height: calc(100vh - 40px); overflow-y: auto; padding: 30px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.auth-modal-dialog h2 { margin: 0 32px 8px 0; font-size: 20px; color: var(--ink-900); }
.auth-modal-copy { margin: 0 0 20px; color: var(--ink-500); font-size: 13.5px; line-height: 1.6; }
.auth-modal-close { position: absolute; top: 12px; right: 14px; border: 0; background: transparent; color: var(--ink-500); font-size: 26px; line-height: 1; cursor: pointer; }
.auth-modal-close:hover { color: var(--ink-900); }
.auth-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
html.theme-dark .auth-modal-dialog { background: #101a2c; border-color: var(--border); }
@media (max-width: 480px) { .auth-modal { padding: 12px; } .auth-modal-dialog { padding: 26px 20px 20px; max-height: calc(100vh - 24px); } .auth-modal-actions { flex-direction: column-reverse; } .auth-modal-actions .btn { width: 100%; } }