/* ============================================================
   AHP Riscos — Design System
   Paleta: branco / #F5F5F5 / #1E40AF / cinza escuro
   Fonte: Inter, system-ui
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --blue: #1E40AF;
  --blue-light: #3B63D6;
  --blue-dark: #1e3a8a;
  --blue-bg: #EFF6FF;
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --green: #059669;
  --green-bg: #ECFDF5;
  --red: #DC2626;
  --red-bg: #FEF2F2;
  --yellow: #D97706;
  --yellow-bg: #FFFBEB;
  --white: #FFFFFF;
  --sidebar-w: 240px;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.10), 0 2px 4px -1px rgba(0,0,0,.06);
}

html, body { height: 100%; font-family: 'Inter', system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--gray-900); background: var(--gray-100); }

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

/* ── Layout ── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--blue-dark);
  color: #CBD5E1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.sidebar-logo h1 { font-size: 16px; font-weight: 700; color: #fff; line-height: 1.2; }
.sidebar-logo span { font-size: 11px; opacity: .6; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav ul { list-style: none; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: #CBD5E1;
  border-radius: 0;
  font-size: 13.5px;
  transition: background .15s, color .15s;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
  background: rgba(255,255,255,.1);
  color: #fff;
  text-decoration: none;
}
.sidebar-nav a.active { border-right: 3px solid #60A5FA; }
.sidebar-nav .icon { width: 16px; text-align: center; opacity: .7; }
.sidebar-nav a.active .icon, .sidebar-nav a:hover .icon { opacity: 1; }

.sidebar-section { padding: 8px 16px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; opacity: .4; margin-top: 8px; }

.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,.1); }
.sidebar-user { font-size: 12px; }
.sidebar-user strong { display: block; color: #fff; font-size: 13px; }
.sidebar-user span { opacity: .6; }

.main-content { margin-left: var(--sidebar-w); flex: 1; display: flex; flex-direction: column; min-height: 100vh; }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-content { padding: 24px; flex: 1; max-width: 1200px; width: 100%; }

/* ── Cards ── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }

/* ── KPI cards ── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.kpi-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 20px;
  border-left: 4px solid var(--blue);
}
.kpi-card.green { border-color: var(--green); }
.kpi-card.red { border-color: var(--red); }
.kpi-card.yellow { border-color: var(--yellow); }
.kpi-label { font-size: 12px; color: var(--gray-500); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 28px; font-weight: 700; color: var(--gray-900); line-height: 1.2; margin-top: 4px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { background: var(--gray-50); color: var(--gray-500); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: 10px 14px; text-align: left; border-bottom: 2px solid var(--gray-200); white-space: nowrap; }
td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }
tbody tr:nth-child(even) { background: #fafafa; }
tbody tr:nth-child(even):hover { background: var(--gray-50); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  gap: 4px;
}
.badge-blue { background: var(--blue-bg); color: var(--blue); }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-yellow { background: var(--yellow-bg); color: var(--yellow); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: all .15s;
  text-decoration: none;
  line-height: 1;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue-light); border-color: var(--blue-light); }
.btn-secondary { background: var(--white); color: var(--gray-700); border-color: var(--gray-300); }
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-success { background: var(--green); color: #fff; border-color: var(--green); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 11px 24px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,64,175,.1); }
.form-control:disabled { background: var(--gray-50); color: var(--gray-400); }
.form-hint { font-size: 11.5px; color: var(--gray-400); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── Alerts / Flash ── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: var(--green-bg); color: #065f46; border: 1px solid #A7F3D0; }
.alert-error { background: var(--red-bg); color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: var(--yellow-bg); color: #92400E; border: 1px solid #FDE68A; }
.alert-info { background: var(--blue-bg); color: var(--blue-dark); border: 1px solid #BFDBFE; }

/* ── Auth ── */
.auth-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--gray-100); }
.auth-card { background: var(--white); border-radius: 12px; box-shadow: var(--shadow-md); padding: 40px; width: 100%; max-width: 420px; }
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo h1 { font-size: 22px; font-weight: 700; color: var(--blue-dark); }
.auth-logo p { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ── Wizard ── */
.wizard-page { min-height: 100vh; background: var(--gray-50); display: flex; flex-direction: column; }
.wizard-topbar { background: var(--white); border-bottom: 1px solid var(--gray-200); padding: 0 24px; height: 56px; display: flex; align-items: center; justify-content: space-between; }
.wizard-topbar h2 { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.progress-bar-wrap { flex: 1; max-width: 400px; margin: 0 24px; }
.progress-bar-track { height: 6px; background: var(--gray-200); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--blue); border-radius: 3px; transition: width .3s; }
.progress-label { font-size: 11px; color: var(--gray-400); margin-top: 3px; text-align: center; }

.wizard-content { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 20px; }
.wizard-card { background: var(--white); border-radius: 12px; box-shadow: var(--shadow-md); padding: 40px; max-width: 640px; width: 100%; }
.wizard-card h3 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--gray-400); margin-bottom: 8px; }
.wizard-question { font-size: 20px; font-weight: 600; color: var(--gray-900); line-height: 1.4; margin-bottom: 28px; }

