/* Admin dashboard */
html, body { height: 100%; }
body { background: var(--bg); }
.adm { display: grid; grid-template-columns: 248px 1fr; min-height: 100dvh; }
.adm-side {
  position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 4px; padding: 20px 14px;
  background: var(--glass); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-right: 1px solid var(--line);
}
.adm-brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.adm-brand img { height: 24px; width: auto; }
.adm-brand .badge { margin-left: auto; }
.adm-nav { display: flex; flex-direction: column; gap: 2px; }
.adm-nav button {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border: 0; border-radius: 10px; background: none;
  color: var(--muted); font-size: 14.5px; font-weight: 500; text-align: left; transition: background .2s, color .2s;
}
.adm-nav button:hover { background: var(--surface2); color: var(--fg); }
.adm-nav button.on { background: var(--surface); color: var(--fg); box-shadow: var(--shadow), inset 0 0 0 1px var(--line); }
.adm-nav button svg { width: 18px; height: 18px; }
.adm-nav .count { margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 980px; background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700; text-align: center; }
.adm-nav .count:empty { display: none; }
.adm-side .grow { flex: 1; }
.adm-me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px; font-size: 13px; }
.adm-me .avatar-btn { width: 32px; height: 32px; font-size: 12px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-weight: 700; flex: none; }
.adm-me div { min-width: 0; flex: 1; }
.adm-me b, .adm-me span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adm-me span { color: var(--muted); }

.adm-main { min-width: 0; padding: 28px clamp(16px, 3vw, 40px) 60px; }
.adm-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.adm-head h1 { margin: 0; font: 700 32px/1.1 var(--display); letter-spacing: -.035em; }
.adm-head p { margin: 4px 0 0; color: var(--muted); font-size: 14.5px; }
.adm-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.adm-section { animation: rise .55s var(--ease-out); }

