/* Admin audit A2–A5: scoped typography, honest hierarchy and usable reflow. */
#adminWorkspace {
  --admin-small: clamp(14px, .82rem + .08vw, 16px);
  --admin-body: clamp(16px, .9rem + .1vw, 18px);
  --admin-ink-soft: #514b3f;
  grid-template-rows: auto minmax(0, 1fr);
  font-size: var(--admin-body);
}
#adminWorkspace [hidden], #appShell[hidden] { display: none !important; }
#adminWorkspace :is(button, a, input, textarea, select, summary):focus-visible {
  outline: 3px solid #8c461f;
  outline-offset: 3px;
}
#adminWorkspace :is(.admin-header, .admin-nav, .admin-ticket-dashboard) :is(button, a, input, textarea, select, summary):focus-visible {
  outline-color: #d4e569;
}
#adminWorkspace button:disabled { cursor: not-allowed; }
#adminWorkspace .admin-header {
  display: grid;
  height: auto;
  max-height: none;
  min-height: 88px;
  grid-template-columns: minmax(250px, 1fr) auto;
  grid-template-rows: auto auto;
  gap: 8px 20px;
  padding: 14px clamp(16px, 2vw, 36px);
  overflow: visible;
}
#adminWorkspace .admin-brand { grid-column: 1; grid-row: 1; }
#adminWorkspace .admin-header-actions { grid-column: 2 !important; grid-row: 1 !important; gap: 10px; }
#adminWorkspace .admin-header-actions button { min-height: 46px; font-size: var(--admin-small); }
#adminWorkspace .admin-session {
  display: flex;
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: end;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
}
#adminWorkspace .admin-session strong { font-size: 14px; color: #cac6b8; font-weight: 500; line-height: 1.4; }
#adminWorkspace .admin-session i { font-size: 14px; }
#adminWorkspace .admin-stage { container: admin-stage / inline-size; }
#adminWorkspace .admin-nav-button { min-height: 94px; gap: 12px; }
#adminWorkspace .admin-nav-button small { white-space: normal; overflow: visible; line-height: 1.5; font-size: 13px; color: #bdb7a5; }
#adminWorkspace .admin-nav-button strong { white-space: normal; overflow: visible; line-height: 1.35; font-size: clamp(20px, 1.08rem + .12vw, 24px); }
#adminWorkspace .admin-nav-badge { color: #f2f5d9 !important; background: #3d491e; font-size: 14px !important; line-height: 1 !important; }
#adminWorkspace .admin-stage-head { min-height: 140px; padding: 28px clamp(20px, 3vw, 50px); align-items: center; }
#adminWorkspace .admin-stage-head h3 { line-height: 1.25; }
#adminWorkspace .admin-view { padding: 26px clamp(16px, 2.5vw, 46px) 40px; }
#adminWorkspace .admin-card-head { flex-wrap: wrap; gap: 10px 20px; }
#adminWorkspace :is(.admin-card-head > span, .admin-card-head div > span, .admin-stage-head > span,
 .admin-overview-summary article span, .admin-overview-summary article small,
 .admin-health-list span, .admin-health-list p, .admin-table th,
 .account-identity small, .account-balance small, .account-state, .account-survivor-rank,
 .account-access small, .account-row-actions button, .setting-row > span, .setting-edit-button,
 .log-subtabs button, .account-subtabs button, .log-level, .event-row time,
 .operation-stat p, .control-field small, .control-safety, .control-status-card > span,
 .backup-summary span, .admin-audit-outcome, .admin-audit-detail small) {
  font-size: var(--admin-small);
  line-height: 1.5;
}
#adminWorkspace :is(.admin-table td, .setting-row code, .settings-edit-note p, .log-message,
 .event-row p, .admin-audit-detail p, .control-status-card p, .control-field select,
 .control-field textarea, .control-intro p, .backup-item p) {
  font-size: var(--admin-body);
  line-height: 1.6;
}
#adminWorkspace .admin-table td strong { font-size: var(--admin-body); }
#adminWorkspace .account-balance { min-height: 44px; gap: 7px; padding: 8px 12px; }
#adminWorkspace .account-balance strong { font-size: 21px; }
#adminWorkspace .account-balance small { font-size: 14px; }
#adminWorkspace .account-identity small { overflow-wrap: anywhere; }
#adminWorkspace .account-row-actions { display: flex; flex-wrap: wrap; gap: 8px; }
#adminWorkspace :is(.account-row-actions button, .setting-edit-button) { min-height: 44px; }
#adminWorkspace .admin-chart-legend b { font-size: 14px; }
#adminWorkspace .admin-chart-legend strong { font-size: 18px; }
#adminWorkspace :is(.admin-chart-axis, .admin-chart-times) { color: #c1bcac; font-size: 13px; }
#adminWorkspace .admin-chart-legend .memory strong { white-space: normal; }
#adminWorkspace .admin-chart-legend { flex-wrap: wrap; }
#adminWorkspace .setting-row { grid-template-columns: 140px minmax(0, 1fr) minmax(0, 1fr) auto; gap: 15px; }
#adminWorkspace .setting-row code { overflow-wrap: anywhere; }

