/* MidPay Dashboard + Admin Portal — dark theme, green accent (#A4D233) */

:root {
  --bg:           #0a0a0a;
  --surface:      #111;
  --surface-2:   #1a1a1a;
  --border:      rgba(255, 255, 255, 0.08);
  --border-hi:   rgba(255, 255, 255, 0.18);
  --text:        #fff;
  --text-2:      rgba(255, 255, 255, 0.7);
  --text-3:      rgba(255, 255, 255, 0.4);
  --green:       #A4D233;
  --green-soft:  rgba(164, 210, 51, 0.12);
  --indigo:      #6366f1;
  --orange:      #f59e0b;
  --blue:        #3b82f6;
  --emerald:     #10b981;
  --red:         #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ── Auth gate ── */
.auth-gate {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; background: var(--bg);
  z-index: 9999;
}
.auth-gate .spinner {
  width: 36px; height: 36px;
  border: 3px solid rgba(164, 210, 51, 0.18);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.auth-gate p { color: var(--text-2); font-size: 14px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Layout shell ── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar-brand {
  padding: 22px 20px; border-bottom: 1px solid var(--border);
  font-size: 20px; font-weight: 800; color: var(--green); letter-spacing: -0.5px;
}
.sidebar-nav { flex: 1; padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar-nav button {
  text-align: left; padding: 11px 14px; border-radius: 10px;
  color: var(--text-2); font-size: 14px; font-weight: 500;
  display: flex; align-items: center; gap: 10px;
  transition: background .15s, color .15s;
}
.sidebar-nav button:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.sidebar-nav button.is-active {
  background: var(--green-soft); color: var(--green);
}
.sidebar-nav button .icon { font-size: 16px; opacity: 0.9; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 14px 12px; display: flex; flex-direction: column; gap: 6px; }
.sidebar-foot a, .sidebar-foot button {
  font-size: 13px; color: var(--text-3); padding: 8px 12px; border-radius: 8px;
  text-align: left; display: flex; align-items: center; gap: 10px;
}
.sidebar-foot a:hover, .sidebar-foot button:hover { color: var(--text); background: rgba(255,255,255,0.04); }

/* ── Main column ── */
.main { flex: 1; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; background: rgba(10,10,10,0.85); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.topbar-user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--green); color: #000; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
}
.topbar-user .meta { font-size: 13px; line-height: 1.3; text-align: right; }
.topbar-user .meta strong { display: block; color: var(--text); }
.topbar-user .meta span { color: var(--text-3); font-size: 12px; }
.topbar-user .signout {
  font-size: 13px; padding: 8px 12px; border-radius: 8px;
  background: rgba(255,255,255,0.06); color: var(--text-2);
}
.topbar-user .signout:hover { background: rgba(255,255,255,0.1); color: var(--text); }

.content { padding: 28px 24px 80px; max-width: 1200px; }

/* ── Cards / pills ── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; margin-bottom: 14px;
}
.card-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.code-pill {
  display: inline-block; padding: 4px 10px; border-radius: 8px;
  background: var(--green-soft); color: var(--green);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; font-weight: 700;
}
.status-pill {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
}
.status-Submitted { background: rgba(164,210,51,0.15); color: var(--green); }
.status-UnderReview { background: rgba(99,102,241,0.18); color: var(--indigo); }
.status-DocumentsRequested { background: rgba(245,158,11,0.18); color: var(--orange); }
.status-DocumentsReceived { background: rgba(59,130,246,0.18); color: var(--blue); }
.status-InProcessing { background: rgba(59,130,246,0.18); color: var(--blue); }
.status-Approved { background: rgba(16,185,129,0.18); color: var(--emerald); }
.status-EquipmentShipping { background: rgba(16,185,129,0.18); color: var(--emerald); }
.status-Active { background: rgba(16,185,129,0.18); color: var(--emerald); }
.status-Declined { background: rgba(239,68,68,0.18); color: var(--red); }

/* ── Pipeline stepper ── */
.pipeline {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 0; align-items: center;
  margin: 18px 0 6px; position: relative;
}
.pipeline-step { display: flex; flex-direction: column; align-items: center; gap: 6px; position: relative; }
.pipeline-step .dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: rgba(255,255,255,0.12); border: 2px solid rgba(255,255,255,0.18);
  z-index: 2; transition: all 0.2s;
}
.pipeline-step.is-done .dot { background: var(--green); border-color: var(--green); }
.pipeline-step.is-current .dot {
  background: var(--green); border-color: var(--green);
  box-shadow: 0 0 0 4px rgba(164,210,51,0.18);
}
.pipeline-step .label {
  font-size: 10px; color: var(--text-3); text-align: center; line-height: 1.2;
  position: absolute; top: 22px; width: 90px; left: 50%; transform: translateX(-50%);
}
.pipeline-step.is-done .label, .pipeline-step.is-current .label { color: var(--text-2); }
.pipeline::before {
  content: ''; position: absolute; top: 6px; left: 6%; right: 6%; height: 2px;
  background: rgba(255,255,255,0.1); z-index: 1;
}
.pipeline.has-progress::after {
  content: ''; position: absolute; top: 6px; left: 6%; height: 2px;
  background: var(--green); z-index: 1; transition: width 0.3s;
}

/* ── Application list ── */
.app-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 20px; margin-bottom: 14px; cursor: pointer; transition: border-color .15s, transform .1s;
}
.app-card:hover { border-color: var(--border-hi); }
.app-card-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-bottom: 6px;
}
.app-card-meta { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.app-card-title { font-size: 16px; font-weight: 700; }

/* ── Detail panel ── */
.detail-back {
  font-size: 13px; color: var(--text-3); padding: 6px 10px; border-radius: 6px;
  margin-bottom: 12px; display: inline-flex; align-items: center; gap: 6px;
}
.detail-back:hover { color: var(--green); }
.detail-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-bottom: 6px;
}
.detail-head h2 { font-size: 22px; font-weight: 700; }

