/* ============================================================
   Sonik Monitor SEFAZ — visual style
   Paleta Sonik:
     #004E8E  azul clássico (brand) — Delphi $8E4E00
     #0078D7  azul seleção (CTA)    — Delphi $D77800
     #8EB4E3  azul médio            — Delphi $E3B48E
     #C6D9F1  azul claro            — Delphi $F1D9C6
     #F0F1F2  cinza muito claro     — Delphi $F2F1F0
   Dark + light themes via [data-theme] on <html>
   ============================================================ */

:root, [data-theme="light"] {
  /* Brand */
  --brand:        #004E8E;  /* azul clássico Sonik */
  --brand-soft:   #C6D9F1;
  --brand-mid:    #8EB4E3;

  /* Backgrounds (do mais claro pro mais saturado) */
  --bg:        #F0F1F2;
  --panel:     #FFFFFF;
  --panel-2:   #F7F9FC;
  --panel-3:   #E5EDF7;

  /* Texto */
  --text:      #0A2540;
  --text-soft: #44607E;
  --dim:       #8EA5BC;

  /* Bordas */
  --border:        #DCE5EF;
  --border-strong: #B9CCE3;

  /* Acento (azul seleção da paleta) */
  --accent:      #0078D7;
  --accent-soft: rgba(0, 120, 215, 0.12);

  /* Status (cores universais — verde/amarelo/vermelho) */
  --green:        #10B981;
  --green-soft:   #D1FAE5;
  --red:          #EF4444;
  --red-soft:     #FEE2E2;
  --yellow:       #F59E0B;
  --yellow-soft:  #FEF3C7;

  --shadow:    0 1px 2px rgba(0, 78, 142, 0.05), 0 1px 3px rgba(0, 78, 142, 0.08);
  --shadow-lg: 0 4px 6px rgba(0, 78, 142, 0.07), 0 10px 15px rgba(0, 78, 142, 0.10);
  --radius:    8px;
  --radius-sm: 6px;
}

[data-theme="dark"] {
  /* Brand fica visível também no escuro */
  --brand:        #4A8BC5;
  --brand-soft:   rgba(74, 139, 197, 0.18);
  --brand-mid:    #2D6EA8;

  /* Backgrounds em tons profundos de azul-marinho — coerente com brand */
  --bg:        #061427;
  --panel:     #0E223C;
  --panel-2:   #163052;
  --panel-3:   #1F4174;

  /* Texto: branco azulado pra harmonizar */
  --text:      #E5EDF7;
  --text-soft: #B9CCE3;
  --dim:       #6E8AAA;

  /* Bordas suaves */
  --border:        #1F3960;
  --border-strong: #2F5187;

  /* Azul seleção um pouco mais brilhante pra contraste */
  --accent:      #2D8BE0;
  --accent-soft: rgba(45, 139, 224, 0.20);

  /* Status (mesmo verde/amarelo/vermelho, com soft mais opaco) */
  --green:        #22C55E;
  --green-soft:   rgba(34, 197, 94, 0.18);
  --red:          #EF4444;
  --red-soft:     rgba(239, 68, 68, 0.20);
  --yellow:       #FBBF24;
  --yellow-soft:  rgba(251, 191, 36, 0.20);

  --shadow:    0 1px 2px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.35), 0 10px 15px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body { background: var(--bg); }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   Nav
   ============================================================ */

.nav {
  /* Grid 3 colunas: brand à esquerda · título centralizado · ações à direita */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 12px 24px;
  /* azul clássico Sonik em AMBOS os temas — identidade forte */
  background: #004E8E;
  border-bottom: none;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 8px rgba(0, 30, 60, 0.18);
}
.nav-left   { justify-self: start; }
.nav-center { justify-self: center; }
.nav-right  { justify-self: end; display: flex; align-items: center; gap: 6px; }

a.nav-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #FFFFFF;
  text-decoration: none;
  /* sutil sombra de texto pra dar profundidade no azul */
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.18);
  transition: opacity 0.15s;
}
a.nav-title:hover { opacity: 0.85; }

