/* Admin panel, final look (phase 3.7, handoff 2.2 and 3.18). Version 2 tokens only; desktop first, menu on top below 1024px. */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body.admin {
  --a-radius: 16px; --a-ctl: 44px; --a-ctl-sm: 36px;
  --text-helper: 600 12px/20px var(--font-family-base);
  --focus-ring: 0 0 0 3px rgba(20, 90, 74, .22);
  background: var(--color-bg); color: var(--color-ink); font: var(--text-body); -webkit-text-size-adjust: 100%;
}
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
a { color: var(--color-primary); }
.app { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.boot { margin: auto; text-align: center; color: var(--color-text-muted); padding: var(--space-6); display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.logo { display: inline-block; width: 44px; height: 44px; border-radius: 14px; flex: none; background: var(--color-primary) url("../img/logo-mark.svg") center / 26px no-repeat; }
.help { font: var(--text-helper); color: var(--color-text-muted); margin: 0; }
.error { font: var(--text-helper); color: var(--color-error); margin: 0; }
.empty { padding: var(--space-8) var(--space-4); text-align: center; color: var(--color-text-muted); margin: 0; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--a-ctl); padding: 0 var(--space-5);
  border-radius: var(--radius-full); border: 0; cursor: pointer; font: 800 14px/22px var(--font-family-base); text-decoration: none; background: var(--color-ink); color: #fff;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-primary:active { background: var(--color-primary-pressed); }
.btn-secondary { background: var(--color-surface); color: var(--color-ink); box-shadow: inset 0 0 0 1.5px var(--color-border); }
.btn-secondary:hover { box-shadow: inset 0 0 0 1.5px var(--color-ink); }
.btn-danger { background: var(--color-error); color: #fff; }
.btn-block { width: 100%; min-height: 52px; }
.btn:disabled { background: var(--color-neutral-bg); color: var(--color-text-muted); box-shadow: none; cursor: default; }
.btn .spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.link { background: none; border: 0; padding: 0; color: var(--color-primary); font: 700 13px/20px var(--font-family-base); text-decoration: none; cursor: pointer; min-height: 24px; }
.link:hover { text-decoration: underline; }
.btn:focus-visible, .link:focus-visible, .chip:focus-visible, .icon-btn:focus-visible, .adm-nav a:focus-visible, .qitem:focus-visible, .tr:focus-visible, .stat:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field label, .field .label { font: var(--text-label); }
.field .req { color: var(--color-error); }
.input { height: var(--a-ctl); border: 1.5px solid transparent; border-radius: var(--a-radius); background: var(--color-bg); padding: 0 var(--space-4); font: var(--text-input); width: 100%; color: var(--color-ink); }
.input::placeholder { color: var(--color-placeholder); }
textarea.input { height: auto; min-height: 96px; padding: var(--space-3) var(--space-4); resize: vertical; line-height: 24px; }
.input:focus { outline: none; border-color: var(--color-focus); background: var(--color-surface); }
.field.has-error .input { border-color: var(--color-error); }

.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; height: var(--a-ctl-sm); padding: 0 var(--space-4); border-radius: var(--radius-full); border: 0;
  background: var(--color-surface); color: var(--color-ink); font: var(--text-chip); cursor: pointer; text-decoration: none; white-space: nowrap; box-shadow: var(--shadow-card);
}
.chip[aria-pressed="true"] { background: var(--color-ink); color: #fff; }
.icon-btn { min-width: 36px; height: 36px; border-radius: var(--radius-full); border: 0; background: var(--color-bg); cursor: pointer; font: 700 12px/1 var(--font-family-base); color: var(--color-ink); padding: 0 var(--space-3); }
.icon-btn:hover { background: var(--color-neutral-bg); }
.icon-btn:disabled { color: var(--color-placeholder); background: var(--color-bg); cursor: default; }
.icon-btn.danger { color: var(--color-error); }
.badge { display: inline-flex; align-items: center; gap: 4px; border-radius: var(--radius-full); padding: 2px 10px; font: 700 12px/20px var(--font-family-base); justify-self: start; }
.badge.on { background: var(--color-success-bg); color: var(--color-success); }
.badge.off { background: var(--color-neutral-bg); color: var(--color-neutral); }
.status { display: inline-flex; align-items: center; height: 26px; padding: 0 10px; border-radius: var(--radius-full); font: 800 11px/1 var(--font-family-base); white-space: nowrap; }
.st-pending { background: var(--status-pending-bg); color: var(--status-pending-text); }
.st-published { background: var(--status-published-bg); color: var(--status-published-text); }
.st-edit { background: var(--status-needs-edit-bg); color: var(--status-needs-edit-text); }
.st-deleted { background: var(--status-deleted-bg); color: var(--status-deleted-text); }
.notice { border-radius: var(--a-radius); padding: var(--space-3) var(--space-4); font: var(--text-helper); margin: 0; }
.notice-warn { background: var(--color-warning-bg); color: var(--color-warning-text); }
.notice-info { background: var(--color-primary-soft); color: var(--color-primary); }
.notice-error { background: var(--color-error-bg); color: var(--color-error); }
.row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.row .input { flex: 1 1 220px; }
.row.between { justify-content: space-between; flex-wrap: nowrap; }
.row.acts .btn { flex: 1 1 auto; }

/* ---------- A01 sign-in ---------- */
.auth { width: 100%; max-width: 440px; margin: auto; padding: var(--space-8) var(--space-4); }
.auth-card { background: var(--color-surface); border-radius: var(--radius-sheet); box-shadow: var(--shadow-card-lg); padding: var(--space-8) var(--space-6); display: flex; flex-direction: column; gap: var(--space-4); }
.auth-head { display: flex; align-items: center; gap: var(--space-3); }
.auth-head strong { display: block; font: 800 16px/24px var(--font-family-base); }
.auth-head small { display: block; font: var(--text-caption); color: var(--color-text-muted); }
.auth-card h1 { margin: var(--space-2) 0 0; font: var(--text-title-1); }
.auth-card .lead { margin: 0; color: var(--color-text-muted); font: var(--text-body); }
.input.phone, .input.code { direction: ltr; text-align: left; letter-spacing: 2px; font: 700 18px/1 var(--font-family-base); height: 52px; }
.input.code { text-align: center; letter-spacing: 10px; }
.auth-card .notice { display: flex; gap: var(--space-2); }

/* ---------- layout: side menu and content ---------- */
.adm { display: flex; min-height: 100vh; align-items: flex-start; gap: var(--space-4); padding: var(--space-4); }
.adm-side {
  flex: none; width: 220px; position: sticky; top: var(--space-4); max-height: calc(100vh - 32px); overflow-y: auto;
  background: var(--color-surface); border-radius: 26px; box-shadow: var(--shadow-card); padding: var(--space-4) var(--space-3); display: flex; flex-direction: column; gap: var(--space-3);
}
.brand { display: flex; align-items: center; gap: var(--space-3); padding: 0 var(--space-2) var(--space-2); }
.brand strong { display: block; font: 800 14px/22px var(--font-family-base); }
.brand small { display: block; font: var(--text-caption); color: var(--color-text-muted); }
.adm-nav { display: flex; flex-direction: column; gap: 4px; }
.adm-nav a, .adm-nav span {
  display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); min-height: 42px; padding: 0 var(--space-4);
  border-radius: var(--radius-full); color: var(--color-ink); text-decoration: none; font: 600 13px/20px var(--font-family-base); white-space: nowrap;
}
.adm-nav a:hover { background: var(--color-bg); }
.adm-nav a[aria-current="page"] { background: var(--color-ink); color: #fff; font-weight: 800; }
.adm-nav span { color: var(--color-placeholder); }
.adm-nav small { font: var(--text-caption); color: var(--color-placeholder); }
.adm-nav .count { background: var(--color-primary); color: #fff; border-radius: var(--radius-full); min-width: 22px; padding: 0 6px; text-align: center; font: 800 11px/22px var(--font-family-base); }
.adm-nav a[aria-current="page"] .count { background: #fff; color: var(--color-ink); }
.adm-side .who { margin-top: auto; padding: var(--space-3) var(--space-2) 0; border-top: 1px solid var(--color-divider); font: var(--text-helper); color: var(--color-text-muted); display: flex; flex-direction: column; gap: var(--space-1); align-items: flex-start; }
.adm-main { flex: 1; min-width: 0; padding: var(--space-2) var(--space-2) var(--space-8); display: flex; flex-direction: column; gap: var(--space-4); }
.adm-main > h1 { margin: 0; font: 800 26px/40px var(--font-family-base); }
h2 { font: var(--text-title-2); margin: 0; }
h3 { font: var(--text-title-3); margin: 0; }

@media (max-width: 1023px) {
  .adm { flex-direction: column; align-items: stretch; padding: var(--space-3); }
  .adm-side { width: auto; position: static; max-height: none; flex-direction: row; align-items: center; gap: var(--space-2); padding: var(--space-2); }
  .adm-side .brand { padding: 0 var(--space-2); }
  .adm-side .brand div { display: none; }
  .adm-nav { flex-direction: row; overflow-x: auto; flex: 1; scrollbar-width: none; }
  .adm-side .who { margin: 0; border: 0; padding: 0 var(--space-2); flex-direction: row; align-items: center; white-space: nowrap; }
  .adm-side .who span { display: none; }
}

/* ---------- panels, tables, two columns ---------- */
.panel { background: var(--color-surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); }
.panel h2 { font: var(--text-title-3); }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-3); }
.stat { display: flex; flex-direction: column; gap: 2px; padding: 18px; border-radius: 26px; background: var(--color-surface); box-shadow: var(--shadow-card); color: var(--color-ink); text-decoration: none; }
.stat b { font: 800 30px/42px var(--font-family-base); }
.stat span { font: 600 12px/20px var(--font-family-base); color: var(--color-text-muted); }
.stat.first { background: var(--color-primary); color: #fff; }
.stat.first span { color: var(--color-on-green-muted); }
.stat:hover { box-shadow: var(--shadow-card-lg); }
@media (max-width: 760px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.table { background: var(--color-surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: auto; }
.tr {
  display: grid; grid-template-columns: 70px minmax(0, 1fr) 120px 130px 110px; gap: var(--space-3); align-items: center; padding: var(--space-2) var(--space-5); min-height: 52px;
  border: 0; border-top: 1px solid var(--color-divider); background: none; width: 100%; text-align: right; font: 500 12px/20px var(--font-family-base); color: var(--color-ink); text-decoration: none; min-width: 640px;
}
button.tr, a.tr { cursor: pointer; }
button.tr:hover, a.tr:hover { background: var(--color-bg); }
.tr.th { border-top: 0; font: 700 11px/18px var(--font-family-base); color: var(--color-text-muted); min-height: 44px; }
.tr .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.tr .acts { display: flex; gap: var(--space-1); flex-wrap: wrap; }
.archive .tr { grid-template-columns: 70px minmax(0, 1fr) 150px minmax(0, 1fr) 110px 230px; }
.dash .tr { grid-template-columns: 80px 2fr 1fr 1fr 120px; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); font: var(--text-helper); color: var(--color-text-muted); }
.filters { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.filters select.input, .filters .input { flex: 1 1 160px; }

.list { background: var(--color-surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); overflow: hidden; }
.list-head, .list-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 110px 120px 280px; gap: var(--space-3); align-items: center; padding: var(--space-2) var(--space-5); }
.list-head { font: 700 11px/18px var(--font-family-base); color: var(--color-text-muted); min-height: 44px; }
.list-row { border-top: 1px solid var(--color-divider); min-height: 54px; font-size: 12px; }
.list-row.off .label { color: var(--color-text-muted); }
.list-row .label { font: 700 13px/20px var(--font-family-base); overflow-wrap: anywhere; }
.list-row .num, .list-row .used { color: var(--color-text-muted); font: var(--text-helper); }
.list-row .acts { display: flex; gap: var(--space-1); justify-content: flex-end; flex-wrap: wrap; }
.list-row .input { height: 38px; }
details.bulk summary { cursor: pointer; color: var(--color-primary); font: var(--text-label); min-height: 36px; display: flex; align-items: center; }
@media (max-width: 760px) {
  .list-head { display: none; }
  .list-row { grid-template-columns: 36px minmax(0, 1fr); }
  .list-row .used, .list-row .badge { grid-column: 2; }
  .list-row .acts { grid-column: 1 / -1; justify-content: flex-start; }
}

.split { display: flex; gap: var(--space-4); align-items: flex-start; }
.split > :first-child { flex: 1.3 1 0; min-width: 0; }
.split > .qpanel { flex: 1 1 0; min-width: 0; position: sticky; top: var(--space-4); max-height: calc(100vh - 32px); overflow: auto; }
@media (max-width: 1023px) { .split { flex-direction: column; align-items: stretch; } .split > .qpanel { position: static; max-height: none; } }
.qlist { display: flex; flex-direction: column; background: var(--color-surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: var(--space-2); gap: 2px; }
.qitem { display: flex; flex-direction: column; gap: 2px; padding: var(--space-3) var(--space-4); border-radius: 18px; text-decoration: none; color: var(--color-ink); font-size: 12px; }
.qitem:hover, .qitem.on { background: var(--color-bg); }
.qitem.on strong { font-weight: 800; }
.qitem strong { font: 700 13px/20px var(--font-family-base); }
.qitem .warn { color: var(--color-warning-text); background: var(--color-warning-bg); border-radius: var(--radius-full); padding: 0 8px; font: 700 11px/22px var(--font-family-base); white-space: nowrap; }
.qpanel { background: var(--color-surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: var(--space-5); display: flex; flex-direction: column; gap: var(--space-3); }
.qpanel h2 { font: var(--text-title-2); }
.qpanel .price { margin: 0; font: 800 18px/28px var(--font-family-base); color: var(--color-primary); }
.qpanel .desc { margin: 0; white-space: pre-line; }
.photos { display: flex; gap: var(--space-2); overflow-x: auto; }
.photos a { position: relative; flex: none; width: 140px; height: 105px; border-radius: var(--a-radius); overflow: hidden; background: var(--color-bg); display: flex; align-items: center; justify-content: center; color: var(--color-ink); }
.photos img { width: 100%; height: 100%; object-fit: cover; }
.photos span { position: absolute; bottom: 4px; right: 4px; left: 4px; background: rgba(23, 43, 38, .72); color: #fff; border-radius: var(--radius-full); font: 600 11px/1.6 var(--font-family-base); padding: 0 6px; text-align: center; }
dl.specs { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; font: var(--text-helper); }
dl.specs dt { color: var(--color-text-muted); }
dl.specs dd { margin: 0; font-weight: 700; }
.owner, .sec { background: var(--color-bg); border-radius: var(--a-radius); padding: var(--space-3) var(--space-4); display: flex; flex-direction: column; gap: 2px; }
.owner h3, .sec h3 { margin: 0 0 var(--space-1); font: var(--text-label); color: var(--color-text-muted); }
.owner p, .sec p { margin: 2px 0; }
.sec.warn { background: var(--color-warning-bg); color: var(--color-warning-text); }

.lform { display: flex; flex-direction: column; gap: var(--space-3); }
.lform-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); }

/* owner edit waiting for approval (step 3.5) */
.revision { background: var(--color-warning-bg); border-radius: var(--a-radius); padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-3); }
.diff .tr { grid-template-columns: 120px minmax(0, 1fr) minmax(0, 1fr); min-width: 0; }
.diff .old { color: var(--color-text-muted); text-decoration: line-through; }
.diff .new { font-weight: 700; }

/* A06 conversations (step 3.6) */
.cgroup { display: flex; flex-direction: column; gap: 2px; padding-bottom: var(--space-2); }
.cg-head { display: flex; flex-direction: column; padding: var(--space-2) var(--space-4) 0; }
.citem .count, .cpanel .count { background: var(--color-error); color: #fff; border-radius: var(--radius-full); min-width: 22px; padding: 0 6px; text-align: center; font: 800 11px/22px var(--font-family-base); }
.clast { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.thread { display: flex; flex-direction: column; gap: 8px; min-height: 200px; max-height: 46vh; overflow-y: auto; padding: var(--space-3); background: var(--color-bg); border-radius: var(--a-radius); }
.cday { align-self: center; margin: 4px 0; }
.cday span { background: var(--color-surface); border-radius: var(--radius-full); padding: 2px 10px; font: 700 11px/20px var(--font-family-base); color: var(--color-text-muted); }
.cmsg { display: flex; max-width: 80%; }
.cmsg.them { align-self: flex-start; }
.cmsg.me { align-self: flex-end; }
.cbub { padding: 8px 12px; border-radius: 16px; display: flex; flex-direction: column; gap: 4px; background: var(--color-surface); }
.cmsg.me .cbub { background: var(--color-primary); color: #fff; }
.cmsg.me .cbub .help { color: var(--color-on-green-muted); }
.cbub p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.catt { display: block; width: 180px; border-radius: 12px; overflow: hidden; color: inherit; }
.catt img { width: 100%; display: block; }
.creply { display: flex; flex-direction: column; gap: var(--space-2); }

/* A10 settings */
.setting { display: flex; flex-direction: column; gap: var(--space-2); }
.setting textarea.input { min-height: 320px; font: var(--text-body); }
.saved { font: var(--text-helper); color: var(--color-success); }
.imgset { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-3); }
.imgcard { background: var(--color-surface); border-radius: var(--radius-card); box-shadow: var(--shadow-card); padding: var(--space-3); display: flex; flex-direction: column; gap: var(--space-2); }
.imgcard .pic { position: relative; aspect-ratio: 16 / 10; border-radius: 18px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: var(--color-bg); color: var(--color-text-muted); font: var(--text-helper); }
.imgcard .pic img { width: 100%; height: 100%; object-fit: cover; }
.imgcard .pic .note { position: absolute; bottom: 8px; right: 8px; background: rgba(23, 43, 38, .72); color: #fff; border-radius: var(--radius-full); padding: 0 10px; font: 700 11px/22px var(--font-family-base); }
.imgcard.hero { grid-column: 1 / -1; max-width: 640px; }
.imgcard.hero .pic { aspect-ratio: 16 / 7; }
.slotgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--space-3); }
.slotgrid .grid4 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }

/* ---------- overlays ---------- */
.toast {
  position: fixed; bottom: var(--space-6); left: 50%; transform: translateX(-50%); z-index: 30; background: var(--color-ink); color: #fff;
  border-radius: var(--radius-full); padding: var(--space-3) var(--space-5); font: 700 13px/20px var(--font-family-base); box-shadow: var(--shadow-float-dark); max-width: calc(100% - 32px);
}
.modal { position: fixed; inset: 0; z-index: 25; background: var(--color-scrim); display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.modal-box { background: var(--color-surface); border-radius: var(--radius-sheet); padding: var(--space-6); width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: var(--space-3); box-shadow: var(--shadow-float); }
.modal-box h2 { font: var(--text-title-2); }
.modal-box p { margin: 0; color: var(--color-text-muted); }
.modal-box .row .btn { flex: 1; }
.modal-box.wide { max-width: 560px; }
@media (prefers-reduced-motion: reduce) { .btn .spin { animation: none; } }