/* Log types have their own tracks; quest detail must not inherit a price column. */
#adminWorkspace .shop-log-row { grid-template-columns: minmax(120px, .7fr) minmax(120px, .7fr) minmax(180px, 1.6fr) minmax(100px, .55fr) minmax(145px, .8fr); gap: 20px; }
#adminWorkspace .quest-log-row { grid-template-columns: minmax(120px, .65fr) minmax(120px, .7fr) minmax(170px, .85fr) minmax(260px, 2fr); }
#adminWorkspace :is(.shop-log-row time, .shop-log-buyer > span, .shop-log-item > span, .shop-log-total > span,
 .shop-log-item small, .shop-log-status, .update-event-row time, .restart-summary-card span, .admin-audit-row time) {
  font-size: var(--admin-small); line-height: 1.5;
}
#adminWorkspace :is(.shop-log-buyer strong, .shop-log-item strong, .shop-log-total strong, .update-event-row p, .restart-summary-card p) { font-size: var(--admin-body); line-height: 1.5; }
#adminWorkspace .shop-log-item small { white-space: normal; overflow-wrap: anywhere; }
#adminWorkspace .shop-log-status { min-height: 40px; padding: 8px 12px; overflow-wrap: anywhere; text-align: center; }
#adminWorkspace .shop-log-status.uncertain, #adminWorkspace .shop-log-status.dispatching { color: #694600; border-color: #927329; background: #f0e0ad; }
#adminWorkspace .admin-audit-list { min-width: 0; }
#adminWorkspace .admin-audit-row { grid-template-columns: minmax(120px, .65fr) minmax(130px, .7fr) minmax(170px, .9fr) minmax(220px, 1.6fr); }

/* Ticket filtering is live; edits are staged and require explicit review. */
#adminWorkspace .admin-ticket-toolbar { grid-template-columns: minmax(170px, 1fr) minmax(145px, .65fr) minmax(160px, .75fr); gap: 12px; padding: 18px; }
#adminWorkspace .admin-ticket-filter-status { grid-column: 1 / -1; min-height: 0; padding: 0; border: 0; background: none; justify-content: flex-start; font-size: 14px; text-align: left; }
#adminWorkspace .admin-ticket-metrics { display: flex; flex-wrap: wrap; gap: 8px; }
#adminWorkspace .admin-ticket-mobile-summary { display: none; }
#adminWorkspace .admin-ticket-metrics article { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px 14px; flex: 1 1 auto; }
#adminWorkspace .admin-ticket-metrics span { font-size: 14px; letter-spacing: 0; }
#adminWorkspace .admin-ticket-metrics strong { margin: 0 0 0 auto; font-size: 25px; line-height: 1.2; }
#adminWorkspace .admin-ticket-layout { grid-template-columns: minmax(300px, .8fr) minmax(0, 1.7fr); min-height: 0; }
#adminWorkspace .admin-ticket-row { padding: 20px; }
#adminWorkspace .admin-ticket-row h4 { font-size: 23px; white-space: normal; line-height: 1.35; }
#adminWorkspace :is(.admin-ticket-toolbar label, .admin-ticket-controls label, .admin-ticket-row header,
 .admin-ticket-row footer, .admin-ticket-detail-head span, .admin-ticket-message header,
 .admin-ticket-event-log li, .admin-ticket-event-log summary, .admin-ticket-composer footer > span) { color: #c7cdbd; font-size: var(--admin-small); letter-spacing: 0; line-height: 1.5; }
#adminWorkspace :is(.admin-ticket-row p, .admin-ticket-detail-head p, .admin-ticket-message p,
 .admin-ticket-composer textarea, .admin-ticket-controls select, .admin-ticket-toolbar input,
 .admin-ticket-toolbar select, .admin-ticket-composer button, .admin-ticket-controls button) { font-size: var(--admin-body); line-height: 1.6; }
