:root {
  --navy: #0f2b3c;
  --navy-2: #16364d;
  --teal: #1d8fa8;
  --teal-soft: #eaf7fb;
  --gold: #f0b13d;
  --green: #2f8b4f;
  --green-soft: #eefaf2;
  --red: #c74848;
  --red-soft: #fff0f0;
  --gray: #6f7d86;
  --surface: #f6f8fb;
  --line: #e5ebef;
  --ink: #142533;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "Segoe UI", Roboto, Arial, sans-serif;
  background: linear-gradient(135deg, #f2f6fa 0%, #e9eff3 100%);
  color: var(--ink);
}
button, input, select, textarea {
  font: inherit;
}
button { cursor: pointer; }

.app-shell {
  min-height: 100vh;
  padding: 24px;
}
.app-shell.hidden { display: none; }

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 24px;
  background: var(--navy);
}
.login-screen.hidden { display: none; }
.login-card {
  width: min(400px, 100%);
  background: white;
  border-radius: 16px;
  padding: 36px 32px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
}
.login-logo {
  display: inline-flex;
  flex-direction: column;
  align-items: stretch;
}
.login-logo-name {
  font-size: 2.1rem;
  font-weight: 800;
  font-style: italic;
  letter-spacing: 0.02em;
  color: var(--navy);
  line-height: 1;
}
.login-logo-sub {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 4px solid var(--gold);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.34em;
  color: var(--gold);
  text-align: right;
}
.login-subtitle {
  margin: 18px 0 26px;
  color: var(--ink);
  font-size: 0.95rem;
}
.login-help {
  margin: -14px 0 22px;
  color: var(--gray);
  font-size: 0.88rem;
  line-height: 1.55;
  text-align: left;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}
.login-form label { color: var(--ink); font-weight: 600; gap: 6px; }
.login-form input { padding: 12px 14px; border-radius: 8px; }
.login-form input::placeholder { color: #b6c0c8; }
.login-form input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(29, 143, 168, 0.15);
}
.login-submit {
  margin-top: 6px;
  padding: 13px 16px;
  border-radius: 8px;
  font-size: 1rem;
}
.login-link {
  display: inline-block;
  margin: 18px 0 16px;
  color: var(--teal);
  font-size: 0.9rem;
  text-decoration: none;
}
.login-link:hover { text-decoration: underline; }
.login-footer {
  border-top: 1px solid var(--line);
  padding-top: 16px;
  font-size: 0.9rem;
  color: var(--ink);
}
.login-footer a {
  color: #e0453a;
  font-weight: 700;
  text-decoration: none;
}
.login-footer a:hover { text-decoration: underline; }
.login-error {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid #f3caca;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.88rem;
  text-align: left;
}
.chip-exit { border-color: rgba(255, 255, 255, 0.35); }

.hidden { display: none !important; }

.login-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px;
  margin-bottom: 20px;
}
.login-tab {
  border: 0;
  background: transparent;
  border-radius: 7px;
  padding: 9px 8px;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--gray);
}
.login-tab.active {
  background: white;
  color: var(--navy);
  box-shadow: 0 2px 6px rgba(20, 37, 51, 0.12);
}

.login-demo {
  margin-top: 18px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px dashed var(--line);
  text-align: left;
  font-size: 0.8rem;
  color: var(--gray);
}
.login-demo strong { display: block; margin-bottom: 6px; color: var(--navy); }
.login-demo p { margin: 3px 0; }
.login-demo code {
  background: var(--teal-soft);
  border-radius: 5px;
  padding: 1px 5px;
  color: var(--navy);
}

.user-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(240, 177, 61, 0.18);
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 600;
}
.user-badge:empty { display: none; }

.admin-section, .imenco-section, .forn-section { display: none; }
.admin-section.active, .imenco-section.active, .forn-section.active { display: block; }

