/* NVQ Portal — dark dashboard theme, amber accent, top header + left
   sidebar. Plain hand-written CSS, no build step. Palette/type/shape
   deliberately matched to the Burraq ISO Portal (BIPM) design language:
   slate-950/900/800 surfaces, amber-500 accent, Plus Jakarta Sans,
   generous rounded corners. One `@import` for the webfont is the only
   external request this file makes.

   Sizing: BIPM keeps its whole UI compact by setting the root font-size
   below the 16px browser default (its rem-based Tailwind spacing/type
   inherits that automatically) plus tight, mostly-px component paddings.
   Mirrored here: html below sets the same 15px/13px root, and every
   fixed-px dimension (avatar/icon circles, header height, card/button/
   input padding) is sized to match rather than left at the original,
   more spacious pass. */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg: #020617;
  --surface: #0f172a;
  --surface-2: #1e293b;
  --surface-3: #334155;
  --border: #1e293b;
  --border-strong: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --amber: #f59e0b;
  --amber-hover: #d97706;
  --amber-bg: rgba(245, 158, 11, 0.12);
  --amber-border: rgba(245, 158, 11, 0.35);
  --on-amber: #020617;

  --success: #34d399;
  --success-bg: rgba(16, 185, 129, 0.12);
  --error: #f87171;
  --error-bg: rgba(239, 68, 68, 0.12);
  --info: #38bdf8;
  --info-bg: rgba(14, 165, 233, 0.12);
  --neutral: #94a3b8;
  --neutral-bg: rgba(148, 163, 184, 0.10);

  --radius-sm: 7px;
  --radius: 10px;
  --radius-lg: 13px;
  --radius-xl: 20px;
  --header-height: 56px;
  --sidebar-width: 208px;
}

* { box-sizing: border-box; }

html {
  font-size: 15px;
}
html, body { height: 100%; }

@media (max-width: 640px) {
  html { font-size: 13px; }
}

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

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

h1, h2, h3 { color: #fff; line-height: 1.3; font-weight: 700; }
h1 { font-size: 1.35rem; margin: 0 0 16px; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }

/* ---------------------------------------------------------------- */
/* Top header bar                                                     */
/* ---------------------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--header-height);
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  color: #fff;
  font-weight: 800;
}
.brand:hover { color: #fff; }
.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--amber);
  color: var(--on-amber);
  font-size: 0.72rem;
  font-weight: 800;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.18);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.brand-name {
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-tagline {
  font-size: 0.66rem;
  font-weight: 500;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-spacer { flex: 1; }

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

.icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 0.85rem;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.topbar-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.6rem;
  font-weight: 800;
  line-height: 15px;
  text-align: center;
}

.role-switch { margin: 0; }
.role-switch select {
  margin: 0;
  width: auto;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 6px 9px;
  border-radius: 999px;
}
.active-role-badge {
  display: inline-block;
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber-border);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 0.68rem;
  font-weight: 700;
  width: fit-content;
  white-space: nowrap;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 7px;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  color: var(--amber);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.75rem;
  flex-shrink: 0;
}
.user-name {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.user-name-wrap { display: none; flex-direction: column; line-height: 1.2; }

.signout-btn {
  display: inline-flex;
  align-items: center;
  background: rgba(239, 68, 68, 0.10);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font: inherit;
  font-weight: 700;
  font-size: 0.7rem;
  cursor: pointer;
}
.signout-btn:hover { background: rgba(239, 68, 68, 0.18); }

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  font-size: 0.95rem;
  cursor: pointer;
  flex-shrink: 0;
}

/* ---------------------------------------------------------------- */
/* App shell: header + sidebar + scrolling main column                */
/* ---------------------------------------------------------------- */

.app-shell {
  display: flex;
  min-height: calc(100vh - var(--header-height));
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: rgba(15, 23, 42, 0.7);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

.sidebar-nav {
  flex: 1;
  padding: 11px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 9px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  color: var(--text-muted);
  font-weight: 700;
  font-size: 0.74rem;
}
.sidebar-nav a:hover {
  background: rgba(30, 41, 59, 0.6);
  color: var(--text);
}
.sidebar-nav a.active {
  background: var(--amber-bg);
  color: var(--amber);
  border-color: var(--amber-border);
}
.nav-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.12);
  font-size: 0.66rem;
  flex-shrink: 0;
}
.sidebar-nav a.active .nav-icon { background: rgba(245, 158, 11, 0.18); }
/* Per-item icon-bubble tints — matches the BIPM sidebar's practice of
   giving each destination its own accent color regardless of active
   state, so the nav reads at a glance even before you look at labels. */
