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

:root {
  --primary:       #00694a;   /* emerald-700 */
  --primary-dark:  #005a3f;   /* emerald-800 */
  --primary-light: #d1fae5;   /* emerald-100 */
  --primary-mid:   #059669;   /* emerald-600 */

  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --surface2:      #f8fafc;
  --card:          #ffffff;
  --border:        #e2e8f0;
  --border-light:  #f1f5f9;

  --fg:            #0f172a;
  --fg-dim:        #334155;
  --muted:         #64748b;
  --text:          #0f172a;

  --sidebar-bg:    #ffffff;
  --sidebar-w:     230px;

  --green-ok:      #16a34a;
  --green-ok-bg:   #dcfce7;
  --yellow:        #b45309;
  --yellow-bg:     #fef3c7;
  --red:           #dc2626;
  --red-bg:        #fee2e2;
  --accent:        #00694a;
  --accent-bg:     #d1fae5;
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

/* ─── APP SHELL ────────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ─── SIDEBAR ────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width .2s ease, min-width .2s ease;
}

.sidebar-brand {
  padding: 16px 16px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.sidebar-brand-name {
  font-family: 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.sidebar-brand-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  margin-top: 2px;
}

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

.login-logo {
  max-width: 140px;
  height: auto;
  margin-bottom: 12px;
  display: block;
}

.sidebar-section-label {
  padding: 18px 16px 6px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
}

.sidebar-nav { flex: 1; padding: 4px 10px 8px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  margin-bottom: 2px;
  border-radius: 7px;
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .12s, color .12s;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--surface2);
  color: var(--fg);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
}

.nav-icon {
  font-size: 14px;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  opacity: .75;
}

.nav-item.active .nav-icon { opacity: 1; }

.sidebar-bottom {
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-sidebar-logout {
  width: 100%;
  padding: 7px 12px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.logout-icon { font-size: 13px; flex-shrink: 0; }

.btn-sidebar-logout:hover {
  background: var(--red-bg);
  border-color: var(--red);
  color: var(--red);
}

/* ─── APP CONTENT ──────────────────────────────────── */
.app-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .2s ease;
}

/* ─── SIDEBAR RECOLHÍVEL ───────────────────────────── */
.app-shell.sidebar-collapsed .sidebar      { width: 56px; min-width: 56px; }
.app-shell.sidebar-collapsed .app-content  { margin-left: 56px; }

.app-shell.sidebar-collapsed .sidebar-brand-name,
.app-shell.sidebar-collapsed .sidebar-brand-sub,
.app-shell.sidebar-collapsed .sidebar-section-label,
.app-shell.sidebar-collapsed .sidebar-user,
.app-shell.sidebar-collapsed .sidebar-logo            { display: none; }
.app-shell.sidebar-collapsed .sidebar-brand           { padding: 8px; justify-content: center; }
.app-shell.sidebar-collapsed .nav-item span:not(.nav-icon)            { display: none; }
.app-shell.sidebar-collapsed .nav-item                { justify-content: center; padding: 10px 0; }
.app-shell.sidebar-collapsed details.nav-group > summary span:not(.nav-icon),
.app-shell.sidebar-collapsed details.nav-group > summary .grp-chevron { display: none; }
.app-shell.sidebar-collapsed details.nav-group > summary              { justify-content: center; }
.app-shell.sidebar-collapsed details.nav-group .nav-item-sub { display: none; }
.app-shell.sidebar-collapsed .sidebar-bottom    { padding: 8px; }
.app-shell.sidebar-collapsed .logout-label      { display: none; }
.app-shell.sidebar-collapsed .btn-sidebar-logout { width: 32px; height: 32px; padding: 0; margin: 0 auto; }

/* Botão de toggle da sidebar */
.btn-sidebar-toggle {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s, color .12s;
  padding: 0;
}
.btn-sidebar-toggle:hover { background: var(--surface2); color: var(--fg); }
.sidebar-toggle-icon { font-size: 14px; display: inline-block; }

/* ─── TOP BAR ──────────────────────────────────────── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.2px;
}

.topbar-meta { font-size: 12px; color: var(--muted); }

/* ─── FILTERS ──────────────────────────────────────── */
.filters {
  display: flex;
  gap: 12px;
  padding: 12px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  align-items: center;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-group label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}

