.admin-header,
.table-header {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-header > *,
.table-header > *,
.admin-grid-two > *,
.logs-filter-card > * {
  min-width: 0;
}

.kicker {
  margin: 0 0 0.4rem;
  color: var(--muted-foreground);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.8rem;
  margin-top: 1.5rem;
}

.metric-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(24, 24, 27, 0.78);
  padding: 1rem;
}

.metric-card span,
.table-header p {
  display: block;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.metric-card strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 0.4rem;
  color: var(--foreground);
  font-size: 1.35rem;
}

.metric-card span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-edit-metrics,
.metric-grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.admin-table-card {
  margin-top: 1rem;
}

.table-header h2 {
  margin: 0;
  font-size: 1.05rem;
}

.table-header p {
  margin: 0.3rem 0 0;
}

.admin-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  margin-top: 1rem;
  -webkit-overflow-scrolling: touch;
}

.admin-table {
  width: 100%;
  min-width: 46rem;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem;
  text-align: left;
  vertical-align: middle;
}

.admin-table th {
  color: var(--muted-foreground);
  font-weight: 650;
}

.sort-link {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: var(--muted-foreground);
  font-weight: 650;
  text-decoration: none;
}

.sort-link:hover,
.sort-link.is-sorted {
  color: var(--foreground);
}

.sort-arrow {
  font-size: 0.7rem;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 1rem;
}

.pagination-summary {
  margin: 0.6rem 0 0;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
}

.pagination-bar .pagination {
  margin-top: 0;
}

.per-page-control {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.per-page-control select {
  width: auto;
  min-width: 4.5rem;
  min-height: 2rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
}

.button.is-disabled {
  pointer-events: none;
  opacity: 0.45;
}

/* Overview charts */
.admin-charts {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1rem;
  margin-top: 1rem;
}

.chart-card {
  min-width: 0;
}

.chart-card h2 {
  margin: 0;
  font-size: 1.05rem;
}

.chart-card .muted-copy {
  margin: 0.3rem 0 0;
}

.bar-chart {
  display: grid;
  grid-template-columns: repeat(14, minmax(0, 1fr));
  align-items: end;
  gap: 0.4rem;
  min-height: 13rem;
  margin-top: 1.25rem;
  padding-top: 0.5rem;
}

.bar-chart-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  align-items: stretch;
  gap: 0.35rem;
}

.bar-chart-track {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  flex: 1 1 auto;
  width: 100%;
  max-width: 1.8rem;
  height: 150px;
  margin: 0 auto;
  border-bottom: 2px solid color-mix(in srgb, var(--primary, #8b5cf6) 75%, transparent);
  border-radius: 0.45rem 0.45rem 0 0;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--border) 55%, transparent));
  overflow: hidden;
}

.bar-chart-bar {
  display: block;
  width: 100%;
  min-height: 0;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--primary-hover, #7c3aed), var(--primary, #8b5cf6));
  box-shadow: 0 0 18px color-mix(in srgb, var(--primary, #8b5cf6) 35%, transparent);
}

.bar-chart-value {
  min-height: 1rem;
  overflow: hidden;
  color: var(--foreground);
  font-size: 0.72rem;
  font-weight: 650;
  line-height: 1;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-chart-label {
  overflow: hidden;
  color: var(--muted-foreground);
  font-size: 0.66rem;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stat-bars {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.25rem;
}

.stat-bar span {
  display: flex;
  justify-content: space-between;
  color: var(--muted-foreground);
  font-size: 0.78rem;
}

.stat-bar span strong {
  color: var(--foreground);
}

.stat-bar-track {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  height: 0.55rem;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.stat-bar-fill {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: 999px;
  background: var(--primary, #8b5cf6);
}

@media (max-width: 900px) {
  .admin-charts {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .metric-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.table-actions {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.table-actions form {
  margin: 0;
}

.logs-filter-card {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.7rem;
  align-items: end;
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.logs-filter-card label {
  display: grid;
  gap: 0.25rem;
  min-width: 0;
}

.logs-filter-card label span {
  color: var(--muted-foreground);
  font-size: 0.72rem;
}

.logs-table td {
  vertical-align: top;
}

.logs-table code {
  white-space: pre-wrap;
  word-break: break-word;
}

.log-time {
  white-space: nowrap;
}

.admin-grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.compact-form {
  display: grid;
  gap: 0.75rem;
}

.compact-form textarea {
  width: 100%;
  resize: vertical;
}

@media (max-width: 980px) {
  .admin-grid-two {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  .logs-filter-card {
    grid-template-columns: 1fr;
  }
}


/* Inline row edit (details/summary in table cells) */
.row-edit {
  margin-top: 0.35rem;
}

.row-edit > summary {
  display: inline-flex;
  align-items: center;
  color: var(--muted-foreground);
  font-size: 0.72rem;
  cursor: pointer;
  list-style: none;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
  opacity: 0.75;
}

.row-edit > summary::-webkit-details-marker { display: none; }

.row-edit[open] > summary {
  opacity: 1;
}

.row-edit-form {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.4rem;
}

.row-edit-form input,
.row-edit-form select {
  width: auto;
  flex: 1;
  min-width: 8rem;
  min-height: 1.9rem;
  font-size: 0.8rem;
  padding: 0.25rem 0.55rem;
}

.storage-edit-form {
  width: min(34rem, calc(100vw - 2rem));
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: end;
  gap: 0.6rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: none;
}

.storage-edit-form label {
  display: grid;
  gap: 0.25rem;
}

.storage-edit-form label span {
  color: var(--muted-foreground);
  font-size: 0.72rem;
}

.storage-edit-form textarea {
  min-height: 5rem;
  resize: vertical;
}

.storage-edit-form .checkbox-field,
.storage-edit-form button {
  align-self: center;
}

@media (max-width: 720px) {
  .storage-edit-form {
    position: static;
    grid-template-columns: 1fr;
    width: 100%;
  }
}
