/* ─── Google Fonts ─────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600;700&display=swap');

/* ─── Variables ────────────────────────────────────────────────── */
:root {
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #1e293b;
  --primary: #1d4ed8;
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --white: #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,.08);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-width: 210px;
  --header-height: 56px;
}

/* ─── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body { font-family: 'DM Sans', sans-serif; background: var(--gray-50); color: var(--gray-900); -webkit-font-smoothing: antialiased; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }
table { border-collapse: collapse; width: 100%; }

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

/* ─── Sidebar ───────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand .brand-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.sidebar-brand span { color: #fff; font-weight: 600; font-size: 15px; letter-spacing: -.3px; }
.sidebar-nav { flex: 1; padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: #94a3b8; font-size: 13.5px; font-weight: 450;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: var(--sidebar-hover); color: #fff; font-weight: 500; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.sidebar-footer {
  padding: 14px 14px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.sidebar-user .user-name { color: #fff; font-size: 12px; font-weight: 500; }
.sidebar-user .user-role { color: #94a3b8; font-size: 11px; }
.btn-logout {
  display: flex; align-items: center; gap: 7px;
  color: #94a3b8; font-size: 12.5px;
  transition: color .15s;
}
.btn-logout:hover { color: #fff; }

/* ─── Main area ─────────────────────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-width);
  display: flex; flex-direction: column;
  min-height: 100vh; flex: 1;
}
.topbar {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 8px; color: var(--gray-500); font-size: 13px; }
.topbar-left svg { color: var(--gray-400); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--gray-50); border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); padding: 6px 12px;
}
.topbar-search input {
  background: none; border: none; outline: none;
  font-size: 13px; color: var(--gray-700); width: 200px;
}
.topbar-search input::placeholder { color: var(--gray-400); }
.topbar-search svg { color: var(--gray-400); width: 15px; height: 15px; flex-shrink: 0; }
.btn-notif { position: relative; color: var(--gray-500); display: flex; }
.btn-notif .dot {
  position: absolute; top: -2px; right: -2px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger); border: 1.5px solid var(--white);
}
.page-content { flex: 1; padding: 30px 30px 40px; }

/* ─── Page header ───────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.page-header p  { font-size: 13px; color: var(--primary); margin-top: 2px; }
.page-header-actions { display: flex; align-items: center; gap: 8px; }

/* ─── Cards ─────────────────────────────────────────────────────── */
.card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-body { padding: 22px 24px; }

/* ─── Stat cards ────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 20px 20px 18px;
  border-left: 4px solid var(--gray-200);
}
.stat-card.yellow  { border-left-color: var(--warning); }
.stat-card.blue    { border-left-color: var(--primary); }
.stat-card.green   { border-left-color: var(--success); }
.stat-card.gray    { border-left-color: var(--gray-400); }
.stat-card-top { display: flex; justify-content: space-between; align-items: flex-start; }
.stat-label { font-size: 12.5px; color: var(--gray-500); font-weight: 500; }
.stat-value { font-size: 30px; font-weight: 700; color: var(--gray-900); margin: 6px 0 4px; line-height: 1; }
.stat-sub   { font-size: 11.5px; color: var(--gray-400); }
.stat-icon  { opacity: .5; }

/* ─── Buttons ───────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; font-weight: 500;
  transition: background .15s, border-color .15s, color .15s;
}
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--white); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-50); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ─── Badges ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600;
}
.badge-pendente    { background: #fef3c7; color: #92400e; }
.badge-aprovacao   { background: #dbeafe; color: #1e40af; }
.badge-aprovado    { background: #dcfce7; color: #166534; }
.badge-rejeitado   { background: #fee2e2; color: #991b1b; }
.badge-ativo       { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.badge-inativo     { background: var(--gray-100); color: var(--gray-500); }
.badge-admin       { background: var(--primary); color: #fff; }
.badge-aprovador   { background: var(--success); color: #fff; }
.badge-executor    { background: #0d9488; color: #fff; }
.badge-tecnica     { background: #dbeafe; color: #1e40af; }
.badge-seguranca   { background: #ffedd5; color: #9a3412; }

/* ─── Avatar ────────────────────────────────────────────────────── */
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--gray-200); color: var(--gray-600);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
  text-transform: uppercase;
}
.avatar-sm { width: 28px; height: 28px; font-size: 10px; }

