/* ── Cards ────────────────────────────────────────────────────────────────── */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: 8px;
  padding: 1.25rem;
}

.card--stat {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card--stat .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-text-primary);
  line-height: 1.1;
}

.card--stat .stat-label {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-weight: 500;
}

.card--stat .stat-icon {
  font-size: 1.25rem;
  color: var(--color-brand);
  margin-bottom: 0.5rem;
}

.card--stat-link {
  text-decoration: none;
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}

.card--stat-link:hover {
  border-color: var(--color-brand);
  background: var(--color-surface-hover);
}

.card--stat-link .stat-value,
.card--stat-link .stat-label,
.card--stat-link .stat-icon {
  color: inherit;
}

.card--stat-link .stat-value { color: var(--color-text-primary); }
.card--stat-link .stat-label { color: var(--color-text-muted); }
.card--stat-link .stat-icon  { color: var(--color-brand); }

.card--pod {
  cursor: pointer;
  transition: border-color 120ms, background 120ms;
}

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

.card--pod .pod-name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: 0.375rem;
}

.card--pod .pod-description {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card--pod .pod-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card--pod .pod-icon {
  font-size: 1.5rem;
  color: var(--color-pod);
  margin-bottom: 0.5rem;
}

.pod-status-label {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.125rem 0.375rem;
  border-radius: 3px;
  vertical-align: middle;
  margin-left: 0.375rem;
}
.label-invite   { background: var(--color-brand-subtle);   color: var(--color-brand); }
.label-request  { background: var(--color-warning-subtle);  color: var(--color-warning); }
.label-open     { background: var(--color-success-subtle);  color: var(--color-success); }
.label-approval { background: var(--color-shared-subtle);   color: var(--color-shared); }

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.4375rem 0.875rem;
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.4;
  transition: background 100ms, color 100ms, border-color 100ms, opacity 100ms;
  cursor: pointer;
  border: 1px solid transparent;
  white-space: nowrap;
  user-select: none;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.btn .mdi {
  font-size: 1rem;
}

.btn-primary {
  background: var(--color-brand);
  color: #1A1100;
  border-color: var(--color-brand);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--color-brand-hover);
  border-color: var(--color-brand-hover);
}

.btn-primary:active {
  background: var(--color-brand-active);
  border-color: var(--color-brand-active);
}

.btn-secondary {
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
  border-color: var(--color-border-default);
}

.btn-secondary:hover {
  background: var(--color-surface-hover);
  border-color: var(--color-border-strong);
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
  font-weight: 600;
}

.btn-danger:hover {
  opacity: 0.9;
}

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

.btn-danger-ghost:hover {
  background: var(--color-danger-subtle);
}

.btn-ghost {
  background: transparent;
  color: var(--color-brand);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--color-brand-subtle);
}

.btn-icon {
  padding: 0.375rem;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text-muted);
  border: 1px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-icon:hover {
  background: var(--color-surface-hover);
  color: var(--color-text-primary);
}

.btn-icon .mdi {
  font-size: 1.125rem;
}

.btn-sm {
  padding: 0.25rem 0.5rem;
  font-size: 0.8125rem;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge .mdi {
  font-size: 0.875rem;
}

.badge-trust    { background: var(--color-trust-subtle);   color: var(--color-trust);    }
.badge-shared   { background: var(--color-shared-subtle);  color: var(--color-shared);   }
.badge-pod      { background: var(--color-pod-subtle);     color: var(--color-pod);      }
.badge-private  { background: var(--color-private-subtle); color: var(--color-private);  }
.badge-success  { background: var(--color-success-subtle); color: var(--color-success);  }
.badge-warning  { background: var(--color-warning-subtle); color: var(--color-warning);  }
.badge-danger   { background: var(--color-danger-subtle);  color: var(--color-danger);   }
.badge-neutral  { background: var(--color-surface-raised); color: var(--color-text-muted); border: 1px solid var(--color-border-subtle); }
.badge-info     { background: var(--color-info-subtle);    color: var(--color-info);     }
.badge-brand    { background: var(--color-brand-subtle);   color: var(--color-brand);    }

/* ── Tables ───────────────────────────────────────────────────────────────── */

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--color-border-subtle);
  border-radius: 8px;
  background: var(--color-surface);
}

.table-wrap table {
  min-width: 500px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead {
  background: var(--color-surface-raised);
}

th {
  text-align: left;
  padding: 0.625rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border-subtle);
  white-space: nowrap;
}

td {
  padding: 0.75rem 1rem;
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border-subtle);
  vertical-align: middle;
}

tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--color-surface-hover);
}

.td-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  justify-content: flex-end;
}

