/*
 * ADMIN OVERRIDES = foundation (main.css) + admin-specific component styling.
 * Admin pages load: tokens.css -> admin.css. The foundation (tokens+base+components)
 * arrives via the single @import below -- main.css is the one foundation source.
 * The body baseline (sans reset, links, headings, scrollbar) lives in base.css.
 * Mono is applied per-element where it belongs (.data-table, .btn, tabular numerics),
 * never on body.
 */

@import url('/design/css/main.css');

:root {
  --app-width: none;
}

.app {
  padding: 0;
}

/* Header */
.header {
  padding: var(--space-md) var(--space-lg) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm-md);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.header h1 {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
  font-weight: var(--weight-normal);
}

.header-meta {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.header-right {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

/* Body */
.body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xs);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* Tab panel override -- flex column for admin layouts */
.tab-panel.active {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

.section-title {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-wider);
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  padding: 0 0 var(--space-xs);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Collapsible section toggles */
.section-title-toggle {
  cursor: pointer;
  user-select: none;
}

.section-title-toggle:hover {
  color: var(--text-primary);
}

.toggle-arrow {
  display: inline-block;
  font-size: var(--text-3xs);
  margin-left: var(--space-sm);
  vertical-align: middle;
  transition: transform var(--transition-fast);
}

.toggle-arrow.open {
  transform: rotate(90deg);
}

/* Status bar -- canonical flex-pinned footer. Last child of .app; pinned by
   flex-shrink:0 below a flex:1; overflow-y:auto scroll region (.body / .tab-panel.active).
   Behavior + slots (sb-context, sb-activity): design/shared/status-bar.js. */
.status-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm-md);
  padding: var(--space-xs) var(--space-lg);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* No context note -> let the lone activity message fill from the left */
.status-bar:not(:has(.sb-context:not(:empty))) {
  justify-content: flex-start;
}

/* Tone color utilities (semantic state) -- shared by .status-bar, .feedback, ... */
.tone-positive {
  color: var(--text-positive);
}

.tone-negative {
  color: var(--text-negative);
}

.tone-warning {
  color: var(--text-warning);
}

.tone-info {
  color: var(--text-info);
}

.tone-muted {
  color: var(--text-muted);
}

/* Target indicator */
.target-indicator {
  font-size: var(--text-xs);
  padding: var(--space-xs) var(--space-sm);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

.target-indicator.remote {
  color: var(--accent-3);
  border-color: var(--accent-3);
}

.target-indicator.local {
  color: var(--accent-1);
  border-color: var(--accent-1);
}

/* Feedback (inline per-field). Color via shared .tone-* (design/shared/feedback.js). */
.feedback {
  font-size: var(--text-xs);
  margin-top: var(--space-sm);
  min-height: 1.2em;
}

input.invalid,
textarea.invalid,
select.invalid {
  border-color: var(--color-negative) !important;
  outline: none;
}

/* Buttons (override components.css) */
.btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  padding: var(--space-sm) var(--space-sm-md);
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.btn:hover {
  border-color: var(--text-muted);
  color: var(--accent-1);
  background: var(--bg-elevated);
}

.btn:active {
  background: var(--bg-surface);
}

.btn-primary {
  background: var(--accent-1);
  border-color: var(--accent-1);
  color: var(--bg-base);
  font-weight: var(--weight-bold);
}

.btn-primary:hover {
  filter: brightness(1.15);
  color: var(--bg-base);
}

.btn-danger {
  background: transparent;
  border-color: var(--accent-4);
  color: var(--accent-4);
  font-weight: var(--weight-normal);
}

.btn-danger:hover {
  background: var(--accent-4);
  color: var(--bg-base);
}

.btn-small {
  padding: var(--space-xs) var(--space-sm);
  font-size: var(--text-2xs);
}

/* Placeholder text */
.placeholder-text {
  color: var(--text-muted);
  letter-spacing: var(--tracking-wide);
}

/* Modal (override components.css inline-toggle pattern to centered overlay) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}

.modal {
  display: block;
  margin-top: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-left: 1px solid var(--border-default);
  padding: var(--space-lg);
  min-width: 360px;
  max-width: 480px;
  animation: none;
}

.modal-title {
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-xs);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-body {
  margin-bottom: var(--space-md);
}

.modal-body p {
  margin-bottom: var(--space-sm);
  line-height: 1.6;
}

.modal-email {
  color: var(--accent-1);
  margin-bottom: var(--space-sm-md);
}

.modal-note {
  color: var(--text-muted);
}

.modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

.modal-body input {
  background: var(--bg-base);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: var(--space-sm) var(--space-sm-md);
  width: 100%;
}

.modal-body input:focus {
  outline: none;
  border-color: var(--accent-1);
}

/* Summary cards */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: var(--space-xs);
  margin-bottom: var(--space-xs);
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: var(--space-sm-md) var(--space-sm) var(--space-sm);
  text-align: center;
}

.card:hover {
  border-color: var(--border-default);
}

.card-value {
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  line-height: 1;
}

.card-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  margin-top: var(--space-sm-md);
}

.card-value.positive {
  color: var(--accent-2);
}

.card-value.negative {
  color: var(--accent-4);
}

.card-value.warning {
  color: var(--accent-3);
}

.card-expandable {
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.card-active {
  border-color: var(--accent-1);
  border-bottom: 2px solid var(--accent-1);
}

.timeline-drawer {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: var(--space-sm-md);
  margin-bottom: var(--space-xs);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

.table-scroll {
  max-height: 50vh;
  overflow-y: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
}

.data-table th {
  text-align: left;
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--border-default);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  font-weight: var(--weight-normal);
  white-space: nowrap;
  background: var(--bg-surface);
}

/* Sticky column headers only inside capped-height scroll panels (.table-scroll).
   Tools using .table-wrap let the whole page scroll, where a viewport-pinned
   header is wrong. */
.table-scroll .data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
}

.data-table td {
  padding: var(--space-xs) var(--space-sm);
  border-bottom: 1px solid var(--border-subtle);
}

.data-table tbody tr:hover td {
  background: var(--bg-overlay);
}

.col-actions {
  text-align: right;
  white-space: nowrap;
}

.col-actions .btn {
  margin-left: var(--space-xs);
}

.col-muted {
  color: var(--text-muted);
}

.empty-state {
  color: var(--text-muted);
  padding: var(--space-lg) var(--space-sm);
  text-align: center;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: var(--scrollbar-w);
  height: var(--scrollbar-w);
}

::-webkit-scrollbar-track {
  background: var(--bg-base);
}

::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-default);
}