/*
 * Clutch Admin stylesheet.
 *
 * Branding: change the --brand-* and --accent-* tokens below to match Clutch's colors.
 * Everything else derives from these tokens. No inline styles are used anywhere
 * (the Content-Security-Policy forbids them), so all presentation lives here.
 */

:root {
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* Brand */
  --brand-ink: #101318;
  --brand-ink-2: #1b2029;
  --accent: #2f5be0;
  --accent-hover: #2349c2;
  --accent-soft: #edf2ff;
  --accent-ring: rgba(47, 91, 224, 0.35);

  /* Neutrals */
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-muted: #f8f9fb;
  --surface-sunken: #f0f2f5;
  --border: #e3e6eb;
  --border-strong: #cdd2da;
  --text: #14171c;
  --text-muted: #555e6b;
  --text-subtle: #6f7785;
  --text-on-dark: #eef1f5;
  --text-on-dark-muted: #a9b1bd;

  /* Status tones */
  --success: #16794a;
  --success-soft: #e7f5ee;
  --success-border: #b9e2cc;
  --danger: #c0262d;
  --danger-soft: #fdeeee;
  --danger-border: #f2c3c5;
  --warning: #8f5300;
  --warning-soft: #fff5e3;
  --warning-border: #f0d7a7;
  --info: #2f5be0;
  --info-soft: #edf2ff;
  --info-border: #c9d6fb;
  --neutral: #4b5563;
  --neutral-soft: #eff1f4;
  --neutral-border: #dde1e7;

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow: 0 1px 3px rgba(16, 24, 40, 0.08), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
  --sidebar-width: 256px;
  --content-width: 1180px;
}

/* ---------- Base ---------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

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

h1,
h2,
h3,
h4 {
  margin: 0;
  line-height: 1.25;
  font-weight: 650;
  letter-spacing: -0.01em;
}

p {
  margin: 0 0 0.75rem;
}

p:last-child {
  margin-bottom: 0;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

code,
pre,
.mono {
  font-family: var(--font-mono);
  font-size: 0.86em;
}

hr,
.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  vertical-align: middle;
}

.icon-sm {
  width: 15px;
  height: 15px;
}

.icon-lg {
  width: 24px;
  height: 24px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}

.skip-link:focus {
  top: 12px;
}

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

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

.small {
  font-size: 0.87rem;
}

.nowrap {
  white-space: nowrap;
}

.stack > * + * {
  margin-top: 1rem;
}

.stack-lg > * + * {
  margin-top: 1.5rem;
}

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

.row-between {
  justify-content: space-between;
}

.grow {
  flex: 1 1 auto;
}

/* ---------- App shell ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  background: var(--brand-ink);
  color: var(--text-on-dark);
  padding: 20px 14px 16px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 10px 22px;
  color: #fff;
  text-decoration: none;
}

.brand:hover {
  text-decoration: none;
}

.brand-name {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-product {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-on-dark-muted);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  margin: 18px 10px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-on-dark-muted);
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-on-dark-muted);
  font-weight: 500;
  text-decoration: none;
}

.nav-link:hover {
  background: var(--brand-ink-2);
  color: #fff;
  text-decoration: none;
}

.nav-link.is-active {
  background: var(--brand-ink-2);
  color: #fff;
}

.nav-link.is-active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.nav-link:focus-visible {
  outline-color: #fff;
}

.nav-link > span:not(.nav-tag) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-tag {
  margin-left: auto;
  font-size: 0.66rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-on-dark-muted);
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-on-dark);
  text-decoration: none;
}

.user-card:hover {
  background: var(--brand-ink-2);
  text-decoration: none;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #2a3140;
  color: #fff;
  font-weight: 650;
  font-size: 0.85rem;
  flex: none;
}

.user-meta {
  min-width: 0;
  line-height: 1.3;
}

.user-name,
.user-role {
  display: block;
}

.user-name {
  font-weight: 600;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.78rem;
  color: var(--text-on-dark-muted);
}

.signout-form {
  margin: 6px 0 0;
}

.signout-button {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-on-dark-muted);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}

.signout-button:hover {
  background: var(--brand-ink-2);
  color: #fff;
}

.release {
  margin: 10px 10px 0;
  font-size: 0.72rem;
  color: #7d8594;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: none;
}

.content {
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 32px 40px 72px;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 40px;
  border-bottom: 1px solid var(--info-border);
  background: var(--info-soft);
  color: #1d3b8f;
  font-size: 0.92rem;
}

.notice-warning {
  border-bottom-color: var(--warning-border);
  background: var(--warning-soft);
  color: var(--warning);
}

.nav-backdrop {
  display: none;
}

@media (max-width: 960px) {
  .app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(84vw, 300px);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

  .nav-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .nav-open .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 40;
    background: rgba(16, 19, 24, 0.45);
  }

  .topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--brand-ink);
    color: #fff;
  }

  .topbar .brand {
    padding: 0;
  }

  .menu-button {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: var(--radius-sm);
    background: transparent;
    color: #fff;
    cursor: pointer;
  }

  .content {
    padding: 22px 16px 56px;
  }

  .notice {
    padding: 10px 16px;
  }
}

/* ---------- Page header ---------- */

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

