/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
  font-weight: 530;
  font-size: var(--fs-sm);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
    transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-tint);
}
.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
}
.btn-ghost:hover {
  background: var(--surface-3);
}

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

.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 25%, transparent);
}
.btn-danger:hover {
  background: color-mix(in srgb, var(--danger-soft) 70%, var(--danger));
}

.btn-sm {
  min-height: 32px;
  padding: 0 10px;
  font-size: var(--fs-xs);
}
.btn-icon {
  width: 36px;
  padding: 0;
}

/* Forms */
[hidden] {
  display: none !important;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field label {
  font-size: var(--fs-sm);
  font-weight: 560;
  color: var(--text-2);
}
.field .hint {
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.input,
.textarea,
.select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.textarea {
  min-height: 120px;
  resize: vertical;
  line-height: var(--lh-body);
}
.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent);
  box-shadow: var(--focus);
  outline: none;
}
.input::placeholder,
.textarea::placeholder {
  color: var(--text-3);
}

/* Surfaces */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.section-title {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-lg);
  font-weight: 580;
  letter-spacing: -0.01em;
}

/* Pills / badges */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--surface-3);
  color: var(--text-2);
  border: 1px solid transparent;
}
.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}
.pill-ok {
  background: var(--success-soft);
  color: var(--success);
}
.pill-warn {
  background: var(--warning-soft);
  color: var(--warning);
}
.pill-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
.pill-info {
  background: var(--info-soft);
  color: var(--info);
}
.pill-accent {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.pill-quiet::before {
  display: none;
}

/* Empty / states */
.empty {
  text-align: center;
  padding: var(--space-7) var(--space-5);
  color: var(--text-3);
}
.empty h3 {
  margin: 0 0 8px;
  color: var(--text);
  font-family: var(--font-display);
  font-weight: 560;
  font-size: var(--fs-xl);
}
.empty p {
  margin: 0 auto var(--space-4);
  max-width: 42ch;
  font-size: var(--fs-sm);
}

.state-banner {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--fs-sm);
}
.state-banner.warn {
  background: var(--warning-soft);
  border-color: color-mix(in srgb, var(--warning) 30%, transparent);
  color: var(--warning);
}
.state-banner.danger {
  background: var(--danger-soft);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
  color: var(--danger);
}
.state-banner.ok {
  background: var(--success-soft);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
  color: var(--success);
}

/* Skeleton */
.skeleton {
  background: linear-gradient(90deg, var(--surface-3), var(--surface-2), var(--surface-3));
  background-size: 200% 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

/* Project cards */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-4);
}

.project-card {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  color: inherit;
}
.project-card-main {
  display: flex;
  flex: 1;
  flex-direction: column;
  color: inherit;
}
.project-card-main:hover {
  color: inherit;
}
.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  color: inherit;
}
.project-card-thumb {
  aspect-ratio: 16 / 10;
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.project-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.project-card-thumb .thumb-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--text-3);
  background:
    linear-gradient(135deg, var(--accent-soft), transparent 60%),
    var(--surface-2);
}
.project-card-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
}
.project-card h3 {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 580;
  letter-spacing: -0.01em;
}
.project-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.project-card-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: var(--fs-xs);
  color: var(--text-3);
  margin-top: auto;
  padding-top: 4px;
}
.project-card-actions {
  min-height: 49px;
  padding: 8px var(--space-4);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.project-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
.project-row {
  display: grid;
  grid-template-columns: minmax(140px, 1.4fr) 0.7fr 0.8fr 0.8fr 0.7fr 0.7fr auto;
  gap: var(--space-3);
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  color: inherit;
  font-size: var(--fs-sm);
}
.project-row-name {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}
.project-row:last-child {
  border-bottom: 0;
}
.project-row:hover {
  background: var(--surface-2);
  color: inherit;
}
.project-list-head {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  font-weight: 650;
  background: var(--surface-2);
}

@media (max-width: 900px) {
  .project-list-head {
    display: none;
  }
  .project-row {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .project-row-actions {
    grid-column: 1 / -1;
  }
}

/* Dashboard tiles */
.dash-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: var(--space-4);
}
.dash-span-2 {
  grid-column: 1 / -1;
}
.tile {
  padding: var(--space-4);
}
.tile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.tile h2 {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 600;
}
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
}
.stat {
  padding: var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.stat-value {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 560;
  letter-spacing: -0.02em;
  line-height: 1;
}
.stat-label {
  margin-top: 6px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-3);
}
.quick-action {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 112px;
  padding: var(--space-4) 42px var(--space-4) var(--space-4);
  border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--border));
  border-radius: var(--radius);
  background: linear-gradient(145deg, var(--surface), color-mix(in srgb, var(--accent-soft) 45%, var(--surface)));
  color: inherit;
  text-align: start;
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  cursor: pointer;
}
.quick-action::after {
  content: "→";
  position: absolute;
  top: 16px;
  right: 16px;
  color: var(--accent-ink);
  font-size: 18px;
  line-height: 1;
}
.quick-action:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-2);
  color: inherit;
}
.quick-action:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 2px;
}
.quick-action strong {
  font-size: var(--fs-md);
}
.quick-action span {
  font-size: var(--fs-xs);
  color: var(--text-3);
}

