/* ═══════════════════════════════════════════════════════════════
   SideQuests Admin — Shared Stylesheet (Light / Accessible Theme)
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg:      #f1f5f9;
  --surface: #ffffff;
  --surface2:#f8fafc;
  --border:  #e2e8f0;
  --text:    #0f172a;
  --muted:   #64748b;
  --accent:  #334155;
  --radius:  10px;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

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

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
  color: #fff;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.topbar-brand {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
}
.sq-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; }
.sq-logo:hover { text-decoration: none; color: #fff; }
.sq-logo-icon { width: 34px; height: 34px; background: rgba(255,255,255,0.12); border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.sq-logo-text { font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.sq-logo-text span { color: #94a3b8; font-weight: 400; }
.topbar-back {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2);
  border-radius: 7px; padding: 6px 13px; font-size: 13px; font-weight: 600;
  color: #fff; white-space: nowrap; transition: background .15s;
  text-decoration: none; cursor: pointer;
}
.topbar-back:hover { background: rgba(255,255,255,.22); text-decoration: none; color: #fff; }
.topbar-back svg { flex-shrink: 0; }
.topbar-back.spinning #ri { animation: spin .9s linear infinite; }
.topbar-user {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(99,102,241,.2); border: 1px solid rgba(99,102,241,.4);
  border-radius: 7px; padding: 6px 12px;
  font-size: 12px; font-weight: 700; color: #a5b4fc;
  white-space: nowrap; letter-spacing: .01em;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  padding: 8px 16px; border-radius: 7px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: all .15s;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:hover { opacity: .85; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-primary { background: #0f172a; color: #fff; }
.btn-primary:hover { background: #1e293b; opacity: 1; }
.btn-surface { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-surface:hover { background: #f8fafc; opacity: 1; }
.btn-danger  { background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; }
.btn-success { background: #d1fae5; color: #059669; border: 1px solid #a7f3d0; }
.btn-warn    { background: #fef3c7; color: #d97706; border: 1px solid #fde68a; }

/* ── Layout ──────────────────────────────────────────────────────── */
.container {
  max-width: 1400px; margin: 0 auto; padding: 28px 24px;
  display: flex; flex-direction: column; gap: 24px;
}
.container-sm { max-width: 900px; margin: 0 auto; padding: 28px 24px; }

.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }

.page-hdr {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 24px;
}
.page-hdr h2 { font-size: 22px; font-weight: 700; }
.page-hdr .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.grid   { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; margin-bottom: 20px; }
@media (max-width: 768px) { .grid, .grid-3 { grid-template-columns: 1fr; } }

