/* ============ PAWS · Client Management — admin.css ============ */
/* v2 theme: Inter, #4183D7 → #002B5C gradient buttons, white cards on #F8FAFC,
   slate text. Also owns the auth.js .modal-overlay rules (auth.js injects the
   DOM; hide/show styles must exist HERE or the login modal stays visible). */

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  background: #F8FAFC;
  color: #1E293B;
  font-size: 14.5px;
  line-height: 1.5;
}
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12.5px; }
.hidden { display: none !important; }
.sp { flex: 1; }

/* ---------- top bar ---------- */
.ad-wrap { max-width: 1080px; margin: 0 auto; padding: 20px 22px 60px; }
.ad-top { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid #E2E8F0; position: sticky; top: 0; background: #F8FAFC; z-index: 40; }
.ad-top h1 { font-size: 21px; font-weight: 800; color: #0F172A; letter-spacing: -0.3px; }
.ad-top .sub { font-size: 12.5px; color: #64748B; margin-top: 2px; }
.bck { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 10px; background: #fff; border: 1px solid #E2E8F0; color: #334155; text-decoration: none; font-size: 18px; font-weight: 700; }
.bck:hover { background: #F1F5F9; }
#authArea { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* ---------- gate ---------- */
.ad-gate { display: flex; justify-content: center; padding: 70px 0; }
.gate-card { background: #fff; border: 1px solid #E2E8F0; border-radius: 18px; padding: 40px 46px; text-align: center; max-width: 420px; box-shadow: 0 8px 30px rgba(15,23,42,.04); }
.gate-ic { font-size: 34px; margin-bottom: 12px; }
.gate-card h3 { font-size: 18px; font-weight: 800; color: #0F172A; margin-bottom: 8px; }
.gate-card p { color: #64748B; font-size: 13.5px; margin-bottom: 20px; }

/* ---------- stats strip ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin: 18px 0 8px; }
.stat { background: #fff; border: 1px solid #E2E8F0; border-radius: 14px; padding: 14px 16px; }
.stat b { display: block; font-size: 24px; font-weight: 800; color: #0F172A; letter-spacing: -0.5px; }
.stat span { font-size: 12px; color: #64748B; font-weight: 600; }

/* ---------- bar + table ---------- */
.ad-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin: 22px 0 12px; flex-wrap: wrap; }
.ad-bar h2 { font-size: 16px; font-weight: 800; color: #0F172A; }
.ad-bar-r { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.hint { font-size: 12px; color: #94A3B8; max-width: 460px; }
.cnt { color: #94A3B8; font-weight: 700; font-size: 13px; }

.ad-table { background: #fff; border: 1px solid #E2E8F0; border-radius: 16px; overflow: hidden; }
.tr { display: grid; grid-template-columns: minmax(190px, 1.6fr) 110px 90px 76px 64px 130px 92px 130px; gap: 10px; align-items: center; padding: 13px 16px; border-bottom: 1px solid #F1F5F9; }
.tr.head { background: #F8FAFC; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: #64748B; padding-top: 10px; padding-bottom: 10px; }
.tr:last-child { border-bottom: none; }
.tr.row:hover { background: #F8FAFC; }
.t-name b { font-size: 14px; color: #0F172A; display: block; }
.t-name .mono { color: #64748B; }
.t-cell { font-size: 13px; color: #334155; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.owners-cell { font-size: 12px; color: #64748B; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: #F1F5F9; color: #475569; }
.badge .dot { width: 7px; height: 7px; border-radius: 50%; background: #94A3B8; }
.badge.active { background: #ECFDF5; color: #047857; }
.badge.active .dot { background: #10B981; }
.badge.paused { background: #FEF3C7; color: #B45309; }
.badge.paused .dot { background: #F59E0B; }
.badge.draft { background: #F1F5F9; color: #64748B; }
.badge.soft { background: #EFF6FF; color: #2563EB; }
.badge.pro { background: #FEF3C7; color: #B45309; }
.badge.free { background: #F1F5F9; color: #475569; }

/* ---------- buttons (v2 gradient) ---------- */
.btn-p { font-family: inherit; font-size: 13px; font-weight: 700; color: #fff; background: linear-gradient(135deg, #4183D7, #002B5C); border: none; border-radius: 10px; padding: 9px 18px; cursor: pointer; box-shadow: 0 2px 8px rgba(2,43,92,.22); transition: opacity .15s, transform .05s; }
.btn-p:hover { opacity: .92; }
.btn-p:active { transform: translateY(1px); }
.btn-p.xs { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-p:disabled { opacity: .5; cursor: not-allowed; }
.btn-s { font-family: inherit; font-size: 12.5px; font-weight: 600; color: #334155; background: #fff; border: 1px solid #E2E8F0; border-radius: 9px; padding: 7px 13px; cursor: pointer; }
.btn-s:hover { background: #F1F5F9; }
.btn-s.xs { padding: 5px 10px; font-size: 12px; }
.btn-danger { font-family: inherit; font-size: 13px; font-weight: 700; color: #DC2626; background: #FEF2F2; border: 1px solid #FECACA; border-radius: 10px; padding: 8px 16px; cursor: pointer; }
.btn-danger:hover { background: #FEE2E2; }

/* ---------- detail drawer ---------- */
.ad-detail { background: #fff; border: 1px solid #E2E8F0; border-radius: 16px; padding: 18px 20px 22px; margin-top: 18px; }
.dt-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.dt-head h2 { font-size: 17px; font-weight: 800; color: #0F172A; }
.dt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 860px) { .dt-grid { grid-template-columns: 1fr; } .stats { grid-template-columns: repeat(2,1fr); } }
.pane { background: #F8FAFC; border: 1px solid #E2E8F0; border-radius: 13px; overflow: hidden; }
.pane-h { display: flex; align-items: baseline; gap: 8px; padding: 12px 15px 0; }
.pane-h .tt { font-size: 13.5px; font-weight: 800; color: #0F172A; }
.pane-h .sub { font-size: 12px; color: #94A3B8; }
.pane-body { padding: 12px 15px 15px; }
.agent-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ava { width: 38px; height: 38px; border-radius: 11px; background: linear-gradient(135deg, #4183D7, #002B5C); color: #fff; font-weight: 800; font-size: 17px; display: inline-flex; align-items: center; justify-content: center; }
.who { flex: 1; min-width: 0; }
.who b { display: block; font-size: 14.5px; color: #0F172A; }
.who span { font-size: 12.5px; color: #64748B; }

.field { margin-top: 10px; }
.field label { display: block; font-size: 11.5px; font-weight: 700; color: #64748B; margin-bottom: 5px; text-transform: uppercase; letter-spacing: .3px; }
.field input, .field textarea, .field select { width: 100%; font-family: inherit; font-size: 13.5px; color: #1E293B; background: #fff; border: 1px solid #E2E8F0; border-radius: 9px; padding: 8px 11px; outline: none; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: #4183D7; box-shadow: 0 0 0 3px rgba(65,131,215,.14); }
.field textarea { resize: vertical; }
.row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.row.right { justify-content: flex-end; }
.mini-msg { font-size: 12px; color: #64748B; }
.mini-msg.ok { color: #059669; }
.mini-msg.err { color: #DC2626; }

.owners { display: flex; flex-direction: column; gap: 6px; }
.owner { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid #E2E8F0; border-radius: 9px; padding: 7px 11px; font-size: 13px; }
.owner .email { font-weight: 600; color: #1E293B; }
.owner .role { font-size: 10.5px; font-weight: 700; color: #2563EB; background: #EFF6FF; border-radius: 999px; padding: 2px 8px; text-transform: uppercase; }
.empty { color: #94A3B8; font-size: 13px; padding: 6px 0; }

.kb-admin { display: flex; flex-direction: column; gap: 7px; max-height: 300px; overflow-y: auto; }
.kb-item { background: #fff; border: 1px solid #E2E8F0; border-radius: 9px; padding: 9px 11px; }
.kb-item .k-top { display: flex; align-items: center; gap: 8px; }
.kb-item .k-title { font-weight: 700; font-size: 13px; color: #0F172A; flex: 1; }
.kb-item .k-cat { font-size: 10px; font-weight: 700; color: #64748B; background: #F1F5F9; border-radius: 999px; padding: 2px 8px; }
.kb-item .k-del { border: none; background: none; color: #94A3B8; font-size: 15px; cursor: pointer; padding: 2px 5px; border-radius: 6px; }
.kb-item .k-del:hover { color: #DC2626; background: #FEF2F2; }
.kb-item .k-content { font-size: 12.5px; color: #475569; margin-top: 4px; }

.dt-danger { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding-top: 14px; border-top: 1px solid #F1F5F9; flex-wrap: wrap; }

/* ---------- modal (auth.js uses .modal-overlay too — MUST stay here) ---------- */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(15,23,42,.55); backdrop-filter: blur(3px); z-index: 80; align-items: flex-start; justify-content: center; padding: 8vh 18px 18px; overflow-y: auto; }
.modal-overlay.open { display: flex; }
body.modal-open { overflow: hidden; }
.modal-card { background: #fff; border-radius: 18px; padding: 24px 26px; width: 100%; max-width: 470px; box-shadow: 0 24px 70px rgba(15,23,42,.3); }
.modal-card h3 { font-size: 17px; font-weight: 800; color: #0F172A; margin-bottom: 6px; }
.modal-card p { font-size: 13px; color: #475569; margin-bottom: 4px; }
.modal-card p.sub { color: #94A3B8; font-size: 12.5px; margin-bottom: 12px; }
.modal-card.danger { border-top: 4px solid #DC2626; }
.modal-card .field input, .modal-card .field textarea, .modal-card .field select { margin-bottom: 2px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#delConfirm { width: 100%; font-family: inherit; font-size: 13.5px; border: 1px solid #E2E8F0; border-radius: 9px; padding: 9px 12px; outline: none; margin-top: 10px; }
#delConfirm:focus { border-color: #DC2626; box-shadow: 0 0 0 3px rgba(220,38,38,.12); }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(80px); background: #0F172A; color: #fff; font-size: 13px; font-weight: 600; padding: 11px 20px; border-radius: 12px; box-shadow: 0 10px 30px rgba(15,23,42,.35); opacity: 0; transition: all .25s; z-index: 120; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* row action buttons */
.act { display: flex; gap: 6px; justify-content: flex-end; }
.act .btn-s { padding: 4px 9px; font-size: 11.5px; }

/* ---------- signups table ---------- */
.tr.u { grid-template-columns: minmax(200px, 1.4fr) minmax(150px, 1fr) minmax(150px, 1.1fr) 90px 105px; }
.u .t-name b { font-size: 13.5px; }
.u .t-name .mono { font-size: 12px; }
.u-title { display: block; font-size: 11.5px; color: #64748B; margin-top: 1px; }
.u-web { font-size: 11.5px; color: #94A3B8; }
.role-pill { font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 2px 9px; text-transform: uppercase; }
.role-pill.owner { color: #2563EB; background: #EFF6FF; }
.role-pill.member { color: #047857; background: #ECFDF5; }
.role-pill.none { color: #94A3B8; background: #F1F5F9; }

/* ============ mobile (≤ 860px: tables → stacked cards) ============ */
@media (max-width: 860px) {
  /* each logical row becomes a card; header row hidden; labels come from data-l */
  .ad-table { background: transparent; border: none; border-radius: 0; overflow: visible; }
  .ad-table .tr.head { display: none; }
  .ad-table .tr { grid-template-columns: 1fr; gap: 6px; padding: 14px; margin-bottom: 10px; background: #fff; border: 1px solid #E2E8F0; border-radius: 14px; }
  .ad-table .tr .t-cell, .ad-table .tr .owners-cell { white-space: normal; overflow: visible; text-overflow: clip; }
  .ad-table .tr [data-l]::before { content: attr(data-l); display: block; font-size: 10px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: #94A3B8; margin-bottom: 2px; }
  .ad-table .tr .t-name b { font-size: 15px; }
  .ad-table .tr .act { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-top: 4px; }
  .ad-table .tr .act .btn-s { width: 100%; padding: 9px 6px; font-size: 12px; text-align: center; }
}

/* ============ mobile small (≤ 480px: spacing, modals, top bar) ============ */
@media (max-width: 480px) {
  .ad-wrap { padding: 12px 12px 44px; }
  .ad-top { gap: 8px; flex-wrap: wrap; }
  .ad-top h1 { font-size: 17px; }
  #authArea { gap: 6px; }
  .ad-gate { padding: 40px 0; }
  .gate-card { padding: 28px 20px; }
  .stat { padding: 11px 13px; }
  .stat b { font-size: 20px; }
  .ad-bar { align-items: stretch; }
  .ad-bar-r { width: 100%; align-items: stretch; }
  .ad-bar-r .btn-p { width: 100%; }
  .ad-detail { padding: 14px; }
  .pane-h { padding: 10px 12px 0; }
  .pane-body { padding: 10px 12px 12px; }
  .dt-head h2 { font-size: 16px; }
  /* 16px inputs → no iOS auto-zoom on focus */
  .field input, .field textarea, .field select, #delConfirm { font-size: 16px; }
  .row { flex-wrap: wrap; }
  .grid2 { grid-template-columns: 1fr; }
  .modal-overlay { padding: 3vh 12px 12px; }
  .modal-card { padding: 20px 16px; }
  .dt-danger { align-items: flex-start; }
  .dt-danger .btn-danger { width: 100%; }
  #_paws_auth_gate > div { padding: 32px 22px !important; }
  .toast { bottom: 16px; font-size: 12.5px; }
}