.comparison-options { display: flex; gap: 12px; margin-bottom: 28px; }
.option-card {
  flex: 1;
  padding: 16px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  transition: all .15s;
  background: var(--white);
}
.option-card:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-bg); }
.option-card.selected { border-color: var(--blue); color: var(--blue); background: var(--blue-bg); }
.option-card.locked { border-color: var(--blue); color: var(--blue); background: var(--blue-bg); cursor: not-allowed; opacity: .85; }
.option-card.locked-other { opacity: .4; cursor: not-allowed; pointer-events: none; }
.option-card .lock-icon { display: block; font-size: 11px; color: var(--blue-light); margin-top: 4px; }

.intensity-section { margin-bottom: 24px; }
.intensity-label { font-size: 13px; font-weight: 500; color: var(--gray-700); margin-bottom: 10px; }
.intensity-grid { display: grid; grid-template-columns: repeat(9, 1fr); gap: 6px; }
.intensity-btn {
  padding: 10px 0;
  border: 1.5px solid var(--gray-300);
  border-radius: var(--radius);
  background: var(--white);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  text-align: center;
  transition: all .15s;
}
.intensity-btn:hover { border-color: var(--blue); color: var(--blue); background: var(--blue-bg); }
.intensity-btn.selected { background: var(--blue); color: #fff; border-color: var(--blue); }

.intensity-meaning { font-size: 11px; color: var(--gray-400); margin-top: 8px; min-height: 16px; text-align: center; }

/* ── Misc ── */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h1 { font-size: 20px; font-weight: 700; }
.breadcrumb { font-size: 12px; color: var(--gray-400); margin-bottom: 4px; }
.breadcrumb a { color: var(--gray-400); }
.breadcrumb a:hover { color: var(--blue); }

.empty-state { text-align: center; padding: 60px 20px; color: var(--gray-400); }
.empty-state h3 { font-size: 16px; color: var(--gray-500); margin-bottom: 8px; }
.empty-state p { font-size: 13px; }

.text-sm { font-size: 12px; }
.text-muted { color: var(--gray-400); }
.fw-600 { font-weight: 600; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }

/* Tabela de critérios no wizard */
.matrix-preview { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 12px; }
.matrix-preview th, .matrix-preview td { padding: 6px 10px; border: 1px solid var(--gray-200); text-align: center; }
.matrix-preview th { background: var(--gray-50); }
.matrix-preview .diag { background: var(--gray-100); }

/* Cor de RC */
.rc-good { color: var(--green); font-weight: 600; }
.rc-bad { color: var(--red); font-weight: 600; }

/* Responsivo */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .comparison-options { flex-direction: column; }
  .intensity-grid { grid-template-columns: repeat(5, 1fr); }
}
