/* ── Variables ──────────────────────────────────────────────── */
:root {
  --navy:   #1A2744;
  --navy-light: #243563;
  --orange: #E87722;
  --orange-dark: #cc6510;
  --bg:     #F5F6F8;
  --white:  #FFFFFF;
  --card:   #FFFFFF;
  --success:#2E7D32;
  --danger: #C62828;
  --warning:#F9A825;
  --gray:   #6B7280;
  --gray-light: #E5E7EB;
  --gray-dark: #374151;
  --text:   #111827;
  --border: #D1D5DB;
  --radius: 14px;
  --radius-sm: 9px;
  --radius-lg: 18px;
  --orange-tint: rgba(232,119,34,0.12);
  --shadow-xs: 0 1px 2px rgba(16,24,40,0.05);
  --shadow: 0 1px 2px rgba(16,24,40,0.05), 0 1px 3px rgba(16,24,40,0.06);
  --shadow-md: 0 4px 14px rgba(16,24,40,0.09), 0 2px 6px rgba(16,24,40,0.05);
  --shadow-lg: 0 16px 40px rgba(16,24,40,0.14);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  height: 100%;
  overflow: hidden; /* page never scrolls — content areas scroll internally */
}
#app { height: 100%; overflow-y: auto; } /* fallback scroll for login/signup/error pages */
a { color: var(--navy); text-decoration: none; }
img { max-width: 100%; }
button { font-family: var(--font); cursor: pointer; border: none; background: none; }
input, select, textarea {
  font-family: var(--font);
  font-size: 16px; /* prevent iOS zoom */
}

/* ── Loading ────────────────────────────────────────────────── */
.loading-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 24px;
}
.loading-logo { width: 100px; opacity: 0.9; }
.loading-spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--gray-light);
  border-top-color: var(--orange);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Layout shells ──────────────────────────────────────────── */
.shell-employee {
  display: flex; flex-direction: column; height: 100%; overflow: hidden;
}
.shell-admin {
  display: flex; height: 100%; overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────────── */
.header {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  height: 56px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.header-logo { height: 36px; width: auto; }
.header-title {
  font-size: 17px; font-weight: 700; color: var(--navy);
  flex: 1;
}
.header-right { display: flex; align-items: center; gap: 8px; }

/* ── Bottom tabs (employee mobile) ─────────────────────────── */
.bottom-tabs {
  display: flex;
  flex-shrink: 0;
  background: var(--white);
  border-top: 1px solid var(--border);
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom);
}
.tab-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 8px 4px; gap: 3px;
  color: var(--gray); font-size: 10px; font-weight: 500;
  transition: color 0.15s;
}
.tab-btn.active { color: var(--orange); }
.tab-icon { font-size: 22px; line-height: 1; }
.main-content {
  flex: 1; min-height: 0; padding: 16px 16px 32px;
  overflow-y: auto;
}

