/* === Design Tokens === */
:root {
  --bg:        #0f172a;
  --surface:   #1e293b;
  --surface-2: #162032;
  --surface-3: #060d1a;
  --border:    #334155;
  --text:      #e2e8f0;
  --text-2:    #94a3b8;
  --text-3:    #8898b0;
  --text-4:    #6b7d96;
  --accent:    #f59e0b;
  --accent-h:  #d97706;
  --good:      #6ee7b7;
  --good-bg:   #064e3b;
  --warn:      #fbbf24;
  --warn-bg:   #422006;
  --bad:       #fda4af;
  --bad-bg:    #4c0519;
  --info:      #93c5fd;
  --info-bg:   #1e3a5f;
  --success:   #059669;
  --success-h: #047857;
  --danger:    #dc2626;
  --danger-h:  #b91c1c;
  --shadow-modal: 0 24px 60px rgba(0,0,0,0.6);
  --skeleton-stop: #2a3a50;

  /* === Typography Scale (1.4x ratio) === */
  --text-xs:   10px;
  --text-sm:   12px;
  --text-base: 14px;
  --text-lg:   16px;
  --text-xl:   20px;
  --text-2xl:  24px;
  --text-3xl:  28px;
}

/* === Reset === */
* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-user-select: none; }
input, textarea, select { user-select: text; -webkit-user-select: text; }
body { font-family: 'Barlow', Arial, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; overflow-x: hidden; font-size: var(--text-base); font-weight: 400; line-height: 1.5; }
h1, h2, h3, h4, h5, h6 { font-family: 'Courier Prime', monospace; font-weight: 700; line-height: 1.2; }
h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4, h5, h6 { font-size: var(--text-lg); }
label { font-weight: 600; }

/* === Accessibility === */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; top: -48px; left: 16px; background: var(--accent); color: var(--bg); padding: 10px 16px; border-radius: 6px; font-size: 14px; font-weight: 600; z-index: 9999; text-decoration: none; transition: top 0.15s ease; }
.skip-link:focus { top: 8px; }