/* ============================================================
   Footer global — Powered by Sonik Tecnologia
   ============================================================ */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 22px 24px;
  margin-top: 36px;
  font-size: 12px;
  color: var(--text-soft);
  border-top: 1px solid var(--border);
  background: var(--panel-2);
}
.site-footer .footer-brand {
  text-decoration: none;
  font-weight: 600;
  transition: opacity 0.15s;
}
.site-footer .footer-brand:hover { opacity: 0.75; }
.site-footer .brand-name { color: var(--brand); }

/* Conteúdo do nav: texto/ícones brancos sobre o azul. */
.nav .brand        { color: #FFFFFF; font-size: 14px; font-weight: 600; }
.nav .brand svg    { color: #C6D9F1; }
.nav .brand-name   { color: #FFFFFF; }  /* "Sonik Tecnologia" — branco sólido */
.nav .nav-user     { color: rgba(255, 255, 255, 0.88); }
.nav .nav-divider  { background: rgba(255, 255, 255, 0.20); }

.nav .icon-btn {
  color: rgba(255, 255, 255, 0.78);
  background: transparent;
  border: none;
}
.nav .icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
}

/* Role-tag dentro do nav */
.nav .role-tag {
  background: rgba(255, 255, 255, 0.16);
  color: #FFFFFF;
}

/* Botão CTA "Entrar" no nav — usa azul seleção pra destacar do nav azul */
.nav .btn-primary,
.nav .btn-sm.btn-primary {
  background: #0078D7;
  color: #FFFFFF;
  border-color: #0078D7;
}
.nav .btn-primary:hover { filter: brightness(1.10); }

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.brand svg { color: var(--brand); }
.brand-logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 4px;
}
/* Destaca "Sonik" em azul clássico, deixa o resto em --text */
.brand-name { color: var(--brand); font-weight: 700; }

.nav-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-cta {
  margin-right: 4px;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  background: var(--panel-2);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  flex-shrink: 0;
}
.icon-btn:hover {
  background: var(--panel-3);
  color: var(--text);
  border-color: var(--border-strong);
}
.icon-btn svg { display: block; }

.nav-divider {
  width: 1px;
  height: 22px;
  background: var(--border);
  margin: 0 4px;
}

.nav-user {
  font-size: 12px;
  color: var(--dim);
  padding: 0 6px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-form { display: inline; margin: 0; }

/* Header compacto no mobile: o grid 3-colunas (1fr auto 1fr) faz o título
   centralizado sobrepor a marca em telas estreitas. Aqui viramos flex em
   linha (sem sobreposição), escondemos a marca "Sonik Tecnologia" (redundante
   — já está no rodapé e o título identifica) e o e-mail do usuário. */
@media (max-width: 640px) {
  .nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
  }
  .nav-left, .nav-center, .nav-right { justify-self: auto; }
  .nav-left .brand-name { display: none; }
  a.nav-title { font-size: 16px; }
  .nav-right { gap: 2px; }
  .nav-user, .nav-divider { display: none; }
}

/* Theme toggle icon visibility — show appropriate icon based on current theme */
.icon-when-dark, .icon-when-light { display: none; }
:root[data-theme="dark"] .icon-when-dark,
:root:not([data-theme="light"]) .icon-when-dark { display: block; }
:root[data-theme="light"] .icon-when-light { display: block; }

/* Floating theme toggle on login page */
.theme-toggle-floating {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 100;
}

/* ============================================================
   Layout
   ============================================================ */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

h1, h2, h3 { color: var(--text); margin-top: 0; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: 0.02em; }

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 24px 0 12px;
}

