/* Shared administrator-center theme. Opt in with <body class="admin-theme">.
   Load after legacy page CSS and before page-specific layout CSS. */
body.admin-theme {
  --theme-yellow: #fee500;
  --theme-yellow-hover: #f5da00;
  --theme-background: #f4f5f7;
  --theme-surface: #fff;
  --theme-ink: #272b30;
  --theme-muted: #626b76;
  --theme-line: #e2e4e7;
  --theme-selected: #f0f2f5;
  --theme-danger: #ac2727;
  --theme-danger-soft: #fff0ed;
  --theme-danger-line: #e9afb2;
  --theme-warning: #805000;
  --theme-warning-soft: #fff3d6;
  --theme-warning-line: #e8cc8b;
  --theme-success: #205834;
  --theme-success-soft: #e8f6ec;
  --theme-badge-red: #c6323c;
  --theme-focus: #215ec1;
  --theme-chart-as-is: #215ec1;
  --theme-chart-content: #7543a2;
  --theme-radius: 6px;
  --theme-font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--theme-ink);
  background: var(--theme-background);
  font: 14px/1.6 var(--theme-font);
}
.admin-theme *, .admin-theme *::before, .admin-theme *::after { box-sizing: border-box; }
.admin-theme [hidden] { display: none !important; }
.admin-theme h1, .admin-theme h2, .admin-theme h3 { color: var(--theme-ink); line-height: 1.4; }
.admin-theme .ui-header, .admin-theme > header { display: flex; flex: none; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-height: 58px; padding: 10px 18px; background: var(--theme-surface); border-bottom: 1px solid var(--theme-line); }
.admin-theme .ui-header h1, .admin-theme > header h1 { margin: 0; font-size: 16px; letter-spacing: -.025em; }
.admin-theme .ui-shell { display: flex; min-width: 0; flex: 1; min-height: 0; height: auto; }
.admin-theme .ui-sidebar { flex: 0 0 240px; width: 240px; min-width: 0; background: var(--theme-surface); border-right: 1px solid var(--theme-line); }
.admin-theme .ui-nav { display: flex; flex-direction: column; gap: 4px; margin: 0; padding: 12px; list-style: none; }
.admin-theme .ui-nav a, .admin-theme .ui-nav button { display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 5px; color: var(--theme-muted); background: transparent; text-decoration: none; text-align: left; font-size: 13px; }
.admin-theme .ui-nav a:hover, .admin-theme .ui-nav button:hover:not(:disabled) { color: var(--theme-ink); background: #f7f8fa; }
.admin-theme .ui-nav [aria-current="page"], .admin-theme .ui-nav .is-active { color: var(--theme-ink); background: var(--theme-selected); box-shadow: inset 3px 0 #454d58; font-weight: 700; }
.admin-theme .ui-content { flex: 1; min-width: 0; padding: 24px; }
.admin-theme .ui-card { min-width: 0; margin-bottom: 16px; padding: 20px; background: var(--theme-surface); border: 1px solid var(--theme-line); border-radius: var(--theme-radius); }
.admin-theme .ui-card > :first-child { margin-top: 0; }
.admin-theme .ui-card > :last-child { margin-bottom: 0; }
.admin-theme .ui-card h2 { font-size: 17px; }
.admin-theme .ui-card h3 { font-size: 14px; }
.admin-theme .ui-table-wrap { width: 100%; max-width: 100%; overflow-x: auto; border: 1px solid var(--theme-line); border-radius: var(--theme-radius); }
.admin-theme .ui-table { width: 100%; border-collapse: collapse; background: var(--theme-surface); font-size: 13px; text-align: left; }
.admin-theme .ui-table th, .admin-theme .ui-table td { padding: 12px 14px; border-bottom: 1px solid var(--theme-line); vertical-align: top; overflow-wrap: normal; word-break: keep-all; }
.admin-theme .ui-table th { color: var(--theme-muted); background: #f7f8fa; font-size: 12px; font-weight: 650; }
/* Shared table readability: labels keep words, long identifiers may wrap. */
.admin-theme .ui-table th { white-space: nowrap; }
.admin-theme .ui-table td .ui-muted, .admin-theme .ui-table td .muted { overflow-wrap: anywhere; }
.admin-theme .stats-table th, .admin-theme .stats-table td { text-align: right; font-variant-numeric: tabular-nums; }
.admin-theme .stats-table th:first-child, .admin-theme .stats-table td:first-child { text-align: left; }
.admin-theme .ui-table tr:last-child td { border-bottom: 0; }
.admin-theme .ui-table tbody tr:hover { background: #fafbfc; }
.admin-theme button, .admin-theme .ui-button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 34px; padding: 6px 12px; border: 1px solid #d0d5dc; border-radius: 5px; background: var(--theme-surface); color: #53606e; font: 600 12px/1.5 var(--theme-font); cursor: pointer; text-decoration: none; }
.admin-theme button:hover:not(:disabled), .admin-theme .ui-button:hover:not(:disabled):not([aria-disabled="true"]) { background: #f3f4f5; border-color: #adb5bf; }
.admin-theme button.primary, .admin-theme .ui-button.primary { background: var(--theme-yellow); border-color: #e6ce00; color: #3c3524; }
.admin-theme button.primary:hover:not(:disabled), .admin-theme .ui-button.primary:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--theme-yellow-hover); border-color: #d4bd00; }
.admin-theme .ui-button.secondary { background: var(--theme-surface); color: #53606e; border-color: #d0d5dc; }
.admin-theme button.danger, .admin-theme .ui-button.danger { color: #fff; background: var(--theme-danger); border-color: #8a1f1f; }
.admin-theme button.danger:hover:not(:disabled), .admin-theme .ui-button.danger:hover:not(:disabled):not([aria-disabled="true"]) { background: #902020; border-color: #781a1a; }
.admin-theme button:disabled, .admin-theme .ui-button[aria-disabled="true"] { opacity: 1; color: #737d89; background: #edf0f3; border-color: #dce0e6; cursor: not-allowed; }
.admin-theme input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), .admin-theme textarea, .admin-theme select, .admin-theme .ui-input { max-width: 100%; min-width: 0; padding: 8px 10px; border: 1px solid #c9cfd7; border-radius: 5px; color: var(--theme-ink); background: var(--theme-surface); font: inherit; }
.admin-theme textarea { width: 100%; resize: vertical; }
.admin-theme input:disabled, .admin-theme textarea:disabled, .admin-theme select:disabled { color: var(--theme-muted); background: #edf0f3; cursor: not-allowed; }
.admin-theme input::placeholder, .admin-theme textarea::placeholder { color: #737d89; opacity: 1; }
.admin-theme :where(button, input, textarea, select, summary, a, [tabindex]):focus-visible { outline: 3px solid var(--theme-focus); outline-offset: 3px; }
.admin-theme .ui-badge, .admin-theme .badge { display: inline-block; vertical-align: middle; border: 1px solid #d5dae1; border-radius: 4px; padding: 2px 6px; background: #edf0f3; color: #53606e; font-size: 11px; font-weight: 650; line-height: 1.5; }
.admin-theme .ui-badge.neutral, .admin-theme .badge.sent, .admin-theme .badge.processed, .admin-theme .badge.superseded, .admin-theme .badge.muted-badge { color: #53606e; background: #edf0f3; border-color: #d5dae1; }
.admin-theme .ui-badge.success, .admin-theme .badge.ok, .admin-theme .badge.drafted { color: var(--theme-success); background: var(--theme-success-soft); border-color: #a9cdb5; }
.admin-theme .ui-badge.warning, .admin-theme .badge.warn, .admin-theme .badge.hold { color: var(--theme-warning); background: var(--theme-warning-soft); border-color: #e8cc8b; }
.admin-theme .ui-badge.danger, .admin-theme .badge.failed, .admin-theme .badge.bad, .admin-theme .badge.confirm, .admin-theme .badge.unverified { color: #9c2028; background: #ffebea; border-color: var(--theme-danger-line); }
.admin-theme .ui-badge.unread { color: #fff; background: var(--theme-badge-red); border-color: var(--theme-badge-red); border-radius: 50px; min-width: 20px; text-align: center; }
.admin-theme .badge.new { color: #53606e; background: #edf0f3; border-color: #d5dae1; }
.admin-theme .badge.sending { color: #65389c; background: #f1eafa; border-color: #d8c4ed; }
.admin-theme .ui-muted, .admin-theme .muted { color: var(--theme-muted); }
/* Opt-in data states and text differences; decoration also identifies changes. */
.admin-theme .ui-empty { margin: 12px 0; padding: 20px 16px; border: 1px dashed #c9cfd7; border-radius: var(--theme-radius); color: var(--theme-muted); background: var(--theme-background); text-align: center; overflow-wrap: anywhere; }
.admin-theme .ui-sample-note { margin: 8px 0; padding: 8px 12px; border-left: 3px solid var(--theme-warning); border-radius: 0 var(--theme-radius) var(--theme-radius) 0; color: var(--theme-warning); background: var(--theme-warning-soft); font-size: 12px; overflow-wrap: anywhere; }
.admin-theme .ui-diff-added { color: var(--theme-success); background: var(--theme-success-soft); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.admin-theme .ui-diff-removed { color: var(--theme-danger); background: var(--theme-danger-soft); text-decoration: line-through; text-decoration-thickness: 2px; }
.admin-theme .ui-alert { flex: none; margin: 0; padding: 12px 18px; border: 1px solid #d5dae1; border-radius: var(--theme-radius); background: #edf0f3; color: #53606e; overflow-wrap: anywhere; }
.admin-theme .ui-alert.warning { color: var(--theme-warning); background: var(--theme-warning-soft); border-color: #e8cc8b; }
.admin-theme .ui-alert.danger, .admin-theme .detection-alert { flex: none; padding: 12px 18px; color: #fff; background: var(--theme-danger); border: 0; border-bottom: 3px solid #781a1a; font-weight: 700; overflow-wrap: anywhere; }
/* Place toast as a sibling before the shell. Normal flow reserves its space;
   never position it above the composer or another actionable control. */
.admin-theme .ui-toast, .admin-theme .send-toast { position: static; inset: auto; transform: none; z-index: auto; flex: none; display: flex; align-items: center; gap: 12px; width: 100%; max-height: min(20vh, 140px); overflow-y: auto; padding: 10px 18px; border: 0; border-bottom: 1px solid #c78620; border-radius: 0; background: var(--theme-warning-soft); color: #633b00; box-shadow: none; font-size: 13px; }
.admin-theme .ui-toast > span, .admin-theme .send-toast > span { flex: 1; min-width: 0; white-space: pre-line; overflow-wrap: anywhere; }
.admin-theme .ui-toast > button, .admin-theme .send-toast > button { flex-shrink: 0; }
.admin-theme .ui-toast.success, .admin-theme .send-toast.sent { color: var(--theme-success); background: var(--theme-success-soft); border-color: #398555; }
.admin-theme .ui-toast.danger, .admin-theme .send-toast.failed, .admin-theme .send-toast.unverified { color: #8b3023; background: var(--theme-danger-soft); border-color: #bf594a; }
.admin-theme .ui-toast.neutral, .admin-theme .send-toast.manual { color: #53606e; background: #edf0f3; border-color: #adb5bf; }
.admin-theme .send-toast.sending { color: #214d85; background: #edf4ff; border-color: #527caf; }
/* Login styling stays here while the auth team owns its markup and behavior.
   Scope by the existing IDs so this also wins when login.css loads later. */
.admin-theme .login-card { max-width: min(400px, 100%); overflow-wrap: anywhere; }
.admin-theme .login-card #googleBtn {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  gap: 10px;
  padding: 10px 14px;
  color: var(--theme-ink);
  background: var(--theme-surface);
  border: 1px solid #c9cfd7;
  font-size: 13px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.admin-theme .login-card #googleBtn:hover:not(:disabled) { background: #f3f4f5; border-color: #adb5bf; }
.admin-theme .login-card #googleBtn:focus-visible { outline: 3px solid var(--theme-focus); outline-offset: 3px; }
.admin-theme .login-card #googleBtn:disabled { color: var(--theme-muted); background: #edf0f3; border-color: #dce0e6; }
.admin-theme .login-card #googleBtn .google-mark {
  flex: none;
  width: auto;
  height: auto;
  border-radius: 0;
  color: var(--theme-muted);
  background: transparent;
  font: 600 14px/1.4 var(--theme-font);
}
.admin-theme .login-card #googleBtn > :last-child { min-width: 0; }
.admin-theme .login-card #notice { margin: 0 0 18px; padding: 14px 16px; font-size: 13px; line-height: 1.75; }
.admin-theme .login-card #noticeTitle { display: block; margin: 0 0 8px; font-size: 15px; line-height: 1.5; }
.admin-theme .login-card #noticeBody { display: block; white-space: pre-line; overflow-wrap: anywhere; word-break: keep-all; }
.admin-theme .login-card .login-hint { line-height: 1.65; overflow-wrap: anywhere; }
@media (max-width: 680px) {
  .admin-theme .ui-header, .admin-theme > header { min-height: 0; padding: 8px 12px; gap: 5px 8px; }
  .admin-theme .ui-header h1, .admin-theme > header h1 { font-size: 14px; }
  .admin-theme .ui-shell { flex-direction: column; }
  .admin-theme .ui-sidebar { flex: none; width: 100%; border-right: 0; border-bottom: 1px solid var(--theme-line); }
  .admin-theme .ui-nav { flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .admin-theme .ui-nav a, .admin-theme .ui-nav button { width: auto; }
  .admin-theme .ui-content { padding: 12px; }
  .admin-theme .ui-card { padding: 14px; }
  .admin-theme .ui-table th, .admin-theme .ui-table td { padding: 10px; }
  .admin-theme .ui-toast, .admin-theme .send-toast { padding: 10px 12px; gap: 8px; font-size: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .admin-theme *, .admin-theme *::before, .admin-theme *::after { scroll-behavior: auto !important; }
}
