:root {
  --color-primary: #3b5fe0;
  --color-primary-dark: #2c48b8;
  --color-primary-light: #eef2ff;
  --color-bg: #f7f8fa;
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-danger: #dc2626;
  --color-danger-light: #fef2f2;
  --color-success: #16a34a;
  --color-success-light: #f0fdf4;
  --sidebar-width: 240px;
  --topbar-height: 64px;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
}

a { color: inherit; text-decoration: none; }

/* Fixed viewport frame: the shell fills the screen and never itself scrolls, so the
   sidebar and topbar stay put and only .content scrolls (see below). */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 20px 20px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--color-border);
}
.sidebar-brand .material-icons-outlined { color: var(--color-primary); }
.sidebar-nav { flex: 1; padding: 12px 12px; overflow-y: auto; }
.sidebar-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--color-text-muted);
  margin: 18px 12px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--color-text-muted);
  font-weight: 500;
  margin-bottom: 2px;
}
.nav-item:hover { background: var(--color-bg); }
.nav-item.active { background: var(--color-primary-light); color: var(--color-primary); }
.nav-item .material-icons-outlined { font-size: 20px; }
.sidebar-footer { padding: 12px; border-top: 1px solid var(--color-border); }

/* Topbar */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
}
.topbar-title { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 12px; }
.live-timer { font-size: 14px; font-weight: 600; color: var(--color-primary); font-variant-numeric: tabular-nums; background: var(--color-primary-light); padding: 2px 10px; border-radius: 999px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.badge-pill {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-muted);
}
.role-pill {
  background: var(--color-primary-light);
  color: var(--color-primary);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .name { font-weight: 600; font-size: 13px; }
.user-chip .role { font-size: 12px; color: var(--color-text-muted); }

/* The only vertical scroll region. min-height:0 lets it shrink inside the flex
   column so overflow-y actually kicks in instead of stretching the whole page. */
.content { padding: 24px; flex: 1; position: relative; overflow-y: auto; min-height: 0; }

/* Cards / tables */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 16px; font-weight: 700; margin: 0; }
.card-subtitle { font-size: 13px; color: var(--color-text-muted); margin: 2px 0 0; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px;
}
.stat-card .stat-label { font-size: 12px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.4px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; margin-top: 6px; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-muted);
  padding: 10px 12px;
  border-bottom: 1px solid var(--color-border);
}
td { padding: 12px; border-bottom: 1px solid var(--color-border); font-size: 13px; }
tr:last-child td { border-bottom: none; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--color-text-muted); }
.empty-state .material-icons-outlined { font-size: 48px; color: var(--color-border); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }
.btn-outline { background: var(--color-surface); border-color: var(--color-border); color: var(--color-text); }
.btn-outline:hover { background: var(--color-bg); }
.btn-outline.active-filter { background: var(--color-primary-light); border-color: var(--color-primary); color: var(--color-primary); }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.status-tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-tag.online { background: var(--color-success-light); color: var(--color-success); }
.status-tag.busy { background: #fff7ed; color: #c2410c; }
.status-tag.offline { background: var(--color-bg); color: var(--color-text-muted); }
.status-tag.away { background: var(--color-primary-light); color: var(--color-primary); }

/* Request status (deo_requests.status) - distinct from the presence colors above. */
.status-tag.status-pending { background: var(--color-bg); color: var(--color-text-muted); }
.status-tag.status-in-progress { background: #fff7ed; color: #c2410c; }
.status-tag.status-processed { background: var(--color-success-light); color: var(--color-success); }

/* Decision (accepted/declined) */
.decision-tag { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.decision-tag.accepted { background: var(--color-success-light); color: var(--color-success); }
.decision-tag.declined { background: var(--color-danger-light); color: var(--color-danger); }
.decision-tag.none { background: var(--color-bg); color: var(--color-text-muted); }

.request-photo-frame {
  position: relative;
  display: inline-block;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--color-border);
  background: var(--color-bg);
}
.request-photo { display: block; width: 400px; height: 400px; object-fit: contain; }
.request-photo-status { position: absolute; top: 12px; left: 12px; }
.request-photo-decision { margin-top: 14px; font-size: 13px; color: var(--color-text-muted); display: flex; align-items: center; gap: 8px; }
.proof-link {
  background: none; border: none; padding: 0; margin-top: 10px; display: block;
  color: var(--color-primary); font-size: 12px; font-weight: 600; cursor: pointer; text-decoration: underline;
}
.proof-link:disabled { opacity: 0.6; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.form-group input, .form-group select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--color-surface);
}
.form-group input:focus, .form-group select:focus { outline: 2px solid var(--color-primary-light); border-color: var(--color-primary); }
.form-error { color: var(--color-danger); font-size: 13px; margin-bottom: 12px; }
.form-hint { color: var(--color-text-muted); font-size: 12px; margin-top: 4px; }

.sort-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: inherit; text-decoration: none; white-space: nowrap; cursor: pointer;
}
.sort-link:hover { color: var(--color-primary); }
.sort-arrow { font-size: 11px; line-height: 1; }
.sort-arrow.muted { color: var(--color-border); }
.sort-link:hover .sort-arrow.muted { color: var(--color-text-muted); }

tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover { background: var(--color-bg); }

/* Login page */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--color-bg); }
.login-card { width: 380px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 14px; padding: 32px; }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; margin-bottom: 24px; justify-content: center; }
.login-brand .material-icons-outlined { color: var(--color-primary); font-size: 26px; }

/* Live page */
.live-stage {
  min-height: calc(100vh - var(--topbar-height) - 48px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Waiting state */
.live-waiting { color: var(--color-text-muted); }
.live-waiting .material-icons-outlined { font-size: 56px; color: var(--color-border); margin-bottom: 16px; }
.live-waiting h2 { margin: 0 0 6px; color: var(--color-text); }
.live-waiting p { margin: 0; font-size: 14px; }

/* Assigned request: one self-contained card - header (reference / warning / keys),
   the photo, then a footer hint - so everything reads as a single organised unit
   instead of badges scattered around the viewport. */
.review-card {
  width: 100%;
  /* Fill the whole review area (no width cap) and stretch to the available height
     so the photo can be shown as large as the space allows - reviewers need to
     read fine detail off it. */
  max-width: none;
  min-height: calc(100vh - var(--topbar-height) - 48px);
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  text-align: left;
}
.review-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.review-ref { display: flex; flex-direction: column; gap: 2px; }
.review-ref-label { font-size: 10px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; color: var(--color-text-muted); }
.review-ref strong { font-size: 15px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.review-warning {
  display: inline-flex; align-items: center; gap: 6px;
  background: #fff7ed; color: #c2410c; border: 1px solid #fdba74;
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
}
.review-warning .material-icons-outlined { font-size: 16px; }
.review-actions { display: flex; gap: 12px; }
/* Body grows to take all remaining height; the photo container fills it, and the
   image scales up to the largest size that fits within (both width and height),
   keeping its aspect ratio. */
.review-body { padding: 18px; display: flex; flex: 1; min-height: 0; position: relative; }
.review-footer { padding: 0 18px 14px; }

.photo-zoom-container {
  overflow: hidden;
  touch-action: none;
  border-radius: var(--radius);
  border: 1px solid var(--color-border);
  background: var(--color-bg);
  cursor: grab;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo-zoom-container.dragging { cursor: grabbing; }
.photo-zoom-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  will-change: transform;
}
.zoom-hint { font-size: 12px; color: var(--color-text-muted); }

.key-hint {
  display: flex; align-items: center; gap: 8px;
}
.key-hint > span { font-size: 12px; font-weight: 600; color: var(--color-text-muted); }
.key-hint kbd {
  border: 1px solid var(--color-border);
  border-bottom-width: 2px;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  background: var(--color-surface);
  transition: background .15s, box-shadow .15s;
}
.key-hint.accept kbd { border-color: var(--color-success); color: var(--color-success); }
.key-hint.decline kbd { border-color: var(--color-danger); color: var(--color-danger); }
.key-hint.armed kbd { box-shadow: 0 0 0 3px var(--color-primary-light); }
.key-hint.accept.armed kbd { background: var(--color-success-light); }
.key-hint.decline.armed kbd { background: var(--color-danger-light); }
.live-toast { position: fixed; bottom: 20px; right: 20px; background: var(--color-text); color: #fff; padding: 10px 16px; border-radius: 8px; font-size: 13px; opacity: 0; transition: opacity .2s; }
.live-toast.show { opacity: 1; }

/* The double-press "Are you sure?" prompt: fixed near the TOP-center of the screen,
   large and high-contrast, so it grabs attention without covering the face being
   reviewed. */
.live-confirm-banner {
  position: fixed;
  top: calc(var(--topbar-height) + 16px);
  left: 50%;
  transform: translateX(-50%);
  padding: 16px 32px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.2);
  z-index: 60;
  text-align: center;
  max-width: 90vw;
}
.live-confirm-banner.accept { background: var(--color-success-light); color: var(--color-success); border: 2px solid var(--color-success); }
.live-confirm-banner.decline { background: var(--color-danger-light); color: var(--color-danger); border: 2px solid var(--color-danger); }

.photo-loader {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; min-height: 320px; color: var(--color-text-muted); font-size: 13px;
  /* Fill the review body so the spinner sits dead-center, not hugging the left edge. */
  flex: 1; width: 100%;
}
.photo-loader .spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 4px solid var(--color-border);
  border-top-color: var(--color-primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Overlays the review body (the exact area the photo/spinner occupy) and centres the
   icon there - NOT the whole viewport - so the tick/cross lands right where the
   spinner and next image appear. */
.live-feedback {
  position: absolute; inset: 18px;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transform: scale(0.6);
  transition: opacity .15s, transform .15s; z-index: 5;
}
.live-feedback .material-icons-outlined { font-size: 96px; }
.live-feedback.show { opacity: 1; transform: scale(1); }
.live-feedback.accept { color: var(--color-success); }
.live-feedback.decline { color: var(--color-danger); }

/* Upload page */
.upload-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.upload-tab { padding: 8px 16px; border-radius: 8px; border: 1px solid var(--color-border); cursor: pointer; font-weight: 600; font-size: 13px; color: var(--color-text-muted); }
.upload-tab.active { background: var(--color-primary-light); color: var(--color-primary); border-color: var(--color-primary-light); }
.upload-panel { display: none; }
.upload-panel.active { display: block; }
.upload-preview { max-width: 320px; border-radius: var(--radius); border: 1px solid var(--color-border); margin-top: 12px; }
.camera-video, .camera-canvas { max-width: 320px; border-radius: var(--radius); border: 1px solid var(--color-border); }
#upload-progress-ring { transition: stroke-dashoffset 100ms linear; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-card {
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: 36px 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.modal-card p { margin: 0; font-size: 14px; font-weight: 600; color: var(--color-text-muted); }

.cmdk-trigger {
  display: flex; align-items: center; gap: 8px;
  background: var(--color-bg); border: 1px solid var(--color-border); border-radius: 8px;
  padding: 7px 12px; font-size: 13px; color: var(--color-text-muted); cursor: pointer;
}
.cmdk-trigger:hover { background: var(--color-primary-light); color: var(--color-primary); }
.cmdk-trigger kbd {
  border: 1px solid var(--color-border); border-radius: 4px; padding: 1px 6px;
  font-size: 11px; background: var(--color-surface);
}
.cmdk-card { align-items: stretch; width: 480px; padding: 20px; }
.cmdk-input {
  width: 100%; padding: 12px 14px; font-size: 16px; border-radius: 8px;
  border: 1px solid var(--color-border); box-sizing: border-box;
}
.cmdk-input:focus { outline: 2px solid var(--color-primary-light); border-color: var(--color-primary); }

.toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { width: 40px; height: 22px; }
