/* Admin panel - shares the merchant dashboard's visual language, with admin-specific touches. */

:root {
  --bg: #f3f4f6; --panel: #ffffff; --ink: #111827; --muted: #6b7280;
  --line: #e5e7eb; --line-2: #d1d5db;
  --sidebar: #0f172a; --sidebar-ink: #cbd5e1; --sidebar-active: #ffffff;
  --primary: #2563eb; --green: #10b981; --pink: #ec4899;
  --yellow: #f59e0b; --red: #ef4444; --grey: #6b7280; --blue: #3b82f6;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.04);
}
body[data-theme=dark] {
  --bg: #0b1220; --panel: #111827; --ink: #e5e7eb; --muted: #9ca3af;
  --line: #1f2937; --line-2: #374151;
  --sidebar: #050a18; --sidebar-ink: #94a3b8; --sidebar-active: #ffffff;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primary); text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { margin-left: auto; }
.center { text-align: center; }

.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; overflow: hidden; }
.sidebar { position: sticky; top: 0; height: 100vh; align-self: start; overflow-y: auto;
  background: var(--sidebar); color: var(--sidebar-ink); padding: 16px 0; display: flex; flex-direction: column; }
.main { overflow-y: auto; display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 16px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }

/* ---- Sidebar ---- */
.brand { display: flex; align-items: center; gap: 10px; padding: 0 18px 16px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg,#f97316,#ec4899,#a855f7); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 12px; }
.brand-title { color: #fff; font-weight: 700; font-size: 16px; }
.brand-sub { color: var(--pink); font-weight: 600; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.nav { display: flex; flex-direction: column; padding: 8px 0; flex: 1; }
.nav-sec { color: #6b7280; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 18px 18px 8px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 18px; color: var(--sidebar-ink); font-size: 14px; cursor: pointer; border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,.04); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.06); color: var(--sidebar-active); border-left-color: var(--primary); }
.nav-item i[data-lucide] { width: 18px; height: 18px; stroke-width: 2; flex: 0 0 18px; }
.sidebar-foot { padding: 8px 18px; border-top: 1px solid rgba(255,255,255,.06); }

.company { font-size: 18px; font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.admin-pill { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; background: linear-gradient(135deg, #f97316, #ec4899); color: #fff; font-size: 12px; font-weight: 600; }
.admin-pill i[data-lucide] { width: 14px; height: 14px; }
.icon-btn { background: transparent; border: 1px solid var(--line); color: inherit; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.icon-btn i[data-lucide] { width: 18px; height: 18px; }

/* ---- Content ---- */
.content { padding: 24px; max-width: 100%; overflow-x: hidden; }
.crumbs { font-size: 14px; margin-bottom: 16px; color: var(--muted); }
.crumbs span:first-child { color: var(--ink); font-weight: 500; }

/* ---- Panels / cards ---- */
.panel { background: var(--panel); border-radius: 12px; padding: 24px; box-shadow: var(--shadow); margin-bottom: 16px; }
.panel h2 { margin: 0 0 16px; font-size: 18px; }
.panel h3 { margin: 18px 0 8px; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.panel input, .panel select { width: 100%; padding: 10px 12px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--panel); color: var(--ink); font: inherit; }

.cards-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.info-card { position: relative; border-radius: 16px; padding: 22px; color: #fff; min-height: 110px; box-shadow: var(--shadow); }
.info-val { font-size: 28px; font-weight: 700; line-height: 1.1; }
.info-lbl { font-size: 13px; opacity: .9; margin-top: 8px; }
.info-ic { position: absolute; right: 16px; bottom: 16px; opacity: .25; }
.info-ic i[data-lucide] { width: 36px; height: 36px; stroke-width: 1.5; }
.info-card.green { background: linear-gradient(135deg,#10b981,#059669); }
.info-card.blue  { background: linear-gradient(135deg,#3b82f6,#2563eb); }
.info-card.grey  { background: linear-gradient(135deg,#6b7280,#4b5563); }
.info-card.pink  { background: linear-gradient(135deg,#ec4899,#db2777); }

.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 24px; }
.kv-grid > div { display: flex; flex-direction: column; gap: 2px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv-grid strong { font-size: 15px; }
.kv-grid .muted { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }

/* ---- Buttons ---- */
.primary { background: var(--primary); color: #fff; border: none; padding: 10px 18px; border-radius: 8px; cursor: pointer; font: inherit; font-weight: 500; display: inline-flex; align-items: center; gap: 8px; }
.primary i[data-lucide] { width: 16px; height: 16px; }
.ghost-btn { background: transparent; border: 1px solid var(--line-2); color: inherit; padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; }
.ghost-btn.small { padding: 4px 10px; font-size: 12px; }
.danger { background: transparent; border: 1px solid var(--red); color: var(--red); padding: 8px 14px; border-radius: 8px; cursor: pointer; font: inherit; display: inline-flex; align-items: center; gap: 8px; }
.danger i[data-lucide] { width: 16px; height: 16px; }
.btn-row { display: flex; gap: 8px; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; }
table.data th { background: var(--bg); font-weight: 600; }
table.data tr.row-action:hover { background: rgba(0,0,0,.02); cursor: pointer; }

/* ---- Status pills ---- */
.pill { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 12px; }
.pill.ok { background: #d1fae5; color: #065f46; }
.pill.bad { background: #fee2e2; color: #991b1b; }
.pill.warn { background: #fef3c7; color: #92400e; }
.pill.muted { background: var(--line); color: var(--muted); }

/* ---- Filters bar ---- */
.merch-bar { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.merch-bar input { max-width: 320px; }
.filters { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.filters input, .filters select { width: auto; padding: 8px 10px; }
.paging { display: flex; gap: 8px; align-items: center; justify-content: center; padding: 16px 0 0; }

/* ---- Soon pill ---- */
.soon-pill { display: inline-block; font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; background: rgba(245, 158, 11, .15); color: #b45309; padding: 2px 6px; border-radius: 4px; margin-left: 6px; vertical-align: middle; }
.nav-item .soon-pill { margin-left: auto; padding: 1px 5px; font-size: 9px; }
body[data-theme=dark] .soon-pill { background: rgba(245, 158, 11, .2); color: #fbbf24; }

/* ---- Placeholder ---- */
.panel.placeholder { text-align: center; padding: 48px 32px; }
.placeholder-ic { width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 16px; background: var(--bg); display: grid; place-items: center; }
.placeholder-ic i[data-lucide] { width: 32px; height: 32px; color: var(--muted); }
.placeholder-list { display: inline-block; text-align: left; list-style: none; padding: 0; margin: 20px 0 0; }
.placeholder-list li { padding: 6px 0; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.placeholder-list i[data-lucide] { width: 16px; height: 16px; color: var(--green); }

/* ---- Form helpers ---- */
label { display: block; font-size: 13px; margin: 12px 0 6px; color: var(--muted); }
.form-msg { margin-top: 8px; padding: 8px 12px; border-radius: 6px; background: #fef3c7; color: #92400e; }
.form-msg.ok  { background: #d1fae5; color: #065f46; }
.form-msg.err { background: #fee2e2; color: #991b1b; }

/* ---- Login page ---- */
.login-body { background: linear-gradient(135deg, #1e3a8a 0%, #6d28d9 100%); min-height: 100vh; display: grid; place-items: center; padding: 24px; font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; }
.login-card { background: var(--panel); border-radius: 16px; padding: 36px 32px 28px; max-width: 400px; width: 100%; box-shadow: 0 20px 50px rgba(0,0,0,.25); color: var(--ink); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-brand .brand-mark { width: 40px; height: 40px; font-size: 14px; }
.login-brand .brand-title { color: var(--ink); font-size: 17px; }
.login-brand .brand-sub { color: var(--muted); font-size: 12px; letter-spacing: 0; text-transform: none; font-weight: 500; }
.login-card h1 { margin: 0 0 6px; font-size: 22px; color: var(--ink); }
.login-card p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.login-card code { background: #f3f4f6; padding: 1px 6px; border-radius: 4px; font-size: 12px; color: #111827; }
.login-card label { display: block; font-size: 12px; font-weight: 500; color: #4b5563; margin: 14px 0 6px; }
.login-card input {
  width: 100%; box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid #d1d5db; border-radius: 8px;
  font: 14px inherit; color: var(--ink);
  background: var(--panel);
  transition: border-color .12s, box-shadow .12s;
}
.login-card input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.login-card .primary {
  width: 100%; margin-top: 18px;
  padding: 10px 16px;
  background: #2563eb; color: #fff;
  border: 0; border-radius: 8px;
  font: 14px inherit; font-weight: 600;
  cursor: pointer;
  transition: background .12s;
}
.login-card .primary:hover { background: #1d4ed8; }
.login-card .form-msg { margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 13px; }
.login-card .form-msg.err { background: #fee2e2; color: #991b1b; }
.login-card .form-msg.ok  { background: #dcfce7; color: #166534; }

/* ---- Toast ---- */
.toast { position: fixed; top: 24px; right: 24px; background: #111827; color: #fff; padding: 12px 18px; border-radius: 8px; z-index: 100; box-shadow: 0 8px 20px rgba(0,0,0,.2); }

/* ---- Drawer (merchant detail) ---- */
.drawer { position: fixed; inset: 0; z-index: 50; }
.drawer-bg { position: absolute; inset: 0; background: rgba(0,0,0,.4); }
.drawer-panel { position: absolute; right: 0; top: 0; height: 100vh; width: 560px; max-width: 100vw; background: var(--panel); overflow-y: auto; box-shadow: -20px 0 60px rgba(0,0,0,.25); display: flex; flex-direction: column; }
.drawer-head { display: flex; align-items: flex-start; gap: 16px; padding: 24px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 4px 0 4px; }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-body { padding: 24px; flex: 1; }
.drawer-actions { display: flex; gap: 12px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }

/* ---- Sidebar collapse ---- */
.app.sidebar-collapsed { grid-template-columns: 64px 1fr; }
.app.sidebar-collapsed .sidebar .brand-title,
.app.sidebar-collapsed .sidebar .brand-sub,
.app.sidebar-collapsed .sidebar .nav-sec,
.app.sidebar-collapsed .sidebar .nav-item > span { display: none; }
.app.sidebar-collapsed .sidebar .nav-item { justify-content: center; padding: 12px 0; }
.app.sidebar-collapsed .sidebar .brand { justify-content: center; padding: 0 0 16px; }
.app.sidebar-collapsed .sidebar .sidebar-foot { justify-content: center; padding: 8px 0; display: flex; }

@media (max-width: 1024px) {
  .app { grid-template-columns: 0 1fr; }
  .app:not(.sidebar-collapsed) .sidebar { position: fixed; top: 0; left: 0; width: 240px; height: 100vh; z-index: 30; }
  .drawer-panel { width: 100vw; }
}

/* ---- Integration footprint ---- */
.footprint-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.fp-card { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); }
.fp-lbl { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.fp-val { font-size: 14px; color: var(--ink); word-break: break-all; }
.fp-val.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

/* Activation timeline */
.fp-timeline { display: flex; flex-direction: column; gap: 10px; }
.fp-step { display: flex; gap: 10px; align-items: flex-start; }
.fp-step strong { font-size: 13px; color: var(--ink); display: block; }
.fp-dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.fp-dot-1 { background: #6366f1; }
.fp-dot-2 { background: #06b6d4; }
.fp-dot-3 { background: #16a34a; }

/* Live/test stacked bar */
.fp-stack-bar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; background: var(--line); }
.fp-stack-bar > span { display: block; height: 100%; }
.fp-stack-legend { display: flex; gap: 16px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.fp-stack-legend .fp-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin: 0 6px -1px 0; }

/* UA-family horizontal bars */
.fp-bars { display: flex; flex-direction: column; gap: 6px; }
.fp-bar-row { display: grid; grid-template-columns: 110px 1fr 40px; gap: 8px; align-items: center; font-size: 12px; }
.fp-bar-lbl { color: var(--ink); text-transform: capitalize; }
.fp-bar-track { background: var(--line); border-radius: 4px; height: 8px; overflow: hidden; }
.fp-bar-fill { background: linear-gradient(90deg, #6366f1, #06b6d4); height: 100%; border-radius: 4px; }
.fp-bar-n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Listing of recent items */
.fp-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.fp-list.compact { gap: 4px; }
.fp-list code { background: var(--panel); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line); }

/* ---- Platform usage view ---- */
.usage-funnel { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.funnel-stage { flex: 1; min-width: 160px; padding: 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); text-align: center; }
.funnel-num { font-size: 32px; font-weight: 700; color: var(--ink); line-height: 1; }
.funnel-lbl { font-size: 12px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .04em; }
.funnel-pct { font-size: 13px; color: #16a34a; font-weight: 600; margin-top: 8px; }
.funnel-arrow { font-size: 22px; color: var(--muted); flex-shrink: 0; }
.usage-bars { display: flex; flex-direction: column; gap: 8px; }

.fp-stack { display: flex; flex-direction: column; gap: 4px; }
.fp-stack-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--line); }
.fp-stack-bar > span { display: block; height: 100%; }
.fp-stack-legend { display: flex; gap: 18px; margin-top: 8px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.fp-stack-legend .fp-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 6px -1px 0; }

/* ---- Create-merchant modal ---- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.55); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 32px 16px; }
/* Attribute selector beats the class-only rule's specificity (20 > 10), so
   setting `hidden` on the backdrop actually hides it. Without this, the
   user-agent default `[hidden] { display: none }` loses to display:flex. */
.modal-backdrop[hidden] { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 24px; width: 100%; max-width: 520px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.modal-card label { display: block; margin: 14px 0 4px; font-size: 13px; color: var(--ink); font-weight: 500; }
.modal-card input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--ink); font: inherit; box-sizing: border-box; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.merch-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
