.admin-shell { display: flex; min-height: 100vh; background: oklch(97% 0.006 258); }

.admin-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: oklch(20% 0.06 258);
  color: oklch(85% 0.01 258);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: sticky;
  top: 0;
}
.admin-sidebar .brand { padding: 20px 22px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid oklch(30% 0.05 258); }
.admin-sidebar .brand img { width: 34px; height: 34px; border-radius: 6px; }
.admin-sidebar .brand .name { font-family: Lora, serif; font-weight: 700; color: white; font-size: 15px; line-height: 1.2; }
.admin-sidebar nav { padding: 14px 10px; flex: 1; }
.admin-sidebar nav a {
  display: block; padding: 10px 14px; border-radius: 6px; font-size: 13.5px; margin-bottom: 2px; color: oklch(80% 0.01 258);
}
.admin-sidebar nav a:hover { background: oklch(28% 0.07 258); color: white; }
.admin-sidebar nav a.active { background: oklch(72% 0.13 85); color: oklch(20% 0.04 85); font-weight: 700; }
.admin-sidebar nav .section-label { font-size: 11px; letter-spacing: 1px; text-transform: uppercase; color: oklch(55% 0.02 258); padding: 16px 14px 6px 14px; }
.admin-sidebar .sidebar-footer { padding: 16px; border-top: 1px solid oklch(30% 0.05 258); font-size: 12.5px; }

.admin-main { flex: 1; min-width: 0; }
.admin-topbar {
  background: white; border-bottom: 1px solid oklch(90% 0.01 258); padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10;
}
.admin-content { padding: 28px; }

.card { background: white; border: 1px solid oklch(90% 0.01 258); border-radius: 8px; padding: 22px; }
.stat-card .value { font-family: Lora, serif; font-size: 30px; font-weight: 700; color: oklch(28% 0.08 258); }
.stat-card .label { font-size: 13px; color: oklch(45% 0.02 258); margin-top: 4px; }

table.admin-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.admin-table th { text-align: left; background: oklch(97% 0.006 258); padding: 10px 14px; font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: oklch(45% 0.02 258); border-bottom: 1px solid oklch(90% 0.01 258); }
table.admin-table td { padding: 12px 14px; border-bottom: 1px solid oklch(94% 0.008 258); vertical-align: middle; }
table.admin-table tr:hover td { background: oklch(98% 0.004 258); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 700; }
.badge-new { background: oklch(90% 0.08 250); color: oklch(35% 0.12 250); }
.badge-contacted { background: oklch(92% 0.09 85); color: oklch(40% 0.1 85); }
.badge-converted { background: oklch(92% 0.09 145); color: oklch(35% 0.1 145); }
.badge-rejected { background: oklch(92% 0.08 25); color: oklch(40% 0.12 25); }
.badge-active { background: oklch(92% 0.09 145); color: oklch(35% 0.1 145); }
.badge-completed { background: oklch(90% 0.03 258); color: oklch(35% 0.05 258); }
.badge-dropped { background: oklch(92% 0.08 25); color: oklch(40% 0.12 25); }
.badge-upgraded { background: oklch(91% 0.08 300); color: oklch(38% 0.13 300); }

.btn-primary { background: oklch(28% 0.08 258); color: white; border: none; padding: 10px 18px; border-radius: 5px; font-weight: 700; font-size: 13.5px; cursor: pointer; }
.btn-secondary { background: oklch(94% 0.008 258); color: oklch(28% 0.08 258); border: 1px solid oklch(88% 0.01 258); padding: 10px 18px; border-radius: 5px; font-weight: 700; font-size: 13.5px; cursor: pointer; }
.btn-danger { background: oklch(55% 0.18 25); color: white; border: none; padding: 10px 18px; border-radius: 5px; font-weight: 700; font-size: 13.5px; cursor: pointer; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: oklch(30% 0.02 258); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

/* ---------- Admin responsive layout ---------- */

/* Data tables keep their natural column widths and scroll horizontally inside
   this wrapper, rather than squeezing columns until they're unreadable. */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap table.admin-table { min-width: 720px; }

/* Sidebar toggle + scrim, desktop-hidden. */
.sidebar-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px; height: 42px;
  padding: 0 9px;
  background: white;
  border: 1px solid oklch(88% 0.01 258);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-toggle span { display: block; height: 2px; width: 100%; background: oklch(28% 0.08 258); border-radius: 2px; }
.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(12, 18, 30, 0.5);
  z-index: 29;
}
.sidebar-scrim.show { display: block; }

/* Admin dashboard/detail grids. */
.admin-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; }
.admin-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.admin-grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
/* Detail pages: a fixed-width rail beside the main column. */
.admin-split      { display: grid; grid-template-columns: 280px 1fr; gap: 20px; align-items: start; }
.admin-split-rail { display: grid; grid-template-columns: 1fr 300px; gap: 20px; align-items: start; }

