:root {
  --admin-bg: #0b0a08;
  --admin-elev: #15130e;
  --admin-line: rgba(250, 248, 243, 0.12);
  --admin-fg: #faf8f3;
  --admin-muted: rgba(250, 248, 243, 0.65);
  --admin-gold: #e8a93b;
  --admin-alert: #e63946;
  --admin-ok: #3ecf8e;
  --admin-warn: #f0b429;
  --admin-radius: 12px;
  --admin-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

.admin-body,
.admin-auth-body {
  margin: 0;
  font-family: var(--admin-font);
  background: var(--admin-bg);
  color: var(--admin-fg);
}

.admin-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.admin-sidebar {
  background: var(--admin-elev);
  border-right: 1px solid var(--admin-line);
  padding: 24px 16px;
}

.admin-brand-title {
  font-weight: 700;
  font-size: 15px;
}

.admin-brand-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--admin-muted);
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 28px;
}

.admin-nav-link {
  display: block;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--admin-muted);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.admin-nav-link:hover,
.admin-nav-link.is-active {
  background: rgba(232, 169, 59, 0.12);
  color: var(--admin-fg);
}

.admin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  border-bottom: 1px solid var(--admin-line);
}

.admin-topbar-title {
  font-size: 20px;
  font-weight: 700;
}

.admin-topbar-user {
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-user-name {
  font-size: 14px;
  font-weight: 600;
  text-align: right;
}

.admin-user-meta {
  font-size: 12px;
  color: var(--admin-muted);
  text-align: right;
}

.admin-content {
  padding: 24px 28px 40px;
}

.admin-section + .admin-section {
  margin-top: 24px;
}

.admin-h2,
.admin-h3 {
  margin: 0 0 16px;
}

.admin-h2 { font-size: 22px; }
.admin-h3 { font-size: 16px; }

.admin-meta {
  color: var(--admin-muted);
  font-size: 14px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.stat-card {
  background: var(--admin-elev);
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius);
  padding: 18px;
}

.stat-label {
  font-size: 12px;
  color: var(--admin-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 700;
}

.admin-filters-row {
  display: grid;
  grid-template-columns: 2fr repeat(3, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.admin-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius);
}

.admin-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--admin-line);
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--admin-muted);
  background: rgba(255, 255, 255, 0.02);
}

.admin-table-meta {
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--admin-muted);
}

.cell-main { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--admin-muted); margin-top: 2px; }

.admin-empty {
  text-align: center;
  color: var(--admin-muted);
  padding: 28px !important;
}

.admin-table td.admin-empty {
  text-align: center;
}

.admin-pagination {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
}

.admin-pagination-info {
  font-size: 13px;
  color: var(--admin-muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.detail-card {
  background: var(--admin-elev);
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius);
  padding: 20px;
}

.detail-list {
  margin: 0;
  display: grid;
  gap: 12px;
}

.detail-list dt {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--admin-muted);
}

.detail-list dd {
  margin: 4px 0 0;
}

.admin-actions-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  color: var(--admin-muted);
}

.field-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--admin-line);
  background: #0f0e0c;
  color: var(--admin-fg);
  font: inherit;
}

textarea.field-input {
  height: auto;
  min-height: 180px;
  padding: 12px;
  line-height: 1.5;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
}

.btn[hidden] {
  display: none !important;
}

.btn-primary {
  background: var(--admin-gold);
  color: #0b0a08;
}

.btn-ghost {
  background: transparent;
  border-color: var(--admin-line);
  color: var(--admin-fg);
}

.btn-danger {
  background: transparent;
  border-color: var(--admin-alert);
  color: var(--admin-alert);
}