#adminWorkspace .admin-ticket-row :is(header, footer), #adminWorkspace .admin-ticket-message header { flex-wrap: wrap; }
#adminWorkspace .admin-ticket-detail-head h4 { font-size: clamp(25px, 1.6rem, 34px); line-height: 1.35; overflow-wrap: anywhere; }
#adminWorkspace .admin-ticket-controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#adminWorkspace .admin-ticket-save-row { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 16px; color: #c7cdbd; font-size: 14px; }
#adminWorkspace .admin-ticket-save-row button { flex: 0 0 auto; }
#adminWorkspace .admin-ticket-thread { min-height: 220px; max-height: 520px; }
#adminWorkspace .admin-ticket-message { width: min(94%, 940px); }
#adminWorkspace .admin-ticket-composer label { display: block; margin: 14px 0 8px; color: #eceddf; font-size: 14px; font-weight: 700; }
#adminWorkspace .admin-ticket-composer textarea { min-height: 145px; }
#adminWorkspace .admin-ticket-compose-mode { display: flex; flex-wrap: wrap; gap: 10px; }
#adminWorkspace .admin-ticket-compose-mode button { display: inline-flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 14px; border: 1px solid #5d654e; background: #151c12; color: #e9ebdf; }
#adminWorkspace .admin-ticket-compose-mode button[aria-pressed="true"] { border-color: #d0df68; color: #f4f7dc; background: #35451b; box-shadow: inset 0 -3px #d0df68; }
#adminWorkspace .admin-ticket-composer[data-mode="note"] { border-top: 3px solid #e1b767; }
#adminWorkspace .admin-ticket-composer[data-mode="note"] .admin-ticket-compose-mode button[aria-pressed="true"] { border-color: #e1b767; color: #ffe5ae; background: #3b2e15; box-shadow: inset 0 -3px #e1b767; }
#adminWorkspace #adminTicketAudience { color: #d9dfc9; font-size: var(--admin-small); line-height: 1.5; margin-top: 12px; }
#adminWorkspace .admin-ticket-back { display: none; padding: 14px 20px; border: 0; border-bottom: 1px solid #4d563d; background: #283319; color: #f4f6e1; font-size: 16px; font-weight: 700; cursor: pointer; }
#adminWorkspace .admin-ticket-back i { margin-right: 10px; }
#adminTicketReviewDialog { width: min(800px, calc(100vw - 32px)); max-height: 90dvh; overflow-y: auto; padding: clamp(20px, 3vw, 36px); }
#adminTicketReviewDialog h2 { margin: 20px 0 14px; font-size: clamp(28px, 2rem, 38px); line-height: 1.3; }
#adminTicketReviewBody { max-height: 40dvh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; padding: 20px; border: 1px solid #a69b80; background: #f5ebd6; color: #211f17; font: 500 17px/1.6 "Inter", sans-serif; }
#adminTicketReviewTarget { margin: 16px 0; color: #423b2b; font-weight: 700; overflow-wrap: anywhere; }
#adminTicketReviewDialog :is(button, p) { font-size: 16px; line-height: 1.5; }
#adminTicketReviewDialog button { min-height: 46px; }