.section-h {
  font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--text-3); margin: 24px 0 10px;
}

/* ── Stage history ── */
.timeline { display: flex; flex-direction: column; gap: 12px; }
.timeline-row {
  display: flex; gap: 12px; padding: 12px 14px;
  background: var(--surface-2); border-radius: 10px; border: 1px solid var(--border);
}
.timeline-row .when { font-size: 12px; color: var(--text-3); flex-shrink: 0; min-width: 110px; }
.timeline-row .what { font-size: 13px; color: var(--text); }
.timeline-row .what strong { color: var(--green); }

/* ── Messages ── */
.msg-thread { display: flex; flex-direction: column; gap: 10px; }
.msg {
  padding: 12px 14px; border-radius: 10px; max-width: 80%;
  font-size: 14px; line-height: 1.5; border: 1px solid var(--border);
}
.msg.from-admin { background: var(--surface-2); align-self: flex-start; }
.msg.from-client { background: var(--green-soft); border-color: rgba(164,210,51,0.25); align-self: flex-end; }
.msg .msg-meta { font-size: 11px; color: var(--text-3); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.msg .doc-badge {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  background: rgba(245,158,11,0.18); color: var(--orange);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
}
.msg.fulfilled .doc-badge {
  background: rgba(16,185,129,0.18); color: var(--emerald);
}

.reply-box {
  margin-top: 14px; padding: 14px; background: var(--surface-2); border-radius: 10px;
  border: 1px solid var(--border);
}
.reply-box textarea {
  width: 100%; min-height: 84px; padding: 10px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  font-family: inherit; font-size: 14px; resize: vertical;
}
.reply-box textarea:focus { outline: none; border-color: var(--green); }
.reply-box .actions { display: flex; gap: 10px; margin-top: 10px; }

/* ── Forms / inputs ── */
.btn-primary {
  padding: 10px 16px; border-radius: 8px; background: var(--green); color: #000;
  font-weight: 700; font-size: 14px;
}
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost {
  padding: 10px 16px; border-radius: 8px; background: rgba(255,255,255,0.06);
  color: var(--text); font-weight: 600; font-size: 14px;
}
.btn-ghost:hover { background: rgba(255,255,255,0.1); }

select, input[type="text"], input[type="search"] {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-family: inherit; font-size: 14px; padding: 10px 12px;
}
select:focus, input:focus { outline: none; border-color: var(--green); }

/* ── Admin grid + table ── */
.admin-stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  padding: 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px;
}
.stat-card .label { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.7px; margin-bottom: 4px; }
.stat-card .value { font-size: 28px; font-weight: 800; color: var(--text); }
.stat-card .value.green { color: var(--green); }
.stat-card .value.indigo { color: var(--indigo); }
.stat-card .value.orange { color: var(--orange); }
.stat-card .value.emerald { color: var(--emerald); }

.admin-toolbar {
  display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap;
}
.admin-toolbar input[type="search"] { flex: 1; min-width: 220px; }

.admin-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.admin-table th, .admin-table td {
  padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border);
}
.admin-table th {
  background: var(--surface-2); color: var(--text-3); font-weight: 600;
  text-transform: uppercase; font-size: 11px; letter-spacing: 0.6px;
}
.admin-table tr { cursor: pointer; transition: background .12s; }
.admin-table tbody tr:hover { background: rgba(164,210,51,0.04); }
.admin-table tbody tr:last-child td { border-bottom: 0; }
.admin-table .col-code { font-family: ui-monospace, Menlo, monospace; color: var(--green); white-space: nowrap; }

/* Admin detail slide-in */
.detail-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 100;
  display: none; align-items: stretch; justify-content: flex-end;
}
.detail-overlay.is-open { display: flex; }
.detail-pane {
  width: 720px; max-width: 92vw; height: 100vh; overflow-y: auto;
  background: var(--bg); border-left: 1px solid var(--border);
  padding: 24px;
}
.detail-pane .close-btn {
  position: absolute; top: 16px; right: 18px; font-size: 22px; color: var(--text-3);
  width: 32px; height: 32px; border-radius: 50%; background: rgba(255,255,255,0.05);
  display: flex; align-items: center; justify-content: center;
}
.detail-pane .close-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }

/* Empty state */
.empty {
  text-align: center; padding: 48px 24px; color: var(--text-3);
}
.empty .big { font-size: 40px; margin-bottom: 8px; }
.empty h3 { font-size: 18px; color: var(--text); margin-bottom: 4px; }
.empty p { font-size: 14px; }

/* Responsive */
@media (max-width: 880px) {
  .sidebar { display: none; }
  .main { width: 100%; }
  .pipeline { grid-template-columns: repeat(8, 1fr); }
  .pipeline-step .label { font-size: 9px; width: 70px; }
}
