:root {
  --bg: #f6f8fb;
  --panel: #fff;
  --text: #1f2328;
  --muted: #5b6570;
  --line: #d8dee6;
  --flat: #1f9d55;
  --up: #b23434;
  --down: #2f6fd6;
  --shadow: 0 10px 26px rgba(23, 29, 35, .08);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; color: var(--text); font: 14px/1.4 "Segoe UI", "Trebuchet MS", sans-serif; background: linear-gradient(135deg, #dff7f4, var(--bg) 46%, #eef5fb) fixed; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.admin-app { width: min(2200px, 100%); margin: 0 auto; padding: 18px; }
.admin-header { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.admin-header h1 { margin: 5px 0 2px; font-size: clamp(24px, 4vw, 34px); }
.admin-header p, .admin-back-link, .admin-status { color: var(--muted); }
.admin-header p { margin: 0; }
.admin-back-link { text-decoration: none; }
.admin-back-link:hover { text-decoration: underline; }
.admin-status { white-space: nowrap; }
.admin-status.is-error, .admin-error { color: #a52f2f; }
.admin-panel { border: 1px solid var(--line); border-radius: 14px; background: var(--panel); box-shadow: var(--shadow); }
.admin-filters { padding: 14px; margin-bottom: 14px; }
.admin-filters form { display: grid; grid-template-columns: repeat(4, minmax(110px, 1fr)) minmax(180px, 2fr) repeat(2, minmax(110px, 1fr)) auto; gap: 10px; align-items: end; }
.admin-filters label, .admin-edit-form label { display: grid; gap: 4px; min-width: 0; }
.admin-filters label span, .admin-edit-form label span { color: var(--muted); font-size: 12px; font-weight: 700; }
.admin-filters input, .admin-filters select, .admin-edit-form input, .admin-edit-form textarea, .admin-review-note { width: 100%; min-width: 0; border: 1px solid #c7d1dc; border-radius: 8px; padding: 8px 9px; color: var(--text); background: #fff; }
.admin-filter-wide { grid-column: auto; }
.admin-primary-button, .admin-secondary-button, .admin-approve-button, .admin-danger-button { min-height: 36px; border-radius: 8px; padding: 7px 12px; border: 1px solid transparent; font-weight: 700; }
.admin-primary-button { color: #fff; background: var(--flat); }
.admin-secondary-button { color: #285d4b; border-color: #b8d8ce; background: #f3fbf5; }
.admin-approve-button { color: #fff; background: var(--flat); }
.admin-danger-button { color: #9e3030; border-color: #edc4c4; background: #fff5f5; }
button:disabled { opacity: .45; cursor: default; }
.admin-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(390px, .85fr); gap: 14px; align-items: start; }
.admin-layout:not(.is-detail-open) .admin-list-panel { grid-column: 1 / -1; }
.admin-list-panel { min-width: 0; }
.admin-list-head, .admin-pagination, .admin-detail-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.admin-list-head { padding: 13px 14px; border-bottom: 1px solid var(--line); }
.admin-table-scroll { overflow-x: auto; }
.admin-table, .admin-detail-table { width: 100%; border-collapse: collapse; }
.admin-table { min-width: 920px; }
.admin-table th, .admin-table td, .admin-detail-table th, .admin-detail-table td { padding: 10px 9px; border-bottom: 1px solid #e6ebf0; text-align: left; vertical-align: top; }
.admin-table th, .admin-detail-table th { color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; text-transform: uppercase; }
.admin-table td { white-space: nowrap; }
.admin-table td span, .admin-table td small { display: block; color: var(--muted); font-size: 12px; }
.admin-activity-row { cursor: pointer; }
.admin-activity-row:hover { background: #f7fbff; }
.admin-owner-links { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.admin-owner-button { margin: -4px; padding: 4px; border: 0; color: #285d91; background: transparent; text-align: left; font: inherit; white-space: normal; }
.admin-owner-button:hover, .admin-owner-button:focus-visible { text-decoration: underline; }
.admin-rating-link { color: #285d91; font-size: 12px; white-space: nowrap; }
.admin-empty { padding: 28px !important; color: var(--muted); text-align: center !important; }
.admin-pagination { padding: 12px 14px; color: var(--muted); }
.admin-detail { min-width: 0; overflow: hidden; }
.admin-detail-head { padding: 13px 14px; border-bottom: 1px solid var(--line); }
.admin-detail-head > div { display: grid; gap: 2px; }
.admin-detail-head span { color: var(--muted); font-size: 12px; overflow-wrap: anywhere; }
.admin-close-button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); background: #fff; font-size: 24px; line-height: 1; }
#adminDetailBody { display: grid; gap: 16px; padding: 14px; }
#adminDetailBody section { border-top: 1px solid var(--line); padding-top: 13px; }
#adminDetailBody section:first-child { border-top: 0; padding-top: 0; }
#adminDetailBody h3 { margin: 0 0 9px; font-size: 15px; }
.admin-detail-facts { display: grid; gap: 6px; }
.admin-detail-facts span { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 8px; }
.admin-detail-facts b { color: var(--muted); font-size: 12px; }
.admin-detail-facts code { overflow-wrap: anywhere; font-size: 11px; }
.admin-score-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 13px; }
.admin-score-grid > div { display: grid; gap: 0; padding: 10px; border: 1px solid currentColor; border-radius: 9px; }
.admin-score-grid strong { font-size: 25px; line-height: 1.1; }
.admin-score-grid span { font-size: 11px; font-weight: 700; text-transform: uppercase; }
.admin-score-comparison { margin-top: 13px; }
.admin-score-comparison h3 { margin: 0 0 7px; font-size: 14px; }
.admin-score-comparison .admin-detail-table th, .admin-score-comparison .admin-detail-table td { padding: 6px 8px; }
.admin-quality-warning { margin: 8px 0 0; color: #8a5a00; }
.score-flat { color: var(--flat); }
.score-up { color: var(--up); }
.score-down { color: var(--down); }
.admin-detail-note, .admin-detail-ids, .admin-muted { color: var(--muted); }
.admin-detail-note { margin: 11px 0 0; }
.admin-detail-ids { margin: 7px 0 0; font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.admin-status { display: inline-block; padding: 3px 7px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.admin-status-pending { color: #8a5a00; background: #fff3ca; }
.admin-status-approved { color: #13733c; background: #ddf4e5; }
.admin-status-rejected, .admin-status-revoked { color: #9e3030; background: #fde5e5; }
.admin-status-draft { color: #536577; background: #e8eef5; }
.admin-race-card { display: grid; gap: 3px; padding: 10px; border: 1px solid #c7d9ea; border-radius: 9px; background: #f5f9fd; }
.admin-race-card span { color: var(--muted); font-size: 12px; }
.admin-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-bottom: 9px; }
.admin-edit-form { display: grid; gap: 9px; }
.admin-edit-form .admin-primary-button { justify-self: start; }
.admin-review-note { display: block; min-height: 60px; margin-bottom: 9px; resize: vertical; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.admin-links { display: flex; flex-wrap: wrap; gap: 8px; }
.admin-links a { color: #285d91; }
.admin-file-download { margin-left: 8px; color: #285d91; font-size: 12px; white-space: nowrap; }
.admin-reviews { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.admin-reviews li { display: grid; gap: 2px; padding: 8px; border-radius: 8px; background: #f6f8fb; }
.admin-reviews li span, .admin-reviews li p { color: var(--muted); font-size: 12px; }
.admin-reviews li p { margin: 3px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.admin-segment-heading th { color: var(--text); background: #f6f8fb; text-transform: none; }
.admin-rating-frame { position: fixed; z-index: 60; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; visibility: hidden; pointer-events: none; }
.admin-rating-frame.is-open { visibility: visible; pointer-events: auto; }
.admin-rating-frame[hidden] { display: none; }

@media (max-width: 1100px) {
  .admin-filters form { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
  .admin-filter-wide { grid-column: span 2; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-detail { order: -1; }
}

@media (max-width: 560px) {
  .admin-app { padding: 10px; }
  .admin-header { display: block; }
  .admin-status { margin-top: 8px; white-space: normal; }
  .admin-filters form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-filter-wide { grid-column: span 2; }
  .admin-filters .admin-primary-button { width: 100%; }
  .admin-form-grid { grid-template-columns: 1fr; }
  .admin-score-grid strong { font-size: 21px; }
  .admin-detail-facts span { grid-template-columns: 82px minmax(0, 1fr); }
  .admin-actions > button { flex: 1 1 calc(50% - 7px); }
}
