:root {
  --bg-0: #0a0e17;
  --bg-1: #111827;
  --bg-2: #1a2235;
  --bg-3: #232d42;
  --bg-hover: #2a3650;
  --border: #2a3650;
  --border-light: #344563;
  --text-0: #f1f5f9;
  --text-1: #94a3b8;
  --text-2: #64748b;
  --green: #00e68a;
  --green-dim: rgba(0, 230, 138, 0.12);
  --red: #ff4d6a;
  --red-dim: rgba(255, 77, 106, 0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.12);
  --yellow: #fbbf24;
  --yellow-dim: rgba(251, 191, 36, 0.12);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-pill: 20px;
  --font-mono: "JetBrains Mono", monospace;
  --font-sans: "DM Sans", -apple-system, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-0);
  color: var(--text-0);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

input,
select,
textarea,
button {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

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

strong,
.mono,
.data-pill,
.chip,
.badge,
.checkbox,
.mini-button,
.loading-note,
.row-item__meta,
.member-chip__meta,
.tile__meta,
.eyebrow,
.footer-note {
  font-family: var(--font-mono);
}

#app {
  min-height: 100vh;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-3);
  border-radius: 3px;
}

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

.app-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 0 16px 24px;
}

.loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  background: var(--green);
  opacity: 0;
  transition: width 0.3s ease, opacity 0.2s ease;
  z-index: 30;
}

.loading-bar.is-active {
  width: 72%;
  opacity: 1;
}

.loading-bar.is-complete {
  width: 100%;
  opacity: 0;
}

.app-header {
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 16px;
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-header__brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-logo {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: linear-gradient(135deg, #00e68a, #00c9ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.app-header__actions,
.hero-strip,
.metrics-row,
.panel-actions,
.button-row,
.chip-row,
.tile__actions,
.row-item__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.app-frame {
  padding-top: 16px;
}

.hero {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
}

.hero-card,
.member-strip,
.panel,
.empty-shell,
.alert,
.modal-sheet,
.toast {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.hero-card,
.member-strip,
.panel,
.empty-shell,
.alert {
  padding: 14px;
}

.hero-card h1,
.empty-shell h1,
.modal-sheet h3 {
  font-size: 16px;
  font-weight: 700;
}

.hero-card p,
.empty-shell p,
.panel h2,
.panel p,
.tile p,
.settings-row span,
.calendar-source__url,
.member-chip__meta,
.row-item__meta {
  color: var(--text-1);
}

.eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hero-card__grid {
  display: grid;
  gap: 12px;
  grid-template-columns: 2.1fr 1fr;
}

.hero-card__copy {
  display: grid;
  gap: 10px;
}

.metrics-row {
  gap: 10px;
}

.data-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
}

.data-pill label {
  color: var(--text-2);
  font-size: 11px;
  font-weight: 400;
}

.member-strip {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 16px;
}

.member-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
  transition: all 0.15s;
}

.member-chip:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.member-chip__avatar {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-weight: 700;
}

.dashboard-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
}

.panel {
  grid-column: span 4;
  transition: all 0.15s;
}

.panel:hover {
  border-color: var(--border-light);
}

.panel[data-width="wide"] {
  grid-column: span 8;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-0);
}

.panel-body {
  display: grid;
  gap: 10px;
}

.button {
  min-height: 40px;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-weight: 700;
  transition: all 0.15s;
}

.button:disabled,
.mini-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.button--positive {
  background: var(--green);
  color: var(--bg-0);
}

.button--positive:hover {
  filter: brightness(1.1);
}

.button--gradient {
  background: linear-gradient(135deg, #00e68a, #00c9ff);
  color: var(--bg-0);
}

.button--ghost {
  min-height: 32px;
  padding: 8px 10px;
  background: var(--bg-3);
  color: var(--text-1);
  border-radius: 6px;
}

.button--ghost:hover,
.mini-button:hover,
.checkbox:hover {
  background: var(--bg-hover);
}

.button--danger,
.mini-button--danger {
  background: var(--red);
  color: #fff;
}

.mini-button,
.checkbox {
  min-height: 32px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--bg-3);
  color: var(--text-1);
  transition: all 0.15s;
}

