:root {
  --color-bg: #f4f6f8;
  --color-surface: #ffffff;
  --color-border: #e2e6ea;
  --color-text: #1c2530;
  --color-text-muted: #63707d;
  --color-primary: #0f5c5c;
  --color-primary-dark: #0a4444;
  --color-primary-light: #e3f0ef;
  --color-accent: #2e8b8b;
  --color-danger: #b3261e;
  --color-danger-light: #fbe9e7;
  --color-warning: #9a6700;
  --color-warning-light: #fff4de;
  --color-success: #1e6f42;
  --color-success-light: #e6f4ea;
  --sidebar-width: 240px;
  --topbar-height: 64px;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 32, 0.06);
  --shadow-md: 0 4px 12px rgba(16, 24, 32, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 14px;
  line-height: 1.5;
}

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

.app-shell {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-primary-dark);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  padding: 18px 20px 16px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-logo {
  height: 34px;
  width: auto;
  display: block;
}

.sidebar-brand span {
  display: block;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.65;
  margin-top: 8px;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  overflow-y: auto;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 2px;
  text-decoration: none;
}

.sidebar-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.sidebar-nav a.active {
  background: var(--color-accent);
  color: #fff;
}

.sidebar-nav .icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.sidebar-section-label {
  padding: 16px 12px 6px;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  opacity: 0.5;
  font-weight: 600;
}

.sidebar-footer {
  padding: 14px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 12px;
  opacity: 0.7;
}

/* Main column */
.main-col {
  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;
  position: sticky;
  top: 0;
  z-index: 5;
}

.topbar-title { font-size: 16px; font-weight: 600; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--color-text-muted);
}

.badge-role {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.content {
  padding: 24px 28px 48px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 21px;
  font-weight: 700;
  margin: 0;
}

.page-subtitle {
  color: var(--color-text-muted);
  font-size: 13px;
  margin-top: 2px;
}

/* Cards */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 20px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.stat-card .stat-icon {
  position: absolute;
  top: 16px;
  right: 18px;
  font-size: 17px;
  opacity: 0.45;
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
}

.stat-card .stat-label {
  color: var(--color-text-muted);
  font-size: 12.5px;
  margin-top: 4px;
}

.stat-card-neutral { border-left-color: var(--color-primary); }

.stat-card-success { border-left-color: var(--color-success); background: var(--color-success-light); }
.stat-card-success .stat-value { color: var(--color-success); }

.stat-card-warning { border-left-color: var(--color-warning); background: var(--color-warning-light); }
.stat-card-warning .stat-value { color: var(--color-warning); }

.stat-card-danger { border-left-color: var(--color-danger); background: var(--color-danger-light); }
.stat-card-danger .stat-value { color: var(--color-danger); }

/* Document sub-file blocks (employee profile) */
.subfile-block { margin-top: 16px; }
.subfile-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}
.subfile-name { font-weight: 700; font-size: 13px; }
.lock-icon { font-size: 13px; }

/* Attention panel */
.attention-panel {
  border: 1px solid #f0c8c4;
  background: var(--color-danger-light);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 22px;
}

.attention-panel.is-clear {
  border-color: #bfe3cc;
  background: var(--color-success-light);
}

.attention-panel h2 {
  font-size: 15px;
  margin: 0 0 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.attention-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-top: 1px solid rgba(0,0,0,0.06);
  font-size: 13px;
}

.attention-row:first-of-type { border-top: none; }

/* Tables */
.table-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.data-table th {
  text-align: left;
  background: #fafbfc;
  padding: 11px 16px;
  font-weight: 600;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.data-table th:hover { color: var(--color-text); }

.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbfc; }

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-bottom: 14px;
  align-items: center;
}

.table-toolbar input[type="text"] {
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.table-toolbar select {
  width: auto;
  min-width: 160px;
}

.filter-modes {
  display: flex;
  gap: 14px;
  align-items: center;
}

.filter-modes label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  color: var(--color-text-muted);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.filter-modes input[type="radio"] {
  width: auto;
  margin: 0;
}

/* Badges / status pills */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
}

.pill-valid, .pill-clear, .pill-active { background: var(--color-success-light); color: var(--color-success); }
.pill-expiring_soon, .pill-suspended, .pill-needs_review { background: var(--color-warning-light); color: var(--color-warning); }
.pill-strong { font-weight: 800; text-transform: uppercase; letter-spacing: 0.3px; }
.pill-expired, .pill-match_found, .pill-inactive { background: var(--color-danger-light); color: var(--color-danger); }
.pill-flagged { background: var(--color-danger-light); color: var(--color-danger); }

/* Forms */
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: var(--color-text-muted); }