.page-title {
  font-size: 1.6rem;
}

.page-description {
  margin-top: 6px;
  max-width: 70ch;
  color: var(--text-muted);
}

.page-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

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

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
}

.section-title {
  font-size: 1.05rem;
  margin-bottom: 12px;
}

/* ---------- Cards and grids ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.card + .card {
  margin-top: 20px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  font-size: 1rem;
  font-weight: 650;
}

.card-subtitle {
  margin-top: 2px;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.card-body {
  padding: 20px;
}

.card-body-flush {
  padding: 0;
}

.card-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-muted);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.grid {
  display: grid;
  gap: 20px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.grid-main-side {
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  align-items: start;
}

.grid > .card + .card {
  margin-top: 0;
}

.grid + .card,
.card + .grid,
.grid + .grid,
.content > .alert,
.manage > .alert {
  margin-top: 20px;
}

.content > .alert:first-child {
  margin-top: 0;
}

.content > .alert + .alert {
  margin-top: 12px;
}

.content > .alert + .grid,
.content > .alert + .card {
  margin-top: 20px;
}

@media (max-width: 1100px) {
  .grid-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .grid-main-side {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 720px) {
  .grid-2,
  .grid-3 {
    grid-template-columns: minmax(0, 1fr);
  }
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 900px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.stat {
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.stat-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.stat-value {
  margin-top: 4px;
  font-size: 1.6rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

/* ---------- Tables ---------- */

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

.table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-subtle);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

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

.table tbody tr:hover td {
  background: var(--surface-muted);
}

.table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.cell-primary {
  font-weight: 600;
}

.cell-secondary {
  display: block;
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
}

.card > .table-wrap .table th:first-child,
.card > .table-wrap .table td:first-child {
  padding-left: 20px;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border: 1px solid var(--neutral-border);
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--neutral);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}

.badge .icon {
  width: 13px;
  height: 13px;
}

.badge-success {
  background: var(--success-soft);
  border-color: var(--success-border);
  color: var(--success);
}

.badge-danger {
  background: var(--danger-soft);
  border-color: var(--danger-border);
  color: var(--danger);
}

.badge-warning {
  background: var(--warning-soft);
  border-color: var(--warning-border);
  color: var(--warning);
}

.badge-info {
  background: var(--info-soft);
  border-color: var(--info-border);
  color: var(--info);
}

.badge-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.badge-info.badge-dot::before {
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.93rem;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.12s ease, border-color 0.12s ease;
}

.btn:hover {
  background: var(--surface-sunken);
  text-decoration: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
}

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

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

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

.btn-danger:hover {
  background: var(--danger-soft);
}

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

.btn-danger-solid:hover {
  background: #a31f25;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--surface-sunken);
}

.btn-link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  box-shadow: none;
  color: var(--accent);
  font-weight: 600;
}

.btn-link:hover {
  background: none;
  text-decoration: underline;
}

.btn-sm {
  min-height: 32px;
  padding: 5px 11px;
  font-size: 0.86rem;
}

