:root {
  --bg: #eef4fb;
  --page-bg: #f7fbff;
  --card: #ffffff;
  --text: #142033;
  --muted: #667085;
  --muted-2: #8391a4;
  --primary: #063d78;
  --primary-2: #0b5ca8;
  --primary-dark: #021f45;
  --primary-soft: #eaf4ff;
  --border: #dde8f5;
  --border-2: #edf2f8;
  --danger: #dc2626;
  --danger-dark: #b42318;
  --success-bg: #dcfce7;
  --success: #0f6b3f;
  --warning-bg: #fff7ed;
  --warning: #c2410c;
  --error-bg: #fff1f3;
  --error: #b42318;
  --shadow-sm: 0 10px 28px rgba(6, 61, 120, .06);
  --shadow-md: 0 16px 44px rgba(6, 61, 120, .09);
  --shadow-lg: 0 24px 70px rgba(3, 27, 61, .18);
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;
  --sidebar-width: 268px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, .10), transparent 34%),
    linear-gradient(180deg, var(--page-bg) 0%, var(--bg) 100%);
  color: var(--text);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

small {
  color: var(--muted);
}

label {
  display: block;
  margin-bottom: 7px;
  color: #26384d;
  font-size: 13px;
  font-weight: 850;
}

/* =========================
   LAYOUT GERAL
========================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 72px;
  padding: 14px 28px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar strong {
  display: block;
  color: var(--primary-dark);
  font-size: 18px;
}

.topbar span {
  color: var(--muted);
  font-size: 13px;
}

.topbar nav {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}

/*
  Antes estava limitado a 1180px. 
  Agora o painel usa melhor a tela inteira.
*/
.container {
  width: calc(100% - 36px);
  max-width: none;
  margin: 28px auto 60px;
}

.admin-body {
  background: var(--bg);
}

.admin-shell {
  min-height: 100vh;
  background: var(--bg);
}

.admin-main {
  min-width: 0;
  min-height: 100vh;
  margin-left: var(--sidebar-width);
  background:
    radial-gradient(circle at top right, rgba(37, 99, 235, .10), transparent 32%),
    linear-gradient(180deg, var(--page-bg) 0%, var(--bg) 100%);
}

.admin-main .container {
  width: calc(100% - 36px);
  max-width: none;
  margin: 0 auto;
  padding: 28px 0 72px;
}

.mobile-topbar {
  display: none;
}

/* =========================
   MENU LATERAL
========================= */

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  min-height: 100vh;
  overflow-y: auto;
  background:
    radial-gradient(circle at 20% 0%, rgba(59, 130, 246, .38), transparent 34%),
    linear-gradient(180deg, #082b5f 0%, #061b3c 100%);
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: 18px 0 45px rgba(15, 23, 42, .14);
  border-right: 1px solid rgba(255, 255, 255, .10);
  z-index: 30;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 0 6px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .14);
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
  font-weight: 900;
  font-size: 20px;
}

.sidebar-brand strong {
  display: block;
  font-size: 16px;
  line-height: 1.15;
}

.sidebar-brand span {
  display: block;
  color: rgba(255, 255, 255, .70);
  font-size: 12px;
  margin-top: 3px;
}

.side-nav {
  display: grid;
  gap: 8px;
}

.side-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 12px 13px;
  border-radius: 14px;
  color: rgba(255, 255, 255, .82);
  font-weight: 800;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}

.side-nav a:hover,
.side-nav a.active {
  background: rgba(255, 255, 255, .14);
  color: #fff;
  transform: translateX(2px);
}

.side-nav a.active {
  box-shadow: inset 3px 0 0 #93c5fd;
}

.side-nav span {
  width: 22px;
  text-align: center;
}

.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid rgba(255, 255, 255, .14);
  padding: 14px 6px 0;
  display: grid;
  gap: 8px;
}

.sidebar-footer small {
  color: rgba(255, 255, 255, .68);
}

.sidebar-footer a {
  color: #fff;
  font-weight: 800;
}

