/* QENEX Admin Portal — Sprint 180
   Brand palette: #0A0E27 bg, #0f172a surface, #22D3EE accent */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Inter:wght@400;500;600&display=swap');

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

:root {
  --bg:        #0A0E27;
  --surface:   #0f172a;
  --surface2:  #1e293b;
  --border:    #1e2d4a;
  --accent:    #22D3EE;
  --accent-dk: #0891B2;
  --text:      #e2e8f0;
  --text-muted:#94a3b8;
  --danger:    #f87171;
  --green:     #4ade80;
  --radius:    8px;
  --font-head: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ─────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
}

.header-brand span.badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  background: var(--accent-dk);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.user-pill .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, opacity 0.15s;
  white-space: nowrap;
  font-family: var(--font-body);
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}
.btn-primary:hover { background: var(--accent-dk); color: #fff; }

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-muted);
}
.btn-ghost:hover { background: var(--surface2); color: var(--text); }

.btn-danger {
  background: transparent;
  border-color: var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

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

/* ── Filter bar ──────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: center;
  margin-bottom: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.filter-bar label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-right: 2px;
}

.filter-bar select,
.filter-bar input[type="text"],
.filter-bar input[type="date"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 10px;
  font-size: 0.85rem;
  font-family: var(--font-body);
  outline: none;
}

.filter-bar select:focus,
.filter-bar input:focus {
  border-color: var(--accent);
}

.filter-spacer { flex: 1; }

/* ── Stats bar ───────────────────────────────── */
.stats-bar {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  min-width: 120px;
}

.stat-card .stat-value {
  font-family: var(--font-head);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Table ───────────────────────────────────── */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  position: sticky;
  top: 0;
  background: var(--surface2);
  z-index: 1;
}

th {
  text-align: left;
  padding: 10px 14px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tr:last-child td { border-bottom: none; }

tbody tr:nth-child(even) { background: rgba(255,255,255,0.02); }
tbody tr:hover { background: rgba(34,211,238,0.04); }

.pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
}

.pill-green  { background: rgba(74,222,128,0.15); color: var(--green); }
.pill-gray   { background: rgba(148,163,184,0.15); color: var(--text-muted); }
.pill-accent { background: rgba(34,211,238,0.15); color: var(--accent); }

/* ── Actions cell ────────────────────────────── */
.actions { display: flex; gap: 6px; }

/* ── Pagination ──────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pagination-controls { display: flex; gap: 0.4rem; align-items: center; }

/* ── Toast ───────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 999;
}

.toast {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem 1.25rem;
  font-size: 0.875rem;
  min-width: 240px;
  animation: slide-in 0.2s ease;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--danger); }

@keyframes slide-in {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Loading ─────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
}

.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-right: 0.75rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Mobile card view ────────────────────────── */
@media (max-width: 768px) {
  main { padding: 1rem 0.75rem; }
  header { padding: 0 0.75rem; }

  .table-wrap { border-radius: 0; border-left: none; border-right: none; }

  table, thead, tbody, th, td, tr { display: block; }
  thead tr { display: none; }

  tbody tr {
    background: var(--surface) !important;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    padding: 0.75rem;
  }

  td {
    padding: 4px 0;
    border: none;
    max-width: 100%;
    white-space: normal;
    display: flex;
    gap: 0.5rem;
  }

  td::before {
    content: attr(data-label);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    min-width: 90px;
    flex-shrink: 0;
  }

  td.actions-cell { flex-wrap: wrap; }
  td.actions-cell::before { content: ''; min-width: 0; }

  .actions { flex-wrap: wrap; }
  .filter-bar { padding: 0.6rem; }
  .stats-bar .stat-card { flex: 1; min-width: 80px; }
}