.btn-block {
  width: 100%;
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn.is-busy {
  pointer-events: none;
  opacity: 0.8;
}

.btn.is-busy::after {
  content: "";
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.button-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.button-group-vertical {
  flex-direction: column;
  align-items: stretch;
}

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

.inline-form {
  display: inline;
  margin: 0;
}

/* ---------- Alerts and messages ---------- */

.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border: 1px solid var(--info-border);
  border-radius: var(--radius);
  background: var(--info-soft);
  color: #1d3b8f;
}

.alert .icon {
  margin-top: 2px;
}

.alert-title {
  font-weight: 650;
}

.alert-success {
  border-color: var(--success-border);
  background: var(--success-soft);
  color: #0f5c37;
}

.alert-error,
.alert-danger {
  border-color: var(--danger-border);
  background: var(--danger-soft);
  color: #8f1b20;
}

.alert-warning {
  border-color: var(--warning-border);
  background: var(--warning-soft);
  color: #6f4000;
}

.alert-neutral {
  border-color: var(--neutral-border);
  background: var(--neutral-soft);
  color: var(--neutral);
}

.messages {
  display: grid;
  gap: 10px;
  margin-bottom: 20px;
}

/* ---------- Forms ---------- */

.form > * + * {
  margin-top: 18px;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding-top: 4px;
}

.field-label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.93rem;
}

.field-optional {
  font-weight: 400;
  color: var(--text-subtle);
}

.field-help {
  margin-top: 6px;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.field-help ul {
  margin: 4px 0 0;
  padding-left: 18px;
}

.field-errors {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  color: var(--danger);
  font-size: 0.88rem;
  font-weight: 500;
}

.input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  box-shadow: var(--shadow-sm);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

input[disabled],
input[readonly],
textarea[readonly] {
  background: var(--surface-sunken);
  color: var(--text-muted);
}

.field-invalid input,
.field-invalid select,
.field-invalid textarea {
  border-color: var(--danger);
}

.field-narrow {
  max-width: 220px;
}

.choice-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.choice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
}

.choice:hover {
  border-color: var(--border-strong);
}

.choice input {
  margin-top: 3px;
  accent-color: var(--accent);
}

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

.checkbox input {
  margin-top: 4px;
  accent-color: var(--accent);
}

fieldset {
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
}

.error-summary {
  margin-bottom: 4px;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.filters select {
  width: auto;
  min-width: 180px;
}

/* ---------- Empty states ---------- */

.empty-state {
  padding: 40px 24px;
  text-align: center;
}

.empty-icon {
  display: inline-grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: var(--surface-sunken);
  color: var(--text-subtle);
}

.empty-title {
  font-size: 1.02rem;
  font-weight: 650;
}

.empty-text {
  max-width: 52ch;
  margin: 6px auto 0;
  color: var(--text-muted);
}

.empty-actions {
  margin-top: 16px;
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Definition lists, timelines, lists ---------- */

.kv {
  display: grid;
  grid-template-columns: minmax(140px, max-content) minmax(0, 1fr);
  gap: 10px 20px;
  margin: 0;
}

.kv dt {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.kv dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 560px) {
  .kv {
    grid-template-columns: minmax(0, 1fr);
    gap: 2px;
  }

  .kv dd {
    margin-bottom: 10px;
  }
}

.timeline {
  margin: 0;
  padding: 0;
  list-style: none;
}

.timeline-item {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.92rem;
}

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

.timeline-time {
  color: var(--text-subtle);
  font-variant-numeric: tabular-nums;
}

.timeline-warning .timeline-message {
  color: var(--warning);
}

.timeline-error .timeline-message {
  color: var(--danger);
}

.list-plain {
  margin: 0;
  padding: 0;
  list-style: none;
}

.list-divided > li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.list-divided > li:first-child {
  padding-top: 0;
}

.list-divided > li:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.attention-item,
.list-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.list-row .grow,
.attention-item .grow {
  min-width: 0;
}

.list-row .module-icon {
  flex: none;
}

.row-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}

.attention-item .icon {
  margin-top: 3px;
}

.tone-danger {
  color: var(--danger);
}

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

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

.tone-success {
  color: var(--success);
}

.milestones {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: milestone;
}

.milestones li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.milestones li:last-child {
  border-bottom: 0;
}

.milestone-marker {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: none;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--text-subtle);
  background: var(--surface);
}

.milestone-done .milestone-marker {
  border-color: var(--success);
  background: var(--success);
  color: #fff;
}

.module-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  color: inherit;
  text-decoration: none;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

a.module-card:hover {
  text-decoration: none;
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.module-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.module-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent);
}

.module-card h3 {
  font-size: 1rem;
}

/* ---------- Progress ---------- */

progress {
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-sunken);
  overflow: hidden;
  appearance: none;
}

progress::-webkit-progress-bar {
  background: var(--surface-sunken);
  border-radius: 999px;
}

progress::-webkit-progress-value {
  background: var(--accent);
  border-radius: 999px;
}

progress::-moz-progress-bar {
  background: var(--accent);
  border-radius: 999px;
}