/* ─── Table ─────────────────────────────────────────────────────── */
.table-wrap { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.table-header { padding: 18px 22px 14px; border-bottom: 1px solid var(--gray-100); }
.table-header h3 { font-size: 14.5px; font-weight: 600; color: var(--gray-900); }
.table-header p  { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
table th { text-align: left; padding: 10px 18px; font-size: 11.5px; font-weight: 600; color: var(--gray-500); text-transform: uppercase; letter-spacing: .04em; background: var(--gray-50); border-bottom: 1px solid var(--gray-100); }
table td { padding: 14px 18px; font-size: 13px; color: var(--gray-700); border-bottom: 1px solid var(--gray-50); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fafbfc; }
tbody tr { cursor: pointer; transition: background .12s; }
.td-actions { display: flex; gap: 10px; justify-content: flex-end; }
.btn-link { font-size: 12px; font-weight: 500; background: none; border: none; }
.btn-link-primary { color: var(--primary); }
.btn-link-primary:hover { color: var(--primary-hover); }
.btn-link-danger { color: var(--danger); }
.btn-link-danger:hover { color: #b91c1c; }

/* ─── Form ──────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group label { font-size: 13px; font-weight: 500; color: var(--gray-700); }
.form-control {
  width: 100%; padding: 9px 12px;
  font-size: 13.5px; color: var(--gray-900);
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  background: var(--white); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29,78,216,.1); }
.form-control::placeholder { color: var(--gray-400); }
.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { font-size: 11.5px; color: var(--danger); margin-top: 3px; }
.form-row { display: grid; gap: 14px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
textarea.form-control { resize: none; min-height: 74px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 6px; }
.checkbox-item { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--gray-700); }
.checkbox-item input[type=checkbox] { width: 15px; height: 15px; accent-color: var(--primary); }
.section-subtitle { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-400); margin-bottom: 10px; margin-top: 4px; }

/* ─── Modal ─────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
  opacity: 0; transition: opacity .2s;
}
.modal-backdrop.show { opacity: 1; }
.modal-box {
  background: var(--white); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  width: 100%; max-width: 520px;
  transform: scale(.96) translateY(8px);
  transition: transform .2s;
}
.modal-backdrop.show .modal-box { transform: scale(1) translateY(0); }
.modal-box.modal-lg { max-width: 680px; }
.modal-box.modal-sm { max-width: 420px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 22px; border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 { font-size: 15px; font-weight: 600; }
.modal-close { color: var(--gray-400); font-size: 20px; line-height: 1; transition: color .15s; }
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 20px 22px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--gray-100); }

/* ─── Filter bar ────────────────────────────────────────────────── */
.filter-bar {
  background: var(--white); border: 1px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  padding: 18px 20px; margin-bottom: 18px;
}
.filter-bar h4 { font-size: 13.5px; font-weight: 600; color: var(--gray-800); margin-bottom: 2px; }
.filter-bar p  { font-size: 12px; color: var(--gray-400); margin-bottom: 12px; }
.filter-row { display: flex; gap: 10px; align-items: center; }
.filter-search {
  flex: 1; display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  padding: 7px 12px; background: var(--white);
}
.filter-search svg { color: var(--gray-400); width: 14px; height: 14px; flex-shrink: 0; }
.filter-search input { flex: 1; border: none; outline: none; font-size: 13px; }
.filter-select {
  padding: 7px 12px; border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm); background: var(--white);
  font-size: 13px; color: var(--gray-700); outline: none;
}
.filter-select:focus { border-color: var(--primary); }

/* ─── Dashboard bottom ──────────────────────────────────────────── */
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.chart-placeholder {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 20px 0;
}

/* ─── Detail page ───────────────────────────────────────────────── */
.back-link { display: inline-flex; align-items: center; gap: 5px; color: var(--gray-500); font-size: 13px; margin-bottom: 16px; transition: color .15s; }
.back-link:hover { color: var(--gray-900); }
.detail-header { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.detail-header h1 { font-size: 20px; font-weight: 700; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 32px; }
.info-item .info-label { font-size: 11.5px; color: var(--gray-400); margin-bottom: 3px; }
.info-item .info-value { font-size: 13.5px; color: var(--gray-800); font-weight: 500; }
.conformidade-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--gray-50); }
.conformidade-row:last-child { border-bottom: none; }
.conformidade-info { display: flex; align-items: center; gap: 10px; }
.conformidade-info .ci-text .ci-name { font-size: 13.5px; font-weight: 500; color: var(--gray-800); }
.conformidade-info .ci-text .ci-meta { font-size: 11.5px; color: var(--gray-400); margin-top: 1px; }

/* ─── Login ─────────────────────────────────────────────────────── */
.login-page { min-height: 100vh; background: var(--gray-50); display: flex; align-items: center; justify-content: center; }
.login-box { background: var(--white); border: 1px solid var(--gray-200); border-radius: 18px; box-shadow: var(--shadow-md); padding: 36px 34px; width: 360px; }
.login-brand { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 26px; }
.login-brand .brand-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 18px; }
.login-brand span { font-size: 18px; font-weight: 700; }
.login-box h2 { font-size: 18px; font-weight: 700; margin-bottom: 4px; }
.login-box .login-sub { font-size: 13px; color: var(--gray-500); margin-bottom: 22px; }

/* ─── Empty state ───────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-400); }
.empty-state p { font-size: 13px; margin-top: 8px; }

/* ─── Loading spinner ───────────────────────────────────────────── */
.spinner { display: flex; justify-content: center; align-items: center; padding: 48px; }
.spinner-ring { width: 28px; height: 28px; border: 3px solid var(--gray-200); border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Section card ──────────────────────────────────────────────── */
.section-card { background: var(--white); border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 22px 24px; margin-bottom: 20px; }
.section-card h2 { font-size: 15px; font-weight: 600; color: var(--gray-900); margin-bottom: 16px; }

/* ─── Action row ────────────────────────────────────────────────── */
.actions-row { display: flex; gap: 10px; margin-bottom: 22px; }

/* ─── Hidden ────────────────────────────────────────────────────── */
.hidden { display: none !important; }