/* =========================
   CABEÇALHOS E CARDS
========================= */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 20px;
  padding: 18px 20px;
  border-radius: 22px;
  background: rgba(255, 255, 255, .76);
  border: 1px solid rgba(226, 232, 240, .9);
  box-shadow: var(--shadow-sm);
}

.page-head.compact {
  margin-top: 28px;
}

.page-head h1,
.page-head h2 {
  margin: 0 0 4px;
  color: #052a52;
  letter-spacing: -.03em;
}

.page-head h1 {
  font-size: 28px;
}

.page-head h2 {
  font-size: 22px;
}

.page-head p {
  margin: 0;
  color: var(--muted);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 20px;
}

.admin-main .card {
  box-shadow: var(--shadow-md);
}

/* =========================
   BOTÕES
========================= */

.btn,
button.btn {
  border: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border-radius: 14px;
  padding: 12px 16px;
  font-weight: 850;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  line-height: 1;
  box-shadow: 0 12px 26px rgba(6, 61, 120, .18);
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.btn:hover,
button.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 34px rgba(6, 61, 120, .24);
}

.btn.secondary {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #cfe4fb;
  box-shadow: none;
}

.btn.secondary:hover {
  background: #dfeeff;
}

.link-danger {
  border: 0;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
  padding: 0;
  font: inherit;
  font-weight: 800;
}

/* =========================
   FORMULÁRIOS
========================= */

input,
select,
textarea {
  width: 100%;
  min-height: 46px;
  border: 1px solid #d4e0ec;
  border-radius: 14px;
  padding: 10px 12px;
  font: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(6, 61, 120, .10);
  background: #fff;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-grid small {
  display: block;
  margin-top: 6px;
  line-height: 1.35;
}

.checkbox-row label {
  display: flex;
  gap: 10px;
  align-items: center;
}

.checkbox-row input {
  width: auto;
  min-height: auto;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 180px) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 18px;
}

.filter-action {
  display: flex;
  align-items: end;
}

.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form select {
  min-width: 220px;
  width: auto;
}

.mini-btn {
  min-height: 36px !important;
  padding: 8px 12px !important;
  border-radius: 10px !important;
}

/* =========================
   TABELAS
========================= */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th,
td {
  padding: 15px 14px;
  border-bottom: 1px solid var(--border-2);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  background: #f8fbff;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .04em;
}

td {
  color: #26384d;
}

tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fbfdff;
}

.actions {
  white-space: nowrap;
}

td.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

td.actions form {
  display: inline;
  margin: 0;
}

/* =========================
   BADGES E ALERTAS
========================= */

.badge,
.badge-soft {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.badge.ok,
.badge-soft.ok {
  background: var(--success-bg);
  color: var(--success);
}

.badge.off,
.badge-soft.off {
  background: #f2f4f7;
  color: #667085;
}

.badge.warn,
.badge-soft.warn {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge-soft.neutral {
  color: #35526f;
  background: #eaf2fb;
}

.badge-soft.blue {
  color: var(--primary);
  background: var(--primary-soft);
}

.alert {
  border-radius: 16px;
  padding: 13px 15px;
  margin-bottom: 16px;
  font-weight: 750;
  border: 1px solid transparent;
}

.alert.success {
  background: var(--success-bg);
  color: var(--success);
  border-color: #b7efcc;
}

.alert.error {
  background: var(--error-bg);
  color: var(--error);
  border-color: #ffd5de;
}

.alert.info {
  background: #eff6ff;
  color: #1e40af;
  border-color: #cfe4fb;
}

.empty {
  color: var(--muted);
  padding: 38px 20px;
  text-align: center;
}

.text-muted {
  color: var(--muted);
}

/* =========================
   LOGIN
========================= */

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, .22), transparent 35%),
    radial-gradient(circle at bottom right, rgba(3, 27, 61, .18), transparent 34%),
    linear-gradient(135deg, #031b3d 0%, #063d78 52%, #021f45 100%);
}

.login-card {
  width: min(430px, 100%);
  background: #fff;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 26px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .22);
  padding: 30px;
}