code {
  background: var(--panel-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-family: ui-monospace, "SF Mono", Consolas, monospace;
  color: var(--text);
}
.muted, .dim { color: var(--dim); }
.error { color: var(--red); margin-top: 8px; font-size: 13px; }

/* ============================================================
   Summary header (dashboard top)
   ============================================================ */

.summary {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 8px;
}
.summary-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.summary-card.summary-alert {
  border-color: var(--red);
  background: linear-gradient(180deg, var(--red-soft), var(--panel));
}
.summary-card.summary-uptime {
  border-left: 3px solid var(--green);
}
.summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  font-weight: 600;
}
.summary-value {
  font-size: 28px;
  font-weight: 700;
  margin: 6px 0 4px;
  color: var(--text);
  letter-spacing: -0.02em;
}
.summary-value .unit { font-size: 18px; color: var(--dim); margin-left: 2px; }
.summary-meta { font-size: 12px; color: var(--dim); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

.status-text-up { color: var(--green); }
.status-text-down { color: var(--red); }
.status-text-unknown { color: var(--dim); }

/* ============================================================
   Chips and badges
   ============================================================ */

.chip {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  background: var(--panel-2);
  color: var(--text-soft);
}
.chip-up { background: var(--green-soft); color: var(--green); }
.chip-down { background: var(--red-soft); color: var(--red); }
.chip-muted { background: var(--panel-3); color: var(--dim); }

.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--panel-3);
  color: var(--dim);
}
.badge-up { background: var(--green); color: white; }
.badge-down { background: var(--red); color: white; }
.badge-unknown { background: var(--panel-3); color: var(--dim); }

.status-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot-up { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-dot-down { background: var(--red); box-shadow: 0 0 0 3px var(--red-soft); animation: pulse-red 1.6s infinite; }
.status-dot-unknown { background: var(--dim); }

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 3px var(--red-soft); }
  50% { box-shadow: 0 0 0 6px var(--red-soft); }
}

.type-icon {
  color: var(--text-soft);
  flex-shrink: 0;
}

/* ============================================================
   Monitor list (Uptime Robot style — rows, not cards)
   ============================================================ */

.monitor-groups {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.monitor-group {
  /* whole group section */
}

.group-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-soft);
  font-weight: 700;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}
.group-name { display: inline-flex; align-items: center; gap: 7px; }
.group-name svg { color: var(--accent); }
.group-count {
  margin-left: auto;
  background: var(--panel-2);
  color: var(--dim);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

.monitor-list {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  cursor: grab;
  opacity: 0;
  transition: opacity 0.1s, color 0.1s;
  width: 18px;
  flex-shrink: 0;
}
.drag-handle:hover { color: var(--text); }
.drag-handle:active { cursor: grabbing; }
.monitor-row:hover .drag-handle { opacity: 0.6; }

.monitor-row-ghost {
  opacity: 0.4;
  background: var(--accent-soft) !important;
}

.monitor-list.admin-mode .monitor-row {
  grid-template-columns: 18px 14px minmax(160px, 240px) 1fr auto;
}

.monitor-row {
  display: grid;
  grid-template-columns: 14px minmax(160px, 240px) 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  text-decoration: none;
  transition: background 0.1s;
}
.monitor-row:last-child { border-bottom: none; }
.monitor-row:hover { background: var(--panel-2); }
.monitor-row.paused { opacity: 0.55; }

.monitor-name {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.monitor-name strong {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.monitor-target {
  color: var(--text-soft);
  font-family: ui-monospace, Consolas, monospace;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  justify-self: start;
  text-align: left;
  min-width: 0;
}

.monitor-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  justify-self: end;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .monitor-row {
    grid-template-columns: 14px 1fr;
    grid-template-rows: auto auto auto;
    row-gap: 4px;
    column-gap: 12px;
  }
  .monitor-target, .monitor-meta { grid-column: 2; justify-self: start; }
}

/* ============================================================
   Empty / login
   ============================================================ */

.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--dim);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.empty svg { margin-bottom: 12px; }
.empty p { margin: 0 0 16px; font-size: 14px; }

/* ============================================================
   Login page (own layout — does not inherit nav)
   ============================================================ */

.login-body {
  background:
    radial-gradient(circle at 20% 20%, var(--brand-soft), transparent 55%),
    radial-gradient(circle at 80% 80%, var(--accent-soft), transparent 55%),
    var(--bg);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  /* mesma faixa azul Sonik do nav */
  box-shadow: inset 0 3px 0 var(--brand);
}

.login-wrap {
  width: 100%;
  max-width: 420px;
}

.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px 28px;
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(20px);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 16px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}
.login-brand {
  margin: 0 0 4px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--brand);
  font-weight: 700;
}
.login-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.login-subtitle {
  margin: 6px 0 0;
  color: var(--dim);
  font-size: 13px;
}