.crud-form { display: flex; flex-direction: column; gap: 12px; }
.detalhes { margin: 0; display: flex; flex-direction: column; gap: 10px; }
.detalhes div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}
.detalhes div:last-child { border-bottom: 0; padding-bottom: 0; }
.detalhes dt { color: var(--gray); font-size: 0.88rem; }
.detalhes dd { margin: 0; font-weight: 600; text-align: right; }
.crud-form label { color: var(--ink); font-weight: 600; }
.crud-copy { margin: 0; color: var(--gray); line-height: 1.6; }

.btn-danger { color: var(--red); border-color: #f3caca; }
.btn-danger:hover { background: var(--red-soft); }

.nota-motivo {
  display: block;
  margin-top: 5px;
  color: var(--gray);
  font-size: 0.78rem;
}

.filtro-data {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  font-size: 0.88rem;
}
.filtro-data input { min-width: 150px; }
.table-scroll { overflow-x: auto; }

.doc-preview {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  background: var(--surface);
}
.doc-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 2px solid var(--navy);
  padding-bottom: 8px;
  margin-bottom: 10px;
}
.doc-header strong { color: var(--navy); font-size: 1.05rem; }
.doc-header span { color: var(--gray); font-weight: 600; }
.doc-preview p { margin: 4px 0; font-size: 0.9rem; }
.doc-aviso {
  margin-top: 10px !important;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  color: var(--gray);
  font-size: 0.8rem !important;
  font-style: italic;
}

.omie-ok, .omie-info {
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.85rem;
  text-align: left;
  line-height: 1.5;
}
.omie-ok { background: var(--green-soft); color: var(--green); border: 1px solid #cdeeda; }
.omie-info { background: var(--surface); color: var(--gray); border: 1px solid var(--line); }

.emails-card { width: min(560px, 100%); }
.lista-emails {
  margin-top: 14px;
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.email-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: var(--surface);
}
.email-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}
.email-meta span { color: var(--gray); font-size: 0.78rem; white-space: nowrap; }
.email-para { margin: 6px 0 4px; color: var(--teal); font-size: 0.82rem; font-weight: 600; }
.email-corpo { margin: 0; color: var(--gray); font-size: 0.88rem; line-height: 1.55; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 18px 24px;
  background: var(--navy);
  color: white;
  border-radius: 24px;
  box-shadow: 0 18px 50px rgba(15, 43, 60, 0.18);
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--teal), var(--gold));
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
}
.brand-mark.small { width: 40px; height: 40px; border-radius: 12px; }
.brand h1 { margin: 0; font-size: 1rem; }
.brand p { margin: 3px 0 0; font-size: 0.85rem; color: rgba(255,255,255,0.75); }
.topbar-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.08);
  color: white;
  padding: 8px 12px;
  border-radius: 999px;
}
.chip.active {
  background: white;
  color: var(--navy);
}

.view { display: none; }
.view.active { display: block; }

.hero {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
  margin-top: 24px;
}
.hero-copy, .hero-card, .panel, .profile-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 10px 25px rgba(20, 37, 51, 0.05);
}
.hero-copy {
  padding: 32px;
}
.hero-copy h2 {
  font-size: 2rem;
  line-height: 1.2;
  margin: 8px 0 14px;
}
.hero-copy p { color: var(--gray); line-height: 1.6; }
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.24em;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--teal);
  margin: 0 0 8px;
}
.hero-actions { display: flex; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.btn {
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 600;
}
.btn-primary { background: var(--teal); color: white; }
.btn-secondary { background: var(--teal-soft); color: var(--navy); }
.btn-outline { background: white; color: var(--navy); border: 1px solid var(--line); }
.hero-card { padding: 24px; }
.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.stat-row > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px;
}
.stat-row strong { display: block; font-size: 1.45rem; color: var(--navy); }
.stat-row span { color: var(--gray); font-size: 0.9rem; }
.timeline { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.timeline-item { display: flex; gap: 12px; align-items: flex-start; }
.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--line);
  margin-top: 5px;
}
.dot.active { background: var(--gold); }
.timeline-item h3 { margin: 0 0 4px; font-size: 0.95rem; }
.timeline-item p { margin: 0; color: var(--gray); font-size: 0.9rem; }