.text-danger {
  color: var(--admin-alert);
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.btn-block { width: 100%; }

.badge {
  display: inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-ok { background: rgba(62, 207, 142, 0.15); color: var(--admin-ok); }
.badge-warn { background: rgba(240, 180, 41, 0.15); color: var(--admin-warn); }
.badge-danger { background: rgba(230, 57, 70, 0.15); color: var(--admin-alert); }
.badge-neutral { background: rgba(250, 248, 243, 0.08); color: var(--admin-muted); }

.flash {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 14px;
}

.flash-message {
  flex: 1;
  min-width: 0;
}

.flash-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.75;
}

.flash-close:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.08);
}

.admin-modal-open {
  overflow: hidden;
}

.admin-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.admin-modal[hidden] {
  display: none;
}

.admin-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.admin-modal-dialog {
  position: relative;
  width: min(100%, 420px);
  padding: 24px;
  border-radius: 12px;
  border: 1px solid var(--admin-line);
  background: var(--admin-elev);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.admin-modal-title {
  margin: 0 0 12px;
  font-size: 18px;
}

.admin-modal-message {
  margin: 0 0 20px;
  color: var(--admin-muted);
  line-height: 1.5;
}

.admin-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.flash-notice {
  background: rgba(62, 207, 142, 0.12);
  border: 1px solid rgba(62, 207, 142, 0.35);
}

.flash-alert {
  background: rgba(230, 57, 70, 0.12);
  border: 1px solid rgba(230, 57, 70, 0.35);
}

.admin-auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.admin-auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--admin-elev);
  border: 1px solid var(--admin-line);
  border-radius: 16px;
  padding: 28px;
}

.admin-auth-title {
  margin: 0 0 8px;
  font-size: 24px;
}

.admin-auth-lead {
  margin: 0 0 24px;
  color: var(--admin-muted);
  font-size: 14px;
  line-height: 1.5;
}

.admin-auth-divider {
  margin: 20px 0;
  text-align: center;
  color: var(--admin-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-auth-form {
  display: grid;
  gap: 12px;
}

.admin-import-form {
  display: grid;
  gap: 8px;
}

.admin-import-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.admin-import-row .field-input {
  flex: 1;
  min-width: 0;
}

.admin-import-row .btn {
  flex-shrink: 0;
  white-space: nowrap;
}

.admin-recent-imports-section {
  margin-top: 32px;
}

.admin-imports-table-wrap {
  overflow-x: auto;
}

.admin-imports-table {
  width: 100%;
  table-layout: fixed;
}

.admin-imports-table th,
.admin-imports-table td {
  padding: 10px 8px;
  vertical-align: middle;
}

.admin-imports-table th {
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.admin-imports-table .admin-imports-col-date {
  width: 9.5rem;
  white-space: nowrap;
  font-size: 13px;
}

.admin-imports-table .admin-imports-col-file {
  width: 22%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.admin-imports-table .admin-imports-file-link {
  color: var(--admin-gold);
  text-decoration: none;
  font-weight: 600;
}

.admin-imports-table .admin-imports-file-link:hover {
  text-decoration: underline;
}

.admin-imports-table .admin-imports-col-status {
  width: 8.5rem;
  white-space: nowrap;
}

.admin-imports-table .admin-imports-col-user {
  width: 12%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
}

.admin-imports-table .admin-imports-col-count {
  width: 3.25rem;
  text-align: center;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  padding-left: 4px;
  padding-right: 4px;
}

.admin-imports-table .admin-imports-col-actions {
  width: 12.5rem;
  padding-right: 10px;
}

.admin-imports-table .admin-imports-col-actions .admin-table-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}

.admin-imports-table .admin-imports-col-actions form {
  display: inline-flex;
  margin: 0;
}

.admin-imports-table .admin-imports-col-actions .btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
}

[data-reconciliation-import-live]:not(:empty) {
  margin-top: 24px;
}

.admin-import-progress {
  margin: 16px 0 0;
  padding: 16px;
  border: 1px solid var(--admin-line);
  border-radius: var(--admin-radius);
  background: rgba(250, 248, 243, 0.03);
}

.admin-import-progress-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 600;
}

.admin-progress-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(250, 248, 243, 0.08);
  overflow: hidden;
}