select {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 6px 10px;
  border-radius: 7px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}

select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,105,74,.12);
}

/* ─── MAIN ─────────────────────────────────────────── */
main { padding: 24px 28px; }

/* ─── LOADING ──────────────────────────────────────── */
.loading-state {
  text-align: center;
  padding: 40px;
  color: var(--muted);
  font-size: 13px;
}

/* ─── BADGE ────────────────────────────────────────── */
.badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

/* ─── CARDS ────────────────────────────────────────── */
.summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  border-radius: 10px 10px 0 0;
}

.card.ok::before   { background: var(--green-ok); }
.card.warn::before { background: var(--yellow); }
.card.bad::before  { background: var(--red); }

.card .card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  margin-bottom: 6px;
}

.card .card-val {
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  margin-bottom: 4px;
}

.card.ok .card-val   { color: var(--green-ok); }
.card.warn .card-val { color: var(--yellow); }
.card.bad .card-val  { color: var(--red); }
.card .card-sub      { font-size: 11px; color: var(--muted); }

/* ─── TABLE ────────────────────────────────────────── */
.table-wrap {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}

.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}

.table-header h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg);
}

table { width: 100%; border-collapse: collapse; }

thead th {
  background: var(--surface2);
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th.num { text-align: right; }

tbody tr { border-bottom: 1px solid var(--border-light); transition: background .1s; }
tbody tr:last-child { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--accent-bg); }

td { padding: 10px 16px; font-size: 13px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ─── STATUS CHIPS ─────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.chip.ok   { background: var(--green-ok-bg); color: var(--green-ok); }
.chip.warn { background: var(--yellow-bg);   color: var(--yellow); }
.chip.bad  { background: var(--red-bg);      color: var(--red); }

/* ─── EMPTY ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px;
  color: var(--muted);
  font-size: 13px;
}

/* ─── LOGIN ────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 4px 24px rgba(0,0,0,.06);
}

.login-brand {
  margin-bottom: 28px;
}

.login-brand-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.3px;
}

.login-brand-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.login-card-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--fg);
  margin: 0 0 4px;
}

.login-card-sub {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 24px;
}

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-error {
  background: var(--red-bg);
  color: var(--red);
  border: 1px solid rgba(220,38,38,.2);
}

.alert-icon { font-size: 15px; }

.field-group { margin-bottom: 16px; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-dim);
  margin-bottom: 6px;
}

.field-input {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--fg);
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  outline: none;
  transition: border-color .12s, box-shadow .12s;
}

.field-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,105,74,.12);
  background: var(--surface);
}

.captcha-wrap { margin: 20px 0; display: flex; justify-content: center; }

.btn-login {
  width: 100%;
  padding: 11px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .12s;
}

.btn-login:hover { background: var(--primary-dark); }

/* ─── RESPONSIVE ───────────────────────────────────── */

/* Tablet largo: sidebar levemente mais estreita */
@media (max-width: 1100px) {
  :root { --sidebar-w: 200px; }
}

/* Tablet / landscape mobile */
@media (max-width: 768px) {
  :root { --sidebar-w: 56px; }

  /* Sidebar colapsa para ícones */
  .sidebar-brand,
  .sidebar-section-label,
  .sidebar-user { display: none; }
  .nav-item span:not(.nav-icon) { display: none; }
  .nav-item { justify-content: center; padding: 10px; }

  /* Topbar */
  .topbar {
    padding: 10px 14px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .topbar-title { font-size: 15px; }

  /* Filtros: grade de 2 colunas */
  .filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 10px 14px;
    align-items: end;
  }
  .filter-group {
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    width: 100%;
  }
  .filters select,
  .filters .filter-input { width: 100% !important; max-width: none !important; }
  .btn-clear { grid-column: 1 / -1; width: 100%; }

  /* Conteúdo */
  main { padding: 12px 14px; }

  /* Tabela: fonte menor, padding reduzido */
  thead th, td { padding: 8px 10px; font-size: 12px; }
}

/* Mobile pequeno: grade de 1 coluna */
@media (max-width: 480px) {
  .filters { grid-template-columns: 1fr; }
}

/* Qualidade: linha com realizado < planejado */
.row-deficit td {
  background-color: rgba(220, 60, 60, 0.18);
}