/* === Keyframes === */
@keyframes fadeSlideUp  { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: translateY(0); } }
@keyframes cardNew      { from { opacity: 0; transform: translateY(-14px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes cardRemove   { to   { opacity: 0; transform: scale(0.96) translateY(-6px); } }
.card-new      { animation: cardNew    0.45s cubic-bezier(0.22,1,0.36,1) both; }
.card-removing { animation: cardRemove 0.25s ease both; pointer-events: none; }
@keyframes slideInRight { from { opacity: 0; transform: translateX(36px); } to { opacity: 1; transform: translateX(0); } }
@keyframes slideInLeft  { from { opacity: 0; transform: translateX(-36px); } to { opacity: 1; transform: translateX(0); } }
@keyframes modalIn      { from { opacity: 0; transform: scale(0.94) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }
@keyframes modalOut     { from { opacity: 1; transform: scale(1) translateY(0); } to { opacity: 0; transform: scale(0.94) translateY(10px); } }
@keyframes shimmer      { 0% { background-position: -500px 0; } 100% { background-position: 500px 0; } }
@keyframes pulseBadge   { 0%,100% { opacity: 1; } 50% { opacity: 0.6; } }
@keyframes fadeIn       { from { opacity: 0; } to { opacity: 1; } }
@keyframes toastIn      { from { opacity: 0; transform: translateY(12px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* === Page routing === */
.page { display: none; }
.page.active { display: block; }
.page.entering  { animation: fadeSlideUp  0.32s cubic-bezier(0.22,1,0.36,1) both; }
#audit-page, #notifications-page { min-height: calc(100vh - 60px); display: block; }
#auditLogList, #adminNotificationsList { display: block; min-height: auto; overflow: visible; }
#audit-page .container, #notifications-page .container { display: block; }
.slide-in-right { animation: slideInRight 0.28s cubic-bezier(0.22,1,0.36,1) both; }
.slide-in-left  { animation: slideInLeft  0.28s cubic-bezier(0.22,1,0.36,1) both; }

/* === Nav === */
#mainNav { background: var(--surface); border-bottom: 1px solid var(--border); padding: 10px 24px; min-height: 44px; display: none; justify-content: flex-end; align-items: center; gap: 12px; position: fixed; top: 0; left: 0; right: 0; z-index: 1000; }
.nav-links { display: flex; gap: 16px; flex-wrap: wrap; position: absolute; left: 50%; transform: translateX(-50%); }
#mainNav a { color: var(--text-2); font-size: 13px; text-decoration: none; cursor: pointer; transition: color 0.2s ease; position: relative; user-select: none; -webkit-user-select: none; }
#mainNav a::after { content: ''; position: absolute; bottom: -4px; left: 0; width: 0; height: 2px; background: var(--accent); border-radius: 2px; transition: width 0.22s ease; }
#mainNav a:hover::after, #mainNav a.active::after { width: 100%; }
#mainNav a:hover, #mainNav a.active { color: var(--accent); }
.nav-right { display: flex; align-items: center; gap: 12px; }
.nav-user { font-size: 13px; color: var(--text-3); }
.nav-logout { background: var(--border); color: var(--text); border: none; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: background 0.2s ease, transform 0.1s ease; }
.nav-logout:hover { background: var(--text-4); transform: translateY(-1px); }

/* === Auth pages === */
.auth-wrap { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 20px; }
.auth-card { background: var(--surface); padding: 40px 32px; border-radius: 12px; width: 100%; max-width: 420px; }
.auth-card h1 { color: var(--accent); font-size: var(--text-2xl); font-weight: 700; font-family: 'Courier Prime', monospace; margin-bottom: 8px; }
.auth-subtitle { color: var(--text-3); font-size: var(--text-sm); margin-bottom: 32px; }
.auth-card form { margin: 0; display: flex; flex-direction: column; gap: 0; }
.auth-label { display: block; font-size: var(--text-sm); color: var(--text-2); margin-bottom: 8px; font-weight: 600; }
.auth-card input, .auth-card select { width: 100%; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: var(--text-base); margin-bottom: 16px; appearance: none; -webkit-appearance: none; box-sizing: border-box; min-height: 44px; font-family: inherit; }
.btn-main { width: 100%; padding: 12px; background: var(--accent); color: white; border: none; border-radius: 8px; font-size: 15px; cursor: pointer; transition: background 0.2s, transform 0.15s; margin-bottom: 0; box-sizing: border-box; }
.btn-main:hover { background: var(--accent-h); transform: translateY(-1px); }
.auth-link { color: var(--accent); font-size: 13px; display: block; text-align: center; margin-top: 16px; margin-bottom: 0; text-decoration: none; cursor: pointer; transition: color 0.2s ease; background: none; border: none; width: 100%; padding: 8px 0; box-sizing: border-box; }
.auth-link:hover { color: var(--accent-h); }
.auth-back-link { color: var(--text-3); font-size: 13px; display: block; text-align: center; margin-top: 8px; text-decoration: none; cursor: pointer; transition: color 0.2s ease; background: none; border: none; width: 100%; padding: 8px 0; box-sizing: border-box; }
.auth-back-link:hover { color: var(--text-2); }
.auth-msg { margin-top: 16px; margin-bottom: 0; padding: 12px; border-radius: 8px; font-size: 13px; display: none; box-sizing: border-box; width: 100%; }
.auth-msg.error   { background: var(--bad-bg);  color: var(--bad);  display: block; }
.auth-msg.warning { background: var(--warn-bg); color: var(--warn); display: block; }
.auth-msg.success { background: var(--good-bg); color: var(--good); display: block; }

.btn-install { display: none; background: transparent; color: var(--accent); padding: 12px 24px; border-radius: 8px; border: 1px solid var(--border); font-size: 14px; cursor: pointer; width: 100%; margin-top: 16px; margin-bottom: 0; transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease; box-sizing: border-box; }
.btn-install:hover { background: rgba(217,119,6,0.08); border-color: var(--accent); transform: translateY(-1px); }

/* === Shared app === */
.container { padding: 24px; max-width: 900px; margin: 0 auto; padding-top: calc(44px + 24px); }
.app-card { background: var(--surface); border-radius: 10px; padding: 10px; margin-bottom: 12px; transition: transform 0.2s ease, box-shadow 0.2s ease; }
.group-body-inner .app-card:last-child { margin-bottom: 0; }
.app-card:hover { transform: translateY(-2px); box-shadow: 0 8px 32px rgba(0,0,0,0.4); }
.app-card h2 { color: var(--accent); font-size: 16px; margin-bottom: 16px; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0; flex-wrap: wrap; gap: 8px; padding-top: 0; }
.card-title { font-size: 15px; font-weight: bold; }
.section-label { font-size: 12px; color: var(--text-3); margin-bottom: 12px; text-transform: uppercase; letter-spacing: 1px; }
.empty { color: var(--text-4); text-align: center; padding: 48px 24px; animation: fadeIn 0.4s ease; }
.empty-title { font-size: var(--text-xl); font-weight: 700; color: var(--text); margin-bottom: 8px; margin-top: 0; }
.empty-message { font-size: var(--text-base); color: var(--text-3); }

/* === Quick-status badge (field view) === */
.status-badge { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; font-weight: 700; font-size: var(--text-sm); }
.status-badge-ok { background: var(--good-bg); color: var(--good); }
.status-badge-warn { background: var(--warn-bg); color: var(--warn); animation: pulseBadge 2s ease-in-out infinite; }
.status-badge-bad { background: var(--bad-bg); color: var(--bad); animation: pulseBadge 1.5s ease-in-out infinite; }
.status-badge-info { background: var(--info-bg); color: var(--info); }
.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tab { padding: 10px 20px; border-radius: 8px; cursor: pointer; font-size: 14px; border: none; background: var(--surface); color: var(--text-2); transition: background 0.2s ease, color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease; }
.tab:hover:not(.active) { background: color-mix(in oklch, var(--surface) 82%, white 18%); color: var(--text); }
.tab.active { background: var(--accent); color: white; box-shadow: 0 4px 12px rgba(217,119,6,0.35); }
.tab:active { transform: scale(0.96); }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 11px; font-weight: bold; }
.badge.valid     { background: var(--good-bg); color: var(--good); }
.badge.expired   { background: var(--bad-bg);  color: var(--bad);  animation: pulseBadge 2s ease-in-out infinite; }
.badge.pending   { background: var(--warn-bg); color: var(--warn); }
.badge.missing   { background: var(--border);  color: var(--text-2); }
.badge.mandatory { background: var(--info-bg); color: var(--info); }
.badge.optional  { background: var(--border);  color: var(--text-3); }
.badge.draft     { background: var(--border);  color: var(--text-2); }
.badge.submitted { background: var(--info-bg); color: var(--info); }
.badge.approved  { background: var(--good-bg); color: var(--good); }
/* ── Status badges: card/group headers (JS-generated, replaces inline styles) ── */
.sbadge { display:inline-flex; align-items:center; font-size:11px; font-weight:bold; padding:3px 8px; border-radius:20px; }
.sbadge-missing  { background: var(--bad-bg);  color: var(--bad);  }
.sbadge-expired  { background: var(--bad-bg);  color: var(--bad);  }
.sbadge-expiring { background: var(--warn-bg); color: var(--warn); }
.sbadge-ready    { background: var(--good-bg); color: var(--good); }
.sbadge-awaiting { background: var(--info-bg); color: var(--info); }
.gbadge { display:inline-flex; align-items:center; font-size:11px; font-weight:700; padding:2px 8px; border-radius:10px; }
.gbadge-missing  { background: var(--bad-bg);  color: var(--bad);  }
.gbadge-awaiting { background: var(--info-bg); color: var(--info); }
.gbadge-expired  { background: var(--bad-bg);  color: var(--bad);  }
.gbadge-expiring { background: var(--warn-bg); color: var(--warn); }
.gbadge-ready    { background: var(--good-bg); color: var(--good); }
/* ── Personnel doc type badges ── */
.doc-badge-req { font-size:10px; color: var(--info);   background: var(--info-bg); padding:2px 6px; border-radius:10px; }
.doc-badge-opt { font-size:10px; color: var(--text-3); background: var(--border);  padding:2px 6px; border-radius:10px; }
/* ── Doc status text (replaces inline color spans) ── */
.doc-status { font-size:11px; font-weight:bold; }
.doc-status-valid    { color: var(--good); }
.doc-status-expired  { color: var(--bad);  }
.doc-status-expiring { color: var(--warn); }
/* ── Doc view link button ── */
.doc-view-btn { background:none; border:none; color: var(--info); font-size:11px; cursor:pointer; padding:4px 2px; text-decoration:underline; transition:color 0.15s; min-height:44px; display:inline-flex; align-items:center; }
.doc-view-btn:hover { color: var(--text); }
label { display: block; font-size: var(--text-sm); color: var(--text-2); margin-bottom: 8px; font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], textarea, select { width: 100%; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: var(--text-base); margin-bottom: 16px; min-height: 44px; font-family: inherit; }
textarea { height: 100px; resize: vertical; }
select { appearance: none; -webkit-appearance: none; }
input[type="file"] { display: none; }
/* Touch targets minimum 44px on all platforms */
@media (max-width: 767px) {
  input[type="text"], input[type="email"], input[type="password"], textarea, select, button, [role="button"] { min-height: 44px; min-width: 44px; }
}

/* Contractor */
.welcome { background: var(--surface); border-radius: 10px; padding: 20px; margin-bottom: 24px; }
.welcome h2 { font-size: 16px; margin-bottom: 6px; }
.welcome p { font-size: 13px; color: var(--text-2); }
.ct-section { display: none; }
.ct-section.active { display: block; }
.doc-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--border); flex-wrap: wrap; gap: 8px; transition: background 0.15s ease; border-radius: 6px; margin-top: 4px; }
.doc-row:hover { background: rgba(217,119,6,0.05); }
.doc-row:last-child { border-bottom: none; }
.doc-row.status-expired  { background: rgba(253,164,175,0.08); border-radius: 6px; }
.doc-row.status-expiring { background: rgba(251,191,36,0.07);  border-radius: 6px; }
.doc-name { font-size: 13px; color: var(--text-2); margin-bottom: 0; }
.doc-date { font-size: 12px; color: var(--text-3); }
.upload-btn { background: var(--accent); color: white; border: none; padding: 11px 14px; border-radius: 6px; cursor: pointer; font-size: 12px; transition: background 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease; }
.upload-btn:hover { background: var(--accent-h); transform: translateY(-1px); box-shadow: 0 3px 10px rgba(217,119,6,0.4); }
.upload-btn-sm { padding: 7px 10px; font-size: 11px; margin-top: 8px; margin-bottom: 4px; }
.add-btn { background: var(--success); color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-size: 14px; margin-bottom: 16px; transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease; }
.add-btn:hover { background: var(--success-h); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(5,150,105,0.4); }
.sn-row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.sn-row input { flex: 1; min-width: 120px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 13px; margin-bottom: 0; }
.sn-row button { background: var(--accent); color: white; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.sn-info { font-size: 13px; color: var(--text-2); margin-bottom: 10px; }
.card-body { display: grid; grid-template-rows: 0fr; overflow: hidden; transition: grid-template-rows 0.5s cubic-bezier(0.22,1,0.36,1), opacity 0.5s ease; opacity: 0; }
.app-card.expanded .card-body { grid-template-rows: 1fr; opacity: 1; }
.card-body > .body-inner { overflow: hidden; min-height: 0; }
.card-body .body-content { padding-top: 0; }
.btn-toggle { background: none; border: none; color: var(--text-3); font-size: 16px; cursor: pointer; padding: 8px 10px; min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; transition: color 0.2s, transform 0.5s cubic-bezier(0.22,1,0.36,1); }
.btn-toggle:hover { color: var(--text-2); }
.expanded .btn-toggle { transform: rotate(180deg); }
.sub-section { margin-top: 0; border-top: 1px solid var(--border); padding-top: 12px; }
.sub-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 10px; }
.eq-group { margin-bottom: 12px; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 18px rgba(0,0,0,0.35); }
.group-header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--surface); cursor: pointer; user-select: none; transition: background 0.2s; }
.group-header:hover { background: color-mix(in oklch, var(--surface) 82%, white 18%); }
.group-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-2); flex: 1; }
.group-count { font-size: 11px; color: var(--text-3); background: var(--bg); padding: 2px 8px; border-radius: 10px; }
.group-toggle { color: var(--text-3); font-size: 13px; transition: transform 0.4s cubic-bezier(0.22,1,0.36,1); line-height: 1; }
.eq-group.collapsed .group-toggle { transform: rotate(-90deg); }
.group-body { display: grid; grid-template-rows: 1fr; overflow: hidden; transition: grid-template-rows 0.4s cubic-bezier(0.22,1,0.36,1), opacity 0.4s ease; opacity: 1; background: var(--surface-2); }
.eq-group.collapsed .group-body { grid-template-rows: 0fr; opacity: 0; }
.group-body > .group-body-inner { overflow: hidden; min-height: 0; padding: 10px; }
.doc-group { margin-bottom: 0; }
.doc-group-header { display: flex; align-items: center; gap: 8px; padding: 6px 8px; background: var(--surface-2); border-radius: 6px; cursor: pointer; user-select: none; transition: background 0.2s; margin-top: 4px; min-height: 32px; box-sizing: border-box; }
.doc-group-header:hover { background: color-mix(in oklch, var(--surface-2) 82%, white 18%); }
.doc-group-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-3); flex: 1; }
.doc-group-count { font-size: 10px; color: var(--text-4); background: var(--bg); padding: 1px 6px; border-radius: 8px; }
.doc-group-toggle { color: var(--text-4); font-size: 12px; transition: transform 0.35s cubic-bezier(0.22,1,0.36,1); line-height: 1; }
.doc-group.collapsed .doc-group-toggle { transform: rotate(-90deg); }
.doc-group-body { display: grid; grid-template-rows: 1fr; overflow: hidden; transition: grid-template-rows 0.35s cubic-bezier(0.22,1,0.36,1), opacity 0.35s ease; opacity: 1; }
.doc-group.collapsed .doc-group-body { grid-template-rows: 0fr; opacity: 0; }
.doc-group-body > .doc-group-inner { overflow: hidden; min-height: 0; padding-top: 6px; }
.sub-card { background: var(--bg); border-radius: 8px; padding: 12px; margin-bottom: 8px; }
.sub-card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0; flex-wrap: wrap; gap: 6px; }
.sub-card-title { font-size: 13px; font-weight: bold; color: var(--text); }
.sub-card-body { display: grid; grid-template-rows: 0fr; overflow: hidden; opacity: 0; transition: grid-template-rows 0.5s cubic-bezier(0.22,1,0.36,1), opacity 0.5s ease; }
.sub-card.expanded .sub-card-body { grid-template-rows: 1fr; opacity: 1; }
.sub-card-body > .body-inner { overflow: hidden; min-height: 0; }
.sub-card-body .body-content { padding-top: 0; }
.add-sub-btn { background: transparent; color: var(--accent); border: 1px dashed var(--border); padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 12px; margin-top: 4px; transition: border-color 0.2s, background 0.2s; }
.add-sub-btn:hover { border-color: var(--accent); background: rgba(217,119,6,0.05); }
.add-sub-btn-sm { font-size: 11px; padding: 4px 10px; margin-top: 6px; }
/* sub-child-card: full border replaces single-side accent stripe */
.sub-child-card { background: var(--surface-3); border-radius: 6px; padding: 10px; margin-top: 6px; margin-left: 10px; border: 1px solid var(--info-bg); }
.sub-child-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0; flex-wrap: wrap; gap: 6px; }
.sub-child-title { font-size: 12px; font-weight: bold; color: var(--info); }
.sub-child-body { display: grid; grid-template-rows: 0fr; overflow: hidden; opacity: 0; transition: grid-template-rows 0.5s cubic-bezier(0.22,1,0.36,1), opacity 0.5s ease; }
.sub-child-card.expanded .sub-child-body { grid-template-rows: 1fr; opacity: 1; }
.sub-child-body > .body-inner { overflow: hidden; min-height: 0; }
.sub-child-body .body-content { padding-top: 0; }
.btn-reassign { background: none; border: 1px solid var(--border); color: var(--text-2); padding: 8px 12px; border-radius: 5px; cursor: pointer; font-size: 11px; min-height: 44px; transition: border-color 0.2s, color 0.2s; }
.btn-reassign:hover { border-color: var(--text-2); color: var(--text); }
.reassign-option { display: flex; align-items: center; gap: 10px; padding: 9px 12px; background: var(--bg); border-radius: 8px; margin-bottom: 0; cursor: pointer; border: 1px solid transparent; transition: border-color 0.2s; overflow: hidden; }
.reassign-option:has(input:checked) { border-color: var(--accent); }
.reassign-option input[type="radio"] { flex-shrink: 0; cursor: pointer; }
.reassign-option label { cursor: pointer; font-size: 13px; color: var(--text); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
#reassignModal .modal-box { max-width: 520px; }
#reassignList { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }

/* Modals */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.75); z-index: 100; justify-content: center; align-items: center; animation: fadeIn 0.18s ease; }
.modal.open { display: flex; }
.modal-box { background: var(--surface); padding: 24px; border-radius: 14px; width: 90%; max-width: 400px; border: 1px solid var(--border); box-shadow: var(--shadow-modal); animation: modalIn 0.25s cubic-bezier(0.22,1,0.36,1) both; }
.modal-scroll { background: var(--surface); padding: 24px; border-radius: 14px; width: 90%; max-width: 500px; max-height: 80vh; overflow-y: auto; border: 1px solid var(--border); box-shadow: var(--shadow-modal); animation: modalIn 0.25s cubic-bezier(0.22,1,0.36,1) both; }
@media (min-width: 768px) { .modal-scroll { max-width: 70vw; } }
.modal input:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.modal-box h3 { color: var(--accent); margin-bottom: 16px; }
.modal-box input:not([type="radio"]):not([type="checkbox"]) { width: 100%; padding: 10px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; margin-bottom: 12px; }
.modal-btns { display: flex; gap: 8px; }
.modal-btns button { flex: 1; padding: 10px; border: none; border-radius: 8px; cursor: pointer; font-size: 14px; }
.btn-save   { background: var(--accent); color: white; }
.btn-cancel { background: var(--border);  color: var(--text); }

