:root {
  color-scheme: light;
  --ink: #162128;
  --muted: #63727c;
  --line: #d9e1e6;
  --panel: #ffffff;
  --page: #eef3f4;
  --sole-primary: #00acd8;
  --sole-secondary: #cb007b;
  --accent: #00acd8;
  --accent-strong: #007fa1;
  --danger: #b42318;
  --warning: #b45309;
  --ok: #157f3b;
  --shadow: 0 14px 42px rgba(19, 32, 38, 0.12);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  background: var(--page);
  overflow-x: hidden;
}

button,
input,
select {
  font: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

.admin-shell {
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 12px;
  min-height: 100vh;
  padding: 14px;
}

.admin-topbar,
.metrics,
.admin-stats,
.filters,
.queue-panel,
.detail-panel {
  border: 1px solid rgba(130, 151, 160, 0.45);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 8px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-size: 12px;
}

.top-actions {
  display: flex;
  gap: 8px;
  min-width: 0;
}

.icon-button,
.text-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
}

.icon-button svg,
.text-button svg,
.empty-detail svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(238, 243, 244, 0.92);
}

.login-overlay.hidden {
  display: none;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(390px, 100%);
  padding: 22px;
  border: 1px solid rgba(130, 151, 160, 0.45);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 12px 0 4px;
  font-size: 22px;
  line-height: 1.15;
}

.login-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.login-card label {
  display: grid;
  gap: 5px;
}

.login-card label span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.login-card input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.login-error {
  min-height: 18px;
  color: var(--danger) !important;
  font-weight: 800;
}

.menu-button,
.drawer-head,
.drawer-backdrop {
  display: none;
}

.filter-drawer,
.drawer-content {
  display: contents;
}

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

.metrics article {
  min-height: 78px;
  padding: 14px;
  background: #fbfdfd;
}

.metrics span,
.filters span,
.detail-grid span,
.detail-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.metrics strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  line-height: 1;
}

.filters {
  display: flex;
  gap: 10px;
  padding: 10px;
  overflow-x: auto;
}

.filters label {
  display: grid;
  gap: 4px;
}

select {
  min-width: 150px;
  height: 36px;
  padding: 0 32px 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  color: var(--ink);
}

.admin-stats {
  overflow: hidden;
}

.stats-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.export-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
}

.stats-grid article {
  display: grid;
  gap: 8px;
  min-height: 136px;
  padding: 12px;
  background: #fbfdfd;
}

.stats-grid article:first-child,
.stats-grid article:nth-child(5) {
  grid-column: span 2;
}

.stats-grid h2 {
  margin: 0;
  font-size: 13px;
  line-height: 1.2;
}

.stat-list {
  display: grid;
  gap: 6px;
  max-height: 130px;
  overflow: auto;
}

.stat-row,
.audit-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px;
  border: 1px solid rgba(130, 151, 160, 0.22);
  border-radius: 6px;
  background: white;
  color: var(--ink);
  font-size: 12px;
}

.stat-row span,
.audit-row span {
  min-width: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.stat-row strong,
.audit-row strong {
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(360px, 440px);
  gap: 12px;
  min-height: 0;
}

.queue-panel,
.detail-panel {
  min-height: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

.panel-head h1,
.detail-head h2 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}

.panel-head p,
.detail-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  align-self: flex-start;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(0, 172, 216, 0.12);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
}

.report-table {
  display: grid;
  max-height: calc(100vh - 262px);
  overflow: auto;
}