.login-error {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--red-soft);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 18px;
  border: 1px solid var(--red);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
}

.input-with-icon {
  position: relative;
}
.input-with-icon svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--dim);
  pointer-events: none;
  z-index: 1;
}
.input-with-icon > input[type="email"],
.input-with-icon > input[type="password"],
.input-with-icon > input[type="text"] {
  width: 100%;
  height: 44px;
  padding: 0 14px 0 40px;
  font-size: 14px;
}
.input-with-icon > input::placeholder { color: var(--dim); }

.login-btn {
  width: 100%;
  justify-content: center;
  height: 44px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 6px;
}

.login-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 42px;
  margin-top: 12px;
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
}
.login-back-btn svg { flex-shrink: 0; }

.login-footer {
  text-align: center;
  margin: 22px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--dim);
  line-height: 1.8;
}
.login-footer-brand {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-soft);
}
.login-footer-brand .brand-name {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
  margin-left: 4px;
}
.login-footer-brand .brand-name:hover { text-decoration: underline; }

/* ============================================================
   Forms
   ============================================================ */

.page-header {
  margin-bottom: 20px;
  max-width: 720px;
  margin-left: auto;
  margin-right: auto;
}
.page-header h1 { margin: 0 0 4px; }
.page-header p { margin: 0; font-size: 14px; }

/* Settings page: stack of cards, all centered with consistent width */
.settings-stack {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.settings-stack > .card,
.settings-stack > .form-card { margin: 0; }

.form-page {
  max-width: 720px;
  margin: 0 auto;
}

.form-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.form-card-compact {
  max-width: 640px;
  margin: 24px auto 0;
}

.form-header {
  text-align: center;
  padding: 32px 32px 20px;
  border-bottom: 1px solid var(--border);
}
.form-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 12px;
}
.form-header h1, .form-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.form-subtitle {
  margin: 6px 0 0;
  color: var(--dim);
  font-size: 13px;
}

.form-body {
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.form-body label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 600;
  color: var(--text-soft);
}

/* Checkbox labels in form-body: inline */
.form-body label:has(> input[type="checkbox"]),
.form-body label.inline-check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  padding: 6px 0;
  color: var(--text);
}
.form-body label:has(> input[type="checkbox"]):hover { color: var(--accent); }

/* Inputs inside form-body fill width and have bigger touch target */
.form-body input[type=text],
.form-body input[type=email],
.form-body input[type=password],
.form-body input[type=number],
.form-body select {
  height: 40px;
  font-size: 14px;
  width: 100%;
  display: block;
}
.form-body .input-with-icon,
.form-body .input-with-suffix { display: block; width: 100%; }
.form-body .input-with-icon > input { height: 40px; }

/* Input with suffix (units like "segundos") */
.input-with-suffix {
  position: relative;
}
.input-with-suffix > input {
  padding-right: 84px;
  text-align: left;
}
.input-with-suffix > .suffix {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  pointer-events: none;
  font-weight: 600;
}

/* Checkbox base */
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

/* Grids inside forms */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
  align-items: end;
}
.grid-2 > .span-2 { grid-column: span 2; }

/* Fieldset for grouped fields */
.fieldset {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin: 4px 0;
}
.fieldset legend {
  padding: 0 8px;
  color: var(--text-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}

/* Footer with right-aligned action buttons */
.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 18px 32px;
  background: var(--panel-2);
  border-top: 1px solid var(--border);
}
.form-actions-buttons {
  display: flex;
  gap: 8px;
  margin-left: auto;
}
.form-error {
  color: var(--red);
  font-size: 13px;
  flex: 1;
}

