/* ZeroLog Ops — modern dark admin theme */

:root {
  --bg-0: #0a0d12;
  --bg-1: #0f131a;
  --bg-2: #151b25;
  --bg-3: #1c2330;
  --bg-4: #232c3c;
  --border: #2a3445;
  --border-soft: #1f2735;
  --text: #e6ecf3;
  --text-soft: #9aa6b8;
  --text-muted: #6b7689;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-soft: rgba(59, 130, 246, 0.12);
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.15);
  --amber: #f59e0b;
  --amber-soft: rgba(245, 158, 11, 0.15);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.15);
  --purple: #a855f7;
  --purple-soft: rgba(168, 85, 247, 0.15);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

code, .mono, pre { font-family: var(--mono); }

.muted { color: var(--text-soft); }
.small { font-size: 12px; }

/* Layout ------------------------------------------------------------ */

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

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--bg-1);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.brand-mark {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--purple) 100%);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
  letter-spacing: 1px;
  box-shadow: 0 6px 18px rgba(59,130,246,0.3);
}
.brand-mark.big { width: 64px; height: 64px; font-size: 22px; margin: 0 auto 12px; }
.brand-name { font-weight: 600; font-size: 14px; }
.brand-tagline { font-size: 11px; color: var(--text-muted); letter-spacing: 0.5px; }

.nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 8px 18px;
}
.nav-section {
  padding: 16px 12px 6px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  font-weight: 600;
}
.nav-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  margin: 1px 0;
  color: var(--text-soft);
  border-radius: 6px;
  font-size: 13px;
}
.nav-link:hover { background: var(--bg-2); color: var(--text); }
.nav-link.active {
  background: var(--accent-soft);
  color: var(--text);
  font-weight: 500;
}
.nav-link .ico {
  display: inline-block;
  width: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.nav-link.active .ico { color: var(--accent); }
.ico-pulse { color: var(--green) !important; animation: pulse 1.6s infinite; }

.sidebar-foot {
  padding: 12px;
  border-top: 1px solid var(--border-soft);
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 6px;
  margin-bottom: 8px;
}
.user-avatar {
  width: 32px; height: 32px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 10px; text-transform: uppercase; letter-spacing: 0.8px; }
.role-super_admin { color: var(--purple); }
.role-admin { color: var(--accent); }
.role-viewer { color: var(--text-muted); }
.logout-form button { width: 100%; }

.content {
  flex: 1;
  padding: 24px 32px 40px;
  max-width: calc(100vw - 264px);
}
.content-bare {
  max-width: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  min-height: 100vh;
}

/* Page head --------------------------------------------------------- */

.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border-soft);
}
.page-head h1 {
  margin: 0 0 4px;
  font-size: 22px;
  font-weight: 600;
}
.page-head .muted { font-size: 13px; }
.page-head-meta { display: flex; align-items: center; gap: 8px; }

/* Pills, dots, badges ----------------------------------------------- */

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  color: var(--text-soft);
}
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}
.dot-green { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot-amber { background: var(--amber); }
.dot-red   { background: var(--red); }
.dot-blue  { background: var(--accent); }
.dot-pulse { animation: pulse 1.6s infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.badge-ok    { background: var(--green-soft);  color: var(--green); }
.badge-warn  { background: var(--amber-soft);  color: var(--amber); }
.badge-err   { background: var(--red-soft);    color: var(--red); }
.badge-muted { background: var(--bg-3);        color: var(--text-soft); }
.badge-blue  { background: var(--accent-soft); color: var(--accent); }

/* Stat grid --------------------------------------------------------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: transform 0.12s ease, border-color 0.12s;
}
.stat-card:hover { transform: translateY(-1px); border-color: var(--border); }
.stat-emph {
  background: linear-gradient(135deg, rgba(59,130,246,0.08) 0%, rgba(168,85,247,0.05) 100%);
  border-color: rgba(59,130,246,0.25);
}
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.8px; }
.stat-value { font-size: 26px; font-weight: 600; margin: 4px 0 4px; }
.stat-foot  { font-size: 12px; color: var(--text-soft); }

/* Panels & tables --------------------------------------------------- */

.panel {
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}
.panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
}
.panel-head h2 { margin: 0; font-size: 13px; font-weight: 600; color: var(--text); }
.link { color: var(--accent); font-size: 12px; }

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th, .data-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
}
.data-table th {
  background: var(--bg-2);
  color: var(--text-soft);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-2); }
.data-table-dense th, .data-table-dense td { padding: 6px 10px; font-size: 12px; }
.data-table .empty { text-align: center; color: var(--text-muted); padding: 18px; }
.row-actions, .row-actions-head { width: 1%; white-space: nowrap; text-align: right; }
.row-actions form.inline { display: inline; }
.inline { display: inline; }

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

