/* ==========================================================================
   Snake Access — design system
   Tokens → base → layout → componentes → páginas → responsivo
   ========================================================================== */

:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --border: #e2e8f1;
  --text: #0f172a;
  --muted: #5d6b82;
  --primary: #16a34a;
  --primary-hover: #15803d;
  --primary-soft: #dcfce7;
  --on-primary: #ffffff;
  --info: #0284c7;
  --info-soft: #e0f2fe;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --sidebar: #0b1220;
  --sidebar-text: #aab6cc;
  --sidebar-active: #ffffff;
  --shadow: 0 1px 2px rgb(15 23 42 / 6%), 0 4px 16px rgb(15 23 42 / 5%);
  --radius: 14px;
  --radius-sm: 10px;
  --font: Inter, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a0f1c;
    --surface: #111a2e;
    --surface-2: #15203a;
    --border: #1f2c47;
    --text: #e7edf8;
    --muted: #8b9bb6;
    --primary: #22c55e;
    --primary-hover: #4ade80;
    --primary-soft: #0f2e1d;
    --on-primary: #04130a;
    --info: #38bdf8;
    --info-soft: #0c2536;
    --warn: #fbbf24;
    --warn-soft: #2e2208;
    --danger: #f87171;
    --danger-soft: #3a1414;
    --sidebar: #070b15;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 25%);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--info);
}

h1 {
  margin: 0 0 4px;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

h3 {
  margin: 0 0 8px;
  font-size: 17px;
}

p {
  margin: 0 0 12px;
}

code {
  font-family: var(--mono);
  font-size: 13px;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 22px 0;
}

img {
  max-width: 100%;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---------- Layout ---------- */
.app {
  display: grid;
  grid-template-columns: 252px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 20px 14px;
  background: var(--sidebar);
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
  color: #fff;
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #22c55e, #0ea5e9);
  color: #04130a;
}

.brand small {
  display: block;
  font-weight: 500;
  font-size: 11px;
  color: var(--sidebar-text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.nav-label {
  padding: 16px 12px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #66748f;
}

.sidebar a.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}

.sidebar a.nav-link:hover {
  background: rgb(255 255 255 / 6%);
  color: #fff;
}

.sidebar a.nav-link.active {
  background: rgb(34 197 94 / 14%);
  color: var(--sidebar-active);
}

.sidebar a.nav-link.active .icon {
  color: #22c55e;
}

.icon {
  flex: none;
  width: 20px;
  height: 20px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding: 14px 10px 4px;
  border-top: 1px solid rgb(255 255 255 / 8%);
  color: #fff;
}

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #1c2a45;
  font-weight: 700;
  font-size: 14px;
}

.sidebar-user strong {
  display: block;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.sidebar-user span {
  font-size: 12px;
  color: var(--sidebar-text);
}

.content {
  min-width: 0;
  padding: 32px clamp(16px, 3vw, 40px) 48px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
}

.topbar {
  display: none;
}

.menu-toggle,
.scrim {
  display: none;
}

/* ---------- Cabeçalho de página ---------- */
.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}

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

.page-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 14px;
}

/* ---------- Botões ---------- */
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-action,
.btn-add,
.btn-activate,
button.btn-action-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}

.btn-primary,
.btn-action,
.btn-add,
.btn-activate {
  background: var(--primary);
  color: var(--on-primary);
}

.btn-primary:hover,
.btn-action:hover,
.btn-add:hover,
.btn-activate:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.btn-danger:hover {
  border-color: var(--danger);
}

.btn-primary:active,
.btn-danger:active {
  transform: translateY(1px);
}

button.btn-action-small,
.btn-action-small {
  padding: 6px 12px;
  font-size: 13px;
}

/* ---------- Cartões e grade ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr));
  gap: 18px;
}

/* sem isso um nome longo alarga a coluna e a página ganha rolagem lateral */
.grid > *,
.content > * {
  min-width: 0;
}

.card {
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-empty {
  grid-column: 1 / -1;
  padding: 56px 24px;
  text-align: center;
}

.card-empty strong {
  display: block;
  margin-bottom: 4px;
  font-size: 17px;
}

.card-empty span {
  color: var(--muted);
}

.host-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  transition: border-color 0.15s, transform 0.15s;
}

.host-card:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.host-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary);
}

.host-title {
  min-width: 0;
  flex: 1;
}

.host-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}

.host-cliente {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 13px;
}

.host-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.chip code {
  color: var(--text);
}

.card-footer {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.card-footer form {
  flex: 1;
  display: flex;
}

.card-footer .btn-primary,
.card-footer .btn-secondary,
.card-footer .btn-danger {
  flex: 1;
  width: 100%;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--muted);
}

.badge.baixa,
.badge.ativo {
  background: var(--primary-soft);
  color: var(--primary);
}