.admin-progress-bar {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--admin-gold), #f5c86a);
  transition: width 0.25s ease;
}

.admin-progress-bar.is-indeterminate {
  position: absolute;
  left: 0;
  top: 0;
  animation: admin-progress-indeterminate 1.4s ease-in-out infinite;
}

@keyframes admin-progress-indeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.admin-import-progress-detail {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--admin-muted);
}

.admin-reorder-buttons {
  display: inline-flex;
  gap: 4px;
  vertical-align: middle;
}

.admin-reorder-buttons .btn-reorder {
  min-width: 32px;
  padding: 4px 8px;
  font-size: 0.75rem;
  line-height: 1;
  font-weight: 700;
  letter-spacing: 0;
}

.admin-inline-form {
  display: inline;
  margin: 0;
}

.admin-category-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  column-gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.admin-category-reorder {
  grid-column: 1;
  align-self: center;
}

.admin-category-title {
  grid-column: 2;
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0;
  min-width: 0;
}

.admin-category-index {
  color: var(--admin-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

.admin-category-actions {
  grid-column: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: nowrap;
}

.admin-category-actions .admin-active-label {
  margin: 0;
  white-space: nowrap;
}

.admin-category-actions .admin-inline-form {
  display: inline-flex;
}

.admin-table-actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
}

.admin-table .col-reorder {
  width: 72px;
  white-space: nowrap;
}

.admin-table .col-order {
  width: 48px;
  text-align: center;
  color: var(--admin-muted);
  font-variant-numeric: tabular-nums;
}

.admin-table .col-question {
  width: auto;
  min-width: 0;
}

.admin-table .col-question .cell-main,
.admin-table .col-question .cell-sub {
  overflow: hidden;
  text-overflow: ellipsis;
}

.admin-table .col-status {
  width: 80px;
  text-align: center;
}

.admin-table th.col-status {
  text-align: center;
}

.admin-table .col-actions {
  width: 84px;
  text-align: right;
}

.admin-table th.col-actions {
  text-align: right;
}

.admin-table .col-actions .admin-table-actions {
  justify-content: flex-end;
}

.admin-table .col-status,
.admin-table .col-actions {
  vertical-align: middle;
}

.admin-table .col-status .admin-active-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
}

.admin-table .col-status .admin-active-label {
  min-height: 32px;
}

.admin-active-toggle {
  display: inline;
  margin: 0;
}

.admin-active-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin: 0;
  font-size: 13px;
  color: var(--admin-muted);
}

.admin-active-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--admin-gold);
  cursor: pointer;
}

.btn-icon-only {
  width: 32px;
  min-width: 32px;
  padding: 0;
}

.admin-icon {
  display: block;
  flex-shrink: 0;
}


.admin-auth-hint {
  margin-top: 16px;
  font-size: 13px;
  color: var(--admin-muted);
  line-height: 1.5;
}

.admin-match-board {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.admin-match-pane .admin-h3 {
  margin-bottom: 12px;
}

.admin-resolved-table-wrap {
  overflow-x: hidden;
}

.admin-resolved-table {
  width: 100%;
  table-layout: fixed;
}

.admin-resolved-table .admin-resolved-col-id {
  width: 5%;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.admin-resolved-table .admin-resolved-col-desc {
  width: 30%;
  min-width: 0;
  overflow-wrap: anywhere;
}

.admin-resolved-table .admin-resolved-col-amount {
  width: 11%;
  white-space: nowrap;
}

.admin-resolved-table .admin-resolved-col-user {
  width: 22%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-resolved-table .admin-resolved-col-date {
  width: 14%;
  white-space: nowrap;
}

.admin-resolved-table .admin-resolved-col-detail {
  width: 18%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-resolved-table .admin-resolved-col-detail a {
  color: var(--admin-gold);
  text-decoration: none;
  font-weight: 600;
}

.admin-resolved-table .admin-resolved-col-detail a:hover {
  text-decoration: underline;
}

.admin-match-table {
  table-layout: fixed;
  width: 100%;
}

.admin-match-table th:first-child,
.admin-match-table td:first-child {
  width: 32px;
  padding-left: 10px;
  padding-right: 4px;
  text-align: center;
}

.admin-match-table--aportes .admin-match-col-tipo {
  width: 72px;
}

.admin-match-table--aportes .admin-match-col-amount {
  width: 88px;
  white-space: nowrap;
}

.admin-match-table--aportes .admin-match-col-ref {
  width: 96px;
  white-space: nowrap;
}

.admin-match-table--aportes .admin-match-col-date {
  width: 120px;
  white-space: nowrap;
}

.admin-match-table--aportes .admin-match-col-suggest {
  width: 88px;
  padding-left: 6px;
  padding-right: 10px;
}

.admin-match-table--cartola {
  table-layout: fixed;
  width: 100%;
}

.admin-match-table--cartola th:first-child,
.admin-match-table--cartola td:first-child {
  width: 32px;
  padding-left: 10px;
  padding-right: 4px;
}

.admin-match-table--cartola .admin-match-col-id {
  width: 52px;
  white-space: nowrap;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.admin-match-table--cartola .admin-match-col-date {
  width: 108px;
  white-space: nowrap;
}

.admin-match-table--cartola .admin-match-col-description {
  width: auto;
}

.admin-match-table--cartola .admin-match-col-description .cell-main {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.admin-match-table--cartola .admin-match-col-amount {
  width: 96px;
  white-space: nowrap;
  text-align: right;
}

.admin-match-table tbody tr.admin-match-row {
  cursor: pointer;
}

.admin-match-table tbody tr.admin-match-row:hover {
  background: rgba(232, 169, 59, 0.06);
}

.admin-match-table tbody tr.admin-match-row.is-selected {
  background: rgba(232, 169, 59, 0.16);
  outline: 1px solid rgba(232, 169, 59, 0.45);
}

.admin-match-table tbody tr.admin-match-row.is-locked {
  opacity: 0.45;
  cursor: not-allowed;
}

.admin-match-table tbody tr.admin-match-row.is-locked:hover {
  background: transparent;
}

.admin-match-table tbody tr.admin-match-row.is-suggested {
  box-shadow: inset 3px 0 0 var(--admin-gold);
  background: rgba(232, 169, 59, 0.08);
}

.admin-match-table tbody tr.admin-match-row.is-amount-mismatch {
  opacity: 0.4;
}

.admin-match-table tbody tr.admin-match-row.is-drafted {
  display: none;
}

.admin-match-radio {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(250, 248, 243, 0.35);
  vertical-align: middle;
}

.admin-match-row.is-selected .admin-match-radio {
  border-color: var(--admin-gold);
  background: var(--admin-gold);
  box-shadow: inset 0 0 0 2px var(--admin-elev);
}

.admin-match-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 0 0 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--admin-line);
}

.admin-match-toolbar .admin-meta {
  margin: 0;
  flex: 1 1 180px;
}

@media (max-width: 1100px) {
  .admin-match-board {
    grid-template-columns: 1fr;
  }
}

.admin-match-card {
  border: 1px solid var(--admin-line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 14px;
  background: rgba(250, 248, 243, 0.02);
}

.admin-match-card.is-resolved {
  opacity: 0.72;
}

.admin-match-grid {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
}

.admin-match-eyebrow {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--admin-muted);
  margin-bottom: 8px;
}

.admin-match-amount {
  font-size: 22px;
  font-weight: 700;
  margin: 6px 0;
}

.admin-match-candidate {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--admin-line);
}

.admin-match-candidate:last-of-type {
  border-bottom: 0;
}

.admin-match-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

@media (max-width: 1100px) {
  .stat-grid,
  .detail-grid,
  .admin-filters-row,
  .admin-import-row,
  .admin-match-grid {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }

  .admin-shell {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--admin-line);
  }
}