.form-card {
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.form-card h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text-soft); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.form-grid .full { grid-column: span 2; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row.is-pk input { background: var(--bg-3) !important; color: var(--text-soft); }

label { font-size: 12px; color: var(--text-soft); display: flex; flex-direction: column; gap: 4px; }
label > span { font-weight: 500; color: var(--text-soft); }
label .meta { font-size: 10px; color: var(--text-muted); font-family: var(--mono); }

input[type="text"], input[type="email"], input[type="password"], input[type="search"],
input[type="number"], textarea, select {
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  outline: none;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input:disabled, input[readonly], textarea[readonly] { opacity: 0.6; }
textarea { resize: vertical; min-height: 80px; }
.full-width { width: 100%; }

.checkbox-row {
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  margin-top: 4px;
}
.checkbox-row.inline { display: inline-flex; }
.checkbox-row input[type="checkbox"] {
  appearance: none;
  width: 16px; height: 16px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
}
.checkbox-row input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox-row input[type="checkbox"]:checked::after {
  content: "✓"; color: white; font-size: 11px; position: absolute;
  top: -1px; left: 2px; font-weight: bold;
}

.form-actions {
  display: flex; align-items: center; gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}
.pull-right { margin-left: auto; }

.inline-form { display: inline-flex; align-items: end; gap: 8px; margin-right: 12px; }
.inline-form label { flex-direction: column; }
.inline-form input { width: 140px; }

.danger-zone {
  background: rgba(239, 68, 68, 0.05);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.danger-zone strong { color: var(--red); }

/* Buttons ----------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.06s;
  background: var(--bg-3);
  color: var(--text);
}
.btn:hover { background: var(--bg-4); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-3); border-color: var(--border); }
.btn-ghost { background: transparent; border-color: var(--border-soft); color: var(--text-soft); }
.btn-ghost:hover { background: var(--bg-2); color: var(--text); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.w-full { width: 100%; }

/* Auth pages -------------------------------------------------------- */

.auth-card {
  background: var(--bg-1);
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 36px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}
.auth-card-wide { max-width: 720px; }
.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand h1 { margin: 4px 0 0; font-size: 22px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label > span { font-size: 12px; }
.auth-form .form-grid { gap: 12px; }
.error-list {
  background: var(--red-soft);
  border: 1px solid rgba(239,68,68,0.3);
  color: var(--red);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  list-style: none;
  margin: 0 0 18px;
  font-size: 12px;
}

/* TOTP setup -------------------------------------------------------- */

.totp-setup {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: start;
}
.totp-qr img {
  width: 200px; height: 200px;
  background: white;
  border-radius: var(--radius-sm);
  padding: 8px;
}
.secret-box {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  word-break: break-all;
  font-size: 13px;
  margin: 8px 0 12px;
}

/* Flashes ----------------------------------------------------------- */

.flash-stack { margin-bottom: 18px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--border);
  font-size: 13px;
}
.flash-success { background: var(--green-soft); border-left-color: var(--green); color: #d1fae5; }
.flash-error   { background: var(--red-soft);   border-left-color: var(--red);   color: #fee2e2; }
.flash-warning { background: var(--amber-soft); border-left-color: var(--amber); color: #fef3c7; }
.flash-info    { background: var(--accent-soft); border-left-color: var(--accent); color: #dbeafe; }

/* OTP live feed ----------------------------------------------------- */

.otp-feed {
  max-height: 540px;
  overflow-y: auto;
  padding: 8px;
}
.otp-row {
  display: grid;
  grid-template-columns: 180px 160px 1fr 1fr;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  margin: 4px 0;
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  border: 1px solid var(--border-soft);
  transition: background 0.4s;
}
.otp-row-new {
  background: var(--accent-soft);
  border-color: var(--accent);
  animation: flash-in 1.5s ease-out;
}
@keyframes flash-in {
  0%   { background: rgba(59,130,246,0.35); }
  100% { background: var(--bg-2); }
}
.otp-time { color: var(--text-muted); font-size: 11px; font-family: var(--mono); }
.otp-phone { font-size: 13px; }
.otp-code-big {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 4px;
  color: var(--accent);
  text-shadow: 0 0 12px rgba(59,130,246,0.35);
}
.otp-code { font-size: 16px; font-weight: 600; color: var(--accent); letter-spacing: 2px; }

/* Grid layout helpers ---------------------------------------------- */

.grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}
@media (max-width: 1100px) {
  .grid-two { grid-template-columns: 1fr; }
  .totp-setup { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: span 1; }
}

/* KV list ----------------------------------------------------------- */

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  row-gap: 8px;
  padding: 16px;
  margin: 0;
}
.kv dt { color: var(--text-soft); font-size: 12px; }
.kv dd { margin: 0; }

/* Filter bar -------------------------------------------------------- */

.filter-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.filter-bar input, .filter-bar select { width: auto; min-width: 200px; }

.pager {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 16px;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 0;
}

/* Error page -------------------------------------------------------- */

.error-card {
  text-align: center;
  padding: 60px 20px;
  margin: 80px auto 0;
  max-width: 400px;
}
.error-code {
  font-size: 96px;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 20px var(--accent-soft);
  margin-bottom: 6px;
  font-family: var(--mono);
}
.error-card h1 { font-size: 18px; margin: 6px 0 16px; }

/* Scrollbar styling ------------------------------------------------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-0); }
::-webkit-scrollbar-thumb { background: var(--bg-3); border-radius: 5px; border: 2px solid var(--bg-0); }
::-webkit-scrollbar-thumb:hover { background: var(--bg-4); }
