:root {
  --navy-950: #0a1930;
  --navy-900: #0f2340;
  --navy-800: #16305a;
  --navy-700: #1e3f74;
  --navy-100: #e8edf6;
  --blue-accent: #2f6fed;
  --paper: #f6f8fb;
  --white: #ffffff;
  --ink: #16213a;
  --ink-soft: #5b6478;
  --line: #dde3ee;
  --green: #1c8a52;
  --green-bg: #e5f6ec;
  --red: #c23b3b;
  --red-bg: #fbe9e9;
  --gray: #6b7280;
  --gray-bg: #eef0f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 35, 64, 0.06), 0 8px 24px rgba(15, 35, 64, 0.06);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Auth screen ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}

@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}

.auth-visual {
  background: linear-gradient(160deg, var(--navy-950), var(--navy-800) 70%, var(--navy-700));
  color: var(--white);
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.auth-visual .brand {
  font-size: 15px;
  letter-spacing: 0.02em;
  font-weight: 600;
  opacity: 0.85;
}

.auth-visual h1 {
  font-size: 34px;
  line-height: 1.25;
  font-weight: 600;
  max-width: 420px;
  margin: 0;
}

.auth-visual p {
  color: rgba(255,255,255,0.68);
  max-width: 380px;
  line-height: 1.6;
}

.auth-visual .foot {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
}

.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.auth-card {
  width: 100%;
  max-width: 360px;
}

.auth-card h2 {
  font-size: 22px;
  margin: 0 0 6px;
}

.auth-card .sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0 0 28px;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--white);
  font-size: 15px;
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--blue-accent);
  box-shadow: 0 0 0 3px rgba(47, 111, 237, 0.14);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease;
}

.btn-primary {
  background: var(--navy-900);
  color: var(--white);
  width: 100%;
}
.btn-primary:hover { background: var(--navy-800); }
.btn-primary:active { transform: translateY(1px); }
.btn-primary:disabled { opacity: 0.6; cursor: default; }

.btn-ghost {
  background: transparent;
  color: var(--navy-900);
  border: 1px solid var(--line);
}
.btn-ghost:hover { background: var(--navy-100); }

.btn-sm { padding: 7px 12px; font-size: 13px; }

.error-msg {
  background: var(--red-bg);
  color: var(--red);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  margin-bottom: 16px;
  display: none;
}

.error-msg.show { display: block; }

/* ---------- App shell (cadastro / dashboard) ---------- */
.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--navy-950);
  color: var(--white);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar .brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar .brand .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--blue-accent);
}

.nav-tabs {
  display: flex;
  gap: 6px;
}

.nav-tabs a {
  text-decoration: none;
  color: rgba(255,255,255,0.75);
  padding: 8px 14px;
  border-radius: 7px;
  font-size: 14px;
  font-weight: 500;
}

.nav-tabs a.active,
.nav-tabs a:hover {
  background: rgba(255,255,255,0.1);
  color: var(--white);
}

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

.topbar .right .email {
  font-size: 13px;
  color: rgba(255,255,255,0.6);
}

.logout-link {
  font-size: 13px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
}
.logout-link:hover { color: var(--white); }

.page {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 64px;
  flex: 1;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.page-head h1 {
  font-size: 24px;
  margin: 0 0 4px;
}

.page-head .sub {
  color: var(--ink-soft);
  font-size: 14px;
  margin: 0;
}

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

@media (max-width: 760px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

.stat-card {
  padding: 18px 20px;
}

.stat-card .label {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 500;
  margin-bottom: 8px;
}

.stat-card .value {
  font-size: 28px;
  font-weight: 700;
  color: var(--navy-950);
}

.stat-card.accent-green .value { color: var(--green); }
.stat-card.accent-red .value { color: var(--red); }
.stat-card.accent-gray .value { color: var(--gray); }

/* Filters */
.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 20px;
  margin-bottom: 16px;
  align-items: center;
}

.filters input[type="text"],
.filters select {
  padding: 9px 12px;
  border-radius: 7px;
  border: 1px solid var(--line);
  font-size: 14px;
  background: var(--white);
}

.filters input[type="text"] { flex: 1; min-width: 180px; }

/* Table */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.data th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.data td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
}

table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--paper); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
}

.badge-green { background: var(--green-bg); color: var(--green); }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-gray { background: var(--gray-bg); color: var(--gray); }

.cell-name { font-weight: 600; color: var(--ink); }
.cell-sub { display: block; font-size: 12.5px; color: var(--ink-soft); font-weight: 400; }

.icon-btn {
  background: none;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 11px;
  font-size: 13px;
  cursor: pointer;
  color: var(--navy-900);
  font-weight: 600;
}
.icon-btn:hover { background: var(--navy-100); }
.icon-btn:disabled { opacity: 0.55; cursor: default; }

.icon-btn.danger { color: var(--red); border-color: rgba(194,59,59,0.3); }
.icon-btn.danger:hover { background: var(--red-bg); }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--ink-soft);
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--navy-950);
  color: var(--white);
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 100;
  max-width: 320px;
}

.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* Form (cadastro) */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 16px;
  padding: 22px 22px 6px;
}

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

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

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 10px 22px 22px;
}

.section-title {
  font-size: 16px;
  font-weight: 700;
  margin: 28px 0 12px;
  color: var(--navy-950);
}

.loading-row td {
  text-align: center;
  color: var(--ink-soft);
  padding: 28px;
}

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }
