:root {
  --bg: #0f1621;
  --bg-alt: #131c2a;
  --panel: #16202f;
  --border: #24314540;
  --border-strong: #2a3a52;
  --text: #e7ecf3;
  --text-dim: #97a3b6;
  --text-faint: #64728a;
  --accent: #2dd4bf;
  --accent-dim: #17635a;
  --green: #34d399;
  --green-bg: #113a2c;
  --link: #5eb3ff;
  --radius: 8px;
}

* { box-sizing: border-box; }

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

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

body.locked .topbar,
body.locked .layout,
body.locked footer {
  display: none;
}

.auth-gate {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
body.locked .auth-gate {
  display: flex;
}

.auth-card {
  width: 100%;
  max-width: 340px;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-logo {
  font-weight: 700;
  font-size: 20px;
  text-align: center;
  margin-bottom: 4px;
}
.auth-logo span { color: var(--accent); }

.auth-subtitle {
  text-align: center;
  color: var(--text-faint);
  font-size: 12.5px;
  margin: 0 0 20px;
}

.auth-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  margin: 10px 0 5px;
}

.auth-input {
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font-size: 14px;
}
.auth-input:focus { outline: 1px solid var(--accent); }

.auth-error {
  min-height: 18px;
  color: #f28b8b;
  font-size: 12.5px;
  margin-top: 8px;
}

.auth-button {
  margin-top: 6px;
  padding: 10px 12px;
  border: none;
  border-radius: var(--radius);
  background: var(--accent);
  color: #05221e;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}
.auth-button:hover { filter: brightness(1.08); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: var(--bg-alt);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.brand .logo { font-weight: 700; font-size: 18px; letter-spacing: 0.3px; }
.brand .logo span { color: var(--accent); }
.brand .subtitle { color: var(--text-faint); font-size: 12px; }

.topbar-search {
  flex: 1;
  max-width: 420px;
  margin: 0 24px;
}
.topbar-search input {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--text);
  font-size: 13px;
}
.topbar-search input:focus { outline: 1px solid var(--accent); }

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

.layout {
  display: flex;
  min-height: calc(100vh - 49px);
}

.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  padding: 16px 0 40px;
  overflow-y: auto;
}

.sidebar h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
  padding: 0 18px;
  margin: 4px 0 10px;
}

.sidebar-filters {
  padding: 0 18px 12px;
}
.sidebar-filters select {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 7px 10px;
  color: var(--text);
  font-size: 12.5px;
}
.sidebar-filters select:focus { outline: 1px solid var(--accent); }

.sidebar-count {
  padding: 0 18px 14px;
  color: var(--text-dim);
  font-size: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.company-list { list-style: none; margin: 0; padding: 0; }

.company-list li a {
  display: block;
  padding: 9px 18px;
  color: var(--text);
  border-left: 3px solid transparent;
}
.company-list li a:hover { background: #1c283a; text-decoration: none; }
.company-list li a.active {
  background: #1a2740;
  border-left-color: var(--accent);
}
.company-list .name {
  display: block;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.company-list .cnpj {
  display: block;
  font-size: 11.5px;
  color: var(--text-faint);
  margin-top: 2px;
}

.status-dot {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 8px;
  background: #3a1414;
  color: #f28b8b;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  vertical-align: middle;
}

.sidebar-empty {
  padding: 12px 18px;
  color: var(--text-faint);
  font-size: 12.5px;
}

main {
  flex: 1;
  padding: 28px 36px 60px;
  max-width: 900px;
}

.welcome { color: var(--text-dim); line-height: 1.7; max-width: 560px; }
.welcome h1 { color: var(--text); font-size: 22px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
}

.detail-header { display: flex; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.detail-header .cnpj-big { font-size: 22px; font-weight: 700; letter-spacing: 0.2px; }
.detail-header .cnpj-small { color: var(--text-faint); font-size: 12.5px; margin-top: 2px; }
.razao-social { font-size: 19px; font-weight: 700; margin: 14px 0 4px; }
.nome-fantasia { color: var(--text-dim); font-size: 13.5px; margin-bottom: 12px; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge.ativa { background: var(--green-bg); color: var(--green); }
.badge.baixada { background: #3a1414; color: #f28b8b; }
.badge.inapta { background: #3a2a10; color: #eec98a; }
.badge.suspensa { background: #3a2a10; color: #eec98a; }

.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px 24px;
  margin-top: 20px;
}
.kv-grid .kv-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-faint); margin-bottom: 3px; }
.kv-grid .kv-value { font-size: 14px; color: var(--text); }

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #1c283a;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--text-faint); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border-strong); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; }
td { padding: 10px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
tr:last-child td { border-bottom: none; }

.tipo-tag { font-size: 11px; padding: 2px 8px; border-radius: 4px; background: #1c283a; color: var(--text-dim); }
.tipo-tag.principal { background: var(--accent-dim); color: #b7f5ee; }

.notice {
  margin-top: 18px;
  padding: 10px 14px;
  background: #2a1f10;
  border: 1px solid #4a3616;
  color: #eec98a;
  border-radius: 6px;
  font-size: 12.5px;
}

footer {
  color: var(--text-faint);
  font-size: 11.5px;
  padding: 30px 36px;
  line-height: 1.6;
}
footer a { color: var(--text-dim); }

@media (max-width: 820px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 260px; }
  main { padding: 20px; }
}
