/* ==========================================================================
   Reloop Mobile — Admin console
   ========================================================================== */

.admin {
  --sidebar-w: 262px;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100dvh;
  background: var(--bg-subtle);
}

/* The public site chrome is hidden while the admin console is active */
body.is-admin #site-header,
body.is-admin #site-footer,
body.is-admin .header,
body.is-admin .footer { display: none; }

@media (max-width: 1024px) {
  .admin { grid-template-columns: minmax(0, 1fr); }
}

.admin__sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: var(--s-6);
  padding: var(--s-5) var(--s-4);
  background: var(--ink-950);
  color: rgba(255, 255, 255, 0.75);
  overflow-y: auto;
}
@media (max-width: 1024px) {
  .admin__sidebar {
    position: fixed;
    z-index: 120;
    inset: 0 auto 0 0;
    width: 288px;
    transform: translateX(-102%);
    transition: transform var(--t-slow) var(--ease-out);
    box-shadow: var(--shadow-xl);
  }
  .admin__sidebar.is-open { transform: none; }
}
.admin__sidebar .brandmark { color: #fff; padding: 6px 8px 0; }
.admin__nav { display: grid; gap: 3px; }
.admin__nav-label {
  padding: 12px 12px 6px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: var(--tracking-widest);
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.35);
}
.admin__nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border-radius: var(--r-sm);
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 560;
  color: rgba(255, 255, 255, 0.68);
  transition: all var(--t-fast) var(--ease-out);
}
.admin__nav-item:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.admin__nav-item.is-active {
  background: linear-gradient(120deg, rgba(22, 179, 116, 0.34), rgba(10, 125, 71, 0.18));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.admin__nav-item svg { flex: none; opacity: 0.9; }
.admin__nav-item .count {
  margin-left: auto;
  font-size: var(--fs-2xs);
  font-family: var(--font-mono);
  padding: 2px 7px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.12);
}
.admin__sidebar-foot {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding: 14px 12px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: var(--fs-xs);
}
.admin__user { display: flex; align-items: center; gap: 10px; }
.admin__avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--blue-600), var(--cyan-500));
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-xs);
  flex: none;
}

.admin__main { min-width: 0; display: flex; flex-direction: column; }
.admin__topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 14px clamp(16px, 3vw, 32px);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.admin__topbar h1 { font-size: 1.125rem; }
.admin__topbar-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.admin__content {
  padding: clamp(18px, 3vw, 32px);
  display: grid;
  gap: clamp(18px, 2.6vw, 28px);
  align-content: start;
}
.admin-burger {
  display: none;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
@media (max-width: 1024px) { .admin-burger { display: grid; } }

/* --- KPI cards ---------------------------------------------------------- */
.kpi-grid {
  display: grid;
  gap: var(--s-4);
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.kpi {
  position: relative;
  overflow: hidden;
  padding: var(--s-5);
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-base) var(--ease-out), box-shadow var(--t-base) var(--ease-out);
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.kpi__top { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.kpi__label {
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-faint);
}
.kpi__value {
  margin-top: 10px;
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 1.2rem + 1.2vw, 2.05rem);
  font-weight: 760;
  letter-spacing: -0.035em;
  color: var(--text-strong);
  line-height: 1.05;
}
.kpi__foot { margin-top: 8px; font-size: var(--fs-xs); color: var(--text-muted); }
.kpi__delta { font-weight: 700; color: var(--green-600); }
.kpi__delta.is-down { color: var(--red-600); }
.kpi__spark { display: flex; align-items: flex-end; gap: 3px; height: 34px; margin-top: 14px; }
.kpi__spark i {
  flex: 1;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(180deg, var(--blue-400), var(--blue-100));
  min-height: 4px;
}

/* --- Panels ------------------------------------------------------------- */
.panel {
  border-radius: var(--r-lg);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-3);
  justify-content: space-between;
  padding: var(--s-5) var(--s-5) var(--s-4);
  border-bottom: 1px solid var(--border);
}
.panel__head h2,
.panel__head h3 { font-size: var(--fs-body); }
.panel__body { padding: var(--s-5); }
.panel__body--flush { padding: 0; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.toolbar .search { min-width: 240px; flex: 1 1 240px; }
.toolbar .select { min-height: 46px; min-width: 160px; width: auto; }

/* --- Table -------------------------------------------------------------- */
.table-wrap { width: 100%; overflow-x: auto; }
.data-table { min-width: 880px; font-size: var(--fs-sm); }
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 13px 16px;
  text-align: left;
  font-family: var(--font-display);
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr { transition: background-color var(--t-fast) var(--ease-out); }
.data-table tbody tr:hover { background: var(--bg-subtle); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table .cell-id {
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--blue-700);
}
.data-table .cell-strong { font-weight: 650; color: var(--text-strong); }
.data-table .cell-num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .cell-actions { text-align: right; white-space: nowrap; }

.row-action {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-xs);
  color: var(--text-muted);
  transition: all var(--t-fast) var(--ease-out);
}
.row-action:hover { background: var(--bg-muted); color: var(--text-strong); }
.row-action--danger:hover { background: var(--red-100); color: var(--red-600); }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-muted);
}
.pager__btns { display: flex; gap: 8px; }