.checkbox {
  min-width: 68px;
}

.chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-1);
}

.chip--active {
  background: var(--blue-dim);
  border-color: var(--blue);
  color: var(--blue);
}

.chip--positive {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

.chip--warning {
  background: var(--yellow-dim);
  border-color: var(--yellow);
  color: var(--yellow);
}

.chip--danger {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.badge--neutral {
  background: var(--bg-3);
  color: var(--text-1);
}

.badge--positive {
  background: var(--green-dim);
  color: var(--green);
}

.badge--active {
  background: var(--blue-dim);
  color: var(--blue);
}

.badge--warning {
  background: var(--yellow-dim);
  color: var(--yellow);
}

.badge--danger {
  background: var(--red-dim);
  color: var(--red);
}

.stack-list,
.tile-list,
.settings-list {
  list-style: none;
  display: grid;
  gap: 10px;
}

.row-item,
.tile,
.settings-row,
.calendar-source {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
  transition: all 0.15s;
}

.row-item:hover,
.tile:hover,
.settings-row:hover,
.calendar-source:hover {
  border-color: var(--border-light);
  background: var(--bg-hover);
}

.row-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
}

.row-item__copy {
  display: grid;
  gap: 4px;
}

.row-item__meta,
.tile__meta,
.calendar-source__url,
.footer-note {
  font-size: 12px;
  color: var(--text-2);
}

.tile {
  display: grid;
  gap: 10px;
}

.tile__head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.tile__meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.surface-paper {
  background: var(--bg-2);
}

.surface-sage {
  background: rgba(0, 230, 138, 0.06);
  border-color: rgba(0, 230, 138, 0.2);
}

.surface-sky {
  background: rgba(59, 130, 246, 0.08);
  border-color: rgba(59, 130, 246, 0.22);
}

.surface-sand {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.22);
}

.calendar-embed {
  width: 100%;
  min-height: 360px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-2);
}

.calendar-source {
  display: grid;
  gap: 8px;
}

.alert {
  margin-bottom: 16px;
  color: var(--red);
}

.empty-shell {
  width: min(720px, calc(100% - 32px));
  margin: 12vh auto 0;
  display: grid;
  gap: 12px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 999px;
  animation: spin 0.6s linear infinite;
}

.loading-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 20;
}

.modal-sheet {
  width: min(480px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
}

.modal-sheet--wide {
  width: min(760px, 100%);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 16px;
}

.icon-button {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--bg-3);
  color: var(--text-1);
  transition: all 0.15s;
}

.icon-button:hover {
  background: var(--bg-hover);
}

.form-stack,
.field,
.fieldset {
  display: grid;
  gap: 10px;
}

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

.field label,
.fieldset legend {
  color: var(--text-1);
  font-size: 12px;
  font-weight: 500;
}

.fieldset {
  border: 0;
}

input,
select,
textarea {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text-0);
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--blue);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-2);
}

.mono-input {
  font-family: var(--font-mono);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-row input {
  width: auto;
}

.footer-note {
  margin-top: 8px;
}

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

@media (max-width: 1024px) {
  .panel,
  .panel[data-width="wide"] {
    grid-column: span 6;
  }

  .hero-card__grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-header,
  .panel-header,
  .modal-header {
    flex-direction: column;
    align-items: start;
    height: auto;
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .panel,
  .panel[data-width="wide"] {
    grid-column: 1 / -1;
  }

  .row-item {
    grid-template-columns: 1fr;
  }

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

  .modal-backdrop {
    align-items: end;
    padding: 0;
  }

  .modal-sheet {
    width: 100%;
    max-height: 85vh;
    border-radius: 12px 12px 0 0;
    animation: modal-slide 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  }
}

@keyframes modal-slide {
  from {
    transform: translateY(100%);
  }

  to {
    transform: translateY(0);
  }
}