.login-card h1 {
  margin: 0 0 8px;
  color: #052a52;
  font-size: 25px;
  letter-spacing: -.03em;
}

.login-card p {
  margin: 0 0 20px;
  color: var(--muted);
}

.login-card button {
  width: 100%;
  margin: 16px 0 12px;
  border: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff;
  border-radius: 14px;
  min-height: 48px;
  font-weight: 900;
  cursor: pointer;
}

.login-card small {
  display: block;
  text-align: center;
}

/* =========================
   QUICK CARDS
========================= */

.quick-sections {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.quick-card {
  margin-bottom: 18px;
}

.quick-card h3 {
  margin: 0 0 6px;
  color: #052a52;
}

.quick-card p {
  margin: 0 0 14px;
  color: var(--muted);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.quick-actions.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.quick-actions.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.quick-actions.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.quick-action {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
  background: #f8fbff;
  color: var(--text);
  display: block;
  transition: border-color .15s ease, background .15s ease, transform .15s ease;
}

.quick-action:hover {
  border-color: var(--primary);
  background: #eff6ff;
  transform: translateY(-1px);
}

.quick-action strong {
  display: block;
  margin-bottom: 4px;
  color: #052a52;
}

.quick-action span {
  color: var(--muted);
  font-size: 13px;
}

.quick-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.dashboard-links {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
}

/* =========================
   SEÇÕES E HELPERS
========================= */

.section-title {
  border-top: 1px solid var(--border);
  padding-top: 18px;
  margin-top: 4px;
}

.section-title h2 {
  margin: 0 0 4px;
  color: #052a52;
  font-size: 18px;
}

.section-title p {
  margin: 0;
  color: var(--muted);
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section-heading-row h2 {
  margin: 0;
  color: #052a52;
}

.code-block {
  display: block;
  overflow-x: auto;
  padding: 14px 16px;
  border-radius: 14px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
}

.check-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: #334155;
}

.check-row input {
  width: auto;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.status-grid > div {
  background: #f8fbff;
  border: 1px solid #dbe7f5;
  border-radius: 16px;
  padding: 14px;
}

/* =========================
   IMPORTAÇÃO
========================= */

.import-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.import-summary > div {
  background: #f8fbff;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 15px;
}

.import-summary strong {
  display: block;
  color: var(--primary);
  font-size: 26px;
  line-height: 1;
}

.import-summary span {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.import-errors {
  margin-bottom: 18px;
}

.import-errors h3,
.help-card h3 {
  margin: 0 0 12px;
  color: #052a52;
}

.import-errors ul {
  margin: 0;
  padding-left: 20px;
  color: var(--error);
}

.help-card {
  margin-top: 18px;
}

.help-card p {
  color: var(--muted);
  margin: 0 0 14px;
}

/* =========================
   RESPONSIVO
========================= */

@media (max-width: 1100px) {
  .dashboard-links {
    grid-template-columns: 1fr;
  }

  .import-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quick-actions.three,
  .quick-actions.four {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .admin-shell {
    display: block;
  }

  .sidebar {
    position: relative;
    inset: auto;
    width: auto;
    min-height: auto;
    height: auto;
    border-radius: 0 0 24px 24px;
    box-shadow: 0 14px 34px rgba(15, 23, 42, .12);
  }

  .side-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sidebar-footer {
    display: none;
  }

  .mobile-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--border);
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 12;
    backdrop-filter: blur(12px);
  }

  .admin-main {
    margin-left: 0;
  }

  .admin-main .container,
  .container {
    width: calc(100% - 22px);
    padding-top: 18px;
  }

  .page-head {
    padding: 14px;
  }

  .filter-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar,
  .page-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 15px;
    border-radius: 18px;
  }

  td.actions {
    flex-direction: column;
    align-items: flex-start;
    gap: 7px;
  }

  .quick-actions,
  .quick-actions.two,
  .quick-actions.three,
  .quick-actions.four {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .side-nav {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding: 18px 12px;
  }

  .import-summary {
    grid-template-columns: 1fr;
  }
}