@media (max-width: 900px) {
  .adm { grid-template-columns: 1fr; }
  .adm-side { position: sticky; z-index: 10; height: auto; flex-direction: row; align-items: center; padding: 10px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
  .adm-side::-webkit-scrollbar { display: none; }
  .adm-brand { padding: 0 8px 0 0; }
  .adm-brand .badge, .adm-side .grow, .adm-me { display: none; }
  .adm-nav { flex-direction: row; }
  .adm-nav button { white-space: nowrap; padding: 8px 12px; }
  .adm-nav button svg { display: none; }
}

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border-radius: 18px; padding: 16px 18px; box-shadow: var(--shadow), inset 0 0 0 1px var(--line); transition: transform .5s var(--spring); }
.kpi:hover { transform: translateY(-2px); }
.kpi .k-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.kpi .k-label i { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.kpi .k-val { display: block; margin-top: 8px; font: 700 30px/1.1 var(--display); letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.kpi .k-sub { font-size: 12.5px; color: var(--faint); }
.kpi.click { cursor: pointer; }

.grid2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-top: 16px; }
@media (max-width: 1100px) { .grid2 { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow), inset 0 0 0 1px var(--line); padding: 18px 20px; min-width: 0; }
.panel h2 { margin: 0 0 14px; font-size: 16px; font-weight: 600; letter-spacing: -.015em; display: flex; align-items: center; gap: 10px; }
.panel h2 .grow { flex: 1; }
.panel h2 .legend-dots { display: flex; gap: 12px; font-size: 12px; color: var(--muted); font-weight: 500; }
.legend-dots span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dots i { width: 8px; height: 8px; border-radius: 2px; }

/* bar chart */
.chart { width: 100%; height: 200px; display: block; }
.chart .bar { transition: opacity .2s; transform-origin: bottom; transform-box: fill-box; animation: grow .9s var(--ease-out) both; }
.chart .bar:hover { opacity: .75; }
@keyframes grow { from { transform: scaleY(0); } }
.chart text { font-size: 10px; fill: var(--faint); font-family: var(--font); }
.chart .grid-line { stroke: var(--line); }

.mini-list { display: flex; flex-direction: column; }
.mini-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border: 0; background: none; width: 100%; text-align: left; font-size: 14px; }
.mini-row + .mini-row { border-top: 1px solid var(--line); }
.mini-row .grow { flex: 1; min-width: 0; }
.mini-row .grow b, .mini-row .grow span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .grow span { color: var(--muted); font-size: 12.5px; }
.av { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; flex: none; background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.av.g2 { background: linear-gradient(135deg, #30D158, #0E7C86); }
.av.g3 { background: linear-gradient(135deg, #FF9F0A, #FF375F); }
.av.g4 { background: linear-gradient(135deg, #BF5AF2, #5E5CE6); }

/* filters */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search { position: relative; flex: 1; min-width: 220px; max-width: 380px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: var(--faint); }
.toolbar .search input, .search input { width: 100%; padding-left: 38px; font-size: 14.5px; padding-top: 10px; padding-bottom: 10px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filter { border: 0; border-radius: 980px; padding: 7px 13px; font-size: 13px; font-weight: 500; background: var(--surface); color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); transition: all .25s var(--ease); }
.filter:hover { color: var(--fg); }
.filter.on { background: var(--fg); color: var(--bg); box-shadow: none; }
.toolbar .field { width: auto; padding: 9px 12px; font-size: 14px; }
.toolbar .seg { min-width: 300px; }

/* tables */
.table-wrap { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow), inset 0 0 0 1px var(--line); overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
.t th { position: sticky; top: 0; text-align: left; font-weight: 500; font-size: 12.5px; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--surface); }
.t th.sortable { cursor: pointer; user-select: none; }
.t th.sortable:hover { color: var(--fg); }
.t th .arr { display: inline-block; margin-left: 4px; opacity: 0; transition: transform .3s var(--spring), opacity .2s; }
.t th.sorted .arr { opacity: 1; }
.t th.sorted.asc .arr { transform: rotate(180deg); }
.t td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.t tr:last-child td { border-bottom: 0; }
.t tbody tr { transition: background .15s; animation: fade .4s var(--ease) both; }
.t tbody tr.click { cursor: pointer; }
.t tbody tr.click:hover { background: color-mix(in srgb, var(--fg) 3.5%, transparent); }
.t .num, .t td.r, .t th.r { text-align: right; font-variant-numeric: tabular-nums; }
.t .who { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.t .who > div:last-child b { display: block; font-weight: 600; }
.t .who > div:last-child span { display: block; color: var(--muted); font-size: 12.5px; }
.t .empty-row td { text-align: center; color: var(--muted); padding: 40px; }
.share { display: inline-block; width: 80px; height: 6px; border-radius: 3px; background: var(--surface2); vertical-align: middle; margin-left: 10px; overflow: hidden; }
.share i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.pager { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 4px 0; font-size: 13px; color: var(--muted); }
.pager div { display: flex; gap: 8px; }
.totals { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.totals div { background: var(--surface); border-radius: 14px; padding: 10px 16px; box-shadow: inset 0 0 0 1px var(--line); font-size: 13px; color: var(--muted); }
.totals b { display: block; color: var(--fg); font-size: 18px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* duplicate-account cards */
.match { display: grid; grid-template-columns: 1fr auto 1fr auto; align-items: center; gap: 16px; padding: 16px 18px; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow), inset 0 0 0 1px var(--line); margin-bottom: 10px; animation: rise .5s var(--ease-out) both; }
.match .person { display: flex; align-items: center; gap: 12px; min-width: 0; border: 0; background: none; text-align: left; padding: 6px; border-radius: 12px; transition: background .2s; }
.match .person:hover { background: var(--surface2); }
.match .person div { min-width: 0; }
.match .person > div:last-child b, .match .person > div:last-child span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.match .person > div:last-child span { font-size: 12.5px; color: var(--muted); }
.match .link-mid { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.match .reasons { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.score { --s: 50; width: 64px; height: 6px; border-radius: 3px; background: var(--surface2); overflow: hidden; }
.score i { display: block; height: 100%; width: calc(var(--s) * 1%); background: linear-gradient(90deg, var(--amber), var(--red)); border-radius: 3px; }
.match .acts { display: flex; flex-direction: column; gap: 6px; }
@media (max-width: 800px) { .match { grid-template-columns: 1fr; } .match .link-mid { flex-direction: row; } .match .acts { flex-direction: row; } }

/* user drawer */
.drawer { position: fixed; inset: 0; z-index: 30; background: var(--scrim); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .3s var(--ease); }
.drawer.closing { animation: fade-out .3s var(--ease) forwards; }
.drawer-page {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--bg); box-shadow: var(--shadow-float);
  display: flex; flex-direction: column; animation: slide-in .55s var(--spring);
}
.drawer.closing .drawer-page { animation: slide-out .3s var(--ease) forwards; }
@keyframes slide-in { from { transform: translateX(100%); } }
@keyframes slide-out { to { transform: translateX(100%); } }
.drawer-head { display: flex; align-items: center; gap: 14px; padding: 18px 20px 12px; }
.drawer-head .av { width: 52px; height: 52px; font-size: 17px; }
.drawer-head .who { flex: 1; min-width: 0; }
.drawer-head h2 { margin: 0; font: 700 22px/1.2 var(--display); letter-spacing: -.025em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-head .sub2 { color: var(--muted); font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer-badges { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 20px 12px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 0 20px 40px; }
.dstats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 14px; }
.dstats div { background: var(--surface); border-radius: 14px; padding: 10px 12px; }
.dstats b { display: block; font: 700 19px/1.2 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.dstats span { font-size: 11.5px; color: var(--muted); }
@media (max-width: 520px) { .dstats { grid-template-columns: 1fr 1fr; } }
.dactions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; font-size: 13.5px; background: var(--surface); border-radius: 14px; padding: 14px 16px; margin-bottom: 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.drawer .seg { margin-bottom: 12px; }
.dlist { background: var(--surface); border-radius: 14px; overflow: hidden; }
.dlist .t td, .dlist .t th { padding: 9px 12px; font-size: 13px; }
.dempty { padding: 28px; text-align: center; color: var(--muted); font-size: 14px; background: var(--surface); border-radius: 14px; }
.denied { min-height: 100dvh; display: grid; place-items: center; text-align: center; padding: 20px; }
.denied h1 { font: 700 28px/1.2 var(--display); letter-spacing: -.03em; margin: 0 0 8px; }
.denied p { color: var(--muted); margin: 0 0 20px; }

/* admin sign in */
.adm-login { min-height: 100dvh; display: grid; place-items: center; padding: 32px 16px; position: relative; overflow: hidden; }
.adm-login::before {
  content: ""; position: absolute; inset: -30%; z-index: -1;
  background: radial-gradient(35% 30% at 30% 25%, color-mix(in srgb, var(--accent-2) 20%, transparent), transparent 70%),
              radial-gradient(30% 30% at 70% 75%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%);
  animation: drift 18s var(--ease) infinite alternate;
}
@keyframes drift { to { transform: translate(4%, -3%) rotate(6deg); } }
.adm-login-card {
  width: 100%; max-width: 400px; padding: 34px 28px 26px; border-radius: var(--r-xl); border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: var(--shadow-float);
  -webkit-backdrop-filter: blur(30px) saturate(160%); backdrop-filter: blur(30px) saturate(160%); animation: pop-in .7s var(--spring);
}
.adm-login-top { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 22px; }
.adm-login-top img { height: 28px; width: auto; display: block; }
.adm-login-card h1 { margin: 0; text-align: center; font: 700 26px/1.2 var(--display); letter-spacing: -.03em; }
.adm-login-card > p { margin: 4px 0 24px; text-align: center; }
.adm-login .form .btn { margin-top: 6px; padding: 14px; font-size: 16px; }
.adm-me .btn { padding: 4px 8px; font-size: 12.5px; }