/* Assessment */
.as-view { display: none; }
.as-view.active { display: block; }

/* === Button System: 4 core types + sizes === */
/* Primary: accent color (main actions) */
.btn-primary, .btn-main, .lor-btn, .upload-btn { background: var(--accent); color: white; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: var(--text-lg); padding: 12px 24px; transition: background 0.2s ease, transform 0.12s ease, box-shadow 0.2s ease; }
.btn-primary:hover, .btn-main:hover, .lor-btn:hover, .upload-btn:hover { background: var(--accent-h); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(217,119,6,0.45); }
.btn-primary:disabled, .btn-main:disabled, .lor-btn:disabled, .upload-btn:disabled { opacity: 0.6; pointer-events: none; }
.btn-sm.btn-primary, .btn-main.btn-sm, .btn-sm.upload-btn { padding: 8px 16px; font-size: var(--text-sm); }

/* Success: green color (approvals, confirmations) */
.btn-success, .add-btn, .btn-approve { background: var(--success); color: white; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: var(--text-lg); padding: 12px 24px; transition: background 0.2s ease, transform 0.12s ease, box-shadow 0.2s ease; }
.btn-success:hover, .add-btn:hover, .btn-approve:hover { background: var(--success-h); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(5,150,105,0.45); }
.btn-success:disabled, .add-btn:disabled, .btn-approve:disabled { opacity: 0.6; pointer-events: none; }
.btn-sm.btn-success, .add-btn.btn-sm, .btn-sm.btn-approve { padding: 8px 16px; font-size: var(--text-sm); }