.report-row {
  display: grid;
  grid-template-columns: 12px minmax(0, 1.3fr) minmax(110px, 0.6fr) minmax(120px, 0.7fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 74px;
  padding: 10px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: white;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.report-row:hover,
.report-row.active {
  background: linear-gradient(90deg, rgba(0, 172, 216, 0.12), rgba(203, 0, 123, 0.06));
}

.row-dot {
  width: 10px;
  height: 40px;
  border-radius: 5px;
  background: var(--accent);
}

.row-title strong,
.row-meta strong {
  display: block;
  font-size: 14px;
  line-height: 1.25;
}

.row-title span,
.row-meta span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  justify-self: start;
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(0, 172, 216, 0.12);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 850;
}

.badge.warn {
  background: #fff7ed;
  color: var(--warning);
}

.badge.danger {
  background: #fef3f2;
  color: var(--danger);
}

.detail-panel {
  position: relative;
  padding: 14px;
}

.hidden {
  display: none !important;
}

.empty-detail {
  display: grid;
  height: 100%;
  min-height: 320px;
  place-items: center;
  align-content: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.detail-content {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 168px);
  overflow: auto;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.detail-map {
  height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dfe8ea;
  overflow: hidden;
}

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

.detail-grid div {
  min-height: 62px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.detail-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 14px;
}

.detail-description {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

.action-group {
  display: grid;
  gap: 8px;
}

.action-group h3 {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 10px;
  font-weight: 800;
}

.text-button.primary {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), #0b91b4);
  color: white;
}

.text-button.danger {
  border-color: rgba(203, 0, 123, 0.34);
  background: rgba(203, 0, 123, 0.08);
  color: #a00062;
}

.audit-list {
  display: grid;
  gap: 7px;
  max-height: 170px;
  overflow: auto;
}

.empty-table {
  display: grid;
  min-height: 240px;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.sole-map-marker {
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  cursor: pointer;
  transform: translateY(-2px);
}

@media (max-width: 980px) {
  .admin-shell {
    padding: 10px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .report-table,
  .detail-content {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .admin-shell {
    gap: 10px;
    padding: 10px;
    grid-template-rows: auto auto auto minmax(0, 1fr);
  }

  .admin-topbar {
    position: sticky;
    top: 8px;
    z-index: 8;
  }

  .brand {
    min-width: 0;
  }

  .brand > span:not(.brand-mark) {
    overflow: hidden;
    max-width: 130px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .top-actions {
    gap: 6px;
  }

  .top-actions .icon-button {
    width: 38px;
    height: 38px;
  }

  .menu-button {
    display: grid;
  }

  .drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: block;
    background: rgba(22, 33, 40, 0.36);
  }

  .drawer-backdrop.hidden {
    display: none;
  }

  .filter-drawer {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 10px;
    z-index: 21;
    display: flex;
    flex-direction: column;
    width: min(330px, calc(100vw - 20px));
    padding: max(14px, env(safe-area-inset-top)) 12px max(14px, env(safe-area-inset-bottom));
    border: 1px solid rgba(130, 151, 160, 0.45);
    border-radius: 0 8px 8px 0;
    background: var(--panel);
    box-shadow: var(--shadow);
    transform: translateX(calc(-100% - 16px));
    transition: transform 160ms ease;
  }

  .filter-drawer.open {
    transform: translateX(0);
  }

  .drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
  }

  .drawer-content {
    display: grid;
    gap: 12px;
    min-height: 0;
    padding-top: 12px;
    overflow: auto;
  }

  .filters {
    display: grid;
    gap: 10px;
    padding: 0;
    border: 0;
    box-shadow: none;
    overflow: visible;
  }

  .filters label,
  select {
    width: 100%;
    min-width: 0;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .stats-head,
  .export-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .export-actions .text-button {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stats-grid article:first-child,
  .stats-grid article:nth-child(5) {
    grid-column: auto;
  }

  .metrics article {
    min-height: 70px;
    padding: 12px;
  }

  .metrics strong {
    font-size: 24px;
  }

  .report-row {
    grid-template-columns: 10px 1fr;
    gap: 8px 10px;
    min-height: 92px;
  }

  .report-row .row-meta,
  .report-row .badge {
    grid-column: 2;
  }

  .button-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .brand > span:not(.brand-mark) {
    display: none;
  }

  .admin-shell {
    padding: 8px;
  }

  .top-actions .icon-button {
    width: 36px;
    height: 36px;
  }

  .metrics {
    gap: 8px;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .metrics article {
    border: 1px solid rgba(130, 151, 160, 0.45);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: var(--shadow);
  }
}