.nav-icon-amber { background: rgba(245, 158, 11, 0.14); color: #f59e0b; }
.nav-icon-sky { background: rgba(14, 165, 233, 0.14); color: #38bdf8; }
.nav-icon-violet { background: rgba(139, 92, 246, 0.14); color: #a78bfa; }
.nav-icon-emerald { background: rgba(16, 185, 129, 0.14); color: #34d399; }
.nav-icon-rose { background: rgba(244, 63, 94, 0.14); color: #fb7185; }
.nav-label { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-badge {
  background: var(--amber);
  color: var(--on-amber);
  border-radius: 999px;
  font-size: 0.64rem;
  font-weight: 800;
  padding: 1px 6px;
  line-height: 1.5;
  flex-shrink: 0;
}

.main-col { flex: 1; min-width: 0; }

.content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 22px 26px 34px;
}
body:not(.has-sidebar) .content {
  padding: 26px 20px;
}

/* ---------------------------------------------------------------- */
/* Forms                                                              */
/* ---------------------------------------------------------------- */

form label {
  display: block;
  margin-bottom: 13px;
  font-weight: 700;
  font-size: 0.76rem;
  color: var(--text);
}
input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.8rem;
  background: var(--bg);
  color: var(--text);
  color-scheme: dark;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 3px var(--amber-bg);
}
input:disabled { color: var(--text-faint); background: var(--surface); }
textarea { min-height: 90px; resize: vertical; }

button, .button {
  display: inline-block;
  background: var(--amber);
  color: var(--on-amber);
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 15px;
  font: inherit;
  font-weight: 800;
  font-size: 0.74rem;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 6px 16px rgba(245, 158, 11, 0.15);
}
button:hover, .button:hover { background: var(--amber-hover); }
button.secondary, .button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border-strong);
  font-weight: 700;
  box-shadow: none;
}
button.secondary:hover { background: var(--surface-3); }
button.danger, .button.danger { background: #ef4444; color: #fff; box-shadow: none; }
button.danger:hover { background: #dc2626; }

.link-button {
  background: none;
  border: none;
  color: var(--amber);
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}

/* ---------------------------------------------------------------- */
/* Cards / tables                                                     */
/* ---------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  margin-bottom: 16px;
  overflow-x: auto;
}
table { width: 100%; border-collapse: collapse; background: transparent; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); font-size: 0.8rem; white-space: nowrap; }
td { white-space: normal; }
th { color: var(--text-muted); font-weight: 700; font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.04em; }
tr:last-child td { border-bottom: none; }

/* Status badges */
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.66rem; font-weight: 800; }
.badge-submitted { background: var(--amber-bg); color: var(--amber); }
.badge-assessor_reviewed { background: var(--info-bg); color: var(--info); }
.badge-iqa_sampled { background: var(--info-bg); color: var(--info); }
.badge-iqa_verified,
.badge-competent,
.badge-verified { background: var(--success-bg); color: var(--success); }
.badge-not_yet_competent,
.badge-referred,
.badge-iqa_returned,
.badge-sent_back { background: var(--error-bg); color: var(--error); }
.badge-not-started { background: var(--neutral-bg); color: var(--neutral); }

/* Flash messages */
.flash { padding: 9px 13px; border-radius: var(--radius-sm); margin-bottom: 14px; font-size: 0.8rem; font-weight: 600; border: 1px solid transparent; }
.flash-success { background: var(--success-bg); color: var(--success); border-color: rgba(52, 211, 153, 0.3); }
.flash-error, .form-error { background: var(--error-bg); color: var(--error); border: 1px solid rgba(248, 113, 113, 0.3); padding: 9px 13px; border-radius: var(--radius-sm); font-weight: 600; }

/* Auth pages (login / setup — no header/sidebar) */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; }
.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.auth-card .brand-mark { width: 44px; height: 44px; font-size: 0.95rem; border-radius: var(--radius-lg); margin: 0 auto 14px; box-shadow: 0 10px 24px rgba(245, 158, 11, 0.2); }
.auth-card h1 { margin-top: 0; margin-bottom: 4px; font-size: 1.2rem; font-weight: 800; text-align: center; letter-spacing: -0.01em; }
.subtitle { color: var(--text-muted); margin-top: 0; margin-bottom: 18px; font-size: 0.76rem; text-align: center; }

/* Portfolio tree */
.tree-unit { margin-bottom: 16px; }
.tree-lo { margin: 8px 0 8px 14px; }
.tree-ac {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  margin-bottom: 7px;
}
.tree-ac-desc { flex: 1; font-size: 0.82rem; }
.progress-bar { background: var(--surface-3); border-radius: 999px; height: 7px; overflow: hidden; }
.progress-bar-fill { background: var(--amber); height: 100%; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.muted { color: var(--text-muted); }
.actions { display: flex; gap: 9px; flex-wrap: wrap; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.filters label { margin-bottom: 0; }
.filters select, .filters input { width: auto; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
.stat-tile .value { font-size: 1.55rem; font-weight: 800; color: var(--amber); }
.stat-tile .label { color: var(--text-muted); font-size: 0.72rem; font-weight: 600; margin-top: 2px; }

.file-list { list-style: none; padding: 0; margin: 6px 0; }
.file-list li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 0.8rem; }
.file-list li:last-child { border-bottom: none; }

/* ---------------------------------------------------------------- */
/* Responsive: collapse sidebar under a toggleable drawer             */
/* ---------------------------------------------------------------- */

@media (min-width: 641px) {
  .user-name-wrap { display: flex; }
}

@media (max-width: 860px) {
  .sidebar-toggle { display: inline-flex; }
  .brand-tagline { display: none; }

  .sidebar {
    position: fixed;
    left: 0;
    top: var(--header-height);
    z-index: 25;
    width: 100%;
    height: auto;
    max-height: calc(100vh - var(--header-height));
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.15s ease, opacity 0.15s ease;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.4);
  }
  .sidebar.open { transform: translateY(0); opacity: 1; pointer-events: auto; }

  .content { padding: 20px 16px 28px; }
}

@media (max-width: 640px) {
  .role-switch, .active-role-badge { display: none; }
}
