/* Moco admin console.
 *
 * Internal operations tool: density and unambiguous state first. It uses the
 * Moco dark palette (plum ground, rose accent, copper/amber for money) so it
 * reads as part of the product, but surfaces stay flat and high-contrast —
 * an operator scanning a KYC queue needs to read rows, not admire glass.
 */

:root {
  --bg: #120a12;
  --bg-raised: #1c0f18;
  --bg-panel: #22121d;
  --bg-hover: #2a1622;
  --bg-input: #170c14;
  --border: #3a2132;
  --border-strong: #55304a;

  --text: #f5e8e8;
  --text-dim: #d8c2cc;
  --text-faint: #9c8492;

  --rose: #e54f9a;
  --rose-700: #b93e77;
  --rose-dim: rgba(229, 79, 154, 0.14);
  --copper: #f29a6e;
  --amber: #f6a23c;
  --amber-dim: rgba(246, 162, 60, 0.14);
  --plum: #5a1f3e;

  --green: #35e98a;
  --green-dim: rgba(53, 233, 138, 0.13);
  --red: #f2555a;
  --red-dim: rgba(242, 85, 90, 0.14);
  --blue: #7fb2ff;
  --blue-dim: rgba(127, 178, 255, 0.13);

  --radius: 10px;
  --font: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--rose); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 12px; }

/* ---------- Brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px;
  background: linear-gradient(135deg, var(--rose-700), var(--rose) 55%, var(--copper));
  display: grid; place-items: center; font-weight: 800; color: #fff;
}
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: -0.2px; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, rgba(185,62,119,.25), transparent 60%), var(--bg); }
.login-card { width: 100%; max-width: 380px; background: var(--bg-raised);
  border: 1px solid var(--border); border-radius: 16px; padding: 30px; }
.login-sub { color: var(--text-dim); margin: 10px 0 20px; }
.hint { color: var(--text-faint); font-size: 12px; margin-top: 14px; }

/* ---------- Form controls ---------- */
label { display: block; font-size: 12px; color: var(--text-dim); margin: 0 0 5px; font-weight: 600; }
input, select, textarea {
  width: 100%; background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px;
  font: inherit; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--rose); box-shadow: 0 0 0 3px var(--rose-dim); }
textarea { resize: vertical; min-height: 70px; }
.field { margin-bottom: 12px; }
.field .help { color: var(--text-faint); font-size: 11.5px; margin-top: 4px; }