/* ── Cards ───────────────────────────────────────────────────────── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card h3 {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .7px; color: var(--muted); margin-bottom: 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.section-label {
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 14px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 10px;
}
.card-head .section-label { margin-bottom: 0; }

/* ── Stats row ───────────────────────────────────────────────────── */
.stats-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stat {
  flex: 1; min-width: 110px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px; text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.stat .sv { font-size: 22px; font-weight: 700; color: var(--text); }
.stat .sl { font-size: 11px; color: var(--muted); margin-top: 2px; }
.stat.green .sv { color: #059669; }
.stat.red .sv   { color: #dc2626; }
.stat.amber .sv { color: #d97706; }
.stat.blue .sv  { color: #2563eb; }

/* ── Stats grid (dashboard) ──────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
@media (max-width: 1100px) { .stats-grid { grid-template-columns: repeat(3,1fr); } }
@media (max-width: 600px)  { .stats-grid { grid-template-columns: repeat(2,1fr); } }
.stat-card {
  background: #fff; border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.stat-label { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.stat-value { font-size: 30px; font-weight: 700; line-height: 1; color: var(--text); margin-bottom: 5px; }
.stat-sub   { font-size: 11px; color: var(--muted); }
.stat-card.green  .stat-value { color: #059669; }
.stat-card.red    .stat-value { color: #dc2626; }
.stat-card.purple .stat-value { color: #7c3aed; }

/* ── Key-value list ──────────────────────────────────────────────── */
.kv-list { display: flex; flex-direction: column; gap: 10px; }
.kv-item { display: flex; gap: 8px; align-items: flex-start; }
.kv-key  { color: var(--muted); font-size: 12px; min-width: 130px; flex-shrink: 0; padding-top: 1px; }
.kv-val  { color: var(--text); word-break: break-word; }

/* ── Tables ──────────────────────────────────────────────────────── */
.table-wrap {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: #f8fafc; }
th {
  text-align: left; padding: 10px 14px;
  color: var(--muted); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px;
  white-space: nowrap; border-bottom: 1px solid var(--border);
  cursor: pointer; user-select: none;
}
th.nosort { cursor: default; }
th:hover, th.sorted { color: var(--text); }
th .si { margin-left: 4px; font-size: 10px; opacity: .45; }
th.sorted .si { opacity: 1; }
td {
  padding: 11px 14px; border-bottom: 1px solid #f1f5f9;
  vertical-align: middle; white-space: normal;
  word-break: break-word; overflow-wrap: anywhere; max-width: 220px;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }
tbody tr.clickable, tr.clickable-row { cursor: pointer; }
tbody tr.clickable:hover td, tbody tr.clickable-row:hover td { background: #f1f5f9; }
tbody tr.err-row    { background: #fff8f8; }
tbody tr.err-row:hover td { background: #fff1f1; }
tbody tr.ack-row    { background: #f9fafb; }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700;
}
.badge-success  { background: #d1fae5; color: #065f46; }
.badge-error    { background: #fee2e2; color: #991b1b; }
.badge-invalid  { background: #fef3c7; color: #92400e; }
.badge-warn    { background: #fef3c7; color: #92400e; }
.badge-info    { background: #ede9fe; color: #5b21b6; }
.badge-muted   { background: #f1f5f9; color: var(--muted); }
.badge-admin   { background: #ede9fe; color: #6d28d9; }
.badge-locked  { background: #fee2e2; color: #dc2626; }
.badge-user    { background: #f1f5f9; color: var(--muted); }
.badge-ack     { background: #f1f5f9; color: var(--muted); }

/* ── Audit event badges ──────────────────────────────────────────── */
.evt-badge { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.evt-success { background: #d1fae5; color: #065f46; }
.evt-failed  { background: #fee2e2; color: #991b1b; }
.evt-blocked { background: #fef3c7; color: #92400e; }
.evt-locked  { background: #fee2e2; color: #dc2626; }
.evt-logout  { background: #f1f5f9; color: var(--muted); }
.evt-info    { background: #ede9fe; color: #5b21b6; }
.evt-warn    { background: #fef3c7; color: #92400e; }

/* ── Pills ───────────────────────────────────────────────────────── */
.pill     { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; letter-spacing: .04em; }
.pill-ok      { background: #d1fae5; color: #059669; }
.pill-err     { background: #fee2e2; color: #dc2626; }
.pill-invalid { background: #fef3c7; color: #d97706; }
.pill-ocr { background: #fef3c7; color: #d97706; }
.pill-admin { background: #ede9fe; color: #6d28d9; }
.pill-user  { background: #f1f5f9; color: var(--muted); }
.pill-ack        { background: #f1f5f9; color: var(--muted); }
.pill-pending    { background: #fef9c3; color: #a16207; }
.pill-processing { background: #dbeafe; color: #1d4ed8; }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 12px; color: #334155;
  margin-bottom: 6px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .4px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%; padding: 9px 12px;
  background: #fff; border: 1.5px solid var(--border);
  border-radius: 7px; color: var(--text); font-size: 13px;
  outline: none; transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: #334155; box-shadow: 0 0 0 3px rgba(51,65,85,.08); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-msg { font-size: 13px; margin-top: 12px; padding: 10px 14px; border-radius: 7px; display: none; }
.form-msg.ok  { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; display: block; }
.form-msg.err { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; display: block; }

/* ── Modals ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 200; display: none; align-items: center; justify-content: center; padding: 24px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 28px;
  width: 480px; max-width: calc(100vw - 32px); max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
.modal h3 { font-size: 17px; font-weight: 700; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 24px; }
.err-msg { font-size: 12px; color: #dc2626; margin-top: 8px; display: none; }

/* Modal (dashboard variant) */
.modal-box  { background: #fff; border: 1px solid var(--border); border-radius: 14px; width: 100%; max-width: 400px; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--border); font-size: 15px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 1.3rem; line-height: 1; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { color: var(--text); background: #f1f5f9; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.field-label { display: block; font-size: 12px; font-weight: 600; color: #334155; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .4px; }
.field-input { width: 100%; padding: 9px 12px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 13px; color: var(--text); background: #fff; outline: none; transition: border-color .15s, box-shadow .15s; }
.field-input:focus { border-color: #334155; box-shadow: 0 0 0 3px rgba(51,65,85,.08); }
.check-row { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer; }
.check-row input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }
.modal-err { font-size: 12px; color: #dc2626; padding: 8px 12px; background: #fee2e2; border-radius: 6px; display: none; }
.modal-err.visible { display: block; }

/* ── Confirm overlay ─────────────────────────────────────────────── */
.confirm-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 1000; align-items: center; justify-content: center; }
.confirm-overlay.active { display: flex; }
.confirm-box { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 28px; max-width: 420px; width: 90%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,.15); }
.confirm-box h3 { font-size: 18px; margin-bottom: 10px; }
.confirm-box p  { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.confirm-box .btns { display: flex; gap: 10px; justify-content: center; }

/* ── Pagination ──────────────────────────────────────────────────── */
.pg { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-top: 1px solid var(--border); background: #f8fafc; }
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 18px; flex-wrap: wrap; gap: 10px; }
.pg-btns { display: flex; gap: 4px; flex-wrap: wrap; }
.pg-btn { min-width: 32px; height: 32px; padding: 0 8px; border: 1px solid var(--border); background: #fff; border-radius: 6px; font-size: 12px; cursor: pointer; color: var(--text); display: flex; align-items: center; justify-content: center; transition: all .1s; }
.pg-btn:hover:not(:disabled) { background: #f1f5f9; border-color: #94a3b8; }
.pg-btn.active { background: #0f172a; color: #fff; border-color: #0f172a; }
.pg-btn:disabled { opacity: .4; cursor: not-allowed; }
.pg-info { font-size: 12px; color: var(--muted); }

/* ── Filters ─────────────────────────────────────────────────────── */
.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; align-items: center; }
.filters select, .filters input {
  background: #fff; border: 1.5px solid var(--border); border-radius: 7px;
  color: var(--text); font-size: 13px; padding: 8px 12px; outline: none; transition: border-color .15s;
}
.filters select:focus, .filters input:focus { border-color: #334155; }
.filters input { flex: 1; min-width: 200px; }

/* ── Table controls (dashboard) ──────────────────────────────────── */
.table-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.search-wrap  { position: relative; flex: 1; min-width: 200px; }
.search-wrap svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.search-input { width: 100%; padding: 8px 12px 8px 34px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 13px; color: var(--text); background: #fff; outline: none; transition: border-color .15s; }
.search-input:focus { border-color: #334155; }
select.ctrl { padding: 8px 12px; border: 1.5px solid var(--border); border-radius: 7px; font-size: 13px; color: var(--text); background: #fff; outline: none; cursor: pointer; }
select.ctrl:focus { border-color: #334155; }
.results-count { font-size: 12px; color: var(--muted); margin-left: auto; white-space: nowrap; }

/* ── Spinner / loading ───────────────────────────────────────────── */
.loading { color: var(--muted); text-align: center; padding: 40px; }
.spin {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--border); border-top-color: #334155;
  border-radius: 50%; animation: spin .6s linear infinite;
  vertical-align: middle; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 40px; color: var(--muted); font-size: 13px; }
.empty-icon { font-size: 2rem; margin-bottom: 8px; }

/* ── Avatar ──────────────────────────────────────────────────────── */
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: #f1f5f9; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; color: #334155; flex-shrink: 0;
}
.avatar-lg {
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, #334155, #0f172a);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 700; color: #fff; flex-shrink: 0;
}

/* ── Details/expandable ──────────────────────────────────────────── */
details { cursor: pointer; }
details summary { list-style: none; display: flex; align-items: center; gap: 6px; }
details summary::-webkit-details-marker { display: none; }
details[open] pre {
  margin-top: 6px; background: #f8fafc; padding: 8px; border-radius: 6px;
  font-size: 11px; color: var(--muted); white-space: pre-wrap; word-break: break-all;
  border: 1px solid var(--border);
}

/* ── Map ─────────────────────────────────────────────────────────── */
#map { height: 280px; border-radius: 8px; border: 1px solid var(--border); overflow: hidden; }

/* ── Skeleton ────────────────────────────────────────────────────── */
.skel {
  background: linear-gradient(90deg, #e2e8f0 25%, #f1f5f9 50%, #e2e8f0 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ── Charts (dashboard) ──────────────────────────────────────────── */
.charts-grid { display: grid; grid-template-columns: 1fr 290px 290px; gap: 14px; }
@media (max-width: 1050px) { .charts-grid { grid-template-columns: 1fr; } }
.chart-card { background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; box-shadow: 0 1px 3px rgba(0,0,0,.04); }
.chart-title { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 18px; }
.chart-canvas-wrap { position: relative; height: 210px; }
.ranked-list  { display: flex; flex-direction: column; gap: 9px; }
.ranked-item  { display: flex; align-items: center; gap: 10px; }
.ranked-num   { font-size: 11px; font-weight: 700; color: var(--muted); width: 14px; text-align: right; flex-shrink: 0; }
.ranked-bw    { flex: 1; min-width: 0; }
.ranked-name  { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.ranked-track { height: 5px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.ranked-fill  { height: 100%; background: #334155; border-radius: 3px; transition: width .6s ease; }
.ranked-count { font-size: 11px; font-weight: 700; color: var(--muted); flex-shrink: 0; min-width: 24px; text-align: right; }

/* ── Error list (dashboard) ──────────────────────────────────────── */
.err-list { display: flex; flex-direction: column; gap: 8px; }
.err-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; background: #fff8f8; border: 1px solid #fecaca; border-radius: 8px; }
.err-msg  { flex: 1; font-size: 12px; font-family: "SF Mono","Fira Code",monospace; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.err-cnt  { font-size: 11px; font-weight: 700; color: #dc2626; background: #fee2e2; padding: 2px 8px; border-radius: 20px; flex-shrink: 0; }

/* ── Icon buttons (dashboard table) ─────────────────────────────── */
.icon-btn { background: none; border: none; cursor: pointer; color: var(--muted); padding: 4px 5px; border-radius: 5px; line-height: 0; transition: color .12s, background .12s; }
.icon-btn:hover          { color: var(--text); background: #f1f5f9; }
.icon-btn.open           { color: #dc2626; }
.icon-btn.pdf:hover      { color: #7c3aed; background: #ede9fe; }
.icon-btn.del:hover      { color: #dc2626; background: #fee2e2; }
.icon-btn svg            { transition: transform .2s; }
.icon-btn.open svg       { transform: rotate(180deg); }
.detail-row td { padding: 0 !important; }
.detail-inner { padding: 10px 16px; font-size: 12px; color: #dc2626; font-family: "SF Mono","Fira Code",monospace; border-top: 1px solid #fecaca; background: #fff8f8; }

/* ── Table column helpers ────────────────────────────────────────── */
.c-time .t-main { font-weight: 600; white-space: nowrap; }
.c-time .t-rel  { font-size: 11px; color: var(--muted); }
.c-time .t-ip   { font-size: 11px; color: var(--muted); font-family: monospace; }
.c-file .f-name { font-weight: 600; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.c-file .f-size { font-size: 11px; color: var(--muted); }
.c-dim  { color: var(--muted); }
.c-none { color: var(--muted); opacity: .6; }
.c-tok .tok-v { font-weight: 600; }
.c-tok .tok-c { font-size: 11px; color: var(--muted); }
.c-hash { font-family: monospace; font-size: 11px; color: var(--muted); max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Page header (user/request detail) ──────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-header h2 { font-size: 22px; font-weight: 700; }
.page-header .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.hdr-info { flex: 1; }
.hdr-info h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.hdr-info .meta { color: var(--muted); font-size: 13px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }

/* ── Stat items (user/request detail) ───────────────────────────── */
.stat-row  { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-item { flex: 1; min-width: 90px; background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; text-align: center; }
.stat-item .sv { font-size: 22px; font-weight: 700; color: var(--text); }
.stat-item .sl { font-size: 11px; color: var(--muted); margin-top: 2px; }
.stat-item.green .sv  { color: #059669; }
.stat-item.blue .sv   { color: #2563eb; }
.stat-item.red .sv    { color: #dc2626; }
.stat-item.purple .sv { color: #7c3aed; }

/* ── Sessions & activity tables ──────────────────────────────────── */
.sessions-table, .activity-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.sessions-table th, .activity-table th { text-align: left; padding: 8px 12px; color: var(--muted); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; border-bottom: 1px solid var(--border); }
.sessions-table td, .activity-table td { padding: 10px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: top; }
.sessions-table tr:last-child td, .activity-table tr:last-child td { border-bottom: none; }
.sessions-table tr:hover td, .activity-table tr:hover td { background: #f8fafc; }
.sess-active  { color: #059669; font-size: 11px; font-weight: 600; }
.sess-expired { color: var(--muted); font-size: 11px; }
.status-dot  { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.dot-green { background: #059669; }
.dot-red   { background: #dc2626; }
.dot-gray  { background: var(--muted); }

/* ── Request detail specific ─────────────────────────────────────── */
.notes-hash { font-family: monospace; font-size: 11px; color: var(--muted); word-break: break-all; background: #f8fafc; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--border); margin-top: 8px; }
.map-placeholder { height: 280px; border-radius: 8px; border: 1px solid var(--border); background: #f8fafc; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 13px; flex-direction: column; gap: 8px; }
.map-placeholder svg { opacity: .4; }
.error-box-req { background: #fff8f8; border: 1px solid #fecaca; border-radius: var(--radius); padding: 16px; }
.error-box-req .error-label { font-size: 12px; font-weight: 600; color: #dc2626; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.error-box-req .error-msg   { color: var(--text); font-size: 13px; }
.ack-box { background: #f8fafc; border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; margin-top: 12px; }

/* ── Auth pages (login / forgot / reset) ─────────────────────────── */
body.auth-page { display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  background: #fff; border: 1px solid var(--border); border-radius: 16px;
  padding: 40px; width: 100%; max-width: 420px;
  box-shadow: 0 10px 40px rgba(0,0,0,.1);
}
.auth-logo { text-align: center; margin-bottom: 28px; }
.auth-logo svg { width: 48px; height: 48px; color: #334155; }
.auth-logo h1 { font-size: 22px; font-weight: 700; margin-top: 12px; color: var(--text); }
.auth-logo p  { color: var(--muted); font-size: 13px; margin-top: 6px; }
.btn-submit {
  width: 100%; padding: 12px; background: #0f172a; color: #fff;
  border: none; border-radius: 8px; font-size: 15px; font-weight: 700;
  cursor: pointer; transition: background .15s; margin-top: 4px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-submit:hover { background: #1e293b; }
.btn-submit:disabled { opacity: .5; cursor: not-allowed; }
.msg { margin-top: 16px; padding: 12px 14px; border-radius: 8px; font-size: 13px; display: none; }
.msg.ok  { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; display: block; }
.msg.err { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; display: block; }
.back-link { text-align: center; margin-top: 24px; font-size: 13px; color: var(--muted); }
.back-link a { color: #334155; font-weight: 600; text-decoration: underline; }
.error-box-login { background: #fff1f1; border: 1px solid #fecaca; border-radius: 8px; padding: 10px 14px; font-size: 13px; color: #dc2626; margin-bottom: 16px; display: none; align-items: center; gap: 8px; }
.error-box-login.visible { display: flex; }
.attempts-warning { font-size: 12px; color: #d97706; margin-top: 5px; display: none; }
.footer-note { margin-top: 20px; text-align: center; font-size: 12px; color: var(--muted); }

/* ── Password strength ───────────────────────────────────────────── */
.strength-bar  { height: 4px; border-radius: 2px; background: var(--border); margin-top: 8px; overflow: hidden; }
.strength-fill { height: 100%; border-radius: 2px; transition: width .3s, background .3s; width: 0; }
.strength-label { font-size: 11px; color: var(--muted); margin-top: 4px; }
.invalid-state { text-align: center; padding: 20px 0; }
.invalid-state p { color: var(--muted); margin-bottom: 16px; }

/* ── Service status panel ────────────────────────────────────────── */
.status-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px;
}
.status-card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.status-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
  transition: background .3s, box-shadow .3s;
}
.status-dot.ok      { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.15); }
.status-dot.warn    { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.15); }
.status-dot.error   { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.15); }
.status-dot.unknown { background: #94a3b8; }
.status-dot.checking { background: #cbd5e1; animation: status-pulse 1.2s infinite; }
@keyframes status-pulse { 0%,100%{opacity:1} 50%{opacity:.35} }
.status-info { flex: 1; min-width: 0; }
.status-name { font-size: 13px; font-weight: 600; color: var(--text); }
.status-meta { font-size: 11px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Dashboard 2-column ──────────────────────────────────────────── */
.dash-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 768px) { .dash-2col { grid-template-columns: 1fr; } }

/* ── Quick links ─────────────────────────────────────────────────── */
.quick-links { display: flex; flex-direction: column; gap: 8px; }
.quick-link {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 8px; color: var(--text);
  text-decoration: none; transition: background .12s, border-color .12s;
}
.quick-link:hover { background: #f8fafc; border-color: #94a3b8; text-decoration: none; color: var(--text); }
.quick-link svg { color: var(--muted); flex-shrink: 0; }
.ql-body { flex: 1; min-width: 0; }
.ql-title { font-size: 13px; font-weight: 600; }
.ql-sub   { font-size: 11px; color: var(--muted); margin-top: 2px; }
.ql-arrow { color: var(--muted); font-size: 18px; font-weight: 300; line-height: 1; }

/* ── Utility ─────────────────────────────────────────────────────── */
.text-muted { color: var(--muted); }
.text-sm    { font-size: 12px; }
.text-xs    { font-size: 11px; }
.monospace  { font-family: monospace; }
.nowrap     { white-space: nowrap; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

/* ═══════════════════════════════════════════════════════════════
   Claude Admin Terminal — Floating AI assistant
   ═══════════════════════════════════════════════════════════════ */

#claude-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, #334155, #1e293b);
  border: 2px solid #475569;
  color: #e2e8f0;
  font-size: 22px;
  cursor: pointer;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
#claude-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,0,0,0.5);
}
#claude-fab .fab-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 12px;
  height: 12px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #0f172a;
  display: none;
}
#claude-fab.has-unread .fab-badge { display: block; }

#claude-terminal {
  position: fixed;
  bottom: 88px;
  right: 24px;
  width: 400px;
  height: 560px;
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  z-index: 1999;
  box-shadow: 0 20px 60px rgba(0,0,0,0.7);
  overflow: hidden;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  transform-origin: bottom right;
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1), opacity 0.15s;
}
#claude-terminal.hidden {
  transform: scale(0.85);
  opacity: 0;
  pointer-events: none;
}

.ct-header {
  background: #161b22;
  border-bottom: 1px solid #30363d;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  cursor: default;
}
.ct-dots {
  display: flex;
  gap: 5px;
}
.ct-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.ct-dot-red   { background: #ff5f57; }
.ct-dot-yellow{ background: #febc2e; }
.ct-dot-green { background: #28c840; }
.ct-dot-red { cursor: pointer; }
.ct-title {
  flex: 1;
  text-align: center;
  font-size: 12px;
  color: #8b949e;
  letter-spacing: 0.5px;
}
.ct-page-badge {
  font-size: 10px;
  color: #58a6ff;
  background: rgba(88,166,255,0.1);
  border: 1px solid rgba(88,166,255,0.2);
  padding: 2px 7px;
  border-radius: 20px;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ct-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.ct-messages::-webkit-scrollbar { width: 4px; }
.ct-messages::-webkit-scrollbar-track { background: transparent; }
.ct-messages::-webkit-scrollbar-thumb { background: #30363d; border-radius: 2px; }

.ct-msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 100%;
  animation: ct-fadein 0.15s ease;
}
@keyframes ct-fadein {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ct-msg-user {
  align-items: flex-end;
}
.ct-msg-user .ct-bubble {
  background: #1f4068;
  border: 1px solid #2d5a8e;
  color: #cdd9e5;
  border-radius: 10px 10px 2px 10px;
  padding: 8px 11px;
  font-size: 12.5px;
  line-height: 1.5;
  max-width: 90%;
  word-break: break-word;
}

.ct-msg-claude {
  align-items: flex-start;
}
.ct-msg-claude .ct-bubble {
  background: #161b22;
  border: 1px solid #30363d;
  color: #e6edf3;
  border-radius: 2px 10px 10px 10px;
  padding: 8px 11px;
  font-size: 12.5px;
  line-height: 1.6;
  max-width: 96%;
  word-break: break-word;
}

/* Markdown inside Claude bubbles */
.ct-bubble code {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11.5px;
  color: #79c0ff;
}
.ct-bubble pre {
  background: #0d1117;
  border: 1px solid #30363d;
  border-radius: 6px;
  padding: 10px;
  overflow-x: auto;
  margin: 6px 0;
}
.ct-bubble pre code {
  background: none;
  border: none;
  padding: 0;
  color: #e6edf3;
  font-size: 11.5px;
}
.ct-bubble strong { color: #f0f6fc; }
.ct-bubble em { color: #8b949e; }
.ct-bubble p { margin: 0 0 6px; }
.ct-bubble p:last-child { margin-bottom: 0; }
.ct-bubble ul, .ct-bubble ol { margin: 4px 0; padding-left: 18px; }
.ct-bubble li { margin: 2px 0; }
.ct-bubble h1,.ct-bubble h2,.ct-bubble h3 {
  color: #f0f6fc;
  margin: 8px 0 4px;
  font-size: 13px;
}
.ct-bubble a { color: #58a6ff; }

.ct-cursor {
  display: inline-block;
  width: 7px;
  height: 13px;
  background: #58a6ff;
  vertical-align: text-bottom;
  animation: ct-blink 0.8s step-end infinite;
  border-radius: 1px;
}
@keyframes ct-blink {
  0%,100% { opacity: 1; }
  50%      { opacity: 0; }
}

.ct-label {
  font-size: 10px;
  color: #484f58;
  padding: 0 2px;
}

.ct-thinking {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 6px 4px;
}
.ct-thinking span {
  width: 6px;
  height: 6px;
  background: #30363d;
  border-radius: 50%;
  animation: ct-bounce 1.2s ease-in-out infinite;
}
.ct-thinking span:nth-child(2) { animation-delay: 0.2s; }
.ct-thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ct-bounce {
  0%,80%,100% { transform: scale(1); background: #30363d; }
  40%         { transform: scale(1.3); background: #58a6ff; }
}

.ct-footer {
  border-top: 1px solid #21262d;
  padding: 10px;
  flex-shrink: 0;
  background: #0d1117;
}
.ct-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #161b22;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 6px 10px;
  transition: border-color 0.15s;
}
.ct-input-row:focus-within {
  border-color: #58a6ff;
}
.ct-prompt-char {
  color: #3fb950;
  font-size: 14px;
  flex-shrink: 0;
  line-height: 1;
  padding-bottom: 2px;
}
.ct-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #e6edf3;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  resize: none;
  max-height: 100px;
  min-height: 18px;
}
.ct-input::placeholder { color: #484f58; }
.ct-send-btn {
  background: #1f4068;
  border: 1px solid #2d5a8e;
  color: #58a6ff;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
  font-size: 13px;
}
.ct-send-btn:hover { background: #2d5a8e; }
.ct-send-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.ct-clear-btn {
  background: transparent;
  border: none;
  color: #484f58;
  font-size: 10px;
  cursor: pointer;
  text-align: center;
  margin-top: 6px;
  width: 100%;
  padding: 2px;
}
.ct-clear-btn:hover { color: #8b949e; }

.ct-welcome {
  text-align: center;
  padding: 24px 12px;
  color: #484f58;
  font-size: 12px;
  line-height: 1.6;
}
.ct-welcome-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.6;
}
.ct-welcome strong { color: #8b949e; display: block; margin-bottom: 4px; }
