/* SeeKyaa admin console. Builds on styles.css (tokens, buttons, dialogs). */

body.admin { min-height: 100vh; padding: 0; background: var(--bg); }
.admin-top { position: sticky; top: 0; z-index: 10; height: 60px; padding: 0 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 1px solid var(--line); background: var(--bar); }
.admin-top .brand { font-size: 19px; }
.admin-tag { margin-left: 4px; padding: 3px 9px; border-radius: 999px; background: var(--solid); color: var(--on-solid); font-size: 11px; font-weight: 500; letter-spacing: .04em; text-transform: uppercase; }
.admin-me { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 500; }
.admin-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); min-height: calc(100vh - 60px); }
.admin-nav { position: sticky; top: 60px; align-self: start; height: calc(100vh - 60px); padding: 18px 12px; display: grid; align-content: start; gap: 4px; border-right: 1px solid var(--line); background: var(--card); }
.admin-nav a { min-height: 42px; padding: 0 12px; display: flex; align-items: center; gap: 10px; border-radius: 12px; color: var(--ink); font-size: 14px; font-weight: 500; text-decoration: none; }
.admin-nav a:hover { background: var(--tint-strong); }
.admin-nav a.active { background: var(--brand-soft); color: var(--brand-dark); }
.admin-count { min-width: 22px; margin-left: auto; padding: 2px 7px; border-radius: 999px; background: #e0245e; color: #fff; font-size: 11px; text-align: center; }
.admin-count.hidden { display: none; }
.admin-main { min-width: 0; padding: 24px clamp(16px, 3vw, 36px) 60px; outline: none; }
.admin-loading { padding: 40px; color: var(--muted); text-align: center; }
body.locked .admin-nav { display: none; }
body.locked .admin-shell { grid-template-columns: 1fr; }

.a-head { margin-bottom: 16px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.a-head .eyebrow { margin: 0 0 2px; }
.a-head h1 { margin: 0; font-size: clamp(26px, 3vw, 32px); letter-spacing: -.03em; }
.a-note { max-width: 720px; margin: -4px 0 16px; color: var(--muted); font-size: 14px; }
.a-muted { color: var(--muted); font-size: 13px; }
.a-block { display: block; color: var(--muted); }
.a-empty { padding: 28px; color: var(--muted); text-align: center; }
.a-link { padding: 0; border: 0; background: none; color: var(--brand); font: inherit; font-weight: 500; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }

.a-card { padding: 16px 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow-card); }
.a-card-title { margin: 0 0 12px; font-size: 16px; }
.a-scroll { overflow-x: auto; }
.a-list { display: grid; gap: 12px; }
.a-two { margin-bottom: 14px; display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; align-items: start; }
.a-two + .a-card, .a-card + .a-card { margin-top: 14px; }

.a-alert { margin-bottom: 16px; padding: 12px 16px; display: flex; flex-wrap: wrap; gap: 10px 20px; border-radius: 14px; background: #fff7e6; color: #6b4e00; font-size: 14px; font-weight: 500; }
.a-alert a { color: inherit; font-weight: 500; }
.a-alert.good { background: #e9f8f0; color: #155c3d; }
.a-alert.bad { background: #fdecef; color: #8e1f35; }

/* Stat tiles */
.a-tiles { margin-bottom: 18px; display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.a-tiles.small { grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.a-tile { padding: 14px 16px; display: grid; gap: 2px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); color: var(--ink); text-decoration: none; box-shadow: var(--shadow-card); }
.a-tile span { color: var(--muted); font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.a-tile strong { font-size: 28px; font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.a-tile small { color: var(--muted); font-size: 12px; }
.a-tile.link:hover { border-color: var(--line-strong); transform: translateY(-1px); }

/* Charts: one series each, brand colour, recessive grid */
.a-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.a-chart { margin: 0; padding: 14px 16px; border: 1px solid var(--line); border-radius: 18px; background: var(--card); box-shadow: var(--shadow-card); }
.a-chart figcaption { margin-bottom: 6px; display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.a-chart figcaption span { color: var(--muted); font-size: 12px; }
.c-wrap { position: relative; }
.c-wrap svg { width: 100%; height: auto; display: block; overflow: visible; }
.c-grid { stroke: var(--track); stroke-width: 1; }
.c-axis { fill: var(--soft); font-size: 10px; font-family: var(--font); }
.c-bar { fill: var(--brand); transition: opacity .12s; }
.c-hit { fill: transparent; }
.c-col.on .c-bar { fill: var(--brand-dark); }
.c-tip { position: absolute; top: -6px; padding: 5px 9px; border-radius: 8px; background: var(--solid); color: var(--on-solid); font-size: 12px; font-weight: 500; white-space: nowrap; pointer-events: none; }
.a-table-view { margin-top: 6px; font-size: 12px; }
.a-table-view summary { color: var(--muted); cursor: pointer; }

/* Tables */
.a-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.a-table th { padding: 8px 10px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 500; text-align: left; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.a-table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.a-table tr:last-child td { border-bottom: 0; }
.a-table.compact td { padding: 7px 10px; font-size: 13px; }
.a-row { cursor: pointer; }
.a-row:hover td { background: var(--tint); }
.a-who { display: flex; align-items: center; gap: 10px; min-width: 0; text-align: left; }
.a-who.link { padding: 0; border: 0; background: none; color: var(--ink); cursor: pointer; }
.a-who strong { display: block; font-size: 14px; }
.a-who small { display: block; overflow: hidden; max-width: 260px; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.a-avatar { width: 36px; height: 36px; flex: 0 0 36px; display: grid; place-items: center; border-radius: 50%; object-fit: cover; background: var(--grad); color: #fff; font-size: 14px; font-weight: 500; }
.a-avatar.large { width: 72px; height: 72px; flex-basis: 72px; font-size: 26px; }
.a-badges { display: flex; flex-wrap: wrap; gap: 5px; }
.a-badge { padding: 3px 9px; border-radius: 999px; background: var(--tint-strong); color: var(--muted); font-size: 11px; font-weight: 500; white-space: nowrap; }
.a-badge.good { background: #e3f6ec; color: #14724a; }
.a-badge.warn { background: #fff1d6; color: #8a5a00; }
.a-badge.bad { background: #fde3e8; color: #b0213f; }
.a-badge.info { background: #e8efff; color: #2e4fae; }
.a-badge.brand { background: var(--brand-soft); color: var(--brand-dark); }

/* Toolbars, chips, search, pager */
.a-toolbar { margin-bottom: 14px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.a-search { flex: 1 1 280px; max-width: 460px; display: flex; gap: 8px; }
.a-search input { flex: 1; min-width: 0; min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--card); font: inherit; font-size: 14px; }
.a-search input:focus { border-color: var(--brand); outline: none; box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .12); }
.a-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.a-chip { min-height: 34px; padding: 0 13px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--card); color: var(--muted); font-size: 13px; font-weight: 500; }
.a-chip:hover { color: var(--ink); }
.a-chip.active { border-color: var(--solid); background: var(--solid); color: var(--on-solid); }
.a-pager { margin-top: 14px; display: flex; align-items: center; justify-content: center; gap: 14px; }
.a-pager-info { margin-top: 10px; text-align: center; }

/* Post / report / enquiry cards */
.a-post-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.a-meta { margin: 8px 0 4px; color: var(--muted); font-size: 12px; }
.a-text { margin: 4px 0 10px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.a-post-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.a-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.a-actions.wrap { margin: 14px 0 6px; }
.a-reason { margin: 10px 0 2px; font-size: 14px; }
.a-report-target { margin: 10px 0; padding: 10px 12px; display: flex; align-items: center; gap: 12px; border-radius: 14px; background: var(--tint); }
.a-quote { margin: 8px 0 12px; padding: 10px 14px; border-left: 3px solid var(--line-strong); border-radius: 0 12px 12px 0; background: var(--tint); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.a-transcript { margin: 8px 0 12px; padding: 10px 12px; display: grid; gap: 6px; max-height: 260px; overflow-y: auto; border-radius: 12px; background: var(--chat-bg); font-size: 13px; }
.a-transcript p { margin: 0; padding: 6px 10px; justify-self: start; border-radius: 10px; background: var(--card); }
.a-transcript p.them { justify-self: end; background: #ffe1ea; }
.a-transcript small { color: var(--soft); }
.a-note-label { display: grid; gap: 4px; margin: 4px 0 10px; font-size: 13px; font-weight: 500; }
.a-note-label small { color: var(--soft); font-weight: 500; }
.a-note-label textarea { padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 12px; font: inherit; font-size: 14px; resize: vertical; }
.a-form { display: grid; gap: 12px; }
.a-form label { display: grid; gap: 4px; font-size: 13px; font-weight: 500; }
.a-form input, .a-form select { min-height: 44px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--card); font: inherit; font-size: 15px; }
.a-locked { max-width: 420px; margin: 60px auto; display: grid; justify-items: center; gap: 10px; text-align: center; }
.a-locked span { font-size: 40px; }
.a-locked h1 { margin: 0; }
.a-locked p { margin: 0 0 8px; color: var(--muted); }

/* User drawer */
.admin-drawer { width: min(100% - 24px, 640px); height: calc(100dvh - 24px); max-height: none; margin: 12px 12px 12px auto; padding: 0; overflow: hidden; border-radius: 20px; }
.admin-drawer[open] { display: flex; flex-direction: column; animation: drawer-in .2s ease-out; }
@keyframes drawer-in { from { transform: translateX(30px); opacity: 0; } }
.drawer-head { padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 18px !important; }
.drawer-head .dialog-close { margin: 0; }
.drawer-body { flex: 1; min-height: 0; padding: 18px; overflow-y: auto; }
.drawer-body h4 { margin: 18px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.u-head { display: flex; align-items: center; gap: 14px; }
.u-head h3 { margin: 0; font-size: 22px; }
.u-head p { margin: 2px 0 6px; }
.u-facts { margin: 14px 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.u-facts div { padding: 10px 12px; border-radius: 12px; background: var(--tint); }
.u-facts dt { color: var(--muted); font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.u-facts dd { margin: 2px 0 0; font-size: 14px; font-weight: 500; }
.u-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; }
.u-counts div { padding: 10px; display: grid; justify-items: center; border: 1px solid var(--line); border-radius: 12px; text-align: center; }
.u-counts div.warn { border-color: #f6c26b; background: #fff8ea; }
.u-counts strong { font-size: 20px; }
.u-counts span { color: var(--muted); font-size: 11px; }
.u-list { margin: 0; padding: 0; display: grid; gap: 6px; list-style: none; }
.u-list li { padding: 8px 10px; border-radius: 10px; background: var(--tint); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }

@media (max-width: 860px) {
  /* Menu row only as tall as it needs, so short pages start at the top (not halfway down) */
  .admin-shell { grid-template-columns: 1fr; grid-template-rows: auto 1fr; align-content: start; }
  .admin-nav { position: sticky; top: 60px; z-index: 5; height: auto; padding: 8px 12px; display: flex; gap: 6px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
  .admin-nav::-webkit-scrollbar { display: none; }
  .admin-nav a { flex: 0 0 auto; min-height: 36px; font-size: 13px; }
  .admin-me .admin-name { display: none; }
  .admin-drawer { width: 100%; height: 100dvh; margin: 0; border-radius: 0; }
  .a-tiles.small { grid-template-columns: 1fr 1fr; }
}

/* The app's <main> rule (760px column) doesn't apply here: the console uses the full width beside the menu. */
main.admin-main { width: auto; max-width: none; margin: 0; }


.a-demo { margin-bottom: 14px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; background: #f4f7ff; border-color: #dfe6fb; }
.a-demo p { margin: 4px 0 0; max-width: 620px; }


:root[data-theme="dark"] body.admin { background: var(--bg); }
:root[data-theme="dark"] .a-search input, :root[data-theme="dark"] .a-form input, :root[data-theme="dark"] .a-form select, :root[data-theme="dark"] .a-note-label textarea { background: var(--card); color: var(--ink); }


/* ---- Analytics and Emails ---- */
.a-three { margin-bottom: 14px; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; align-items: start; }
.a-two + .a-three, .a-charts + .a-two { margin-top: 14px; }
.a-rank { margin: 0; padding: 0; display: grid; gap: 9px; list-style: none; }
.a-rank li { display: grid; grid-template-columns: minmax(90px, 34%) 1fr auto; align-items: center; gap: 10px; font-size: 13px; }
.a-rank-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-rank-bar { height: 8px; overflow: hidden; border-radius: 999px; background: var(--track); }
.a-rank-bar i { display: block; height: 100%; border-radius: inherit; background: var(--grad); }
.a-rank-num { min-width: 56px; display: grid; justify-items: end; font-weight: 600; font-variant-numeric: tabular-nums; }
.a-rank-num small { color: var(--soft); font-size: 11px; font-weight: 400; }
.a-cols { height: 130px; display: flex; align-items: flex-end; gap: 3px; }
.a-col { min-width: 0; height: 100%; flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.a-col i { width: 100%; min-height: 2px; border-radius: 4px 4px 0 0; background: rgba(var(--brand-rgb), .45); }
.a-col.peak i { background: var(--grad); }
.a-col span { color: var(--soft); font-size: 10px; }
.a-muted.small, .small { font-size: 12px; }
.a-tile strong.small { font-size: 18px; }
.nowrap { white-space: nowrap; }
.a-who { display: inline-flex; align-items: center; gap: 8px; }
.a-avatar.small { width: 26px; height: 26px; flex-basis: 26px; font-size: 12px; }
.a-scroll-x { overflow-x: auto; scrollbar-width: thin; }
.a-scroll-x .a-chips { flex-wrap: nowrap; }
.a-bad { color: var(--bad-ink, #c62a47); font-weight: 600; }
.a-copy { margin: 8px 0; display: flex; gap: 8px; }
.a-copy input { min-width: 0; flex: 1; min-height: 38px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--tint); color: var(--ink); font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.a-link.small { margin-left: 8px; font-size: 12px; font-weight: 400; }
.a-scroll-x .a-chip { flex: 0 0 auto; white-space: nowrap; }
.a-two > .a-chart { margin: 0; }

/* Stats tiles that should span the full width (Analytics, Emails) */
.a-tiles.fill { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
/* Replies and likes on Content posts */
.a-stat-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.a-stat-badge { padding: 4px 10px; display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 999px; background: var(--tint); color: var(--muted); font-size: 12px; }
.a-stat-badge strong { color: var(--ink); font-weight: 700; }
/* Sections and location lists */
.a-section-title { margin: 22px 0 12px; font-size: 18px; }
.a-section-title small { margin-left: 8px; color: var(--muted); font-size: 13px; font-weight: 400; }
.a-card-sub { margin-left: 8px; color: var(--soft); font-size: 12px; font-weight: 400; }
.a-link-plain { color: var(--ink); text-decoration: none; }
.a-link-plain:hover { color: var(--brand); }
.a-rank .fi { margin-right: 4px; border-radius: 2px; }
.small-link { font-size: 12px; }
/* Live activity: the table (about 9/12) with a filter panel on the right (about 3/12) */
.a-with-panel { display: grid; grid-template-columns: minmax(0, 3fr) minmax(240px, 1fr); gap: 16px; align-items: start; }
.a-with-panel-main { min-width: 0; }
.a-filter-panel { position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
.a-filter-head { display: flex; align-items: baseline; justify-content: space-between; }
.a-filter-applied { margin-bottom: 10px; display: flex; flex-wrap: wrap; gap: 6px; }
.a-filter-title { margin: 14px 0 6px; color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.a-filter-list { display: grid; gap: 2px; }
.a-filter-item { width: 100%; min-height: 34px; padding: 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 0; border-radius: 9px; background: transparent; color: var(--ink); font-size: 13px; text-align: left; cursor: pointer; }
.a-filter-item:hover { background: var(--tint-strong); }
.a-filter-item.active { background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; }
.a-filter-item span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.a-filter-item b { flex: 0 0 auto; color: var(--soft); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.a-filter-item.active b { color: var(--brand-dark); }
@media (max-width: 1100px) {
  .a-with-panel { grid-template-columns: 1fr; }
  .a-filter-panel { position: static; max-height: none; order: -1; }
}
/* ---- Phones ---- */
@media (max-width: 640px) {
  .admin-top { height: 56px; padding: 0 12px; padding-top: env(safe-area-inset-top); height: calc(56px + env(safe-area-inset-top)); }
  .admin-top .brand { font-size: 17px; gap: 7px; }
  .admin-top .brand-logo { width: 28px; height: 28px; flex-basis: 28px; }
  .admin-tag { padding: 2px 7px; font-size: 10px; }
  .admin-me { gap: 6px; }
  .admin-me .avatar { width: 32px; height: 32px; flex: 0 0 32px; font-size: 13px; }
  .admin-name, .admin-btn-label, .admin-back-label { display: none; }
  .admin-me .button-small { min-width: 36px; min-height: 36px; padding: 0 10px; }
  .admin-nav { top: calc(56px + env(safe-area-inset-top)); }
  .admin-main { padding: 16px 14px 48px; }
  /* Page titles: buttons go under the title instead of squeezing it */
  .a-head { flex-wrap: wrap; align-items: flex-start; }
  .a-head > div:first-child { min-width: 0; flex: 1 1 100%; }
  .a-head h1 { font-size: 26px; }
  .a-card { padding: 14px; border-radius: 16px; }
  .a-toolbar { gap: 8px; }
  .a-search { flex: 1 1 100%; }
  /* Tables become stacked cards: each row a block, each value with its column name beside it */
  .a-table thead { display: none; }
  .a-table, .a-table tbody, .a-table tr { display: block; width: 100%; }
  .a-table tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .a-table tr:last-child { border-bottom: 0; }
  /* The column name sits in a fixed strip on the left; everything in the cell (however many lines) stays on the right */
  .a-table td { position: relative; min-height: 22px; padding: 3px 0 3px calc(34% + 10px) !important; display: block; border: 0 !important; font-size: 14px; overflow-wrap: anywhere; }
  .a-table td::before { content: attr(data-label); position: absolute; left: 0; top: 5px; width: 34%; color: var(--muted); font-size: 11px; font-weight: 600; line-height: 1.3; letter-spacing: .03em; text-transform: uppercase; }
  .a-table td[data-label=""] { padding-left: 0 !important; }
  .a-table td[data-label=""]::before { display: none; }
  .a-table td.a-empty, .a-table td[colspan] { display: block; padding: 20px 0 !important; text-align: center; }
  .a-table td.a-empty::before, .a-table td[colspan]::before { display: none; }
  .a-table td .a-actions { justify-content: flex-start; }
  .a-tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
}
@media (max-width: 380px) {
  .a-tiles { grid-template-columns: 1fr; }
}
.a-flag { width: 20px; height: 15px; margin-right: 6px; border-radius: 3px; vertical-align: -2px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .12); }

/* Social card maker */
.social-previews { margin: 14px 0 4px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; align-items: end; }
.social-preview { margin: 0; display: grid; gap: 8px; }
.social-preview img { width: 100%; border-radius: 12px; box-shadow: 0 6px 20px rgba(0, 0, 0, .25); }
.social-preview figcaption { display: grid; gap: 6px; justify-items: start; font-size: 12.5px; color: var(--muted); }
.social-caption { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); color: var(--ink); font: inherit; font-size: 14px; line-height: 1.5; resize: vertical; }
@media (max-width: 560px) { .social-previews { grid-template-columns: minmax(0, 1fr); } }