.progress-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 0.9rem;
}

/* ---------- Details, code, links ---------- */

.disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.disclosure > summary {
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.92rem;
}

.disclosure > :not(summary) {
  padding: 0 14px 14px;
}

.technical {
  max-height: 420px;
  margin: 0;
  padding: 12px 14px;
  overflow: auto;
  border-radius: var(--radius-sm);
  background: #10141b;
  color: #d8dee9;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.link-box {
  display: flex;
  gap: 8px;
}

.link-box input {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.qr {
  display: block;
  width: 200px;
  height: 200px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.recovery-codes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, max-content));
  gap: 6px 28px;
  margin: 0;
  padding: 16px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-muted);
  font-family: var(--font-mono);
  font-size: 1rem;
  list-style: none;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
}

/* ---------- Sign-in and minimal layouts ---------- */

.auth {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, #e6ebf7 0%, rgba(230, 235, 247, 0) 70%),
    var(--bg);
}

.auth-brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 22px;
  color: var(--brand-ink);
  text-decoration: none;
}

.auth-brand:hover {
  text-decoration: none;
}

.auth-brand .brand-name {
  color: var(--brand-ink);
}

.auth-brand .brand-product {
  color: var(--text-muted);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.auth-card-wide {
  max-width: 560px;
}

.auth-card .page-title {
  font-size: 1.35rem;
}

.auth-card > * + * {
  margin-top: 16px;
}

.auth-footer {
  margin-top: 20px;
  font-size: 0.84rem;
  color: var(--text-subtle);
  text-align: center;
}

.or-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text-subtle);
  font-size: 0.84rem;
}

.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--border);
}

.option-card {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
}

.option-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  text-decoration: none;
}

.option-card .module-icon {
  flex: none;
}

.option-title {
  font-weight: 650;
}

@media (max-width: 480px) {
  .auth-card {
    padding: 24px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ---------- Account security pages (django-allauth) ---------- */

.manage {
  max-width: 760px;
}

.manage-body > * + * {
  margin-top: 16px;
}

.panel {
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.panel > * + * {
  margin-top: 10px;
}

.panel .section-title {
  margin-bottom: 0;
}

.option-card .option-title,
.option-card .small {
  display: block;
}

.option-card .small {
  margin-top: 2px;
}

/* ---------- Tables on narrow screens: each row becomes a labeled block ---------- */

@media (max-width: 640px) {
  .table-stack thead {
    display: none;
  }

  .table-stack,
  .table-stack tbody,
  .table-stack tr,
  .table-stack td {
    display: block;
    width: 100%;
  }

  .table-stack tr {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
  }

  .table-stack tbody tr:last-child {
    border-bottom: 0;
  }

  .table-stack td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 3px 0;
    border: 0;
    text-align: right;
  }

  .table-stack td::before {
    content: attr(data-label);
    flex: none;
    font-size: 0.8rem;
    color: var(--text-subtle);
    text-align: left;
  }

  .table-stack td:first-child {
    display: block;
    padding-bottom: 6px;
    text-align: left;
  }

  .table-stack td:first-child::before,
  .table-stack td[data-label=""]::before {
    content: none;
  }

  .card > .table-wrap .table-stack td:first-child {
    padding-left: 0;
  }

  .table-stack tbody tr:hover td {
    background: none;
  }
}

/* ---------- Script Manager ---------- */

.tabs {
  display: flex;
  gap: 4px;
  margin: -8px 0 22px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.93rem;
  white-space: nowrap;
}

.tab:hover {
  color: var(--text);
  text-decoration: none;
}

.tab.is-active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-count,
.count-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--neutral-soft);
  color: var(--neutral);
  font-size: 0.75rem;
  font-weight: 650;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
}

.tab-count-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.now-running + .card,
.content > .card.terminal-card {
  margin-top: 20px;
}

#queue-running > .alert {
  margin-bottom: 16px;
}

.running-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.running-title {
  font-size: 1.05rem;
  font-weight: 650;
}

#queue-lists {
  margin-top: 20px;
}

.queue-grid + .card {
  margin-top: 20px;
}

.job-list {
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 520px;
  overflow-y: auto;
}

.job-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 20px;
  border-bottom: 1px solid var(--border);
}

.job-row:last-child {
  border-bottom: 0;
}

.job-row:hover {
  background: var(--surface-muted);
}

.job-check {
  margin-top: 4px;
  width: 16px;
  height: 16px;
  flex: none;
}

