:root {
  /* Paleta Securland — azul profundo do "SECUR" + teal do "LAND"/ícone do logo. */
  --bg: #f2f6f9;
  --surface: #ffffff;
  --sidebar-bg: #0a2540;
  --sidebar-text: #b9cbdc;
  --sidebar-text-active: #ffffff;
  --text: #10233a;
  --text-muted: #64748b;
  --border: #dfe6ee;
  --primary: #1565c0;
  --primary-hover: #0d4c94;
  --accent: #22a9c4;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warning: #b45309;
  --warning-bg: #fef3c7;
  --info-bg: #e0f0f7;
  --shadow: 0 1px 2px rgba(10, 37, 64, 0.06), 0 1px 3px rgba(10, 37, 64, 0.08);
  --radius: 10px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1420;
    --surface: #101e30;
    --sidebar-bg: #060f1c;
    --text: #e6edf5;
    --text-muted: #90a3b8;
    --border: #1e3348;
    --primary: #4c9eea;
    --primary-hover: #6fb4f0;
    --accent: #35c2df;
    --success-bg: #0f3420;
    --danger-bg: #3a1414;
    --warning-bg: #3a2a0d;
    --info-bg: #123246;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

/* Garante que o atributo "hidden" ganha sempre a qualquer regra de display mais específica
   (ex. #login-view { display: flex } abaixo) — sem isto, elementos com display explícito por
   ID ficam visíveis mesmo com hidden=true, e as duas vistas aparecem empilhadas. */
[hidden] { display: none !important; }

body {
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

h1, h2, h3 { font-weight: 650; letter-spacing: -0.01em; }

/* ---------- Login ---------- */

#login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

#login-view form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
  width: 100%;
  max-width: 340px;
}

.login-logo {
  display: block;
  width: 100%;
  max-width: 260px;
  margin: 0 auto 1.25rem;
}

#login-view h1 {
  text-align: center;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-muted);
  margin: 0 0 1.5rem;
}

/* ---------- Shell / sidebar ---------- */

.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 1.25rem 0.75rem;
}

.brand {
  padding: 0.5rem 0.75rem 1.5rem;
}
.brand img {
  width: 100%;
  max-width: 176px;
  display: block;
  /* o logo é azul/teal sobre fundo transparente — clareia um pouco para se destacar melhor
     no fundo azul-marinho escuro da sidebar. */
  filter: brightness(1.15) saturate(1.05);
}
.brand small { display: block; font-weight: 400; font-size: 0.72rem; color: var(--sidebar-text); opacity: 0.75; margin-top: 0.4rem; }

.nav-item {
  display: flex;
  align-items: center;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--sidebar-text);
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  font-size: 0.92rem;
  cursor: pointer;
  margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }

/* Separa Users/Settings (definições do backoffice em si) do resto (dados operacionais:
   clientes, códigos, licenças, instalações) — mesma ideia de agrupamento visual que um
   <hr>, só que discreta o suficiente para não competir com os nav-item à volta. */
.nav-separator {
  height: 1px;
  margin: 0.6rem 0.75rem;
  background: rgba(255, 255, 255, 0.12);
}

.sidebar-footer { margin-top: auto; }
.logout-btn {
  width: 100%;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--sidebar-text);
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}
.logout-btn:hover { color: #fff; border-color: rgba(255, 255, 255, 0.35); }

.content {
  flex: 1;
  min-width: 0;
  padding: 1.75rem 2.25rem 3rem;
}

.topbar { margin-bottom: 1.5rem; }
.topbar h1 { font-size: 1.4rem; margin: 0; }
.topbar p { color: var(--text-muted); margin: 0.2rem 0 0; font-size: 0.88rem; }

.view-panel { display: flex; flex-direction: column; gap: 1.25rem; }

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}
.card h2 { font-size: 1.02rem; margin: 0 0 0.25rem; }
.card .card-hint { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 1rem; }

/* ---------- Forms ---------- */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  align-items: end;
  margin-bottom: 0.75rem;
}

.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label { font-size: 0.78rem; color: var(--text-muted); font-weight: 600; }

input, select, button {
  font: inherit;
}

input[type="text"], input[type="email"], input[type="password"], input[type="datetime-local"], input[type="search"], select {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

/* ---------- Table search/filter toolbar ---------- */

.table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 0.85rem;
}
.table-toolbar input[type="search"] {
  flex: 1 1 240px;
  min-width: 180px;
}
.table-toolbar select {
  flex: 0 0 auto;
}
input:focus, select:focus {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

button {
  cursor: pointer;
  border: none;
  border-radius: 7px;
  padding: 0.55rem 1rem;
  font-weight: 600;
  font-size: 0.88rem;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1px solid var(--danger); padding: 0.3rem 0.6rem; font-size: 0.78rem; }
.btn-danger-outline:hover { background: var(--danger-bg); }

/* ---------- Alerts (feedback) ---------- */

.alert {
  border-radius: 8px;
  padding: 0.6rem 0.85rem;
  font-size: 0.85rem;
  margin-top: 0.5rem;
}
.alert a { color: inherit; font-weight: 700; }
.alert-info { background: var(--info-bg); color: var(--primary); }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-error { background: var(--danger-bg); color: var(--danger); }

/* ---------- Modal (ex.: "Reissue license" a partir da linha da tabela) ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 20, 32, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: 0 8px 30px rgba(10, 37, 64, 0.25);
  padding: 1.5rem;
  width: 100%;
  max-width: 440px;
}
.modal-box h3 { margin: 0 0 0.35rem; }
.modal-box .card-hint { margin: 0 0 1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.2rem; }

/* ---------- Tables ---------- */

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
th {
  text-align: left;
  padding: 0.5rem 0.6rem;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: 0.6rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
code {
  background: var(--bg);
  padding: 0.15rem 0.4rem;
  border-radius: 5px;
  font-size: 0.82em;
}

/* ---------- Badges (status) ---------- */

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-active, .badge-licensed { background: var(--success-bg); color: var(--success); }
.badge-revoked, .badge-expired { background: var(--danger-bg); color: var(--danger); }
.badge-redeemed { background: var(--info-bg); color: var(--primary); }
.badge-trial { background: var(--warning-bg); color: var(--warning); }

/* Legenda ao lado de um badge (ex. o plano ao lado do status da licença) — nunca texto solto
   sem hierarquia visual clara na mesma célula. */
.badge-caption { color: var(--text-muted); font-size: 0.82rem; margin-left: 0.35rem; }

/* ---------- Responsive ---------- */

@media (max-width: 820px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex: none; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { padding: 0.4rem 0.75rem; }
  .sidebar-footer { margin-top: 0; margin-left: auto; }
  .nav-item { white-space: nowrap; }
  .content { padding: 1.25rem; }
}
