* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--page-background);
}

a {
  color: inherit;
}

.container {
  padding: 12px clamp(16px, 4vw, 48px) 60px;
  max-width: 1280px;
  margin: 0 auto;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(16px, 4vw, 48px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  object-fit: cover;
}

.brand-name {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Site footer */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  width: 100%;
  padding: 40px clamp(16px, 4vw, 48px) 56px;
  max-width: 1280px;
  margin: 0 auto;
  color: var(--color-text-faint);
  font-size: 13px;
}

.site-footer-credit {
  flex-basis: 100%;
  text-align: center;
  margin: 4px 0 0;
  font-size: 12.5px;
}

.site-footer-credit strong {
  color: var(--color-text-secondary);
  font-weight: 700;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
}

/* Card */
.card {
  background: var(--color-surface-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--color-surface-glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 24px 26px;
}

.grid-cards a.card {
  text-decoration: none !important;
}

.card-lg {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card-lg);
  padding: 56px 64px;
}

.card-flush {
  padding: 0;
  /* Every <table class="table"> in this app is wrapped in a flush card, so
     this alone gives every table a contained horizontal scroll instead of
     the page itself overflowing on narrow viewports. */
  overflow-x: auto;
  overflow-y: hidden;
}

.card-dashed {
  border: 2px dashed var(--color-border-dashed);
  border-radius: var(--radius-md);
  padding: 26px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--color-text-secondary);
  text-decoration: none;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-secondary {
  background: var(--color-surface-glass-strong);
  color: var(--color-text);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
  font-weight: 600;
}

.btn-danger {
  background: transparent;
  color: var(--status-failed-fg);
  border: 1px solid var(--status-failed-fg);
}

.btn-lg {
  width: 100%;
  padding: 16px 24px;
  border-radius: var(--radius-sm);
  font-size: 15px;
}

.btn-icon {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--color-text-faint);
}

.btn-icon:hover {
  background: rgba(0, 0, 0, 0.04);
}

/* Chips / pills */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border-radius: var(--radius-xs);
  font-size: 13px;
  font-weight: 600;
  background: var(--status-neutral-bg);
  color: var(--status-neutral-fg);
}

.chip-row {
  display: flex;
  width: 100%;
  justify-content: space-between;
}

.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-neutral-dot);
}

.chip-success {
  background: var(--status-success-bg);
  color: var(--status-success-fg);
}
.chip-success .chip-dot {
  background: var(--status-success-dot);
}

.chip-progress {
  background: var(--status-progress-bg);
  color: var(--status-progress-fg);
}
.chip-progress .chip-dot {
  background: var(--status-progress-dot);
}

.chip-failed {
  background: var(--status-failed-bg);
  color: var(--status-failed-fg);
}
.chip-failed .chip-dot {
  background: var(--status-failed-dot);
}

/* Standalone dot modifiers (not nested inside a .chip), e.g. an environment
   status indicator next to a heading rather than a full pill. */
.chip-dot.chip-success {
  background: var(--status-success-dot);
}
.chip-dot.chip-progress {
  background: var(--status-progress-dot);
}
.chip-dot.chip-failed {
  background: var(--status-failed-dot);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  background: var(--color-surface-pill);
  color: var(--color-pill-text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-warning {
  background: var(--status-progress-bg);
  color: var(--status-progress-fg);
}

/* Toggleable filter pills: a checkbox visually hidden behind a label
   styled as a .pill, e.g. <label class="pill-toggle"><input type=checkbox>
   <span class="pill">Success</span></label> - see the deployments/logs tab
   filter forms. */
.pill-toggle {
  display: inline-flex;
  cursor: pointer;
}

.pill-toggle input {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}

.pill-toggle input:checked + .pill {
  background: var(--color-primary);
  color: var(--color-primary-text);
}

/* Forms */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-secondary);
}

.input,
select.input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--color-border);
  background: var(--color-surface-glass-strong);
  font-family: var(--font-sans);
  font-size: 13.5px;
  color: var(--color-text);
}

.input:focus,
select.input:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: -1px;
}

.field-error {
  color: var(--status-failed-fg);
  font-size: 12.5px;
}

.search-field {
  position: relative;
}

.search-field .input {
  padding-left: 38px;
  background: var(--color-surface-glass-strong);
}

.search-field svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

/* Tabs */
.tab-nav {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
}