.job-order {
  min-width: 22px;
  color: var(--text-subtle);
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  padding-top: 2px;
}

.job-main {
  flex: 1;
  min-width: 0;
}

.job-meta {
  flex: none;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.toolbar {
  justify-content: flex-start;
  align-items: center;
}

.toolbar-group {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.select-sm {
  min-height: 32px;
  padding: 4px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  font: inherit;
  font-size: 0.86rem;
  max-width: 170px;
}

.empty-compact {
  padding: 22px 20px;
}

/* Terminal (console output) */

.terminal {
  margin: 0;
  padding: 14px 16px;
  overflow: auto;
  background: #0f131a;
  color: #d8dee9;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  tab-size: 4;
}

.card > .terminal {
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.terminal-medium {
  height: 340px;
}

.terminal-tall {
  height: 560px;
}

.terminal .t-line {
  min-height: 1.55em;
}

.terminal .t-in {
  color: #9ecbff;
  font-weight: 600;
}

.terminal .t-note {
  color: #88c0d0;
}

.terminal .t-progress {
  color: #a3be8c;
}

.terminal:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.terminal-note {
  padding: 8px 20px 14px;
}

/* Console tab: a full console window */

.console-shell {
  display: flex;
  flex-direction: column;
  border: 1px solid #1f2632;
  border-radius: var(--radius-lg);
  background: #0f131a;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.console-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  background: #161b24;
  border-bottom: 1px solid #1f2632;
  color: #c7ced9;
  font-size: 0.88rem;
}

.console-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.console-jobs {
  color: #a3be8c;
}

.console-actions {
  display: flex;
  gap: 8px;
}

.console-button {
  border-color: #2c3544;
  background: transparent;
  color: #d8dee9;
  box-shadow: none;
}

.console-button:hover {
  background: #1f2632;
}

.terminal-console {
  height: calc(100vh - 380px);
  min-height: 380px;
  border-radius: 0;
  cursor: text;
}

.console-input {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #161b24;
  border-top: 1px solid #1f2632;
}

.console-prompt {
  color: #9ecbff;
  font-family: var(--font-mono);
  font-weight: 700;
}

.console-input input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid #2c3544;
  border-radius: var(--radius);
  background: #0f131a;
  color: #eef1f5;
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.console-input input:focus {
  outline: none;
  border-color: #9ecbff;
}

.console-start {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 18px;
  background: var(--surface);
}

.console-start-fields {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.console-help {
  margin-top: 10px;
}

.console-shell.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  border-radius: 0;
}

.console-shell.is-fullscreen .terminal-console {
  flex: 1;
  height: auto;
}

body.console-fullscreen {
  overflow: hidden;
}

/* Settings */

.settings-section {
  margin: 0;
  padding: 0;
  border: 0;
  min-width: 0;
}

.settings-section + .settings-section {
  margin-top: 8px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.setting + .setting {
  margin-top: 18px;
}

.setting-input {
  display: flex;
  align-items: center;
  gap: 10px;
}

.setting-input input {
  max-width: 140px;
}

.setting-unit {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.setting-recommended {
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.checklist {
  margin: 0;
  padding: 0;
  list-style: none;
}

.checklist li {
  position: relative;
  padding-left: 26px;
  font-size: 0.93rem;
}

.checklist li + li {
  margin-top: 10px;
}

.checklist li::before {
  content: "✓";
  position: absolute;
  left: 4px;
  color: var(--success);
  font-weight: 700;
}

.key-field + .key-field {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.key-field .input {
  margin-top: 6px;
  font-family: var(--font-mono);
}

.build-card.is-live {
  border-color: var(--success-border);
}

.break {
  word-break: break-word;
}

@media (max-width: 720px) {
  .job-row {
    padding: 11px 14px;
  }

  .job-meta {
    display: none;
  }

  .terminal-console {
    height: calc(100vh - 300px);
  }
}

.terminal-short {
  height: 150px;
}

.console-shell.is-idle .terminal-console {
  height: 220px;
  min-height: 0;
}

.toolbar .btn,
.toolbar .select-sm {
  white-space: nowrap;
}

.filters select {
  max-width: 260px;
}

.key-group + .key-group {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.key-group-name {
  font-weight: 650;
}

.key-rows {
  margin-top: 8px;
}

.key-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 0;
}

.key-row .mono {
  min-width: 0;
  overflow-wrap: anywhere;
}