@media (max-width: 900px) {
  .dash-grid {
    grid-template-columns: 1fr;
  }
  .stat-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* Command palette */
.palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 28, 0.4);
  z-index: 80;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
}
.palette-backdrop.is-open {
  display: flex;
}
.palette {
  width: min(560px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  overflow: hidden;
  animation: palette-in 160ms var(--ease);
}
@keyframes palette-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.palette-input {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--border);
  padding: 16px 18px;
  font-size: var(--fs-lg);
  background: transparent;
  outline: none;
  box-shadow: none !important;
}
.palette-list {
  max-height: 360px;
  overflow: auto;
  padding: 8px;
}
.palette-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  text-align: start;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  color: var(--text);
}
.palette-item:hover,
.palette-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.palette-item kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  background: var(--surface-3);
  padding: 2px 6px;
  border-radius: 4px;
}
.palette-group {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  padding: 10px 12px 4px;
  font-weight: 650;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 28, 0.4);
  z-index: 70;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.is-open {
  display: flex;
}
.modal {
  width: min(480px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  padding: var(--space-5);
}
.modal h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 560;
}
.modal p {
  margin: 0 0 var(--space-4);
  color: var(--text-2);
  font-size: var(--fs-sm);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Feed */
.feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}
.feed-card {
  overflow: hidden;
  color: inherit;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.feed-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-2);
  color: inherit;
}
.feed-thumb {
  aspect-ratio: 16 / 11;
  background: var(--surface-3);
  overflow: hidden;
  position: relative;
}
.feed-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 400ms var(--ease);
}
.feed-card:hover .feed-thumb img {
  transform: scale(1.03);
}
.feed-body {
  padding: var(--space-4);
}
.feed-body h3 {
  margin: 0 0 6px;
  font-size: var(--fs-md);
  font-weight: 580;
}
.feed-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  font-size: var(--fs-xs);
  color: var(--text-3);
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.tab {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 12px 14px;
  font-size: var(--fs-sm);
  font-weight: 530;
  color: var(--text-3);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  white-space: nowrap;
}
.tab:hover {
  color: var(--text);
}
.tab.is-active {
  color: var(--accent-ink);
  border-bottom-color: var(--accent);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 10px;
  border-radius: 5px;
  font-size: var(--fs-xs);
  font-weight: 560;
  color: var(--text-3);
  cursor: pointer;
}
.segmented button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

.kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-3);
}

.toast-host {
  position: fixed;
  bottom: 20px;
  inset-inline-end: 20px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  min-width: 240px;
  max-width: 360px;
  padding: 12px 14px;
  background: var(--text);
  color: var(--surface);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  box-shadow: var(--shadow-2);
  animation: toast-in 200ms var(--ease);
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
table.data th,
table.data td {
  padding: 12px 14px;
  text-align: start;
  border-bottom: 1px solid var(--border);
}
table.data th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-3);
  background: var(--surface-2);
  font-weight: 650;
}
table.data tr:last-child td {
  border-bottom: 0;
}
table.data tr:hover td {
  background: var(--surface-2);
}

@media (max-width: 700px) {
  .stack-cards .data thead {
    display: none;
  }
  .stack-cards .data tr {
    display: block;
    padding: 12px;
    border-bottom: 1px solid var(--border);
  }
  .stack-cards .data td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    padding: 4px 0;
  }
  .stack-cards .data td::before {
    content: attr(data-label);
    color: var(--text-3);
    font-weight: 560;
  }
}

/* Platform admin */
.admin-section {
  margin-top: var(--space-5);
}
.admin-collapsible {
  padding: 0;
  overflow: hidden;
}
.admin-collapsible > summary {
  list-style: none;
  cursor: pointer;
  padding: var(--space-4);
  margin: 0;
}
.admin-collapsible > summary::-webkit-details-marker {
  display: none;
}
.admin-collapsible > summary > span:first-child {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}
.admin-collapsible > summary > span:last-child::before {
  content: "▸";
  display: inline-block;
  margin-inline-end: 6px;
}
.admin-collapsible[open] > summary {
  border-bottom: 1px solid var(--border);
}
.admin-collapsible[open] > summary > span:last-child::before {
  transform: rotate(90deg);
}
.admin-section-body {
  padding: var(--space-4);
}
.admin-table-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.admin-table-controls .input {
  min-width: min(100%, 280px);
}
.admin-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-3);
}
.admin-stat-grid-small {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}
.admin-control-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
}
.admin-inline-field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.admin-inline-field .input,
.admin-cap-input {
  width: 72px;
  min-height: 34px;
  padding: 5px 8px;
}
.admin-wrap-cell {
  max-width: 440px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.admin-disabled-row {
  opacity: 0.52;
}
@media (max-width: 700px) {
  .admin-inline-field {
    width: 100%;
    margin-inline-start: 0;
  }
}