/* --- Status select (inline editing) ------------------------------------- */
.status-select {
  appearance: none;
  min-height: 34px;
  padding: 5px 30px 5px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: var(--fs-2xs);
  font-weight: 700;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236d7889' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}
.status-select[data-status="new"] { background-color: var(--blue-50); color: var(--blue-700); border-color: #c4e8d4; }
.status-select[data-status="pickup_scheduled"] { background-color: var(--cyan-100); color: var(--cyan-600); border-color: #c0ecd8; }
.status-select[data-status="collected"] { background-color: #eef1f5; color: #334155; border-color: #d7dee7; }
.status-select[data-status="under_verification"] { background-color: var(--amber-100); color: #a86a05; border-color: #f6dfb4; }
.status-select[data-status="offer_confirmed"] { background-color: #ecfdf5; color: #047857; border-color: #bfeeda; }
.status-select[data-status="payment_pending"] { background-color: #fff1f0; color: #b42318; border-color: #fbd5d3; }
.status-select[data-status="completed"] { background-color: var(--green-100); color: var(--green-600); border-color: #c5eedd; }
.status-select[data-status="cancelled"] { background-color: var(--grey-100); color: var(--grey-500); border-color: var(--border); }

/* --- Drawer form (record editor) ---------------------------------------- */
.sheet {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  visibility: hidden;
  pointer-events: none;
}
.sheet.is-open { visibility: visible; pointer-events: auto; }
.sheet__scrim {
  position: absolute;
  inset: 0;
  background: rgba(5, 7, 10, 0.5);
  opacity: 0;
  transition: opacity var(--t-base) var(--ease-out);
}
.sheet.is-open .sheet__scrim { opacity: 1; }
.sheet__panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(560px, 100vw);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-xl);
  transform: translateX(102%);
  transition: transform var(--t-slow) var(--ease-out);
}
.sheet.is-open .sheet__panel { transform: none; }
.sheet__head {
  display: flex;
  align-items: flex-start;
  gap: var(--s-4);
  padding: var(--s-5) var(--s-6);
  border-bottom: 1px solid var(--border);
}
.sheet__head h2 { font-size: var(--fs-h4); }
.sheet__body { flex: 1; overflow-y: auto; padding: var(--s-6); display: grid; gap: var(--s-4); }
.sheet__foot {
  display: flex;
  gap: var(--s-3);
  justify-content: flex-end;
  padding: var(--s-4) var(--s-6);
  border-top: 1px solid var(--border);
  background: var(--bg-subtle);
}

/* --- Admin login -------------------------------------------------------- */
.login-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--gutter);
  background:
    radial-gradient(800px 400px at 80% 0%, rgba(22, 179, 116, 0.18), transparent 60%),
    radial-gradient(700px 400px at 5% 100%, rgba(10, 125, 71, 0.26), transparent 60%),
    var(--ink-950);
}
.login-card {
  width: min(440px, 100%);
  padding: clamp(26px, 4vw, 40px);
  border-radius: var(--r-xl);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-dark);
  color: #fff;
}
.login-card .field__label { color: rgba(255, 255, 255, 0.86); }
.login-card .input {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
  color: #fff;
}
.login-card .input::placeholder { color: rgba(255, 255, 255, 0.38); }
.login-card .input:focus { border-color: var(--cyan-400); box-shadow: 0 0 0 3px rgba(74, 211, 156, 0.26); }
.login-hint {
  margin-top: var(--s-5);
  padding: 13px 15px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.05);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  font-size: var(--fs-xs);
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.62);
}
.login-hint code {
  font-family: var(--font-mono);
  color: var(--cyan-400);
}

/* --- Charts (pure CSS) -------------------------------------------------- */
.bars { display: grid; gap: 14px; }
.bar-row { display: grid; gap: 7px; }
.bar-row__top { display: flex; justify-content: space-between; font-size: var(--fs-xs); }
.bar-row__top strong { font-family: var(--font-display); color: var(--text-strong); }
.bar-track { height: 9px; border-radius: var(--r-pill); background: var(--grey-150); overflow: hidden; }
.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue-600), var(--cyan-500));
  transition: width 700ms var(--ease-out);
}
.donut {
  --pct: 60;
  position: relative;
  width: 148px;
  height: 148px;
  margin-inline: auto;
  border-radius: 50%;
  background: conic-gradient(var(--blue-600) calc(var(--pct) * 1%), var(--grey-150) 0);
  display: grid;
  place-items: center;
}
.donut::before {
  content: "";
  position: absolute;
  inset: 15px;
  border-radius: 50%;
  background: var(--bg-elevated);
}
.donut__inner { position: relative; text-align: center; }
.donut__inner b {
  display: block;
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 760;
  letter-spacing: -0.03em;
  color: var(--text-strong);
}
.donut__inner span { font-size: var(--fs-2xs); color: var(--text-muted); }

.legend { display: grid; gap: 10px; margin-top: var(--s-5); }
.legend li { display: flex; align-items: center; gap: 10px; font-size: var(--fs-xs); color: var(--text-muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend b { margin-left: auto; font-family: var(--font-display); color: var(--text-strong); }

/* --- Admin misc --------------------------------------------------------- */
.mini-list { display: grid; gap: 0; }
.mini-list li {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 13px 0;
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-sm);
}
.mini-list li:last-child { border-bottom: 0; }
.mini-list__meta { margin-left: auto; font-size: var(--fs-xs); color: var(--text-muted); white-space: nowrap; }

.tag-editor { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 8px 6px 13px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  font-size: var(--fs-xs);
  font-weight: 600;
  font-family: var(--font-mono);
}
.tag-chip button { color: var(--text-faint); }
.tag-chip button:hover { color: var(--red-600); }

.rule-note {
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: var(--blue-50);
  border: 1px solid #c4e8d4;
  font-size: var(--fs-xs);
  line-height: 1.65;
  color: #075c37;
}
.mono-table { font-family: var(--font-mono); font-size: var(--fs-xs); }
.mono-table code { color: var(--blue-700); }