input[type="text"], input[type="password"], input[type="date"], input[type="email"],
input[type="tel"], input[type="number"], input[type="file"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  font-size: 13.5px;
  font-family: inherit;
  background: var(--color-surface);
  color: var(--color-text);
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
}

.btn:hover { text-decoration: none; }

.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-dark); }

.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border); }
.btn-secondary:hover { background: #f2f4f6; }

.btn-danger { background: var(--color-danger); color: #fff; }

/* Login page */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--color-primary-dark), var(--color-primary) 60%);
}

.login-card {
  background: var(--color-surface);
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-md);
}

.login-logo {
  height: 56px;
  width: auto;
  display: block;
  margin: 0 auto 16px;
}

.login-card h1 {
  font-size: 19px;
  margin: 0 0 2px;
  text-align: center;
}

.login-card p.subtitle {
  color: var(--color-text-muted);
  margin: 0 0 24px;
  font-size: 13px;
  text-align: center;
}

.login-card label { margin-top: 14px; }
.login-card label:first-of-type { margin-top: 0; }

.flash {
  padding: 10px 14px;
  border-radius: 7px;
  font-size: 13px;
  margin-bottom: 14px;
}

.flash-error { background: var(--color-danger-light); color: var(--color-danger); }
.flash-info { background: var(--color-primary-light); color: var(--color-primary-dark); }
.flash-success { background: var(--color-success-light); color: var(--color-success); }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px 24px;
}

.info-label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--color-text-muted);
  margin-bottom: 3px;
}

.info-value {
  display: block;
  font-size: 14px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-muted);
  font-size: 13.5px;
}

.text-muted { color: var(--color-text-muted); }
.mt-0 { margin-top: 0; }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: -260px; z-index: 20; transition: left 0.15s; }
  .sidebar.open { left: 0; }
  .app-shell { display: block; }
  .content { padding: 16px; }
}

/* Conditional spouse fields on the intake form */
.spouse-block { display: none; }

/* Checklist (radio/checkbox groups) on forms */
.check-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  padding: 4px 0 2px;
}
.check-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--color-text);
  margin: 0;
  cursor: pointer;
  white-space: nowrap;
}
.check-item input { width: auto; margin: 0; }

/* Folder-completeness checklist */
.checklist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px 20px;
}
.checklist-item { display: flex; align-items: center; gap: 9px; font-size: 13.5px; }
.check-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.check-mark.ok { background: var(--color-success-light); color: var(--color-success); }
.check-mark.missing { background: var(--color-danger-light); color: var(--color-danger); }
.check-mark.na { background: #eceff1; color: var(--color-text-muted); }

/* Modal (exclusion check details) */
.modal-overlay {
  display: none;
  position: fixed; inset: 0; z-index: 50;
  background: rgba(16, 24, 32, 0.5);
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-box {
  background: var(--color-surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  width: 100%; max-width: 560px;
  max-height: 85vh; overflow-y: auto;
  padding: 22px 24px;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-close { background: none; border: none; font-size: 24px; line-height: 1; cursor: pointer; color: var(--color-text-muted); }
.modal-pre {
  background: #f6f8fa; border: 1px solid var(--color-border); border-radius: 7px;
  padding: 12px; font-size: 12px; white-space: pre-wrap; word-break: break-word;
  max-height: 260px; overflow-y: auto; margin-top: 4px;
}

/* ---- Blank printable intake form ---- */
.print-sheet {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 32px 36px;
  max-width: 800px;
}
.print-header {
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 14px;
  margin-bottom: 20px;
}
.print-logo { height: 46px; width: auto; }
.print-org { font-size: 16px; font-weight: 700; color: var(--color-primary-dark); }
.print-title { font-size: 13px; color: var(--color-text-muted); }
.fill-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-primary-dark);
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 4px;
  margin: 22px 0 12px;
}
.fill-row { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 14px; }
.fill-label { font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.fill-line { flex: 1; min-width: 120px; border-bottom: 1px solid #333; height: 18px; }
.fill-muted { font-size: 11px; color: var(--color-text-muted); font-style: italic; }
.fill-check-group { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 2px 0 14px; }
.fill-check { font-size: 12.5px; white-space: nowrap; }
.pbox { display: inline-block; width: 12px; height: 12px; border: 1px solid #333; margin-right: 6px; vertical-align: middle; }
.print-footer {
  margin-top: 28px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
  font-size: 11px;
  color: var(--color-text-muted);
  text-align: center;
}

@media print {
  .sidebar, .topbar, .btn, .table-toolbar, .form-actions, .flash, .no-print { display: none !important; }
  .app-shell { display: block; }
  .content { padding: 0; }
  body { background: #fff; }
  .card, .table-wrap, .stat-card { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  .print-sheet { border: none; padding: 0; max-width: none; }
  .fill-section-title { break-after: avoid; }
  .fill-row { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