@container admin-stage (max-width: 1150px) {
  #adminWorkspace .admin-ticket-layout { grid-template-columns: 1fr; }
  #adminWorkspace .admin-ticket-layout[data-detail-open="true"] .admin-ticket-queue { display: none; }
  #adminWorkspace .admin-ticket-layout[data-detail-open="false"] .admin-ticket-inspector { display: none; }
  #adminWorkspace .admin-ticket-back { display: block; width: 100%; text-align: left; }
  #adminWorkspace .admin-ticket-queue { max-height: none; border: 0; }
  #adminWorkspace :is(.accounts-table, .banned-table) { display: block; min-width: 0; border: 0; background: transparent; }
  #adminWorkspace :is(.accounts-table, .banned-table) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #adminWorkspace :is(.accounts-table, .banned-table) tbody { display: grid; gap: 16px; padding: 16px; }
  #adminWorkspace :is(.accounts-table, .banned-table) tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--admin-line); border-radius: 8px; background: rgba(255,252,245,.45); }
  #adminWorkspace :is(.accounts-table, .banned-table) td { display: grid; min-width: 0; gap: 8px; padding: 16px; border: 0; border-bottom: 1px solid var(--admin-line); }
  #adminWorkspace :is(.accounts-table, .banned-table) td::before { content: attr(data-label); color: #78512f; font-size: 14px; font-weight: 700; }
  #adminWorkspace :is(.accounts-table, .banned-table) td:first-child,
  #adminWorkspace :is(.accounts-table, .banned-table) td:last-child { grid-column: 1 / -1; }
  #adminWorkspace :is(.shop-log-row, .quest-log-row, .admin-audit-row) { grid-template-columns: 1fr 1fr; gap: 16px; padding: 20px; }
  #adminWorkspace .shop-log-item, #adminWorkspace .admin-audit-detail { grid-column: 1 / -1; }
  #adminWorkspace .shop-log-status { grid-column: auto; grid-row: auto; }
  #adminWorkspace .setting-row { grid-template-columns: minmax(0, 1fr) auto; }
  #adminWorkspace .setting-row code { grid-column: 1; }
  #adminWorkspace .setting-edit-button { grid-column: 2; grid-row: 1 / span 3; }
}
@container admin-stage (max-width: 650px) {
  #adminWorkspace .admin-ticket-toolbar { grid-template-columns: 1fr 1fr; }
  #adminWorkspace .admin-ticket-toolbar label:first-child { grid-column: 1 / -1; }
  #adminWorkspace .admin-ticket-controls { grid-template-columns: 1fr; }
  #adminWorkspace .admin-ticket-save-row, #adminWorkspace .admin-ticket-composer footer { flex-direction: column; align-items: stretch; }
  #adminWorkspace .admin-ticket-detail-head { flex-direction: column; }
  #adminWorkspace .admin-ticket-metrics article { padding: 8px 12px; }
  #adminWorkspace .admin-ticket-metrics strong { font-size: 21px; }
  #adminWorkspace :is(.shop-log-row, .quest-log-row, .admin-audit-row) { grid-template-columns: 1fr; }
  #adminWorkspace :is(.shop-log-row, .quest-log-row, .admin-audit-row) > * { grid-column: 1; grid-row: auto; }
  #adminWorkspace .admin-chart-tooltip { min-width: 0; width: min(300px, 90%); }
}
@media (max-width: 1100px) {
  /* Keep narrow-window/text-zoom reflow independent of Safari size-query
     evaluation: the viewport also enforces single-pane tickets and cards. */
  #adminWorkspace .admin-ticket-layout { grid-template-columns: 1fr; }
  #adminWorkspace .admin-ticket-layout[data-detail-open="true"] .admin-ticket-queue { display: none; }
  #adminWorkspace .admin-ticket-layout[data-detail-open="false"] .admin-ticket-inspector { display: none; }
  #adminWorkspace .admin-ticket-back { display: block; width: 100%; text-align: left; }
  #adminWorkspace .admin-ticket-queue { max-height: none; border: 0; }
  #adminWorkspace :is(.accounts-table, .banned-table) { display: block; min-width: 0; border: 0; background: transparent; }
  #adminWorkspace :is(.accounts-table, .banned-table) thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  #adminWorkspace :is(.accounts-table, .banned-table) tbody { display: grid; gap: 16px; padding: 16px; }
  #adminWorkspace :is(.accounts-table, .banned-table) tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--admin-line); border-radius: 8px; background: rgba(255,252,245,.45); }
  #adminWorkspace :is(.accounts-table, .banned-table) td { display: grid; min-width: 0; gap: 8px; padding: 16px; border: 0; border-bottom: 1px solid var(--admin-line); }
  #adminWorkspace :is(.accounts-table, .banned-table) td::before { content: attr(data-label); color: #78512f; font-size: 14px; font-weight: 700; }
  #adminWorkspace :is(.accounts-table, .banned-table) td:first-child,
  #adminWorkspace :is(.accounts-table, .banned-table) td:last-child { grid-column: 1 / -1; }
  #adminWorkspace :is(.shop-log-row, .quest-log-row, .admin-audit-row) { grid-template-columns: 1fr 1fr; gap: 16px; padding: 20px; }
  #adminWorkspace .shop-log-item, #adminWorkspace .admin-audit-detail { grid-column: 1 / -1; }
  #adminWorkspace .shop-log-status { grid-column: auto; grid-row: auto; }
  #adminWorkspace .setting-row { grid-template-columns: minmax(0, 1fr) auto; }
  #adminWorkspace .setting-row code { grid-column: 1; }
  #adminWorkspace .setting-edit-button { grid-column: 2; grid-row: 1 / span 3; }
  #adminWorkspace .admin-header { grid-template-columns: minmax(0, 1fr) auto; }
  #adminWorkspace .admin-header-actions button { width: 46px; padding: 0; }
  #adminWorkspace .admin-header-actions button > span { display: none; }
  #adminWorkspace .admin-header-actions .language-toggle span { display: inline; }
  #adminWorkspace #adminLogout { display: inline-flex; }
  #adminWorkspace .admin-brand h2 { font-size: 28px; }
}
@media (max-width: 820px) {
  #adminWorkspace .admin-layout { grid-template-columns: 115px minmax(0, 1fr); }
  #adminWorkspace .admin-nav-button { grid-template-columns: 1fr; padding: 12px 8px; gap: 7px; }
  #adminWorkspace .admin-nav-button small { display: none; }
  #adminWorkspace .admin-nav-button strong { font-family: "Inter", sans-serif; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
  #adminWorkspace .admin-header-actions { gap: 6px; }
}
@media (max-width: 700px) {
  #adminWorkspace .admin-layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  #adminWorkspace .admin-nav { flex-direction: row; overflow-x: auto; border-bottom: 1px solid #5c6249; }
  #adminWorkspace .admin-nav-button { min-height: 72px; width: auto; min-width: 140px; max-width: 175px; flex: 0 0 auto; }
  #adminWorkspace .admin-ticket-toolbar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #adminWorkspace .admin-ticket-toolbar label:first-child { grid-column: 1 / -1; }
  #adminWorkspace .admin-ticket-controls { grid-template-columns: minmax(0, 1fr); }
  #adminWorkspace .admin-ticket-detail-head { flex-direction: column; }
  #adminWorkspace :is(.shop-log-row, .quest-log-row, .admin-audit-row) { grid-template-columns: 1fr; }
  #adminWorkspace :is(.shop-log-row, .quest-log-row, .admin-audit-row) > * { grid-column: 1; grid-row: auto; }
  #adminWorkspace .admin-chart-tooltip { min-width: 0; width: min(300px, 90%); }
  #adminWorkspace .admin-ticket-save-row, #adminWorkspace .admin-ticket-composer footer { flex-direction: column; align-items: stretch; }
  #adminWorkspace .admin-ticket-metrics { display: none; }
  #adminWorkspace .admin-ticket-mobile-summary { display: block; margin: 0; color: #514b3f; font-size: 15px; font-weight: 700; }
  #adminWorkspace .admin-ticket-dashboard:has([data-detail-open="true"]) :is(.admin-ticket-toolbar, .admin-ticket-mobile-summary) { display: none; }
}
@media (max-width: 560px) {
  #adminWorkspace .admin-header { padding: 10px 12px; gap: 8px; }
  #adminWorkspace .admin-brand h2, #adminWorkspace .admin-brand p { display: none; }
  #adminWorkspace .admin-brand .brand-mark { width: 40px; height: 40px; flex-basis: 40px; }
  #adminWorkspace .admin-session { justify-self: start; }
  #adminWorkspace .admin-session strong { font-size: 13px; }
  #adminWorkspace .admin-stage-head { min-height: 110px; padding: 20px 16px; gap: 12px; }
  #adminWorkspace .admin-stage-head h3 { font-size: 32px; }
  #adminWorkspace .admin-view { padding: 16px 12px 28px; }
  #adminWorkspace .admin-ticket-toolbar { padding: 14px; }
  #adminWorkspace .admin-ticket-toolbar label { font-size: 13px; }
  #adminWorkspace .admin-ticket-message { width: 100%; }
}
