:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --border: #e2e6ec;
  --text: #1c2430;
  --text-muted: #6b7686;
  --primary: #1d4ed8;
  --primary-dark: #1638a6;
  --success: #1a8a4a;
  --success-bg: #e6f6ec;
  --danger: #c02b3a;
  --danger-bg: #fbe7e9;
  --warning: #b8720a;
  --warning-bg: #fdf1de;
  --neutral-bg: #eceff3;
  --sidebar-bg: #14181f;
  --sidebar-text: #c7cdd8;
  --radius: 8px;
  font-family: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* Sidebar */
.sidebar {
  width: 230px; flex-shrink: 0; background: var(--sidebar-bg); color: var(--sidebar-text);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; border-bottom: 1px solid #262c37; }
.brand-mark { background: var(--primary); color: #fff; font-weight: 700; font-size: 13px; width: 34px; height: 34px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.brand-text { font-weight: 600; color: #fff; font-size: 14px; line-height: 1.2; }
.brand-text small { color: var(--sidebar-text); font-weight: 400; font-size: 11px; }
.sidebar-nav { flex: 1; padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav a { color: var(--sidebar-text); padding: 10px 12px; border-radius: 6px; font-size: 13.5px; font-weight: 500; }
.sidebar-nav a:hover { background: #1f242e; text-decoration: none; color: #fff; }
.sidebar-nav a.active { background: var(--primary); color: #fff; }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid #262c37; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; }
.user-name { color: #fff; font-size: 13px; font-weight: 600; }
.user-role { font-size: 11.5px; color: var(--sidebar-text); }
.logout-link { font-size: 12.5px; color: #ff9b9b; }

/* Main content */
.main-content { flex: 1; padding: 26px 32px; max-width: 1400px; }
.mobile-nav-toggle { display: none; }

/* Header row */
.page-header { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.page-header h1 { margin: 0 0 4px; font-size: 22px; }
.page-header p { margin: 0; color: var(--text-muted); font-size: 13.5px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: var(--radius); border: 1px solid transparent; font-size: 13.5px; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--neutral-bg); }
.btn-danger { background: var(--danger-bg); color: var(--danger); border-color: #f2c3c8; }
.btn-danger:hover { background: #f6d3d7; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }

/* Cards / surfaces */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 16px; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.stat-card .stat-value { font-size: 26px; font-weight: 700; }
.stat-card .stat-label { color: var(--text-muted); font-size: 12.5px; margin-top: 2px; }

/* Progress bar */
.progress-bar { height: 8px; background: var(--neutral-bg); border-radius: 4px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--success); }

/* Tables */
table { width: 100%; border-collapse: collapse; background: var(--surface); }
th, td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; font-size: 13px; vertical-align: middle; }
th { background: #f8f9fb; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); font-weight: 600; }
tr:hover td { background: #fafbfd; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.table-wrap table { border: none; }
.table-wrap .table-wrap { border: none; }

/* Badges */
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-pass { background: var(--success-bg); color: var(--success); }
.badge-fail { background: var(--danger-bg); color: var(--danger); }
.badge-blocked { background: #eee0f7; color: #6c2bb3; }
.badge-na { background: var(--neutral-bg); color: var(--text-muted); }
.badge-neutral { background: var(--neutral-bg); color: var(--text-muted); }
.badge-progress { background: #e2ecfc; color: var(--primary-dark); }
.badge-critical { background: var(--danger-bg); color: var(--danger); }
.badge-high { background: var(--warning-bg); color: var(--warning); }
.badge-medium { background: #e2ecfc; color: var(--primary-dark); }
.badge-low { background: var(--neutral-bg); color: var(--text-muted); }

/* Forms */
label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 5px; color: #414b59; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px; font-size: 13.5px; background: #fff; color: var(--text); font-family: inherit;
}
textarea { resize: vertical; min-height: 70px; }
.form-row { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; background: #f8f9fb; border: 1px solid var(--border); border-radius: 6px; padding: 9px 11px; }
.checkbox-item input { width: auto; }
.checkbox-item label { margin: 0; font-weight: 500; }

/* Filters bar */
.filters-bar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: flex-end; }
.filters-bar .form-row { margin-bottom: 0; min-width: 150px; }

/* Flash */
.flash { padding: 11px 16px; border-radius: 6px; margin-bottom: 18px; font-size: 13.5px; font-weight: 500; }
.flash-success { background: var(--success-bg); color: var(--success); }
.flash-error { background: var(--danger-bg); color: var(--danger); }

/* Login page */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar-bg); }
.login-card { background: #fff; padding: 34px; border-radius: 12px; width: 340px; }
.login-card h1 { font-size: 18px; margin: 0 0 4px; }
.login-card p.sub { color: var(--text-muted); font-size: 12.5px; margin: 0 0 22px; }

.text-muted { color: var(--text-muted); }
.mb-0 { margin-bottom: 0; }
.actions-cell { display: flex; gap: 8px; white-space: nowrap; align-items: center; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }

/* Checkpoints: summary bar + filter pills */
.cp-summary-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; padding: 12px 14px; background: #f8f9fb; border: 1px solid var(--border); border-radius: 8px; }
.cp-summary-text { font-weight: 600; font-size: 13.5px; white-space: nowrap; }
.cp-summary-pct { font-weight: 700; font-size: 13.5px; color: var(--success); white-space: nowrap; min-width: 40px; text-align: right; }
.filter-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.filter-pill { background: var(--neutral-bg); border: 1px solid transparent; border-radius: 20px; padding: 5px 12px; font-size: 12px; font-weight: 600; color: var(--text-muted); cursor: pointer; }
.filter-pill:hover { background: #e2e6ec; }
.filter-pill.active { background: var(--primary); color: #fff; }
.cp-status-select { min-width: 130px; }
.cp-saved-indicator { font-size: 11.5px; color: var(--success); opacity: 0; transition: opacity .2s; white-space: nowrap; }
.cp-saved-indicator.visible { opacity: 1; }
.cp-saved-indicator.is-error { color: var(--danger); }

@media (max-width: 880px) {
  .sidebar { position: fixed; left: -230px; top: 0; z-index: 50; transition: left .18s ease; box-shadow: 4px 0 12px rgba(0,0,0,.2); }
  .sidebar.open { left: 0; }
  .main-content { padding: 18px; width: 100%; }
  .mobile-nav-toggle { display: block; background: none; border: none; font-size: 22px; margin-bottom: 14px; cursor: pointer; }
}