button { font: inherit; cursor: pointer; }
.btn, .btn-primary, .btn-ghost, .btn-danger, .btn-ok {
  border-radius: 8px; padding: 7px 13px; border: 1px solid transparent; font-weight: 600;
  white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn-primary { background: linear-gradient(90deg, var(--rose-700), var(--rose)); color: #fff; width: 100%; padding: 10px; margin-top: 4px; }
.btn-primary.inline { width: auto; padding: 7px 13px; margin: 0; }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-danger { background: var(--red-dim); color: var(--red); border-color: rgba(242,85,90,.35); }
.btn-danger:hover { background: rgba(242,85,90,.24); }
.btn-ok { background: var(--green-dim); color: var(--green); border-color: rgba(53,233,138,.3); }
.btn-ok:hover { background: rgba(53,233,138,.22); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.error-msg { background: var(--red-dim); color: var(--red); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; font-size: 12.5px; }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 208px 1fr; height: 100vh; }
.sidebar { background: var(--bg-raised); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 16px 10px; overflow-y: auto; }
.sidebar .brand { padding: 0 6px 16px; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-group { color: var(--text-faint); font-size: 10.5px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; margin: 12px 8px 4px; }
.nav-item { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: transparent; border: 0; color: var(--text-dim); text-align: left;
  padding: 7px 10px; border-radius: 8px; font-weight: 500; }
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--rose-dim); color: var(--text); box-shadow: inset 2px 0 0 var(--rose); }
.nav-count { background: var(--rose); color: #fff; font-size: 10.5px; font-weight: 700;
  border-radius: 99px; padding: 0 6px; min-width: 18px; text-align: center; }
.nav-count[data-count="0"] { display: none; }
.sidebar-foot { border-top: 1px solid var(--border); padding: 12px 6px 0; margin-top: 12px;
  color: var(--text-faint); font-size: 12px; }
.sidebar-foot strong { color: var(--text-dim); display: block; font-family: var(--mono); font-size: 12px; }

main { overflow-y: auto; padding: 20px 24px 40px; min-width: 0; }
.view-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.view-head h1 { font-size: 20px; margin: 0; letter-spacing: -0.3px; }
.view-sub { color: var(--text-faint); margin: 3px 0 0; font-size: 12.5px; max-width: 760px; }
.view-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Stat cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.stat { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stat-label { color: var(--text-faint); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 22px; font-weight: 700; margin-top: 2px; letter-spacing: -0.4px; }
.stat-value.money { color: var(--amber); }
.stat.attn { border-color: rgba(229,79,154,.45); background: linear-gradient(180deg, var(--rose-dim), var(--bg-raised)); }
.stat.clickable { cursor: pointer; }
.stat.clickable:hover { border-color: var(--border-strong); }
.section-title { font-size: 13px; color: var(--text-dim); font-weight: 700; margin: 22px 0 10px; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Data table ---------- */
.dt { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.dt-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; border-bottom: 1px solid var(--border); }
.dt-toolbar input[type=search] { width: 230px; }
.dt-toolbar select, .dt-toolbar input[type=date] { width: auto; padding: 6px 8px; font-size: 12.5px; }
.dt-toolbar .dt-total { margin-left: auto; color: var(--text-faint); font-size: 12px; }
.dt-scroll { overflow: auto; max-height: calc(100vh - 230px); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { position: sticky; top: 0; z-index: 1; background: var(--bg-panel); color: var(--text-faint);
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--text); }
th .arrow { color: var(--rose); margin-left: 3px; }
tbody tr { transition: background .1s; }
tbody tr.clickable { cursor: pointer; }
tbody tr:hover { background: var(--bg-hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* The row actions column stays on screen even when a wide table scrolls sideways. */
th.col-pin, td.col-pin { position: sticky; right: 0; background: var(--bg-panel); box-shadow: -8px 0 8px -8px rgba(0,0,0,.6); }
th.col-pin { z-index: 2; }
tbody tr:hover td.col-pin { background: var(--bg-hover); }
td .sub { display: block; color: var(--text-faint); font-size: 11.5px; }
.dt-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; color: var(--text-faint); font-size: 12px; }
.dt-foot .pager { display: flex; align-items: center; gap: 6px; }
.dt-foot select { width: auto; padding: 4px 6px; font-size: 12px; }
.dt-loading { opacity: .55; pointer-events: none; }
.empty { padding: 34px 16px; text-align: center; color: var(--text-faint); }
.empty-mark { font-size: 22px; margin-bottom: 6px; }

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 700; white-space: nowrap; border: 1px solid transparent; text-transform: capitalize; }
.b-green { background: var(--green-dim); color: var(--green); }
.b-red { background: var(--red-dim); color: var(--red); }
.b-amber { background: var(--amber-dim); color: var(--amber); }
.b-rose { background: var(--rose-dim); color: var(--rose); }
.b-blue { background: var(--blue-dim); color: var(--blue); }
.b-grey { background: rgba(255,255,255,.06); color: var(--text-faint); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot.off { background: var(--text-faint); }
.money { color: var(--amber); font-variant-numeric: tabular-nums; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* ---------- Drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(5,2,5,.55); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 96vw); z-index: 41;
  background: var(--bg-raised); border-left: 1px solid var(--border-strong);
  display: flex; flex-direction: column; box-shadow: -20px 0 50px rgba(0,0,0,.45); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 18px; border-bottom: 1px solid var(--border); }
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-body { overflow-y: auto; padding: 16px 18px 30px; }
.drawer-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

.kv { display: grid; grid-template-columns: 150px 1fr; gap: 6px 14px; margin-bottom: 8px; }
.kv dt { color: var(--text-faint); font-size: 12px; }
.kv dd { margin: 0; word-break: break-word; }
.panel { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 12px; }
.panel h3 { margin: 0 0 10px; font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
.panel table th { position: static; background: transparent; }
.panel table td, .panel table th { padding: 6px 8px; }
.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 900px) { .cols-2 { grid-template-columns: 1fr; } .shell { grid-template-columns: 1fr; } .sidebar { display: none; } }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photo-grid a, .photo-grid .ph { display: block; aspect-ratio: 1; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--bg-input); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-cell { display: flex; flex-direction: column; gap: 6px; }
.photo-cell .btn-sm { width: 100%; }
.thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border); display: block; background: var(--bg-input); }
.thumbs { display: flex; gap: 4px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--text-faint); font-size: 11.5px; }
.blockers { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Dialog ---------- */
/* Dialog layout. The overlay is a fixed full-viewport flex box and the
   dialog centres with margin:auto — "safe" centring: when the dialog fits it
   is centred, when it does not it starts at the top edge instead of being
   pushed above/left of the viewport (which grid place-items:center does, and
   a fixed overlay cannot be scrolled to reach). Width and height come from
   the viewport, never from content; the body scrolls inside the dialog and
   the header and the Cancel/Confirm footer always stay visible. */
.modal-backdrop {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0;
  z-index: 60; background: rgba(5,2,5,.65);
  display: flex; padding: 16px;
  overflow: auto; overscroll-behavior: contain;
}
.modal {
  margin: auto;
  width: min(460px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  background: var(--bg-raised); border: 1px solid var(--border-strong); border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,.5); overflow: hidden;
}
.modal.wide { width: min(860px, calc(100vw - 32px)); }
.modal-form { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; margin: 0; }
.modal-head { padding: 18px 20px 6px; flex: 0 0 auto; }
.modal-body { padding: 6px 20px 14px; overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.modal h3 { margin: 0; font-size: 16px; }
.modal p, .modal .modal-msg { color: var(--text-dim); margin: 0 0 14px; }
.del-warn { color: var(--red); display: block; margin-bottom: 8px; }
.del-cols { display: grid; gap: 10px; }
@media (min-width: 760px) { .del-cols { grid-template-columns: repeat(3, 1fr); } }
.del-cols h4, .panel h4 { margin: 10px 0 4px; font-size: 12.5px; color: var(--text); }
.del-list { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.6; }
.upload-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 6px; }
.upload-tile { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; max-width: 170px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex: 0 0 auto;
  padding: 12px 20px; border-top: 1px solid var(--border); background: var(--bg-raised); }

/* ---------- Health ---------- */
.health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.health { background: var(--bg-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.health .h-title { display: flex; align-items: center; justify-content: space-between; font-weight: 700; margin-bottom: 6px; }
.health .h-detail { color: var(--text-faint); font-size: 12px; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 80;
  background: var(--bg-panel); border: 1px solid rgba(53,233,138,.4); color: var(--text);
  padding: 9px 16px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.bad { border-color: rgba(242,85,90,.5); }

/* ---------- Settings: login background ---------- */
.lb-grid { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 22px; align-items: start; }
@media (max-width: 760px) { .lb-grid { grid-template-columns: 1fr; } }
.lb-types { display: flex; gap: 8px; margin: 10px 0 14px; flex-wrap: wrap; }
.lb-type { display: flex; align-items: center; gap: 6px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 999px; cursor: pointer; font-weight: 500; }
.lb-type input { width: auto; margin: 0; }
.lb-type:has(input:checked) { border-color: var(--rose); color: var(--text); background: var(--bg-hover); }
.lb-actions { display: flex; gap: 8px; align-items: center; margin: 6px 0 8px; flex-wrap: wrap; }
.lb-phone { position: relative; width: 220px; aspect-ratio: 9 / 19.5; border-radius: 26px; overflow: hidden; border: 1px solid var(--border-strong); background: #170c14; }
.lb-media, .lb-media img, .lb-media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.lb-default { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-faint); font-size: 11px; background: radial-gradient(circle at 30% 20%, #3a1a33, #120a10 70%); }
.lb-overlay { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.05) 35%, rgba(0,0,0,.55) 100%); }
.lb-mock { position: absolute; left: 14px; right: 14px; bottom: 26%; display: flex; flex-direction: column; align-items: center; gap: 9px; }
.lb-mock-toggle { display: flex; width: 100%; border-radius: 999px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); padding: 3px; font-size: 9px; color: #fff; }
.lb-mock-toggle span { flex: 1; text-align: center; padding: 4px 0; border-radius: 999px; }
.lb-mock-toggle span:first-child { background: rgba(255,255,255,.22); font-weight: 700; }
.lb-mock-input { width: 100%; border-radius: 14px; background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.22); padding: 8px 10px; font-size: 9px; color: rgba(255,255,255,.75); }
.lb-mock-btn { width: 64px; height: 26px; border-radius: 999px; display: grid; place-items: center; color: #fff; font-size: 13px; background: linear-gradient(90deg, #d10a6a, #f2468f); }

/* Post details inside the permanent-delete dialog. */
.del-details { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 12px 0 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-input); font-size: 12.5px; }
.del-details dt { color: var(--text-faint); }
.del-details dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }

/* Edit + Delete side by side in an Actions cell. */
.row-actions { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.toplayer-dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

/* ---------- Login: First Admin Setup ---------- */
.login-title { font-size: 18px; font-weight: 700; color: var(--rose); margin: 0 0 6px; }
.optional { color: var(--text-faint); font-weight: 400; }

/* ---------- Nav icon (settings gear, admin shield) ---------- */
.nav-icon { display: inline-block; width: 18px; text-align: center; font-size: 13px; }

/* ---------- Admin Management ---------- */
.admin-mgmt-sections { display: grid; gap: 20px; }
.admin-mgmt-sections .panel { padding: 20px; }
.admin-mgmt-sections h3 { margin: 0 0 14px; font-size: 15px; font-weight: 700; }
.admin-mgmt-sections h4 { margin: 0 0 10px; font-size: 13.5px; font-weight: 600; color: var(--text-dim); }
.admin-mgmt-sections .field { margin-bottom: 10px; }
.admin-mgmt-sections .btn-primary.inline { margin-top: 6px; }