@media (max-width: 1100px) {
  .admin-grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 1024px) {
  /* Sidebar becomes an off-canvas drawer. */
  .sidebar-toggle { display: flex; }
  .admin-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 30;
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow-y: auto;
  }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { width: 100%; }

  .admin-split, .admin-split-rail { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .admin-sidebar { transition: none; }
}

@media (max-width: 760px) {
  .admin-content { padding: 18px 16px; }
  .admin-topbar { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  .admin-grid-3, .admin-grid-2 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .stat-card .value { font-size: 24px; }
  /* Stack toolbar rows (search box + primary action) instead of cramming. */
  .admin-toolbar { flex-direction: column; align-items: stretch !important; }
  .admin-toolbar form { max-width: none !important; }
  .admin-toolbar .btn-primary { text-align: center; }
}

@media (max-width: 560px) {
  .admin-grid-4 { grid-template-columns: 1fr; }

  /* Key/value detail tables (those NOT in a .table-wrap) stack label above
     value, so a fixed `width` on the th doesn't crush the value column. */
  .card > table.admin-table th,
  .card > table.admin-table td {
    display: block;
    width: auto !important;
    border-bottom: none;
    padding: 4px 14px;
  }
  .card > table.admin-table th { padding-top: 12px; background: transparent; }
  .card > table.admin-table td { padding-bottom: 12px; border-bottom: 1px solid oklch(94% 0.008 258); }
}

@media print {
  .no-print { display: none !important; }
  body { background: white !important; }
  .table-wrap { overflow: visible !important; }
  .table-wrap table.admin-table { min-width: 0 !important; }
}

/* Pager: rows-per-page selector + page links under admin lists */
.pager-bar { margin-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.pager-size { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 13px; color: oklch(40% 0.02 258); margin: 0; }
.pager-size label { display: flex; align-items: center; gap: 6px; }
.pager-size select { padding: 5px 8px; border: 1px solid oklch(88% 0.01 258); border-radius: 5px; background: white; font-size: 13px; cursor: pointer; }
.pager-count { color: oklch(50% 0.02 258); }
.pager-links { flex: 1; min-width: 0; }

/* Upload guidance (recommended px + max size) and the live "selected file" readout */
.upload-hint { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: oklch(50% 0.02 258); margin-top: 5px; line-height: 1.5; }
.upload-hint strong { color: oklch(35% 0.03 258); font-weight: 700; }
.upload-hint-note { flex-basis: 100%; }
.upload-info { font-size: 12px; margin-top: 4px; color: oklch(40% 0.1 145); }
.upload-info.is-error { color: oklch(50% 0.18 25); font-weight: 700; }

/* Reports: filter bar, summary tiles and the period / group breakdown tables */
.rpt-filters { margin-bottom: 18px; display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.rpt-filters label { display: block; font-size: 12px; color: oklch(45% 0.02 258); margin-bottom: 4px; }
.rpt-filters .rpt-actions { display: flex; gap: 8px; }
.rpt-presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.rpt-presets a { font-size: 12.5px; font-weight: 700; padding: 5px 11px; border-radius: 999px; border: 1px solid oklch(88% 0.01 258); color: oklch(35% 0.04 258); text-decoration: none; background: white; }
.rpt-presets a.on { background: oklch(28% 0.08 258); border-color: oklch(28% 0.08 258); color: white; }
.rpt-window { font-size: 13px; color: oklch(45% 0.02 258); margin: -6px 0 16px; }
.rpt-window strong { color: oklch(28% 0.08 258); }
.rpt-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.rpt-tile .k { font-size: 12px; color: oklch(45% 0.02 258); text-transform: uppercase; letter-spacing: .5px; }
.rpt-tile .v { font-size: 24px; font-weight: 800; margin-top: 4px; color: oklch(25% 0.06 258); }
.rpt-tile .s { font-size: 12px; color: oklch(55% 0.02 258); }
.rpt-tile.good { background: oklch(97% 0.02 150); }
.rpt-tile.warn { background: oklch(97% 0.02 25); }
.rpt-section-title { font-weight: 700; font-size: 14px; padding: 14px 16px 0; }
table.admin-table td.num, table.admin-table th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.admin-table tr.rpt-total td { font-weight: 800; background: oklch(97% 0.006 258); }
table.admin-table tr.rpt-empty td { color: oklch(62% 0.01 258); }
.rpt-bar { min-width: 120px; }
.rpt-bar span { display: block; height: 8px; border-radius: 4px; background: oklch(58% 0.12 258); min-width: 2px; }
@media print {
  .rpt-filters, .rpt-presets, .pager-bar { display: none !important; }
}
