/* V2 admin console: sidebar + content layout and two-panel sign-in.
   Loaded after style.css and theme.css (which supply the tokens). */
body { background: var(--bg); color: var(--text); }
[hidden] { display: none !important; }
.a-app, .a-big, .a-head h1, .a-form-head h1, .stat b, .card h2 { font-family: var(--display); }

/* brand */
.a-brand { display: flex; align-items: center; gap: 10px; }
.a-mark { width: 34px; height: 34px; flex: none; border-radius: 11px; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; }
.a-mark svg { width: 18px; height: 18px; }
.a-mark.lg { width: 38px; height: 38px; border-radius: 12px; }
.a-mark.lg svg { width: 20px; height: 20px; }
.a-app { font-weight: 600; font-size: 16px; }
.a-sub { font-size: 12px; color: var(--muted); }

/* ── sign in ── */
.a-login { min-height: 100dvh; box-sizing: border-box; padding: 16px; display: flex; flex-wrap: wrap; gap: 16px; }
.a-intro { flex: 1 1 420px; min-height: 280px; box-sizing: border-box; padding: clamp(28px, 4vw, 56px); border-radius: 32px; background: #141418; border: 1px solid #1F1F26; display: flex; flex-direction: column; justify-content: space-between; gap: 40px; }
.a-intro .a-app { font-size: 18px; }
.a-intro-text { display: flex; flex-direction: column; gap: 16px; max-width: 460px; }
.a-intro-text p { margin: 0; font-size: 16px; line-height: 1.55; color: var(--muted-2); }
.a-intro-text .a-big { font-size: clamp(36px, 4.4vw, 60px); line-height: 1; font-weight: 700; letter-spacing: -0.035em; color: var(--text); }
.a-intro-text .a-app { font: inherit; }
.a-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.a-chips span { height: 34px; padding: 0 14px; border-radius: 17px; border: 1px solid #2A2A32; color: #C9CBD3; font-size: 13px; display: flex; align-items: center; }
.a-login-main { flex: 1 1 420px; box-sizing: border-box; padding: 40px 24px; display: flex; align-items: center; justify-content: center; }
.a-form { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 22px; }
.a-form-head { display: flex; flex-direction: column; gap: 8px; }
.a-form-head h1 { margin: 0; font-size: 32px; font-weight: 700; letter-spacing: -0.02em; }
.a-form-head p { margin: 0; font-size: 15px; color: var(--muted); }
.a-field { display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 500; color: #C9CBD3; }
.a-input { display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 4px 0 16px; border-radius: 18px; background: #141418; border: 1px solid #26262E; color: #7C7F8A; }
.a-input:focus-within { border-color: var(--accent); }
.a-input > svg { width: 18px; height: 18px; flex: none; }
.a-input input:not([type=checkbox]) { flex: 1; min-width: 0; height: 44px; padding: 0; background: transparent; border: 0; border-radius: 0; color: var(--text); font: 400 15px Inter, system-ui, sans-serif; box-shadow: none; }
.a-input input:focus { outline: none; box-shadow: none; }
.a-input input::placeholder { color: #7C7F8A; }
.a-eye { width: 44px; height: 44px; flex: none; border: 0; border-radius: 14px; background: transparent; color: var(--muted-2); display: grid; place-items: center; cursor: pointer; }
.a-eye svg { width: 18px; height: 18px; }
.a-form .err { margin: -10px 0 0; }
.a-form .err:empty { display: none; }
.a-submit { height: 54px; margin-top: 6px; border: 0; border-radius: 27px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; gap: 8px; font: 600 15px Inter, system-ui, sans-serif; cursor: pointer; }
.a-submit svg { width: 18px; height: 18px; }
.a-note { margin: 0; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.a-note svg { width: 16px; height: 16px; flex: none; }

/* ── shell ── */
.a-shell { min-height: 100dvh; display: flex; flex-wrap: wrap; }
.a-side { flex: 1 1 248px; box-sizing: border-box; padding: 24px 16px; border-inline-end: 1px solid #1C1C22; display: flex; flex-direction: column; gap: 24px; }
.a-side > .a-brand { padding: 0 8px; }
.a-nav { display: flex; flex-direction: column; gap: 2px; }
.a-nav button { height: 44px; padding: 0 12px; border: 0; border-radius: 14px; background: transparent; color: var(--muted-2); display: flex; align-items: center; gap: 12px; font: 500 14px Inter, system-ui, sans-serif; cursor: pointer; text-align: start; }
.a-nav button:hover { background: #141418; color: var(--text); }
.a-nav button svg { width: 18px; height: 18px; flex: none; }
.a-nav button > span:first-of-type { flex: 1; }
.a-nav button[aria-current] { background: #1B1B21; color: var(--text); font-weight: 600; }
.a-nav button[aria-current] svg { color: var(--accent); stroke-width: 2; }
.nav-count { flex: none !important; font-size: 12px; color: var(--muted-2); font-weight: 500; }
.a-sep { height: 1px; background: #1C1C22; }
.a-grow { flex: 1; }
.a-me { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 18px; background: #141418; border: 1px solid #1F1F26; }
.a-me .avatar { width: 38px; height: 38px; flex: none; border-radius: 13px; font-size: 16px; }
.a-me-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.a-me-text b { font-size: 14px; }
.a-me-text span { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.a-out { width: 40px; height: 40px; flex: none; border: 0; border-radius: 12px; background: #201417; color: #FF8A8A; display: grid; place-items: center; cursor: pointer; }
.a-out svg { width: 18px; height: 18px; }

.a-main { flex: 999 1 560px; min-width: 0; box-sizing: border-box; padding: 28px clamp(16px, 3vw, 40px) 40px; display: flex; flex-direction: column; gap: 24px; }
.a-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.a-head > div { display: flex; flex-direction: column; gap: 6px; }
.a-head .a-sub { font-size: 13px; }
.a-head h1 { margin: 0; font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; }
.a-open { height: 44px; padding: 0 18px; border-radius: 22px; background: var(--text); color: var(--bg); display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; text-decoration: none; }
.a-open svg { width: 16px; height: 16px; }

/* stats */
.stats { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 0; }
.stat { padding: 18px 20px; border-radius: 22px; background: #141418; border: 1px solid #1F1F26; box-shadow: none; display: flex; flex-direction: column; gap: 10px; }
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.stat b { margin: 0; font-size: 32px; font-weight: 600; line-height: 1; }
.live { width: 8px; height: 8px; border-radius: 50%; background: #5A5D66; }
.live.on { background: var(--accent); }

/* cards + tables */
.tab-pane { display: flex; flex-direction: column; gap: 16px; }
.card { margin: 0; padding: 18px 20px; border-radius: 24px; background: #141418; border: 1px solid #1F1F26; box-shadow: none; }
.card h2 { font-size: 16px; font-weight: 600; }
.card h2 .muted { font-weight: 400; }
.card-head { margin-bottom: 14px; }
.a-filter { position: relative; flex: 0 1 300px; display: flex; align-items: center; }
.a-filter svg { position: absolute; inset-inline-start: 14px; width: 16px; height: 16px; color: #7C7F8A; pointer-events: none; }
.card-head .a-filter input { max-width: none; width: 100%; height: 44px; padding-inline: 38px 14px; border-radius: 22px; background: #1B1B21; border: 1px solid #26262E; }
.table-wrap { margin: 0 -20px; overflow-x: auto; }
table { font-size: 14px; }
th, td { padding: 14px 12px; border-bottom: 1px solid #1F1F26; }
th:first-child, td:first-child { padding-inline-start: 20px; }
th:last-child, td:last-child { padding-inline-end: 20px; }
thead tr { border-top: 1px solid #1F1F26; }
th { padding-block: 12px; color: var(--muted); font-size: 12px; font-weight: 500; border-top: 1px solid #1F1F26; }
td { color: #C9CBD3; }
th.num, td.num { text-align: end; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #17171C; }
.muted-cell { color: var(--muted); }
.muted-cell .soft { color: #C9CBD3; }
.user-cell { gap: 12px; color: var(--text); }
.user-cell .avatar { width: 38px; height: 38px; border-radius: 13px; font-size: 15px; }
td .acts { justify-content: flex-end; flex-wrap: nowrap; align-items: center; }
#usersBody .acts { gap: 6px; }
.btn.sm { height: 36px; padding: 0 12px; border-radius: 18px; background: transparent; border: 1px solid #2A2A32; color: #E2E3E8; font-size: 13px; font-weight: 500; }
.btn.sm.primary { padding: 0 14px; background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn.sm.danger { color: #FF8A8A; border-color: #3A2226; }
.more-gap { width: 36px; flex: none; }
.more-btn { width: 36px; height: 36px; padding: 0; border: 1px solid #2A2A32; border-radius: 50%; background: transparent; color: #E2E3E8; display: grid; place-items: center; cursor: pointer; }
.more-btn[aria-expanded="true"] { background: #24242B; border-color: #3A3A44; }
.more-btn svg { width: 16px; height: 16px; }
.row-menu { top: calc(100% + 8px); width: 220px; padding: 6px; border-radius: 18px; background: #1B1B21; border: 1px solid #2A2A32; box-shadow: 0 18px 40px rgba(0,0,0,.5); }
.row-menu button { height: 40px; padding: 0 12px; border-radius: 12px; font-size: 13px; font-weight: 500; color: #E2E3E8; }
.row-menu .warn { color: #FFC27A; }
.row-menu .danger { color: #FF8A8A; }
.row-menu .danger:hover { background: #2A1518; }
.row-menu hr { border: 0; border-top: 1px solid #2A2A32; margin: 4px 6px; }
.tag { border-radius: 11px; padding: 3px 8px; font-size: 11px; letter-spacing: .02em; text-transform: uppercase; background: #1B1B21; color: var(--muted-2); }
.tag.admin { background: #2A3312; color: var(--accent); }
.tag.on { background: #2A3312; color: var(--accent); }
.tag.off { background: #2A1518; color: #FF8A8A; }
.dot { background: var(--accent); }

/* ── phone / narrow: sidebar becomes a top bar ── */
@media (max-width: 799px) {
  .a-side { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 12px; padding: 14px 16px 12px; border-inline-end: 0; border-bottom: 1px solid #1C1C22; position: sticky; top: 0; z-index: 20; background: var(--bg); }
  .a-side > .a-brand { flex: 1 1 auto; min-width: 0; padding: 0; }
  .a-grow, .a-sep { display: none; }
  .a-me { order: 1; flex: none; padding: 0; background: none; border: 0; gap: 8px; }
  .a-me .avatar { width: 36px; height: 36px; border-radius: 12px; }
  .a-me-text { display: none; }
  .a-out { width: 44px; height: 44px; }
  .a-side .a-nav { order: 2; flex: 1 1 100%; flex-direction: row; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .a-side .a-nav::-webkit-scrollbar { display: none; }
  .a-side .a-nav:not([aria-label]) { order: 3; margin-top: -4px; }
  .a-nav button { flex: none; height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid #1F1F26; gap: 8px; font-size: 13px; }
  .a-nav button[aria-current] { border-color: #26262E; }
  .nav-count { margin-inline-start: 2px; }
}
@media (max-width: 600px) {
  .a-main { padding: 20px 16px 32px; gap: 18px; }
  .a-head { align-items: stretch; }
  .a-head h1 { font-size: 28px; }
  .a-desc { font-size: 13px; }
  .a-head-acts { width: 100%; }
  .a-head-acts > :not([hidden]) { flex: 1 1 auto; justify-content: center; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px 16px; border-radius: 18px; gap: 8px; }
  .stat b { font-size: 26px; }
  .stat-label { font-size: 12px; }
  .card { padding: 16px; border-radius: 20px; }
  .card-head { flex-wrap: wrap; gap: 10px; }
  .card-head h2 { flex: 1 1 100%; }
  .a-filter { flex: 1 1 100%; }
  .table-wrap { margin: 0 -16px; -webkit-overflow-scrolling: touch; }
  th:first-child, td:first-child { padding-inline-start: 16px; }
  th:last-child, td:last-child { padding-inline-end: 16px; }
  th, td { padding-block: 12px; }
  .row-menu { inset-inline-end: 0; inset-inline-start: auto; }
  .dialog { width: calc(100% - 24px); max-height: calc(100dvh - 24px); padding: 20px; border-radius: 22px; }
  .dialog h3 { font-size: 19px; }
  .dialog .actions > * { flex: 1 1 auto; }
  .dialog.viewer { width: 100%; max-width: 100%; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  #tab-settings form, #tab-settings label { max-width: none !important; }
  .a-login { padding: 12px; gap: 8px; }
  .a-intro { min-height: 0; padding: 24px; border-radius: 24px; gap: 20px; }
  .a-intro .a-chips { display: none; }
  .a-intro-text .a-big { font-size: 34px; }
  .a-intro-text p { font-size: 14px; }
  .a-login-main { padding: 20px 8px 32px; }
  .a-form-head h1 { font-size: 26px; }
}
.table-wrap:has(.row-menu:not([hidden])) { padding-bottom: 220px; }

/* ── page header extras ── */
.a-desc { margin: 2px 0 0; max-width: 640px; font-size: 14px; line-height: 1.5; color: var(--muted-2); }
.a-desc:empty { display: none; }
.a-head-acts { display: flex; gap: 8px; flex-wrap: wrap; }
.a-cta, .a-ghost { height: 44px; padding: 0 18px; border-radius: 22px; display: flex; align-items: center; gap: 8px; font: 600 14px Inter, system-ui, sans-serif; cursor: pointer; }
.a-cta { border: 0; background: var(--accent); color: var(--on-accent); }
.a-ghost { background: transparent; border: 1px solid #2A2A32; color: #E2E3E8; font-weight: 500; }
.a-cta svg { width: 16px; height: 16px; }
.stats[hidden] { display: none; }

/* ── buttons / badges in rows ── */
.btn.sm svg { width: 15px; height: 15px; }
.btn.sm { gap: 6px; display: inline-flex; align-items: center; }
.icon-del { width: 36px; height: 36px; flex: none; padding: 0; border-radius: 50%; border: 1px solid #3A2226; background: #201417; color: #FF8A8A; display: grid; place-items: center; cursor: pointer; }
.icon-del svg { width: 15px; height: 15px; }
.row-menu button { display: flex; align-items: center; gap: 10px; width: 100%; }
.row-menu button svg { width: 16px; height: 16px; flex: none; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px; border-radius: 13px; background: #1B1B21; color: var(--muted-2); font-size: 12px; font-weight: 500; white-space: nowrap; }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.on { background: #2A3312; color: var(--accent); }
.love-av { width: 38px; height: 38px; flex: none; border-radius: 13px; background: #3A1A2A; color: #FF9EC4; display: grid; place-items: center; }
.love-av svg { width: 18px; height: 18px; }
.acct { display: inline-flex; align-items: center; gap: 8px; color: var(--text); }
.acct .avatar { width: 26px; height: 26px; border-radius: 9px; font-size: 12px; }
#tab-love table, #tab-users table, #tab-sessions table, #tab-chats table, #tab-backups table, #tab-audit table { min-width: 760px; }
.empty-note { color: var(--muted); }

/* ── modals ── */
.dialog { padding: 28px; border-radius: 28px; background: #141418; border: 1px solid #1F1F26; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.dialog::backdrop { background: rgba(5,5,8,.7); }
.dialog h3 { font-size: 22px; font-weight: 700; }
.dialog form { gap: 16px; }
.dialog label, #tab-settings label { display: flex; flex-direction: column; gap: 8px; font-size: 13px; font-weight: 500; color: #C9CBD3; }
.dialog label.toggle-row { flex-direction: row; align-items: center; justify-content: space-between; }
.dialog input:not([type=checkbox]):not([type=file]), .dialog select, .dialog textarea,
#tab-settings input:not([type=checkbox]):not([type=file]), #tab-settings select {
  min-height: 48px; box-sizing: border-box; padding: 0 16px; border-radius: 18px; background: #1B1B21; border: 1px solid #26262E; color: var(--text); font: 400 15px Inter, system-ui, sans-serif; box-shadow: none; }
.dialog textarea { padding: 12px 16px; resize: vertical; }
.dialog .actions { margin-top: 4px; }
.dialog .btn, #tab-settings .btn:not(.sm) { height: 44px; padding: 0 20px; border-radius: 22px; background: transparent; border: 1px solid #2A2A32; color: #E2E3E8; font-weight: 500; }
.dialog .btn.primary, #tab-settings .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.dialog .btn.danger, #tab-settings .btn.danger { background: #201417; border-color: #3A2226; color: #FF8A8A; }
.dialog.viewer { padding: 0; }
#loveInfo { display: grid; gap: 4px; padding: 12px 14px; border-radius: 16px; background: #1B1B21; border: 1px solid #26262E; }
.secret-box { border-radius: 16px; background: #1B1B21; border: 1px solid #26262E; }

/* ── focus ── */
:is(button, a, input, select, textarea, [tabindex]):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.a-input input:focus-visible { outline: none; }

/* ── love letter dialog: steps, design cards, draft ── */
.love-dialog { width: min(640px, calc(100vw - 32px)); }
.love-steps { display: flex; gap: 6px; padding: 4px; border-radius: 22px; background: #0E0E12; border: 1px solid #1F1F26; }
.love-step { flex: 1; height: 36px; border-radius: 18px; border: 0; background: transparent; color: #8A8C96; font-weight: 600; cursor: pointer; }
.love-step.on { background: #23232B; color: #F2F3F6; }
.love-pane { display: flex; flex-direction: column; gap: 16px; }
.love-pane[hidden] { display: none; }
.draft-note { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 14px; background: #1A1A10; border: 1px solid #34321C; color: #E8DFA0; }
.draft-note[hidden] { display: none; }
.design-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.design-card { display: flex; flex-direction: column; border-radius: 18px; border: 2px solid #2A2A32; background: #0E0E12; overflow: hidden; cursor: pointer; text-align: left; padding: 0; color: inherit; }
.design-card.on { border-color: var(--accent); }
.design-thumb { position: relative; height: 220px; overflow: hidden; background: #000; }
.design-thumb iframe { position: absolute; top: 0; left: 0; width: 400%; height: 400%; border: 0; transform: scale(.25); transform-origin: 0 0; pointer-events: none; }
.design-meta { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; }
.design-meta b { font-size: 13px; line-height: 1.35; }
.design-meta .btn { height: 32px !important; padding: 0 14px !important; align-self: flex-start; }

/* ── phone: table rows become stacked cards (labels come from data-label, set in admin.js) ── */
@media (max-width: 600px) {
  #dash table { min-width: 0 !important; }
  #dash thead { display: none; }
  #dash table, #dash tbody, #dash tr, #dash td { display: block; width: auto; }
  #dash tbody tr { padding: 14px 16px; border-bottom: 1px solid #1F1F26; }
  #dash tbody tr:hover { background: none; }
  #dash td { padding: 5px 0 !important; border: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; white-space: normal; text-align: end; min-width: 0; overflow-wrap: anywhere; }
  #dash td::before { content: attr(data-label); flex: none; color: var(--muted); font-size: 12px; text-align: start; }
  #dash td[data-label=""]::before, #dash td:first-child::before { display: none; }
  #dash td:first-child { padding-bottom: 10px !important; justify-content: flex-start; text-align: start; font-size: 15px; }
  #dash td:last-child:not(:first-child) { padding-top: 10px !important; }
  #dash td .acts { flex-wrap: wrap; justify-content: flex-end; }
  #dash td[colspan] { justify-content: center; text-align: center; }
  .table-wrap:has(.row-menu:not([hidden])) { padding-bottom: 0; }
  .row-menu { z-index: 30; }
}
@media (max-width: 799px) {
  /* keep the top bar at screen width; its section pills scroll inside it instead of widening the page */
  .a-shell { flex-direction: column; flex-wrap: nowrap; }
  .a-side { flex: none; width: 100%; min-width: 0; }
  .a-side .a-nav { min-width: 0; max-width: calc(100% + 32px); }
  .a-main { flex: 1 1 auto; width: 100%; }
}
@media (max-width: 600px) {
  #dash td:last-child:not(:first-child)::before { display: none; }
  #dash td:last-child:not(:first-child) { justify-content: flex-end; }
}

.reasons-box { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.reason-list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.reason-row { display: flex; gap: 8px; }
.reason-row input { flex: 1; min-width: 0; }
.sms-row { align-items: center; }
.sms-num { flex-shrink: 0; min-width: 4.5em; font-size: 13px; font-weight: 600; }
