*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #0f172a;
  color: #e2e8f0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Nav */
nav {
  background: #1e293b;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid #334155;
}
.brand { font-weight: 700; font-size: 1.1rem; color: #f8fafc; text-decoration: none; }
.nav-links a {
  color: #94a3b8;
  text-decoration: none;
  margin-left: 1.25rem;
  font-size: 0.9rem;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.nav-links a:hover { color: #f8fafc; }
.nav-links a.active { color: #f8fafc; border-bottom-color: #3b82f6; }

/* Main */
main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

h1 { font-size: 1.5rem; margin-bottom: 1rem; color: #f1f5f9; }
h2 { font-size: 1.1rem; margin-bottom: 0.75rem; color: #cbd5e1; }

/* Flash messages */
.flash {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.flash-success { background: #14532d; color: #86efac; border: 1px solid #166534; }
.flash-error   { background: #450a0a; color: #fca5a5; border: 1px solid #7f1d1d; }

/* Cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 1.25rem 1rem;
}
.card-ok    { border-color: #166534; }
.card-error { border-color: #7f1d1d; }
.card-label { font-size: 0.75rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.3rem; }
.card-value { font-size: 1.75rem; font-weight: 700; margin: 0.25rem 0; line-height: 1.2; }
.card-ok .card-value   { color: #86efac; }
.card-error .card-value { color: #fca5a5; }
.card-sub   { font-size: 0.8rem; color: #94a3b8; margin-top: 0.25rem; }

/* Section */
.section { margin: 1.5rem 0; }

/* Table */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  background: #1e293b;
  border-radius: 8px;
  overflow: hidden;
}
th {
  text-align: left;
  padding: 0.6rem 0.75rem;
  background: #1e293b;
  color: #94a3b8;
  border-bottom: 1px solid #334155;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid #0f172a;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #263346; }
code { font-family: monospace; font-size: 0.85em; color: #7dd3fc; }

/* Filter form */
.filter-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  align-items: center;
}

/* Inputs */
.text-input {
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.875rem;
  min-width: 200px;
}
.text-input:focus { outline: none; border-color: #3b82f6; }
.duration-select { min-width: 130px; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  border: 1px solid #334155;
  background: #334155;
  color: #e2e8f0;
  cursor: pointer;
  font-size: 0.875rem;
  text-decoration: none;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn:hover { background: #475569; }
.btn-warning { background: #9a3412; border-color: #c2410c; color: #fed7aa; }
.btn-warning:hover { background: #c2410c; }
.btn-danger { background: #7f1d1d; border-color: #991b1b; color: #fca5a5; }
.btn-danger:hover { background: #991b1b; }
.btn-secondary { background: #1e293b; }
.btn-secondary:hover { background: #263346; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8rem; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.4; cursor: not-allowed; pointer-events: none; }
.table-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.table-actions form { margin: 0; }
.status-pill { display: inline-block; padding: 0.2rem 0.45rem; border: 1px solid #475569; border-radius: 999px; color: #94a3b8; font-size: 0.75rem; white-space: nowrap; }
.status-pill-active { border-color: #b45309; color: #fed7aa; background: #451a03; }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}
.pagination .page-info {
  color: #64748b;
  font-size: 0.85rem;
  margin: 0 0.5rem;
}
.pagination a.btn, .pagination span.btn { min-width: 2.2rem; text-align: center; padding: 0.35rem 0.6rem; }
.pagination .current { background: #3b82f6; border-color: #2563eb; color: #fff; }

/* Result count */
.result-count {
  color: #64748b;
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 1rem;
  color: #475569;
  font-size: 0.75rem;
  border-top: 1px solid #1e293b;
}

.muted { color: #475569; font-size: 0.875rem; margin: 0.5rem 0; }

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #475569;
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.9rem; }

/* Charts */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.chart-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 1rem;
}
.chart-card h2 {
  font-size: 0.85rem;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}
.chart-card canvas { max-height: 220px; }

/* Audit log parsed row */
.audit-ts    { color: #64748b; font-size: 0.8rem; white-space: nowrap; }
.audit-action { font-weight: 600; }
.audit-ip    { color: #7dd3fc; font-family: monospace; font-size: 0.85em; }
.audit-result-success { color: #86efac; }
.audit-result-failed  { color: #fca5a5; }