.td-meta {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

.td-icon {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.td-icon .mdi {
  font-size: 1.125rem;
  flex-shrink: 0;
}

/* ── Modals ───────────────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
  animation: fadeIn 100ms ease;
}

.modal {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-default);
  border-radius: 10px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: slideUp 150ms ease;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.modal--wide {
  max-width: 680px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.125rem 1.25rem 1rem;
  border-bottom: 1px solid var(--color-border-subtle);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--color-border-subtle);
  flex-shrink: 0;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Toasts ───────────────────────────────────────────────────────────────── */

#toast-host {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 2000;
}

.toast {
  background: var(--color-surface-overlay);
  border: 1px solid var(--color-border-default);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  color: var(--color-text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: toastIn 200ms ease;
  max-width: 320px;
}

.toast--success { border-left: 3px solid var(--color-success); }
.toast--danger  { border-left: 3px solid var(--color-danger);  }
.toast--warning { border-left: 3px solid var(--color-warning); }
.toast--info    { border-left: 3px solid var(--color-info);    }

.toast .mdi {
  font-size: 1.125rem;
  flex-shrink: 0;
}

@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Forms ────────────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 0.375rem;
}

.form-input,
.form-select,
.form-textarea {
  display: block;
  width: 100%;
  padding: 0.5625rem 0.75rem;
  background: var(--color-surface);
  border: 1px solid var(--color-border-default);
  border-radius: 6px;
  color: var(--color-text-primary);
  font-size: 0.875rem;
  transition: border-color 100ms;
  outline: none;
  appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 2px var(--color-brand-subtle);
}

.form-input::placeholder {
  color: var(--color-text-disabled);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238892A0' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
  cursor: pointer;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.25rem;
}

.form-error {
  font-size: 0.8125rem;
  color: var(--color-danger);
  margin-top: 0.5rem;
  padding: 0.5rem 0.75rem;
  background: var(--color-danger-subtle);
  border-radius: 6px;
  border: 1px solid var(--color-danger);
}

.form-toggle {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  cursor: pointer;
  user-select: none;
}

.form-toggle input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--color-brand);
  cursor: pointer;
}

.form-toggle span {
  font-size: 0.875rem;
  color: var(--color-text-primary);
}

/* ── Tabs ─────────────────────────────────────────────────────────────────── */

.tabs {
  margin-bottom: 1.5rem;
}

.tab-bar {
  display: flex;
  border-bottom: 1px solid var(--color-border-subtle);
  gap: 0;
  margin-bottom: 1.25rem;
  overflow-x: auto;
  overflow-y: hidden;
}

.tab-btn {
  padding: 0.625rem 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-muted);
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  cursor: pointer;
  white-space: nowrap;
  transition: color 100ms, border-color 100ms;
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: var(--color-text-secondary);
}

.tab-btn.active {
  color: var(--color-brand);
  border-bottom-color: var(--color-brand);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* ── Spinner ──────────────────────────────────────────────────────────────── */

.spinner-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--color-border-subtle);
  border-top-color: var(--color-brand);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Empty state ──────────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4rem 2rem;
  text-align: center;
  color: var(--color-text-muted);
}

.empty-state .mdi {
  font-size: 3rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.9375rem;
  max-width: 280px;
}

/* ── Timeline ─────────────────────────────────────────────────────────────── */

.timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--color-border-subtle);
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 0.125rem;
}

.timeline-icon .mdi {
  font-size: 1rem;
  color: var(--color-brand);
}

.timeline-content {
  flex: 1;
}

.timeline-text {
  font-size: 0.875rem;
  color: var(--color-text-primary);
  margin-bottom: 0.125rem;
}

.timeline-time {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* ── Notice row ───────────────────────────────────────────────────────────── */

.notice-row {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-bottom: 1px solid var(--color-border-subtle);
  align-items: center;
}

.notice-row.unread {
  background: var(--color-brand-subtle);
}

.notice-row:last-child {
  border-bottom: none;
}

.notice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-brand);
  margin: 0 auto;
}

/* ── Admin banner ──────────────────────────────────────────────────────────── */

.admin-banner {
  background: var(--color-danger-subtle);
  color: var(--color-danger);
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 6px;
  margin-bottom: 1.5rem;
  border: 1px solid var(--color-danger);
}

/* ── Dropdown/search result ────────────────────────────────────────────────── */

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--color-surface-overlay);
  border: 1px solid var(--color-border-default);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 100;
  max-height: 200px;
  overflow-y: auto;
}

.search-result-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--color-text-primary);
  transition: background 80ms;
}

.search-result-item:hover {
  background: var(--color-surface-hover);
}

.search-result-item .namespace {
  font-weight: 600;
}

.search-result-item .display-name {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
}

.search-wrap {
  position: relative;
}

/* ── Impact preview ────────────────────────────────────────────────────────── */

.impact-preview {
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: 6px;
  padding: 1rem;
}

.impact-item {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  padding: 0.25rem 0;
}

.impact-item strong {
  color: var(--color-text-primary);
}

/* ── Settings theme swatches ───────────────────────────────────────────────── */

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.theme-swatch {
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color 120ms, box-shadow 120ms;
}

.theme-swatch.active {
  border-color: var(--color-brand);
  box-shadow: 0 0 0 2px var(--color-brand-subtle);
}

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

.swatch-preview {
  height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 6px;
}

.swatch-bar {
  height: 8px;
  border-radius: 4px;
}

.swatch-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: 0.375rem 0.625rem;
  background: var(--color-surface-raised);
  text-align: center;
}

/* ── Resource visibility ───────────────────────────────────────────────────── */

.visibility-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 1rem;
}

/* ── Back button / breadcrumb ──────────────────────────────────────────────── */

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  cursor: pointer;
  margin-bottom: 1.25rem;
  transition: color 100ms;
  background: none;
  border: none;
  padding: 0;
}

.back-btn:hover {
  color: var(--color-text-primary);
}

.back-btn .mdi {
  font-size: 1rem;
}

/* ── Description text ─────────────────────────────────────────────────────── */

.text-muted {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.text-secondary {
  color: var(--color-text-secondary);
}

/* ── Utility ──────────────────────────────────────────────────────────────── */

.flex-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.coming-soon {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}

[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--color-surface-overlay);
  border: 1px solid var(--color-border-default);
  color: var(--color-text-secondary);
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 100ms;
  z-index: 100;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

.monospace {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.8125rem;
}

/* ── List controller — search + pagination ─────────────────────────────────── */

.lc-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.lc-toolbar-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
}

.lc-toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.lc-count {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 0 0.25rem;
}

.pager-label {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  min-width: 5rem;
  text-align: center;
}