/* ── Admin sidebar ──────────────────────────────────────────── */
.admin-sidebar {
  width: 250px;
  background: linear-gradient(180deg, #1F2E52 0%, #131C34 100%);
  display: flex; flex-direction: column;
  height: 100%;
  flex-shrink: 0;
  border-right: 1px solid rgba(0,0,0,0.25);
}
.sidebar-header {
  padding: 18px 16px 15px;
  display: flex; align-items: center; gap: 11px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sidebar-logo {
  height: 32px; width: auto;
  background: #fff; padding: 5px 8px;
  border-radius: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}
.sidebar-brand { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.sidebar-brand-title { font-size: 14px; font-weight: 700; color: #fff; letter-spacing: -0.01em; }
.sidebar-brand-sub { font-size: 11px; font-weight: 500; color: rgba(255,255,255,0.5); }
.sidebar-nav { flex: 1; padding: 8px 10px; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.sidebar-group-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
  color: rgba(255,255,255,0.36);
  padding: 13px 10px 5px;
}
.sidebar-group-label:first-child { padding-top: 5px; }
.sidebar-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 11px;
  color: rgba(255,255,255,0.74);
  font-size: 14px; font-weight: 500;
  cursor: pointer;
  border-radius: 10px;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-link.active {
  background: linear-gradient(180deg, var(--orange), var(--orange-dark));
  color: #fff;
  box-shadow: 0 4px 12px rgba(232,119,34,0.42);
}
.sidebar-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; flex-shrink: 0;
  color: rgba(255,255,255,0.6);
}
.sidebar-icon svg { width: 19px; height: 19px; }
.sidebar-link:hover .sidebar-icon, .sidebar-link.active .sidebar-icon { color: #fff; }
.sidebar-footer {
  padding: 8px 10px 14px; display: flex; flex-direction: column; gap: 2px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.admin-content {
  flex: 1; min-height: 0; padding: 28px 32px; overflow-y: auto; min-width: 0;
  background: var(--bg);
}
.admin-header {
  background: rgba(255,255,255,0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding: 0 24px;
  height: 60px;
  display: flex; align-items: center; gap: 12px;
  flex-shrink: 0; z-index: 50;
}
.admin-header-title { font-size: 15px; font-weight: 700; color: var(--navy); flex: 1; letter-spacing: -0.01em; }
.admin-header-right { display: flex; align-items: center; gap: 10px; }
.admin-user { display: flex; align-items: center; gap: 9px; }
.admin-user-name { font-size: 13px; font-weight: 600; color: var(--gray-dark); }
.admin-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(180deg, var(--navy-light), var(--navy));
  color: #fff; font-size: 12px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  letter-spacing: 0.02em; flex-shrink: 0;
}
.hamburger-btn {
  display: none; padding: 7px;
  color: var(--navy); cursor: pointer;
  background: transparent; border-radius: 8px;
}
.hamburger-btn svg { width: 22px; height: 22px; }
.hamburger-btn:hover { background: rgba(0,0,0,0.05); }

@media (max-width: 768px) {
  .admin-sidebar {
    position: fixed; left: -250px; top: 0; bottom: 0; height: auto; z-index: 200;
    transition: left 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .admin-sidebar.open { left: 0; }
  .sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
    z-index: 199;
  }
  .sidebar-overlay.open { display: block; }
  .hamburger-btn { display: flex; }
  .admin-content { padding: 18px 16px; }
  .admin-user-name { display: none; }

  /* Tables on phones: keep every row on one line and let the wrapper
     scroll sideways — long text truncates with … instead of stacking
     each word on its own line. */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .table-wrap td { white-space: nowrap; max-width: 62vw; overflow: hidden; text-overflow: ellipsis; }
  .table-wrap th { padding: 10px 12px; }
  .table-wrap td { padding: 11px 12px; }
}

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid rgba(16,24,40,0.05);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 700; color: var(--navy); letter-spacing: -0.01em; }

/* ── Stat cards (dashboard) ─────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid rgba(16,24,40,0.05);
  padding: 20px; text-align: left;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-value { font-size: 34px; font-weight: 800; color: var(--navy); letter-spacing: -0.02em; line-height: 1.1; }
.stat-value.danger { color: var(--danger); }
.stat-value.success { color: var(--success); }
.stat-label { font-size: 11.5px; color: var(--gray); margin-top: 7px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Training item cards ─────────────────────────────────────── */
.training-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px;
  margin-bottom: 12px;
  border-left: 4px solid var(--navy);
}
.training-card.overdue { border-left-color: var(--danger); }
.training-card.completed { border-left-color: var(--success); }
.training-card-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.training-card-meta {
  display: flex; flex-wrap: wrap; gap: 6px;
  font-size: 12px; color: var(--gray); margin-bottom: 12px;
}
.chip {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 100px;
  background: var(--gray-light); color: var(--gray-dark);
  font-size: 11px; font-weight: 500;
}
.chip.overdue { background: #FDECEA; color: var(--danger); }
.chip.due { background: #EBF0FF; color: var(--navy); }
.chip.completed { background: #E8F5E9; color: var(--success); }
.chip.warning { background: #FFF8E1; color: var(--warning); }
.media-icons { display: flex; gap: 6px; margin-bottom: 12px; }
.media-icon {
  font-size: 11px; padding: 3px 8px;
  border-radius: 100px; background: var(--gray-light);
  color: var(--gray-dark); font-weight: 500;
}

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 7px; padding: 11px 18px;
  border-radius: 10px; font-weight: 600;
  font-size: 14.5px; cursor: pointer; letter-spacing: -0.01em;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, filter 0.15s ease;
  border: none; line-height: 1;
  min-height: 44px;
}
.btn:active { transform: scale(0.97); }
.btn svg { width: 18px; height: 18px; }
.btn-primary {
  background: linear-gradient(180deg, #ef8434, var(--orange)); color: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12), 0 2px 8px rgba(232,119,34,0.28);
}
.btn-primary:hover { filter: brightness(1.04); box-shadow: 0 2px 12px rgba(232,119,34,0.42); }
.btn-secondary {
  background: linear-gradient(180deg, #26386a, var(--navy)); color: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12);
}
.btn-secondary:hover { filter: brightness(1.1); }
.btn-ghost {
  background: rgba(26,39,68,0.06); color: var(--navy);
}
.btn-ghost:hover { background: rgba(26,39,68,0.11); }
.btn-danger {
  background: linear-gradient(180deg, #d83b3b, var(--danger)); color: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12), 0 2px 8px rgba(198,40,40,0.26);
}
.btn-danger:hover { filter: brightness(1.05); }
.btn-success {
  background: linear-gradient(180deg, #369a3c, var(--success)); color: white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12), 0 2px 8px rgba(46,125,50,0.26);
}
.btn-success:hover { filter: brightness(1.05); }
.btn-sm {
  padding: 7px 13px; font-size: 13px; min-height: 34px; border-radius: 8px; gap: 5px;
}
.btn-sm svg { width: 15px; height: 15px; }
.btn-icon { padding: 0; width: 34px; min-width: 34px; min-height: 34px; }
.btn-icon svg { width: 16px; height: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--gray-dark); margin-bottom: 6px;
}
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px; color: var(--text);
  background: white;
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
}
.form-input::placeholder, .form-textarea::placeholder { color: #9AA1AC; }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(232,119,34,0.13);
}
.form-textarea { resize: vertical; min-height: 80px; }
.check-line {
  display: flex; align-items: flex-start; gap: 10px;
  cursor: pointer; margin: 0;
  font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.45;
}
.check-line input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--orange); margin: 1px 0 0; }
.form-select { background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-position: right 10px center; background-repeat: no-repeat; background-size: 16px; padding-right: 36px; }

/* ── OTP input ──────────────────────────────────────────────── */
.otp-grid { display: flex; gap: 8px; justify-content: center; margin: 20px 0; }
.otp-input {
  width: 48px; height: 60px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center; font-size: 24px; font-weight: 700;
  color: var(--navy);
}
.otp-input:focus { border-color: var(--orange); outline: none; }

/* ── Login page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.login-box {
  width: 100%; max-width: 400px;
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 32px 24px;
}
.login-logo { height: 80px; display: block; margin: 0 auto 16px; }
.login-title { font-size: 22px; font-weight: 800; text-align: center; color: var(--navy); margin-bottom: 4px; }
.login-sub { font-size: 13px; color: var(--gray); text-align: center; margin-bottom: 24px; }
.dev-banner {
  background: var(--warning); color: #333;
  padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 12px; text-align: center; margin-bottom: 16px;
  font-weight: 600;
}

/* ── Phone input ────────────────────────────────────────────── */
.phone-input-wrapper { position: relative; }
.phone-prefix {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  font-weight: 600; color: var(--gray); pointer-events: none;
}
.phone-input { padding-left: 34px !important; }

/* ── Section headers ─────────────────────────────────────────── */
.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.section-title { font-size: 20px; font-weight: 800; color: var(--navy); letter-spacing: -0.02em; }
.section-sub { font-size: 13px; color: var(--gray); margin-top: 2px; }

/* ── Tabs (within page) ─────────────────────────────────────── */
.page-tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--gray-light);
  margin-bottom: 20px; overflow-x: auto;
}
.page-tab {
  padding: 9px 14px; font-size: 14px; font-weight: 600;
  color: var(--gray); cursor: pointer; white-space: nowrap;
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  transition: all 0.15s;
}
.page-tab:hover { color: var(--navy); background: rgba(16,24,40,0.03); }
.page-tab.active { color: var(--orange); border-bottom-color: var(--orange); }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid rgba(16,24,40,0.05); background: white; }
table { width: 100%; border-collapse: collapse; background: white; font-size: 14px; }
thead { background: #F7F8FA; color: var(--gray); }
th { padding: 12px 16px; text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; border-bottom: 1px solid var(--gray-light); }
td { padding: 13px 16px; border-bottom: 1px solid #F1F2F4; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tr:hover td { background: #FAFBFC; }

/* ── Matrix view ────────────────────────────────────────────── */
.matrix-wrap {
  overflow: auto; max-height: 70vh;
  border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid rgba(16,24,40,0.05); background: white;
}
.matrix-table { border-collapse: collapse; font-size: 12.5px; min-width: 100%; background: white; }
.matrix-table th, .matrix-table td { padding: 9px 10px; border: 1px solid var(--border); white-space: nowrap; }
.matrix-table .freeze { position: sticky; left: 0; background: white; z-index: 10; min-width: 130px; }
.matrix-table thead th { background: var(--navy); color: white; position: sticky; top: 0; z-index: 5; }
.matrix-table thead th:not(.freeze) {
  white-space: normal; min-width: 104px; max-width: 150px;
  font-size: 10px; line-height: 1.35; vertical-align: middle; text-align: center;
}
.matrix-table thead th.freeze { z-index: 15; background: var(--navy); color: white; }
.matrix-cell-done { color: var(--success); text-align: center; font-size: 14px; }
.matrix-cell-none { text-align: center; color: var(--gray-light); }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 48px 24px; color: var(--gray);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-title { font-size: 18px; font-weight: 700; color: var(--gray-dark); margin-bottom: 6px; }
.empty-sub { font-size: 14px; }

/* ── Toast ──────────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; align-items: center;
}
.toast {
  background: #1F2937; color: white;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease, toast-out 0.3s ease 2.5s forwards;
  pointer-events: auto;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(10px); } }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 500;
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
}
.modal {
  background: white; border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto;
}
@media (min-width: 600px) {
  .modal { border-radius: var(--radius); }
}
.modal-title { font-size: 18px; font-weight: 800; color: var(--navy); margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ── Lesson player ──────────────────────────────────────────── */
.player-page { padding-bottom: 40px; max-width: 700px; margin: 0 auto; }
.step-tracker {
  display: flex; align-items: center;
  background: white; border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 16px;
  margin-bottom: 16px; gap: 4px;
  overflow-x: auto;
}
.step {
  display: flex; flex-direction: column; align-items: center;
  flex: 1; gap: 4px; min-width: 60px;
}
.step-dot {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--gray-light); color: var(--gray);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.step.done .step-dot { background: var(--success); color: white; }
.step.active .step-dot { background: var(--orange); color: white; }
.step-label { font-size: 10px; color: var(--gray); font-weight: 500; }
.step-divider { height: 2px; flex: 1; background: var(--gray-light); min-width: 12px; }
.step.done .step-divider { background: var(--success); }

.section-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px;
  overflow: hidden;
}
.section-card-header {
  padding: 14px 16px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--gray-light);
}
.section-card-title { font-size: 16px; font-weight: 700; color: var(--navy); }
.section-card-body { padding: 16px; }

.video-wrapper { position: relative; background: black; border-radius: 0; }
video { width: 100%; max-height: 260px; display: block; }

/* Quiz */
.quiz-question { font-size: 17px; font-weight: 700; color: var(--navy); margin-bottom: 16px; }
.quiz-progress { font-size: 12px; color: var(--gray); margin-bottom: 12px; }
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
  padding: 14px 16px; border: 2px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 15px; text-align: left; background: white;
  transition: all 0.15s; min-height: 48px;
}
.quiz-option:hover { border-color: var(--orange); background: #FFF8F2; }
.quiz-option.selected { border-color: var(--orange); background: #FFF8F2; }
.quiz-option.correct { border-color: var(--success); background: #E8F5E9; color: var(--success); }
.quiz-option.wrong { border-color: var(--danger); background: #FDECEA; color: var(--danger); }

/* Signature canvas */
.sig-canvas-wrap { border: 2px solid var(--border); border-radius: var(--radius-sm); background: white; position: relative; }
#sig-canvas { width: 100%; height: 150px; touch-action: none; cursor: crosshair; display: block; }
.sig-clear { position: absolute; top: 8px; right: 8px; }

/* ── Progress bar (upload) ──────────────────────────────────── */
.progress-wrap { margin: 12px 0; }
.progress-bar-bg {
  height: 8px; background: var(--gray-light);
  border-radius: 100px; overflow: hidden;
}
.progress-bar-fill {
  height: 100%; background: var(--orange);
  border-radius: 100px; transition: width 0.3s ease;
}
.progress-label { font-size: 12px; color: var(--gray); margin-top: 4px; }

/* ── Dropzone ────────────────────────────────────────────────── */
.dropzone {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 32px 16px; text-align: center; cursor: pointer;
  transition: all 0.15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--orange); background: #FFF8F2; }
.dropzone-icon { font-size: 32px; margin-bottom: 8px; }
.dropzone-text { font-size: 14px; color: var(--gray); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 100px; font-size: 11px; font-weight: 700;
  background: var(--danger); color: white;
}

/* ── Confetti ────────────────────────────────────────────────── */
.confetti-wrap {
  text-align: center; padding: 24px; background: #E8F5E9;
  border-radius: var(--radius); margin-bottom: 16px;
}
.confetti-icon { font-size: 48px; margin-bottom: 8px; }
.confetti-title { font-size: 20px; font-weight: 800; color: var(--success); }
.confetti-sub { font-size: 14px; color: var(--gray); }

/* ── Greeting ────────────────────────────────────────────────── */
.greeting { font-size: 22px; font-weight: 800; color: var(--navy); margin-bottom: 4px; }
.greeting-sub { font-size: 14px; color: var(--gray); margin-bottom: 16px; }

/* ── Misc ────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--gray-light); margin: 16px 0; }
.text-sm { font-size: 13px; }
.text-gray { color: var(--gray); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-navy { color: var(--navy); }
.fw-bold { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.justify-between { justify-content: space-between; }
.page-title { font-size: 26px; font-weight: 800; color: var(--navy); margin-bottom: 4px; letter-spacing: -0.02em; }
.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: center; }
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2px solid var(--gray-light); border-top-color: var(--orange);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
.hidden { display: none !important; }

/* ── Collapsible ────────────────────────────────────────────── */
.collapsible-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--card);
  border-radius: var(--radius); box-shadow: var(--shadow);
  cursor: pointer; font-weight: 600; color: var(--navy);
  margin-bottom: 8px;
}
.collapsible-body { display: none; }
.collapsible-body.open { display: block; }

/* ── Switch toggle ──────────────────────────────────────────── */
.toggle-wrap { display: flex; align-items: center; gap: 10px; }
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--gray-light); border-radius: 100px;
  transition: 0.2s; cursor: pointer;
}
.toggle-slider::before {
  content: ""; position: absolute;
  width: 18px; height: 18px; left: 3px; bottom: 3px;
  background: white; border-radius: 50%; transition: 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--orange); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* Admin page tabs wrapper */
.admin-page { min-height: 0; }

/* ── Form builder ───────────────────────────────────────────── */
.fb-topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.fb-title-input {
  flex: 1; min-width: 140px; font-size: 17px; font-weight: 700; color: var(--navy);
  border: 1.5px solid transparent; border-radius: 10px; padding: 8px 10px; background: transparent;
}
.fb-title-input:hover { border-color: #d7dce3; background: #fff; }
.fb-title-input:focus { border-color: var(--orange); background: #fff; outline: none; }
.fb-save-status { font-size: 12px; font-weight: 600; color: var(--gray); white-space: nowrap; }
.fb-save-status.dirty { color: var(--warning); }
.fb-save-status.saved { color: var(--success); }
.fb-topbar-actions { display: flex; gap: 8px; }

.fb-layout { display: grid; grid-template-columns: 230px minmax(0,1fr) 290px; gap: 14px; align-items: start; }
.fb-panel-title { font-size: 14px; font-weight: 700; color: var(--navy); }
.fb-panel-sub { font-size: 11.5px; color: var(--gray); margin: 2px 0 10px; }

.fb-palette { padding: 14px; position: sticky; top: 0; max-height: calc(100vh - 185px); overflow-y: auto; }
.fb-palette-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 9px; border-radius: 9px;
  cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none;
  border: 1px solid transparent; font-size: 13px; font-weight: 600; color: var(--gray-dark);
}
.fb-palette-item:hover { background: rgba(232,119,34,0.08); border-color: rgba(232,119,34,0.25); color: var(--navy); }
.fb-palette-item:hover .fb-palette-add { opacity: 1; }
.fb-palette-glyph {
  width: 26px; height: 26px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: #f0f2f6; border-radius: 7px; font-size: 13px; font-weight: 700; color: var(--navy);
}
.fb-palette-label { flex: 1; }
.fb-palette-add { opacity: 0; color: var(--orange); font-weight: 800; font-size: 16px; }

.fb-canvas-wrap { min-width: 0; }
.fb-canvas { padding: 16px; min-height: 320px; }
.fb-canvas.fb-drop-target { outline: 2px dashed var(--orange); outline-offset: -6px; }
.fb-canvas-empty { text-align: center; padding: 60px 16px; color: var(--gray); }

.fb-field {
  display: flex; align-items: stretch; gap: 4px; border: 1.5px solid #e4e8ee; border-radius: 12px;
  background: #fff; margin-bottom: 10px; cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.fb-field:hover { border-color: #c9d2de; }
.fb-field.selected { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(232,119,34,0.15); }
.fb-field.fb-dragging { opacity: 0.45; }
.fb-field-layout { background: #f7f9fb; }
.fb-field-grip {
  flex: none; display: flex; align-items: center; padding: 0 4px 0 8px; color: #b7bec9;
  cursor: grab; touch-action: none;
}
.fb-field-grip:active { cursor: grabbing; }
.fb-field-body { flex: 1; min-width: 0; padding: 11px 4px 12px 2px; }
.fb-field-top { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.fb-field-type { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--gray); }
.fb-req-chip { font-size: 10px; font-weight: 700; color: var(--danger); background: #FDECEA; border-radius: 99px; padding: 1px 8px; }
.fb-field-label { font-size: 14.5px; font-weight: 600; color: var(--text); overflow-wrap: anywhere; }
.fb-field-heading { font-size: 17px; font-weight: 800; color: var(--navy); overflow-wrap: anywhere; }
.fb-field-help { font-size: 12px; color: var(--gray); margin-top: 1px; overflow-wrap: anywhere; }
.fb-field-ghost { font-size: 12.5px; color: #9aa1ac; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-ghost-line { border-bottom: 1.5px dashed #d7dce3; padding-bottom: 5px; max-width: 320px; min-height: 12px; }
.fb-ghost-box { border: 1.5px dashed #d7dce3; border-radius: 8px; padding: 9px 10px; max-width: 320px; white-space: normal; }
.fb-field-actions { flex: none; display: flex; flex-direction: column; justify-content: center; gap: 4px; padding: 6px 8px 6px 0; }
.fb-icon-btn {
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border: none; background: transparent; border-radius: 7px; color: #98a1ad; cursor: pointer;
}
.fb-icon-btn:hover { background: #f0f2f6; color: var(--navy); }
.fb-icon-btn.fb-icon-danger:hover { background: #FDECEA; color: var(--danger); }
.fb-icon-btn.disabled { opacity: .3; cursor: default; }

.fb-drop-indicator { height: 3px; background: var(--orange); border-radius: 99px; margin: 6px 2px; box-shadow: 0 0 0 2px rgba(232,119,34,0.2); }
.fb-drag-ghost {
  position: fixed; z-index: 3000; pointer-events: none; background: var(--navy); color: #fff;
  font-size: 12.5px; font-weight: 700; padding: 6px 12px; border-radius: 8px; box-shadow: var(--shadow-md);
}
body.fb-drag-active { user-select: none; -webkit-user-select: none; cursor: grabbing; }

.fb-settings { padding: 16px; position: sticky; top: 0; max-height: calc(100vh - 185px); overflow-y: auto; }
.fb-settings-close { display: none; }
.fb-opt-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.fb-opt-grip { color: #b7bec9; cursor: grab; touch-action: none; flex: none; display: flex; }
.fb-opt-row .form-input { flex: 1; padding: 7px 10px; font-size: 13.5px; }

/* Preview */
.fb-pv-banner {
  background: #EBF0FF; color: var(--navy); font-size: 12.5px; font-weight: 600;
  border-radius: 9px; padding: 9px 12px; margin-bottom: 14px;
}
.fb-pv-title { font-size: 20px; font-weight: 800; color: var(--navy); margin-bottom: 16px; }
.fb-pv-heading { font-size: 17px; font-weight: 800; color: var(--navy); margin: 18px 0 10px; padding-top: 10px; border-top: 1px solid #edf0f4; }
.fb-pv-instructions { background: #f7f9fb; border-radius: 10px; padding: 12px 14px; font-size: 13.5px; color: var(--gray-dark); margin-bottom: 16px; white-space: pre-wrap; }
.fb-pv-choice { display: flex; align-items: center; gap: 10px; padding: 8px 2px; cursor: pointer; font-size: 14px; margin: 0; }
.fb-pv-choice input { width: 18px; height: 18px; flex: none; accent-color: var(--orange); }
.fb-pv-rating { display: flex; gap: 4px; }
.fb-pv-star { border: none; background: transparent; font-size: 27px; color: #d7dce3; cursor: pointer; padding: 2px; line-height: 1; }
.fb-pv-star.on { color: var(--orange); }
.fb-pv-sigbox {
  border: 1.5px dashed #c9d2de; border-radius: 10px; padding: 26px 12px; text-align: center;
  color: var(--gray); font-size: 13.5px; background: #fafbfc;
}
.fb-previewing .fb-palette, .fb-previewing .fb-settings { display: none; }
.fb-previewing { grid-template-columns: minmax(0,1fr); max-width: 620px; }

.fb-mobile-add { display: none; }
.fb-sheet-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(16,24,40,0.45); z-index: 1900;
}
.fb-sheet-backdrop.open { display: block; }
.fb-sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 2000; background: #fff;
  border-radius: 18px 18px 0 0; padding: 10px 16px 24px; box-shadow: 0 -8px 30px rgba(0,0,0,0.18);
  transform: translateY(105%); transition: transform .22s ease; max-height: 70vh; overflow-y: auto;
}
.fb-sheet.open { transform: translateY(0); }
.fb-sheet-handle { width: 42px; height: 4px; border-radius: 99px; background: #d7dce3; margin: 4px auto 12px; }
.fb-sheet-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.fb-sheet-item {
  display: flex; align-items: center; gap: 9px; padding: 11px 10px; border: 1.5px solid #e4e8ee;
  border-radius: 11px; background: #fff; font-size: 13px; font-weight: 600; color: var(--gray-dark);
  cursor: pointer; text-align: left;
}
.fb-sheet-item:active { border-color: var(--orange); background: rgba(232,119,34,0.06); }

@media (max-width: 900px) {
  .fb-layout { grid-template-columns: minmax(0,1fr); }
  .fb-palette { display: none; }
  .fb-mobile-add {
    display: inline-flex; position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
    z-index: 1500; border-radius: 99px; box-shadow: 0 6px 20px rgba(232,119,34,0.45); padding: 12px 22px;
  }
  .fb-previewing ~ .fb-mobile-add, .fb-layout.fb-previewing + .fb-mobile-add { display: none; }
  .fb-settings {
    position: fixed; inset: auto 0 0 0; top: auto; z-index: 1800; border-radius: 18px 18px 0 0;
    max-height: 72vh; box-shadow: 0 -8px 30px rgba(0,0,0,0.18);
    transform: translateY(105%); transition: transform .22s ease;
  }
  .fb-settings.open { transform: translateY(0); }
  .fb-settings-close { display: inline-flex; }
  .fb-canvas { padding: 12px; margin-bottom: 90px; }
}

/* ── Employee form fill page ─────────────────────────────────────────────── */
.form-fill-page { max-width: 640px; margin: 0 auto; }
.form-fill-page .card { padding: 18px 16px; }
.form-fill-heading {
  font-size: 17px; font-weight: 700; color: var(--navy);
  border-bottom: 2px solid var(--border); padding-bottom: 6px; margin: 18px 0 12px;
}
.form-fill-heading:first-child { margin-top: 0; }
.form-fill-instructions {
  background: rgba(26,39,68,0.05); border-left: 3px solid var(--navy);
  border-radius: 8px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; white-space: pre-wrap;
}
.form-fill-options { display: flex; flex-direction: column; gap: 8px; }
.form-fill-option {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px; margin: 0;
  border: 1.5px solid var(--border); border-radius: 10px; background: #fff; cursor: pointer;
  font-size: 15px;
}
.form-fill-option input { width: 18px; height: 18px; flex: none; }
.form-fill-option.selected { border-color: var(--orange); background: rgba(232,119,34,0.06); }
.form-fill-yesno { display: flex; gap: 10px; }
.form-fill-yesno .btn { flex: 1; }
.form-fill-stars { display: flex; align-items: center; gap: 4px; }
.form-fill-star {
  font-size: 28px; line-height: 1; background: none; border: none; cursor: pointer;
  color: #d7dce3; padding: 2px 4px;
}
.form-fill-star.on { color: var(--orange); }
.form-fill-file {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fff;
  font-size: 14px;
}
.ff-sig { width: 100%; height: 150px; display: block; touch-action: none; }

/* Dollar-amount field ($ prefix input) */
.ff-money { position: relative; }
.ff-money-prefix {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--gray); font-weight: 600; pointer-events: none;
}
.ff-money .form-input { padding-left: 28px; }

/* ── Employee profile & equipment ─────────────────────────────────────────── */
.row-link { cursor: pointer; }
.row-link:hover td { background: #f0f3f8; }
.ep-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.ep-avatar {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: var(--navy); color: #fff; display: flex; align-items: center;
  justify-content: center; font-weight: 700; font-size: 20px;
}
.ep-meta { font-size: 13.5px; color: var(--gray); margin-top: 6px; line-height: 1.6; }
.ep-sub { font-size: 12px; color: var(--gray); margin-top: 2px; }
.ep-item { padding: 10px 0; border-bottom: 1px solid var(--gray-light); }
.ep-item:last-child { border-bottom: none; padding-bottom: 0; }
.ep-form { background: var(--bg); border: 1px solid var(--gray-light); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.ep-form-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ep-form-row > div { flex: 1; min-width: 130px; }
.ep-form-inline { display: flex; gap: 8px; margin-bottom: 10px; }
.ep-form-inline .form-input { flex: 1; }

/* ── Mobile visual hierarchy (≤768px) ─────────────────────────
   Kept at the END of the file on purpose: these override base rules of
   EQUAL specificity, and later-in-file wins (media queries add none). */
@media (max-width: 768px) {
  .admin-content { padding: 16px 14px 28px; }
  .page-title { font-size: 21px; }
  .section-title { font-size: 17px; }
  .section-header { margin-bottom: 12px; }
  .card { padding: 16px 14px; margin-bottom: 12px; }
  .card-header { margin-bottom: 12px; }
  .card-title { font-size: 14px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
  .stat-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .stat-card { padding: 14px 16px; }
  .stat-value { font-size: 26px; }
  .stat-label { font-size: 10.5px; margin-top: 4px; }

  .btn { min-height: 42px; padding: 10px 15px; font-size: 13.5px; }
  .btn-sm { min-height: 34px; padding: 7px 12px; font-size: 12.5px; }
  .btn-icon { width: 34px; min-width: 34px; min-height: 34px; padding: 0; }
  .fb-mobile-add { padding: 12px 22px; }

  .page-tabs { margin-bottom: 14px; }
  .page-tab { padding: 8px 11px; font-size: 13px; }

  table { font-size: 13px; }
  th { font-size: 10.5px; }
  .filter-row { gap: 8px; margin-bottom: 12px; }
  .filter-row .form-input, .filter-row .form-select { max-width: none !important; flex: 1 1 100%; }
  .empty-state { padding: 32px 16px; }

  .matrix-table .freeze { min-width: 112px; }
  .matrix-wrap { max-height: 62vh; }
}
