/* Automizi Admin Tools — minimal styling. Served from /static (CSP style-src
   'self'); no inline styles anywhere. */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #6b7280;
  --line: #e5e7eb;
  --brand: #2563eb;
  --danger: #dc2626;
  --ok: #059669;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
/* App shell — MOBILE-FIRST (Rule #2). Base: a stacked column with a horizontal
   top nav bar. At >=800px it becomes a fixed-width left sidebar. */
.layout { display: flex; flex-direction: column; min-height: 100vh; }
.sidebar {
  background: #0f172a;
  color: #cbd5e1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem 0.5rem;
  padding: 0.6rem 1rem;
}
.sidebar .brand {
  display: block;
  padding: 0.3rem 0.6rem;
}
.sidebar .brand img {
  display: block;
  height: 36px;
  width: auto;
  max-width: 100%;
  background: #fff;
  border-radius: 8px;
  padding: 4px 8px;
}
.sidebar .brand-title {
  margin: 0.85rem 0 0;
  color: #fff;
  font-weight: 600;
  font-size: 1.32rem;
  text-align: center;
}
.sidebar .brand-rule {
  width: 100%;
  border: 0;
  border-top: 1px solid #1e293b;
  margin: 0.75rem 0;
}
.side-nav { display: flex; flex-flow: row wrap; gap: 0.15rem; }
.side-nav .section { display: none; } /* section labels only show in the sidebar */
.nav-link {
  color: #cbd5e1;
  padding: 0.55rem 0.7rem;
  border-radius: 7px;
  display: block;
}
.nav-link:hover { background: #1e293b; color: #fff; text-decoration: none; }
.nav-link.active { background: var(--brand); color: #fff; }
.sidebar-foot { margin-left: auto; display: flex; align-items: center; gap: 0.5rem; }
.sidebar-foot .who { display: flex; align-items: center; gap: 0.4rem; }
.sidebar-foot .email { font-size: 0.85rem; color: #94a3b8; word-break: break-all; }
.sidebar-foot form { margin: 0; }
.sidebar-foot .btn { width: auto; }

.content { flex: 1; min-width: 0; }
.content > main { padding: 1rem; }
.spacer { flex: 1; }

/* Logged-out pages (login): no sidebar. */
.layout--plain { display: block; }

@media (min-width: 800px) {
  .layout { flex-direction: row; }
  .sidebar {
    width: 240px;
    flex-shrink: 0;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0;
    padding: 1rem 0.75rem;
  }
  .sidebar .brand { padding: 0.25rem 0.5rem 0; }
  .sidebar .brand img {
    width: 100%;
    height: auto;
    padding: 10px 12px;
  }
  .side-nav { flex-direction: column; }
  .side-nav .section {
    display: block;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #64748b;
    padding: 0.9rem 0.65rem 0.3rem;
  }
  .sidebar-foot {
    margin-top: auto;
    margin-left: 0;
    display: block;
    padding-top: 1rem;
    border-top: 1px solid #1e293b;
  }
  .sidebar-foot .who {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    padding: 0.4rem 0.65rem;
  }
  .sidebar-foot form { margin-top: 0.5rem; padding: 0 0.65rem; }
  .sidebar-foot .btn { width: 100%; }
  .content > main { padding: 1.5rem 2rem; }
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.25rem;
  margin-bottom: 1rem;
}
h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--line); }
td { overflow-wrap: anywhere; } /* long emails/ids wrap instead of forcing scroll */
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; }
label { display: block; margin: 0.75rem 0 0.25rem; font-weight: 600; }
input, select {
  width: 100%;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit;
  background: #fff;
}
.btn {
  display: inline-block;
  padding: 0.5rem 0.9rem;
  border-radius: 7px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font: inherit;
}
.btn.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.muted { color: var(--muted); }
.error { color: var(--danger); margin: 0.5rem 0; }
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; font-size: 0.8rem; border: 1px solid var(--line); }
.badge.admin { color: var(--brand); border-color: var(--brand); }
.badge.off { color: var(--danger); border-color: var(--danger); }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.pager { display: flex; gap: 0.75rem; align-items: center; margin-top: 1rem; }
.card-narrow { max-width: 420px; margin: 2rem auto; }
.mt { margin-top: 1rem; }

/* Full-width white page header (title + optional CTA buttons). Spans the whole
   content column, sticks to the top on scroll. Rendered by partials/header.ejs
   so every page shares it. */
.page-header {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 0.75rem 1rem;
}
.page-header h1 { margin: 0; font-size: 1.2rem; }
.page-actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
@media (min-width: 800px) {
  .page-header { padding: 0.9rem 2rem; }
  .page-header h1 { font-size: 1.3rem; }
}

/* Status badge variants. */
.badge.ok { color: var(--ok); border-color: var(--ok); }
.badge.warn { color: #b45309; border-color: #f59e0b; }

/* Filter form grid (audit log). */
.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.5rem 0.75rem;
  align-items: end;
}
.filters .field label { margin-top: 0; }
.filters .field--actions { display: flex; gap: 0.5rem; align-items: end; }

/* Audit log: collapsible disclosure rows (no wide table / horizontal scroll).
   Each row's summary shows the key fields; expanding reveals full detail. */
.audit-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 0.5rem;
}
.audit-item > summary {
  list-style: none;
  cursor: pointer;
  padding: 0.6rem 0.85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.9rem;
}
.audit-item > summary::-webkit-details-marker {
  display: none;
}
.audit-item > summary::before {
  content: '▸';
  color: var(--muted);
  font-size: 0.8rem;
}
.audit-item[open] > summary::before {
  content: '▾';
}
.audit-item .ai-when {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  white-space: nowrap;
}
.audit-item .ai-action {
  font-weight: 600;
}
.audit-item .ai-resource {
  color: var(--muted);
}
.audit-item .ai-end {
  margin-left: auto;
}
.audit-item .ai-detail {
  padding: 0.25rem 0.85rem 0.85rem;
  border-top: 1px solid var(--line);
}
.audit-item .ai-detail dl {
  display: grid;
  grid-template-columns: 1fr; /* mobile-first: stacked label/value */
  gap: 0.15rem 1rem;
  margin: 0.85rem 0 0;
}
.audit-item .ai-detail dt {
  color: var(--muted);
  margin-top: 0.5rem;
}
.audit-item .ai-detail dd {
  margin: 0;
  word-break: break-word;
}
@media (min-width: 560px) {
  .audit-item .ai-detail dl {
    grid-template-columns: 150px 1fr;
    gap: 0.3rem 1rem;
  }
  .audit-item .ai-detail dt {
    margin-top: 0;
  }
}

/* Pretty-printed JSON blocks. */
.code {
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.45;
  white-space: pre;
}