/* Legacy .form class kept for backwards compat (not used after refactor) */
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 640px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 500;
}
.form .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; align-items: end; }

input[type=text], input[type=email], input[type=password], input[type=number], select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Hide native spinner arrows on number inputs — visually noisy and inconsistent */
input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  appearance: none;
  margin: 0;
}

input[type=checkbox] { accent-color: var(--accent); }

/* ============================================================
   Buttons
   ============================================================ */

button, .btn-primary, .btn-secondary, .btn-danger, .btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
  font-family: inherit;
}
button:hover, .btn-secondary:hover { background: var(--panel-2); }

.btn-primary, button.primary, button[type=submit]:not(.nav-link):not(.logout) {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.btn-primary:hover { filter: brightness(1.1); }

.btn-danger, button.danger {
  background: var(--red);
  border-color: var(--red);
  color: white;
}
.btn-danger:hover { filter: brightness(1.1); }

.btn-sm { padding: 5px 11px; font-size: 12px; }

.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
  flex-wrap: wrap;
}

.secondary { background: var(--panel); border: 1px solid var(--border-strong); color: var(--text); }

/* ============================================================
   Monitor detail page
   ============================================================ */

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 4px;
}
.detail-header h1 {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, 1fr);
  margin: 20px 0 28px;
}
@media (max-width: 800px) { .stats { grid-template-columns: repeat(2, 1fr); } }

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--radius);
}
.stat-card .window {
  color: var(--dim);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
}
.stat-card .big {
  font-size: 24px;
  font-weight: 700;
  margin: 6px 0 4px;
  letter-spacing: -0.02em;
}

/* ============================================================
   Tables
   ============================================================ */

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table th, .table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.table tr:last-child td { border-bottom: none; }
.table th {
  color: var(--dim);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--panel-2);
}

/* canvas (chart) background */
canvas { background: var(--panel); border-radius: var(--radius); padding: 8px; border: 1px solid var(--border); }

/* ============================================================
   Generic card (used in settings page)
   ============================================================ */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}
.card-header h2 { margin: 0; font-size: 15px; }
.card-header p.small { font-size: 12px; margin: 2px 0 0; }

.table-flush {
  border: none;
  border-radius: 0;
}
.table-flush thead th { background: transparent; }

.text-right { text-align: right; }
.text-right .btn-secondary, .text-right .btn-danger { margin-left: 6px; }

.chip-tg {
  background: rgba(40, 144, 224, 0.15);
  color: #2890e0;
  display: inline-flex; align-items: center; gap: 4px;
}
.chip-email {
  background: rgba(168, 85, 247, 0.15);
  color: #a855f7;
  display: inline-flex; align-items: center; gap: 4px;
}

.empty-inline {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 24px;
  color: var(--dim);
  font-size: 13px;
}
.empty-inline p { margin: 0; }

/* Role tag (badge for admin/viewer next to email in nav) */
.role-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}
.role-tag.role-admin { background: var(--accent-soft); color: var(--accent); }
.role-tag.role-viewer { background: var(--panel-3); color: var(--dim); }

/* Inline form for adding a new user (Settings page) */
.new-user-row {
  padding: 22px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
}

.user-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 16px;
}
@media (max-width: 700px) {
  .user-form-grid { grid-template-columns: 1fr; }
}

.user-form-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  color: var(--text-soft);
}
.user-form-grid input,
.user-form-grid select {
  width: 100%;
  height: 38px;
  font-size: 14px;
}

.new-user-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.new-user-actions .error {
  flex: 1;
  margin: 0;
  font-size: 12px;
}

/* Role select inside the users table */
.role-select {
  height: 30px;
  padding: 2px 8px;
  font-size: 12px;
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.role-select:disabled { opacity: 0.5; cursor: not-allowed; }

/* Alpine x-cloak: hide until Alpine initializes */
[x-cloak] { display: none !important; }

/* Small helper */
.small { font-size: 12px; }