.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-top: 24px;
}
.profile-card { padding: 24px; }
.profile-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(29,143,168,0.16), rgba(240,177,61,0.16));
  color: var(--navy);
}
.profile-card h3 { margin: 16px 0 8px; }
.profile-card p { color: var(--gray); line-height: 1.6; }

.workspace { display: grid; grid-template-columns: 260px 1fr; gap: 20px; margin-top: 24px; }
.sidebar {
  background: white;
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 20px;
  height: fit-content;
}
.sidebar-header { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.sidebar-header h3 { margin: 0; font-size: 1rem; }
.sidebar-header p { margin: 2px 0 0; color: var(--gray); font-size: 0.9rem; }
.nav-list { display: flex; flex-direction: column; gap: 8px; }
.nav-item {
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--gray);
  border-radius: 12px;
  padding: 10px 12px;
}
.nav-item.active {
  background: var(--teal-soft);
  color: var(--navy);
  font-weight: 700;
}
.content { display: flex; flex-direction: column; gap: 20px; }
.panel { padding: 22px; }
.hero-panel { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.hero-panel h2 { margin: 4px 0 0; font-size: 1.35rem; }
.pill-group { display: flex; gap: 10px; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 10px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.85rem;
}
.pill.success { background: var(--green-soft); color: var(--green); }
.pill.warning { background: #fff7e9; color: #a56500; }
.pill.error { background: var(--red-soft); color: var(--red); }
.pill.neutral { background: var(--teal-soft); color: var(--navy); }

.grid.two-col { display: grid; grid-template-columns: 1.2fr 0.8fr; gap: 20px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 16px; }
.section-title h3 { margin: 0; font-size: 1.05rem; }
.section-title span { color: var(--gray); font-size: 0.9rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
label { display: flex; flex-direction: column; color: var(--gray); font-size: 0.9rem; gap: 7px; }
input, select, textarea {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: white;
  color: var(--ink);
}
textarea { resize: vertical; }
.full { grid-column: 1 / -1; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.file-row { display: flex; gap: 10px; flex-wrap: wrap; }
.file-btn { border: 1px dashed var(--line); background: var(--surface); border-radius: 12px; padding: 10px 12px; }
.kpi-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.kpi-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  background: var(--surface);
}
.kpi-card strong { display: block; font-size: 1.3rem; color: var(--navy); }
.kpi-card span { color: var(--gray); font-size: 0.85rem; }
.alert { padding: 12px 14px; border-radius: 14px; background: #fff8e8; color: #8a5b00; border: 1px solid #f5e0b1; }

.list-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.list-card:last-child { border-bottom: 0; }
.list-card p { margin: 4px 0 0; color: var(--gray); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input, .toolbar select { flex: 1; min-width: 140px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); }
th { color: var(--gray); font-weight: 600; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--navy);
  color: white;
  box-shadow: 0 12px 25px rgba(15, 43, 60, 0.18);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 43, 60, 0.45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 22px;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  width: min(420px, 100%);
  background: white;
  border-radius: 24px;
  padding: 22px;
  box-shadow: 0 20px 40px rgba(15, 43, 60, 0.2);
}
.modal-close { border: 0; background: transparent; font-size: 1.25rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

@media (max-width: 1040px) {
  .hero, .grid.two-col, .profile-grid { grid-template-columns: 1fr; }
  .workspace { grid-template-columns: 1fr; }
}

@media (max-width: 680px) {
  .app-shell { padding: 14px; }
  .topbar, .hero-copy, .hero-card, .panel, .profile-card, .sidebar { border-radius: 18px; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .hero-panel { flex-direction: column; align-items: flex-start; }
  .form-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr; }
  .list-card { flex-direction: column; align-items: flex-start; }
}
