:root {
  --font-sans: "Inter", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  --bg-page: #0f172a;
  --bg-gradient-mid: #1e3a5f;
  --bg-muted: #f1f5f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 10px 40px rgba(15, 23, 42, 0.08);
  --shadow-card: 0 4px 24px rgba(15, 23, 42, 0.06);
}

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

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg-muted);
  min-height: 100vh;
}

/* ----- Dashboard shell ----- */
.page-dashboard {
  background: linear-gradient(165deg, var(--bg-page) 0%, var(--bg-gradient-mid) 42%, var(--bg-muted) 42%);
  background-attachment: fixed;
}

.page-dashboard .container {
  padding-bottom: 48px;
}

.container {
  width: min(1180px, 94%);
  margin: 0 auto;
  padding-top: 28px;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow-card);
  margin-bottom: 16px;
  border: 1px solid rgba(226, 232, 240, 0.85);
}

.card h1,
.card h2,
.card h3 {
  margin: 0 0 6px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.card h2 {
  font-size: 1.25rem;
}

.card h3 {
  font-size: 1rem;
  color: var(--text);
  margin-top: 4px;
}

.card > p:not(.help-text) {
  margin: 0 0 12px;
  color: var(--text-muted);
  font-size: 0.94rem;
}

.help-text {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.help-text strong {
  color: var(--text);
  font-weight: 600;
}

.alert {
  border-left: 4px solid #f59e0b;
  border-radius: var(--radius-sm);
}

.alert-warning {
  background: linear-gradient(90deg, #fffbeb 0%, #fff 100%);
  color: #92400e;
}

.alert-warning code {
  font-size: 0.82em;
  background: rgba(146, 64, 14, 0.1);
  padding: 2px 7px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

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

.header .title-block h1 {
  font-size: clamp(1.15rem, 2.5vw, 1.45rem);
  color: var(--surface);
  margin: 0 0 6px;
}

.header .subtitle {
  margin: 0;
  font-size: 0.9rem;
  color: rgba(248, 250, 252, 0.85);
}

.header .subtitle strong {
  color: #fff;
}

.header.card {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.92) 0%, rgba(30, 58, 95, 0.98) 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow-md);
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  align-self: center;
}

.header-actions .btn-secondary {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1.2;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-link:focus {
  position: fixed;
  left: 12px;
  top: 12px;
  width: auto;
  height: auto;
  z-index: 9999;
  padding: 10px 14px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  overflow: visible;
}

.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #bbf7d0;
  background: linear-gradient(90deg, #f0fdf4 0%, #fff 100%);
}

.notice-success .notice__text {
  margin: 0;
  color: #166534;
  font-weight: 500;
}

.notice__dismiss {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.notice__dismiss:hover {
  text-decoration: underline;
}

.section-head {
  margin-bottom: 18px;
}

.section-head h2 {
  margin-bottom: 4px;
}

.section-head__hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.card-nudge {
  border-color: rgba(37, 99, 235, 0.25);
  box-shadow: 0 4px 28px rgba(37, 99, 235, 0.08);
}

.empty-state {
  text-align: center;
  padding: 28px 16px 8px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
}

.empty-state__title {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 700;
}

.empty-state__steps {
  margin: 0 auto 20px;
  padding: 0;
  max-width: 28rem;
  text-align: left;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.empty-state__steps li {
  margin-bottom: 8px;
}

.empty-state__cta {
  display: inline-block;
  text-decoration: none;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
}

.config-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.config-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  transition: box-shadow 0.15s;
}

.config-card:hover {
  box-shadow: var(--shadow-md);
}

.config-card__head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(180deg, var(--surface-soft) 0%, var(--surface) 100%);
  border-bottom: 1px solid var(--border);
}

.config-card__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.config-card__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.badge-outline {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid var(--border);
  color: var(--text-muted);
  background: var(--surface);
}

.config-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 12px 20px;
  margin: 0;
  padding: 16px 18px;
}

.config-meta__item {
  margin: 0;
}

.config-meta__item--wide {
  grid-column: 1 / -1;
}

.config-meta__label {
  display: block;
  margin: 0 0 4px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.config-meta__value {
  display: block;
  font-size: 0.88rem;
  word-break: break-word;
  color: var(--text);
}

.config-card__error {
  margin: 0 18px 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.86rem;
}

.config-card__foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: var(--surface-soft);
  border-top: 1px solid var(--border);
}

.config-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.config-card__actions form {
  margin: 0;
}

.config-card__delete {
  margin: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 16px;
}

.panel {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
}

.panel p {
  margin: 6px 0 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.panel small {
  display: block;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 12px;
}

label:first-of-type {
  margin-top: 0;
}

input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-top: 6px;
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:hover {
  border-color: #cbd5e1;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

input[readonly] {
  background: var(--surface-soft);
  color: var(--text-muted);
  cursor: default;
}

button {
  border: 0;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  cursor: pointer;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.9rem;
  transition: background 0.15s, transform 0.05s;
}

button:active {
  transform: scale(0.98);
}

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

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

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

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

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

.btn-secondary {
  background: var(--surface-soft);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-block {
  width: 100%;
  margin-top: 16px;
}

.btn-sm {
  padding: 7px 11px;
  font-size: 0.78rem;
}

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

.status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: lowercase;
}

.status-success {
  background: #dcfce7;
  color: #166534;
}

.status-running {
  background: #fef9c3;
  color: #854d0e;
}

.status-error {
  background: #fee2e2;
  color: #991b1b;
}

.status-pending {
  background: #e2e8f0;
  color: #475569;
}

/* ----- Auth pages ----- */
.page-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: linear-gradient(165deg, var(--bg-page) 0%, var(--bg-gradient-mid) 38%, var(--bg-muted) 38%);
  background-attachment: fixed;
}

.auth {
  width: min(420px, 100%);
}

.auth-brand {
  text-align: center;
  margin-bottom: 20px;
}

.auth-brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent) 0%, #1e40af 100%);
  color: #fff;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.03em;
  box-shadow: var(--shadow-md);
}

.auth-brand h1 {
  margin: 14px 0 4px;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.auth-brand p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.auth-card h1 {
  display: none;
}

.auth-card .card-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0 0 16px;
}

.auth-footer {
  margin-top: 18px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.auth-footer a:hover {
  text-decoration: underline;
}

.error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-weight: 600;
  font-size: 0.88rem;
}

.inline-form {
  display: inline-block;
  margin-right: 6px;
}

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

  .header .title-block h1 {
    font-size: 1.1rem;
  }
}