.tab-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  background: var(--color-surface-glass);
  color: oklch(30% 0.02 260);
}

.tab-link.active {
  background: var(--color-primary);
  color: white;
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 5px;
  border-radius: 50%;
  background: oklch(58% 0.22 25);
  color: white;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1;
  vertical-align: middle;
  box-shadow: 0 0 0 2px var(--color-surface-glass);
}

.tab-link.active .nav-badge {
  box-shadow: 0 0 0 2px var(--color-primary);
}

.tab-link.disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text-secondary);
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border-faint);
}

.table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--color-border-faint);
  font-size: 13.5px;
}

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

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--color-text-secondary);
  text-align: center;
}

.empty-state svg {
  opacity: 0.5;
}

/* Grid layouts */
.grid {
  display: grid;
  gap: 22px;
}

.grid-cards {
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, 1fr);
}

.grid-picker {
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

/* Global progress bar - signals a request is in flight (htmx or a plain
   link/form navigation). Driven by static/web/js/app.js. */
#progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: var(--color-primary);
  opacity: 0;
  z-index: 2000;
  pointer-events: none;
}

/* Confirm dialog - replaces native confirm() for destructive/notable form
   submissions. See static/web/js/confirm-dialog.js. */
.confirm-dialog {
  border: none;
  border-radius: var(--radius-md);
  padding: 24px 26px;
  max-width: 380px;
  width: calc(100% - 32px);
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-card-lg);
  color: var(--color-text);
  font-family: var(--font-sans);
}

.confirm-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.confirm-dialog p {
  margin: 0 0 20px;
  font-size: 14px;
  line-height: 1.5;
}

/* Toast (OOB swap target) */
#toast-region {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
}

.toast {
  background: var(--color-primary);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-xs);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: var(--shadow-card);
  animation: toast-in 0.15s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Utility */
.muted {
  color: var(--color-text-secondary);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  /* Lets a .row shrink below its content's natural width when it's itself a
     flex item (e.g. the topbar's brand+breadcrumb row) - a flex item's
     default min-width:auto would otherwise ignore any overflow/truncate
     rules on its children entirely. */
  min-width: 0;
}

.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.masked-value {
  letter-spacing: 2px;
  color: var(--color-text-secondary);
  font-family: monospace;
}

.revealed-value {
  font-family: monospace;
  font-size: 13px;
}

/* Responsive: phones and small tablets. Structural changes only - continuous
   properties (container/topbar padding) already scale via clamp() above. */
@media (max-width: 640px) {
  /* Tab strips (repository detail: up to 6 tabs; admin: 3) become a
     horizontal-scroll strip instead of overflowing or wrapping. */
  .tab-nav {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }

  .tab-nav::-webkit-scrollbar {
    display: none;
  }

  .tab-link {
    flex: 0 0 auto;
  }

  /* Fixed/floored-width grids all collapse to one column - safer than
     relying on auto-fill's natural collapse, which sits right at the edge
     of overflowing once container padding is accounted for. */
  .grid-3,
  .grid-cards,
  .grid-picker {
    grid-template-columns: 1fr;
  }

  /* Lets topbar-actions drop to its own line under the brand/breadcrumb
     instead of everything competing for one row. */
  .topbar {
    flex-wrap: wrap;
    row-gap: 8px;
  }

  /* Desktop-sized card padding (login, connect, select-customer) is too
     roomy on a phone. */
  .card-lg {
    padding: 32px 24px;
  }

  /* Keeps the toast clear of both edges instead of a fixed 24px-from-right
     box that could overflow a narrow viewport. */
  #toast-region {
    left: 16px;
    right: 16px;
    bottom: 16px;
  }

  .toast {
    width: auto;
  }

  /* Bumped toward the ~44px touch-target guideline. */
  .avatar {
    width: 44px;
    height: 44px;
  }

  .btn-icon {
    width: 40px;
    height: 40px;
  }
}

/* Truncates long inline text (e.g. a repository name/URL in the breadcrumb)
   instead of letting it push sibling flex items off-screen. Needs min-width:0
   on the element itself since flex items default to min-width:auto, which
   ignores overflow rules entirely. */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Terminal tab's xterm.js container - capped relative to viewport height so
   it never dominates a short phone screen. See static/web/js/terminal.js,
   which fits xterm's internal canvas to whatever size this resolves to. */
.terminal-container {
  height: min(480px, 60vh);
  background: #1e1e1e;
}