.badge.media {
  background: var(--info-soft);
  color: var(--info);
}

.badge.alta {
  background: var(--warn-soft);
  color: var(--warn);
}

.badge.critica,
.badge.inativo {
  background: var(--danger-soft);
  color: var(--danger);
}

/* ---------- Formulários ---------- */
label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(34 197 94 / 18%);
}

input:disabled {
  opacity: 0.6;
}

input[type="checkbox"] {
  width: auto;
  margin-right: 8px;
  accent-color: var(--primary);
}

.host-form-grid,
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
}

.form-field,
.form-group {
  min-width: 0;
}

.host-form-actions,
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.check-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.check-list label {
  display: flex;
  align-items: center;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
}

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

/* ---------- Tabelas ---------- */
.table-wrap {
  overflow-x: auto;
}

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

.sessions-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.sessions-table td {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

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

.sessions-table tbody tr:hover {
  background: var(--surface-2);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.row-actions form {
  margin: 0;
}

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

/* Auditoria */
.audit-table {
  display: grid;
}

.audit-head,
.audit-row {
  display: grid;
  grid-template-columns: 1.4fr 1.2fr 1fr 1.2fr;
  gap: 12px;
  padding: 12px 14px;
  align-items: center;
}

.audit-head {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}

.audit-row {
  border-bottom: 1px solid var(--border);
}

.audit-row:last-child {
  border-bottom: 0;
}

.audit-action {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}

.audit-ip,
.audit-date {
  color: var(--muted);
  font-size: 13px;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 20px;
}

.page-btn {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
}

.page-btn:hover {
  border-color: var(--primary);
}

.page-info {
  color: var(--muted);
  font-size: 14px;
}

/* ---------- Avisos ---------- */
.alert-warning {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid var(--warn);
  border-radius: var(--radius-sm);
  background: var(--warn-soft);
  color: var(--text);
  font-size: 14px;
}

.alert-warning .icon {
  color: var(--warn);
  margin-top: 2px;
}

.alert-error {
  margin-bottom: 16px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 14px;
  text-align: center;
}

.alert-ok {
  margin-bottom: 16px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 14px;
}

.content .alert-error {
  text-align: left;
}

/* ---------- Instruções ---------- */
.steps {
  display: grid;
  gap: 0;
  counter-reset: step;
}

.step {
  position: relative;
  padding: 0 0 26px 52px;
}

.step::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
}

.step:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 16px;
  top: 40px;
  bottom: 6px;
  width: 2px;
  background: var(--border);
}

.step figure {
  margin: 12px 0 0;
}

.step figure img {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.step figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.kv {
  display: grid;
  gap: 8px;
  margin: 8px 0 0;
}

.kv div {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.kv dt {
  min-width: 150px;
  color: var(--muted);
  font-weight: 600;
}

.kv dd {
  margin: 0;
  word-break: break-all;
  font-family: var(--mono);
  font-size: 13px;
}

/* ---------- Login ---------- */
.auth {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 20px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgb(34 197 94 / 14%), transparent 60%),
    radial-gradient(800px 500px at 100% 110%, rgb(14 165 233 / 14%), transparent 60%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 34px 30px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.auth-card .brand {
  padding: 0 0 22px;
  color: var(--text);
}

.auth-card h1 {
  font-size: 22px;
}

.auth-card .page-sub {
  margin-bottom: 22px;
}

.auth-card .form-field {
  margin-bottom: 16px;
}

.auth-card .btn-primary {
  width: 100%;
  padding: 12px;
  margin-top: 4px;
}

.auth-foot {
  margin-top: 22px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Responsivo ---------- */
@media (max-width: 900px) {
  .app {
    display: block;
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--sidebar);
    color: #fff;
  }

  .topbar .brand {
    padding: 0;
  }

  .menu-btn {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgb(255 255 255 / 8%);
    color: #fff;
    cursor: pointer;
  }

  .sidebar {
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: 272px;
    transform: translateX(-100%);
    transition: transform 0.2s;
  }

  .sidebar .brand {
    display: none;
  }

  .menu-toggle:checked ~ .sidebar {
    transform: none;
  }

  .scrim {
    display: none;
  }

  .menu-toggle:checked ~ .scrim {
    position: fixed;
    inset: 0;
    z-index: 25;
    display: block;
    background: rgb(0 0 0 / 55%);
  }

  .content {
    padding-top: 22px;
  }

  .audit-head {
    display: none;
  }

  .audit-row {
    grid-template-columns: 1fr;
    gap: 2px;
  }
}

@media (max-width: 560px) {
  .grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .host-form-actions,
  .form-actions {
    flex-direction: column-reverse;
  }

  .host-form-actions > *,
  .form-actions > * {
    width: 100%;
  }

  .filter-form,
  .filter-form select {
    width: 100%;
  }
}