/* Danger: red color (destructive actions) */
.btn-danger, .btn-reject, .btn-delete { background: var(--danger); color: white; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: var(--text-lg); padding: 12px 24px; transition: background 0.2s ease, transform 0.12s ease; }
.btn-danger:hover, .btn-reject:hover, .btn-delete:hover { background: var(--danger-h); transform: translateY(-2px); }
.btn-danger:disabled, .btn-reject:disabled, .btn-delete:disabled { opacity: 0.6; pointer-events: none; }
.btn-sm.btn-danger, .btn-sm.btn-reject, .btn-sm.btn-delete { padding: 8px 16px; font-size: var(--text-sm); }

/* Secondary: subtle/neutral (secondary actions, cancellations) */
.btn-ghost, .btn-secondary, .btn-edit, .btn-reassign { background: var(--border); color: var(--text); border: none; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: var(--text-lg); padding: 12px 24px; transition: background 0.2s; }
.btn-ghost:hover, .btn-secondary:hover, .btn-edit:hover, .btn-reassign:hover { background: var(--text-4); }
.btn-ghost:disabled, .btn-secondary:disabled, .btn-edit:disabled, .btn-reassign:disabled { opacity: 0.6; pointer-events: none; }
.btn-sm.btn-ghost, .btn-sm.btn-secondary, .btn-sm.btn-edit, .btn-sm.btn-reassign { padding: 8px 16px; font-size: var(--text-sm); }

