/* ── Reset & base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #0d1117;
  --surface:   #161b22;
  --border:    #30363d;
  --text:      #e6edf3;
  --muted:     #7d8590;
  --accent:    #3fb950;
  --accent-dim:#1a3a24;
  --danger:    #f85149;
  --danger-dim:#3d1a1a;
  --mono:      'JetBrains Mono', monospace;
  --sans:      'Inter', system-ui, sans-serif;
  --radius:    8px;
}

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 28px;
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.brand-icon { font-size: 20px; color: var(--accent); }
.brand-name { font-weight: 600; letter-spacing: -.3px; }

.user-pill {
  font-size: 13px;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 3px 12px;
  font-family: var(--mono);
}

.btn-ghost {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 4px 10px;
  border-radius: var(--radius);
  transition: color .15s, background .15s;
}
.btn-ghost:hover { color: var(--text); background: var(--border); }

.main {
  max-width: 720px;
  margin: 40px auto;
  padding: 0 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

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

.card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}

.ip-display { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.ip-mono { font-family: var(--mono); font-size: 26px; font-weight: 500; letter-spacing: -.5px; }

.badge { font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; letter-spacing: .04em; }
.badge-active   { background: var(--accent-dim); color: var(--accent); }
.badge-inactive { background: #1f1f27; color: var(--muted); }

.expires-line { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.expires-line strong { color: var(--text); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.1); }
.btn-primary { background: var(--accent); color: #0d1117; }
.btn-danger  { background: var(--danger-dim); color: var(--danger); border: 1px solid var(--danger); }

.ip-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ip-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  padding: 8px 12px 8px 0;
  border-bottom: 1px solid var(--border);
}
.ip-table td { padding: 10px 12px 10px 0; border-bottom: 1px solid #1e242b; vertical-align: middle; }
.ip-table code { font-family: var(--mono); font-size: 13px; color: var(--accent); }
.row-mine td { background: #12201a; }

.btn-table-revoke {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 12px;
  transition: border-color .15s, color .15s;
}
.btn-table-revoke:hover { border-color: var(--danger); color: var(--danger); }

.empty-state { color: var(--muted); font-size: 13px; text-align: center; padding: 20px 0; }

.footer { text-align: center; font-size: 12px; color: var(--muted); padding: 24px; }
.footer code { font-family: var(--mono); color: var(--text); }

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-wrap {
  width: 100%;
  max-width: 380px;
  padding: 40px 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
}
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 28px; }
.login-title { font-size: 20px; font-weight: 600; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--muted); margin-bottom: 24px; }

.btn-m365 {
  width: 100%;
  justify-content: center;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #d0d7de;
  padding: 11px;
  font-weight: 500;
}
.btn-m365:hover { background: #f3f3f3; filter: none; }

.local-form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; color: var(--muted); font-weight: 500; }
.field input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  transition: border-color .15s;
}
.field input:focus { outline: none; border-color: var(--accent); }
.btn-primary { width: 100%; justify-content: center; }

.alert-error {
  background: var(--danger-dim);
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}
.login-note { font-size: 11px; color: var(--muted); text-align: center; margin-top: 20px; }

/* ── Dashboard / trazabilidad ── */
.main-wide { max-width: 1100px; }

.topbar-sep { color: var(--border); }
.topbar-section { font-size: 13px; color: var(--muted); font-weight: 500; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.stat-num { font-family: var(--mono); font-size: 28px; font-weight: 500; letter-spacing: -.5px; }
.stat-num.stat-warn { color: var(--danger); }
.stat-lbl {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}
.filter-bar input, .filter-bar select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  transition: border-color .15s;
}
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--accent); }
.filter-bar input[type="text"] { min-width: 150px; }
.btn-sm { padding: 8px 16px; font-size: 13px; }

.table-scroll { overflow-x: auto; }
.events-table { min-width: 860px; }
.events-table td { font-size: 12.5px; }
.nowrap { white-space: nowrap; font-family: var(--mono); color: var(--muted); }
.ev-detail { color: var(--muted); max-width: 260px; }
.table-note { font-size: 11px; color: var(--muted); margin-top: 12px; }

/* Badges por tipo de acción */
.ev {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 5px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.ev-grant        { background: var(--accent-dim); color: var(--accent); }
.ev-login        { background: #12233a; color: #58a6ff; }
.ev-logout       { background: #1f1f27; color: var(--muted); }
.ev-revoke       { background: var(--danger-dim); color: var(--danger); }
.ev-revoke_admin { background: #3a2a12; color: #e3a008; }
.ev-login_failed { background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }
.ev-grant_failed { background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }
.ev-revoke_failed{ background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }
.ev-expire       { background: #1f1f27; color: var(--muted); }
.ev-startup      { background: #1f1f27; color: var(--muted); }

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

@media (max-width: 600px) {
  .topbar { padding: 0 16px; }
  .main { margin: 20px auto; }
  .ip-mono { font-size: 20px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