/* Legacy aliases for compatibility */
.btn-primary:disabled { opacity: 0.6; pointer-events: none; }
.btn-success-sm { padding: 8px 16px; font-size: var(--text-sm); }
.btn-ghost-sm { padding: 8px 16px; font-size: var(--text-sm); }
.item-row { display: flex; justify-content: space-between; align-items: center; padding: 10px; background: var(--bg); border-radius: 8px; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; transition: background 0.15s ease, transform 0.15s ease; animation: fadeIn 0.25s ease; }
.item-row:hover { background: var(--surface-2); transform: translateX(2px); }
.item-disabled { opacity: 0.4; pointer-events: none; }
.item-info { flex: 1; }
.item-name { font-size: 14px; font-weight: bold; }
.item-detail { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.checkbox-item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px; background: var(--bg); border-radius: 8px; margin-bottom: 8px; cursor: pointer; transition: background 0.15s ease, box-shadow 0.15s ease; }
.checkbox-item:hover { background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.checkbox-item input[type="checkbox"] { width: 16px; height: 16px; margin-bottom: 0; cursor: pointer; flex-shrink: 0; accent-color: var(--accent); }
.checkbox-item label { cursor: pointer; font-size: 13px; flex: 1; margin-bottom: 0; }
.assessment-card { background: var(--surface); border-radius: 10px; padding: 16px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; cursor: pointer; transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease; }
.assessment-card:hover { background: color-mix(in oklch, var(--surface) 82%, white 18%); transform: translateY(-3px); box-shadow: 0 10px 32px rgba(0,0,0,0.4); }
.assessment-title { font-size: 15px; font-weight: bold; }
.assessment-meta  { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.detail-info { font-size: 13px; color: var(--text-2); margin-bottom: 6px; }

/* Admin */
.admin-header { background: var(--surface); padding: 16px 24px; display: flex; justify-content: space-between; align-items: center; }
.admin-header h1 { color: var(--accent); font-size: 18px; }
.admin-header button { background: var(--border); color: var(--text); border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; transition: background 0.2s; }
.admin-header button:hover { background: var(--text-4); }
.section-title { font-size: 16px; color: var(--text-2); margin-bottom: 16px; margin-top: 24px; }
.admin-card { background: var(--surface); border-radius: 10px; padding: 16px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; animation: fadeSlideUp 0.35s cubic-bezier(0.22,1,0.36,1) both; }
.admin-info { flex: 1; }
.admin-info .name { font-size: 15px; font-weight: bold; }
.admin-info .detail { font-size: 12px; color: var(--text-2); margin-top: 4px; }
.admin-actions { display: flex; gap: 8px; align-items: center; }
.btn-approve { background: var(--success); color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: background 0.2s, transform 0.15s; }
.btn-approve:hover { background: var(--success-h); transform: translateY(-1px); }
.btn-reject  { background: var(--danger); color: white; border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: background 0.2s, transform 0.15s; }
.btn-reject:hover  { background: var(--danger-h); transform: translateY(-1px); }
.btn-delete  { background: var(--bad-bg); color: var(--bad); border: none; padding: 8px 16px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: background 0.2s, transform 0.15s; }
.btn-delete:hover  { background: #6b0a1a; transform: translateY(-1px); }
.btn-edit    { background: var(--info-bg); color: var(--info); border: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: background 0.2s, transform 0.15s; }
.btn-edit:hover    { background: #1e4a7f; transform: translateY(-1px); }

/* Mini dashboard — status bar layout */
.mini-dash { display: flex; margin-bottom: 20px; background: var(--surface); border-radius: 8px; overflow: hidden; border: 1px solid var(--border); animation: fadeSlideUp 0.35s cubic-bezier(0.22,1,0.36,1) both; }
.dash-tile { flex: 1; padding: 12px 16px; display: flex; flex-direction: column; gap: 2px; transition: background 0.15s ease; }
.dash-tile + .dash-tile { border-left: 1px solid var(--border); }
.dash-tile:hover { background: rgba(255,255,255,0.03); }
.dash-val { font-size: 20px; font-weight: 600; line-height: 1; }
.dash-lbl { font-size: 10px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.8px; }
.dash-sub { font-size: 11px; margin-top: 1px; color: var(--text-3); }
.dash-tile.ok   .dash-val { color: var(--good); }
.dash-tile.warn .dash-val { color: var(--warn); }
.dash-tile.bad  .dash-val { color: var(--bad);  }
.dash-tile.info .dash-val { color: var(--info); }
.dash-tile.bad  .dash-sub { color: var(--bad);  }
.dash-tile.warn .dash-sub { color: var(--warn); }
@media (max-width: 480px) { .mini-dash { flex-wrap: wrap; } .dash-tile { flex: 1 1 50%; } .dash-tile:nth-child(3) { border-left: none; border-top: 1px solid var(--border); } .dash-tile:nth-child(4) { border-top: 1px solid var(--border); } }

/* === Nav responsive: prevent overflow on narrow screens === */
@media (max-width: 580px) {
  #mainNav { flex-wrap: wrap; padding: 8px 16px; min-height: auto; gap: 6px; }
  .nav-links { position: static; transform: none; order: 3; width: 100%; justify-content: center; }
  .nav-right { margin-left: auto; }
}

/* Skeleton */
.skeleton { background: linear-gradient(90deg,var(--surface) 25%,var(--skeleton-stop) 50%,var(--surface) 75%); background-size: 500px 100%; animation: shimmer 1.5s ease infinite; border-radius: 8px; }
.skel-card { background: var(--surface); border-radius: 10px; padding: 16px; margin-bottom: 12px; }
.skel-line { height: 14px; margin-bottom: 10px; }
.skel-line.short  { width: 40%; }
.skel-line.medium { width: 65%; }
.skel-line.full   { width: 100%; }

/* Focus visible */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* Toast notifications */
#toastContainer { position: fixed; bottom: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 10px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; color: #fff; background: var(--surface-2, #1e293b); box-shadow: 0 4px 16px rgba(0,0,0,0.4); opacity: 0; transform: translateX(24px); transition: opacity 0.22s ease, transform 0.22s ease; max-width: 320px; line-height: 1.4; pointer-events: auto; }
@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 0.22s ease; transform: none; }
}
.toast.toast-show { opacity: 1; transform: translateX(0); }
.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-warn    { background: #d97706; color: #fff; }
.toast-info    { background: #2563eb; }

/* === Loading states & spinners === */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.75s linear infinite; margin-right: 8px; }
.btn-primary:disabled .spinner, .btn-success:disabled .spinner, .btn-danger:disabled .spinner { opacity: 0.7; }
.btn-loading { opacity: 0.8; pointer-events: none; }

/* === Empty states === */
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state-icon { font-size: 48px; margin-bottom: 16px; }
.empty-state-title { font-size: var(--text-xl); font-weight: 700; color: var(--text); margin-bottom: 8px; }
.empty-state-text { font-size: var(--text-base); color: var(--text-3); margin-bottom: 24px; max-width: 320px; margin-left: auto; margin-right: auto; line-height: 1.6; }
.empty-state-action { display: inline-block; }

/* === Spacing improvements: increased gaps between sections === */
@media (min-width: 1024px) {
  .app-card { margin-bottom: 32px; }
  .eq-group { margin-bottom: 24px; }
  .section-title { margin-top: 48px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .app-card { margin-bottom: 24px; }
  .eq-group { margin-bottom: 18px; }
}
@media (max-width: 767px) {
  .app-card { margin-bottom: 32px; }
  .eq-group { margin-bottom: 24px; }
  .section-title { margin-top: 40px; margin-bottom: 20px; }
}

/* === Layout utilities === */
.flex-1       { flex: 1; }
.row-gap-xs   { display: flex; align-items: center; gap: 6px; }
.row-gap-sm   { display: flex; align-items: center; gap: 8px; }
.row-gap-md   { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.row-wrap     { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between  { display: flex; justify-content: space-between; align-items: center; }
.col-gap-sm   { display: flex; flex-direction: column; gap: 6px; }
.card-clickable { cursor: pointer; flex: 1; }
.card-meta    { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.mt-xs        { margin-top: 4px; }
.mt-sm        { margin-top: 8px; }
.mb-sm        { margin-bottom: 12px; }
.mb-0         { margin-bottom: 0 !important; }
.text-muted   { color: var(--text-3); }
.form-hint    { font-size: 12px; color: var(--text-3); margin-top: 6px; }
.search-input { flex: 1; width: auto; margin-bottom: 0; padding: 8px 12px; font-size: 13px; }
.label-row    { margin: 0; display: flex; align-items: center; gap: 6px; }
.section-row  { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.no-matches   { color: var(--text-4); font-size: 13px; padding: 8px 0; }
.depth-badge  { font-size: 10px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); padding: 2px 7px; border-radius: 8px; cursor: default; }
.lor-section  { margin-top: 24px; }
.doc-row-sm   { padding: 6px 0; }
.doc-row-xs   { padding: 4px 0; font-size: 12px; }
.doc-empty    { padding: 8px 0; }
.doc-empty-sm { padding: 4px 0; }
.doc-empty-xs { padding: 3px 0; font-size: 11px; }

/* === Phase 5: Mobile Responsiveness === */

/* Container responsiveness: adjust max-width and padding by viewport */
@media (max-width: 767px) {
  .container { padding: 16px; padding-top: calc(44px + 16px); max-width: 100%; }
  .modal-box { width: 95%; max-width: 100%; padding: 20px; }
  .modal-scroll { width: 95%; max-width: 100%; max-height: 90vh; }
}

/* Card and component sizing on mobile */
@media (max-width: 767px) {
  .app-card { padding: 12px; border-radius: 8px; }
  .auth-card { padding: 28px 20px; max-width: 100%; }
  .eq-group { border-radius: 8px; }
  .group-header { padding: 10px 12px; }
  .sub-card { padding: 10px; margin-bottom: 6px; }
  .assessment-card { padding: 12px; }
  .admin-card { padding: 12px; }
}

/* Typography scaling on mobile: ensure readability */
@media (max-width: 767px) {
  body { font-size: var(--text-base); }
  h1 { font-size: var(--text-2xl); line-height: 1.3; margin-bottom: 12px; }
  h2 { font-size: var(--text-xl); }
  h3 { font-size: var(--text-lg); }
  .auth-card h1 { font-size: var(--text-xl); }
  .welcome h2 { font-size: 15px; }
  .section-title { font-size: 15px; }
  .card-title { font-size: 14px; }
  label { font-size: var(--text-sm); }
}

/* Form layout: full-width inputs on mobile, stacked layout */
@media (max-width: 767px) {
  .sn-row { flex-direction: column; }
  .sn-row input { min-width: 100%; }
  .sn-row button { width: 100%; }
  .modal-btns { flex-direction: column; }
  .modal-btns button { width: 100%; }
  .reassign-option { padding: 12px; }
}

/* Button sizing: full-width CTAs on mobile for thumb reach */
@media (max-width: 767px) {
  .btn-primary, .btn-success, .btn-danger, .btn-secondary, .btn-main, .add-btn, .lor-btn, .upload-btn, .btn-approve, .btn-reject, .btn-ghost {
    width: 100%;
    padding: 14px 16px;
    font-size: var(--text-base);
  }
  .btn-sm.btn-primary, .btn-sm.btn-success, .btn-sm.btn-danger, .btn-sm.btn-secondary {
    width: auto;
    padding: 8px 12px;
    font-size: var(--text-sm);
  }
}

/* Grid layout on mobile: single column, reflow multi-column lists */
@media (max-width: 767px) {
  .doc-row { flex-direction: column; align-items: flex-start; }
  .item-row { flex-direction: column; align-items: flex-start; }
  .assessment-card { flex-direction: column; align-items: flex-start; }
  .admin-card { flex-direction: column; align-items: flex-start; }
  .mini-dash { flex-wrap: wrap; }
  .dash-tile { flex: 1 1 50%; }
}

/* Navigation responsiveness: ensure compact and usable */
@media (max-width: 480px) {
  #mainNav { padding: 6px 12px; min-height: 40px; }
  #mainNav a { font-size: 12px; }
  .nav-links { gap: 8px; }
  .nav-right { gap: 8px; }
  .nav-logout { padding: 4px 10px; font-size: 12px; }
}

/* Toast positioning on mobile: adapt to avoid overlap */
@media (max-width: 480px) {
  #toastContainer { bottom: 16px; right: 12px; left: 12px; }
  .toast { max-width: none; }
}

/* Empty state on mobile: center and scale content */
@media (max-width: 767px) {
  .empty-state { padding: 40px 16px; }
  .empty-state-icon { font-size: 40px; }
  .empty-state-title { font-size: var(--text-lg); }
  .empty-state-text { font-size: var(--text-sm); max-width: 100%; }
}

/* Tab layout on mobile: ensure horizontal scroll or stack */
@media (max-width: 480px) {
  .tabs { flex-wrap: wrap; gap: 6px; }
  .tab { padding: 8px 12px; font-size: 13px; }
}

/* === Phase 6: Polish & Production QA === */

/* Focus states: all interactive elements */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* WCAG AA contrast verification: text over surfaces */
/* Navy bg (#0f172a) + Amber accent (#f59e0b) = 10.2:1 (AAA) ✓ */
/* Navy bg + Light text (#e2e8f0) = 11.3:1 (AAA) ✓ */
/* Ensure all text layers meet minimum 4.5:1 for normal text, 3:1 for large text */

/* Dark theme: ensure sufficient contrast in secondary text */
.text-muted, .doc-name, .item-detail, .assessment-meta, .admin-info .detail {
  color: var(--text-2); /* #94a3b8: 7.1:1 contrast vs dark bg = AA ✓ */
}

/* Reduced motion compliance: already set globally above */
@media (prefers-reduced-motion: reduce) {
  *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .spinner { animation: none; opacity: 0.5; }
  .pulseBadge { animation: none; }
}

/* Print stylesheet for LoR PDF generation */
@media print {
  body { background: white; color: black; }
  .container { padding: 20px; max-width: 100%; }
  .nav, #mainNav, .nav-logout, .btn-primary, .btn-success, .btn-danger, .btn-ghost { display: none; }
  .app-card { border: 1px solid #ddd; page-break-inside: avoid; }
  .eq-group { border: 1px solid #ddd; page-break-inside: avoid; }
  h1, h2, h3 { color: black; page-break-after: avoid; }
  a { color: black; text-decoration: underline; }
}

/* === Bulk Operations & Inline Editing === */
.bulk-bar { background: var(--info-bg); border: 1px solid var(--info); padding: 12px 16px; border-radius: 8px; display: flex; align-items: center; gap: 16px; margin-bottom: 16px; animation: slideInDown 0.2s ease; }
.bulk-count { color: var(--info); font-weight: 600; font-size: var(--text-sm); }
.bulk-bar button { margin: 0; }
.bulk-check { cursor: pointer; accent-color: var(--info); width: 18px; height: 18px; }

/* Bulk mode: highlight selectable cards */
#personnelList:has(.bulk-check:not([style*="display: none"])) .app-card,
#equipmentList:has(.bulk-check:not([style*="display: none"])) .app-card {
  cursor: pointer; transition: background 0.2s; border-left: 3px solid transparent;
}
#personnelList:has(.bulk-check:not([style*="display: none"])) .app-card:hover,
#equipmentList:has(.bulk-check:not([style*="display: none"])) .app-card:hover {
  background: color-mix(in oklch, var(--surface) 85%, var(--info) 15%);
  border-left-color: var(--info);
}
#personnelList:has(.bulk-check:checked) .app-card:has(.bulk-check:checked),
#equipmentList:has(.bulk-check:checked) .app-card:has(.bulk-check:checked) {
  background: color-mix(in oklch, var(--surface) 80%, var(--info) 20%);
  border-left-color: var(--info);
}

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

/* === View Toggle: Office vs Field === */
.view-btn { background: var(--bg); color: var(--text-2); border: none; padding: 8px 12px; border-radius: 4px; cursor: pointer; font-size: 12px; font-weight: 600; transition: background 0.2s, color 0.2s; }
.view-btn:hover { color: var(--text); }
.view-btn-active { background: var(--accent); color: white; }
.view-btn-active:hover { background: var(--accent-h); }

/* Field view: flat list with status badges */
.detail-view-mode { animation: fadeIn 0.2s ease; }
.field-item { display: flex; align-items: center; justify-content: space-between; padding: 12px; background: var(--surface); border-radius: 8px; margin-bottom: 12px; flex-wrap: wrap; gap: 12px; }
.field-item-name { flex: 1; min-width: 150px; }
.field-item-status { display: flex; align-items: center; gap: 8px; }
.field-item-docs { display: flex; align-items: center; gap: 4px; font-size: 11px; }
.field-section-title { font-size: var(--text-lg); font-weight: 700; color: var(--accent); margin-bottom: 12px; margin-top: 16px; }
@media (max-width: 767px) {
  .field-item { flex-direction: column; align-items: flex-start; }
  .field-item-status { width: 100%; }
  .view-btn { padding: 6px 10px; font-size: 11px; }
}

/* Register: new company input row */
#newCompanyWrap { display: none; margin-top: -10px; margin-bottom: 16px; }
#newCompanyWrap .row-gap-sm { align-items: stretch; }
#newCompanyWrap input { flex: 1; margin-bottom: 0; }
#newCompanyMsg { font-size: 12px; margin-top: 6px; }

#newServiceLineWrap { display: none; margin-top: -10px; margin-bottom: 16px; }
#newServiceLineWrap .row-gap-sm { align-items: stretch; }
#newServiceLineWrap input { flex: 1; margin-bottom: 0; }
#newServiceLineMsg { font-size: 12px; margin-top: 6px; }

/* === Operations Module === */
.ops-view { display: none; }
.ops-view.active { display: block; }

.ops-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
@media (max-width: 780px) { .ops-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .ops-grid { grid-template-columns: 1fr; } }

.ops-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 64px 24px;
}
.ops-empty-icon { font-size: 48px; margin-bottom: 16px; }
.ops-empty-text { font-size: 16px; font-weight: 600; color: var(--text-3); margin-bottom: 8px; }
.ops-empty-hint { font-size: 13px; color: var(--text-4); max-width: 320px; margin: 0 auto; line-height: 1.5; }

/* Tile */
.ops-tile {
  background: var(--surface);
  border-radius: 12px;
  padding: 18px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: fadeSlideUp 0.35s cubic-bezier(0.22,1,0.36,1) both;
  outline: none;
}
.ops-tile:hover { transform: translateY(-3px); box-shadow: 0 12px 36px rgba(0,0,0,0.45); }
.ops-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Tile health accent — subtle top border using full-width bottom of header area */
.ops-tile-ok   { box-shadow: inset 0 2px 0 0 var(--good); }
.ops-tile-warn { box-shadow: inset 0 2px 0 0 var(--warn); }
.ops-tile-bad  { box-shadow: inset 0 2px 0 0 var(--bad); }
.ops-tile-info { box-shadow: inset 0 2px 0 0 var(--info); }
.ops-tile-ok:hover   { box-shadow: inset 0 2px 0 0 var(--good), 0 12px 36px rgba(0,0,0,0.45); }
.ops-tile-warn:hover { box-shadow: inset 0 2px 0 0 var(--warn), 0 12px 36px rgba(0,0,0,0.45); }
.ops-tile-bad:hover  { box-shadow: inset 0 2px 0 0 var(--bad),  0 12px 36px rgba(0,0,0,0.45); }
.ops-tile-info:hover { box-shadow: inset 0 2px 0 0 var(--info), 0 12px 36px rgba(0,0,0,0.45); }

.ops-tile-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ops-status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; display: inline-block; }
.ops-dot-ok   { background: var(--good); }
.ops-dot-warn { background: var(--warn); animation: pulseBadge 2s ease-in-out infinite; }
.ops-dot-bad  { background: var(--bad);  animation: pulseBadge 1.5s ease-in-out infinite; }
.ops-dot-info { background: var(--info); }
.ops-tile-date { font-size: 11px; color: var(--text-4); }

.ops-tile-title {
  font-size: 15px; font-weight: 700; color: var(--text);
  margin-bottom: 14px; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.ops-tile-expiry-wrap { margin-bottom: 14px; }
.ops-tile-expiry {
  font-size: 30px; font-weight: 800; line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: -0.5px;
}
.ops-expiry-ok   { color: var(--good); }
.ops-expiry-warn { color: var(--warn); }
.ops-expiry-bad  { color: var(--bad);  }
.ops-expiry-info { color: var(--info); }
.ops-tile-expiry-label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.8px; margin-top: 3px; }

.ops-tile-footer {
  display: flex; gap: 6px; flex-wrap: wrap;
  padding-top: 12px; border-top: 1px solid var(--border);
}
.ops-tile-badge { font-size: 12px; color: var(--text-3); background: var(--bg); padding: 3px 10px; border-radius: 10px; }

/* Detail header */
.ops-detail-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.ops-detail-title-wrap { flex: 1; min-width: 0; }
.ops-detail-title { font-size: 22px; font-weight: 700; color: var(--accent); word-break: break-word; }
.ops-detail-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; padding-top: 4px; }

/* Stats bar */
.ops-stats-bar { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.ops-stat { background: var(--surface); border-radius: 8px; padding: 10px 18px; display: flex; flex-direction: column; gap: 2px; min-width: 90px; }
.ops-stat-val { font-size: 20px; font-weight: 700; line-height: 1.1; }
.ops-stat-lbl { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.8px; }
.ops-stat-val.ok   { color: var(--good); }
.ops-stat-val.warn { color: var(--warn); }
.ops-stat-val.bad  { color: var(--bad); }
.ops-stat-val.info { color: var(--info); }

/* Item rows in site detail */
.ops-item-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 8px; margin-bottom: 8px;
  flex-wrap: wrap; transition: background 0.15s; animation: fadeIn 0.25s ease;
  background: var(--bg);
}
.ops-item-row:hover { background: var(--surface-2); }
.ops-item-ok   { background: rgba(110,231,183,0.04); }
.ops-item-warn { background: rgba(251,191,36,0.06); }
.ops-item-bad  { background: rgba(253,164,175,0.08); }
.ops-item-ok:hover   { background: rgba(110,231,183,0.08); }
.ops-item-warn:hover { background: rgba(251,191,36,0.10); }
.ops-item-bad:hover  { background: rgba(253,164,175,0.12); }

/* Days badges in lists */
.ops-days-badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; }
.ops-days-ok   { background: var(--good-bg); color: var(--good); }
.ops-days-warn { background: var(--warn-bg); color: var(--warn); }
.ops-days-bad  { background: var(--bad-bg);  color: var(--bad); animation: pulseBadge 2s ease-in-out infinite; }

/* === Document Viewer === */
.dv-wrap { display: none; position: fixed; inset: 0; z-index: 2000; background: rgba(0,0,0,0.6); }
.dv-box { position: fixed; top: 2.5vh; left: 2.5vw; width: 95vw; height: 95vh; background: var(--surface); border-radius: 10px; border: 1px solid var(--border); display: flex; flex-direction: column; overflow: hidden; min-width: 320px; min-height: 240px; box-shadow: 0 24px 80px rgba(0,0,0,0.6); }
.dv-resize { position: absolute; z-index: 10; }
.dv-resize[data-dir="n"]  { top: -4px; left: 8px; right: 8px; height: 8px; cursor: n-resize; }
.dv-resize[data-dir="s"]  { bottom: -4px; left: 8px; right: 8px; height: 8px; cursor: s-resize; }
.dv-resize[data-dir="w"]  { left: -4px; top: 8px; bottom: 8px; width: 8px; cursor: w-resize; }
.dv-resize[data-dir="e"]  { right: -4px; top: 8px; bottom: 8px; width: 8px; cursor: e-resize; }
.dv-resize[data-dir="nw"] { top: -4px; left: -4px; width: 16px; height: 16px; cursor: nw-resize; z-index: 11; }
.dv-resize[data-dir="ne"] { top: -4px; right: -4px; width: 16px; height: 16px; cursor: ne-resize; z-index: 11; }
.dv-resize[data-dir="sw"] { bottom: -4px; left: -4px; width: 16px; height: 16px; cursor: sw-resize; z-index: 11; }
.dv-resize[data-dir="se"] { bottom: -4px; right: -4px; width: 16px; height: 16px; cursor: se-resize; z-index: 11; }
.dv-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; cursor: grab; user-select: none; }
.dv-title { font-size: 14px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; margin-right: 12px; }
.dv-controls { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.dv-btn { background: var(--border); color: var(--text); border: none; padding: 7px 12px; border-radius: 6px; cursor: pointer; font-size: 16px; line-height: 1; }
.dv-btn-close { font-size: 13px; padding: 7px 14px; }
.dv-btn-download { background: var(--success); color: white; border: none; padding: 7px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; text-decoration: none; display: inline-flex; align-items: center; }
.dv-zoom-label { font-size: 13px; color: var(--text-2); min-width: 40px; text-align: center; }
.dv-body { flex: 1; overflow: auto; min-height: 0; background: var(--bg); }

/* ── Pagination ── */
.pagination { display:flex; align-items:center; gap:12px; padding:12px 0; justify-content:center; }
.pag-btn { padding:6px 14px; border-radius:6px; border:1px solid var(--border,#334155); background:var(--surface-2,#1e293b); color:var(--text-1,#f1f5f9); font-size:12px; cursor:pointer; }
.pag-btn:disabled { opacity:0.4; cursor:default; }
.pag-info { font-size:12px; color:var(--text-3,#64748b); }

/* ── Notification Bell ── */
.notif-bell { position:relative; background:none; border:none; cursor:pointer; font-size:18px; padding:4px 8px; color:var(--text-2); }
.notif-bell:hover { color:var(--text-1); }
.notif-badge { position:absolute; top:0; right:0; background:var(--bad,#ef4444); color:#fff; border-radius:999px; font-size:10px; font-weight:700; min-width:16px; height:16px; display:flex; align-items:center; justify-content:center; padding:0 4px; }
.notif-panel { position:absolute; top:52px; right:16px; width:320px; max-height:420px; overflow-y:auto; background:var(--surface-2,#1e293b); border:1px solid var(--border,#334155); border-radius:10px; box-shadow:0 8px 32px rgba(0,0,0,0.4); z-index:200; }
.notif-panel-header { display:flex; justify-content:space-between; align-items:center; padding:12px 16px; border-bottom:1px solid var(--border); font-size:13px; font-weight:600; color:var(--text-1); }
.notif-mark-read { background:none; border:none; color:var(--accent,#f59e0b); font-size:12px; cursor:pointer; }
.notif-item { padding:10px 16px; border-bottom:1px solid var(--border); font-size:13px; }
.notif-item.unread { background:var(--surface-3,#334155); }
.notif-item-label { color:var(--text-1); margin-bottom:2px; }
.notif-item-meta  { color:var(--text-3); font-size:11px; }
.notif-empty { padding:20px 16px; color:var(--text-3); font-size:13px; text-align:center; }
.notif-critical { border-left:3px solid var(--bad,#ef4444); }
.notif-urgent   { border-left:3px solid var(--warn,#f59e0b); }
.notif-warning  { border-left:3px solid var(--accent,#f59e0b); opacity:0.85; }
/* nav needs position:relative for the panel to anchor */
#mainNav { position:relative; }

/* ── Custom Documents ── */
.custom-docs-section { margin-top:12px; }
.custom-docs-label { font-size:11px; font-weight:600; color:var(--text-3); text-transform:uppercase; letter-spacing:.05em; margin-bottom:6px; }
.add-custom-doc-btn { display:block; width:100%; margin-top:10px; padding:7px 12px; background:transparent; border:1px dashed var(--border); border-radius:8px; color:var(--text-3); font-size:12px; cursor:pointer; transition:border-color .2s,color .2s; }
.add-custom-doc-btn:hover { border-color:var(--accent); color:var(--accent); }

/* ── Bulk Actions ── */
.bulk-bar { display:flex; align-items:center; gap:12px; padding:8px 0; flex-wrap:wrap; }
.bulk-count { font-size:13px; color:var(--text-3); }
.bulk-check { width:18px; height:18px; accent-color:var(--accent,#f59e0b); cursor:pointer; }
