*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0;
    font-family: var(--wa-font-sans, system-ui, sans-serif);
    background-color: var(--wa-color-surface-default, #f4f4f5);
    color: var(--wa-color-neutral-950, #09090b);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top nav */
.site-nav {
    background-color: #18181b;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 1.5rem;
    height: 56px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.site-nav__brand {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: #fff;
    text-decoration: none;
    margin-right: 2rem;
    white-space: nowrap;
}
.site-nav__links {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex: 1;
}
.site-nav__right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}
.site-nav__user { font-size: 0.8rem; color: #a1a1aa; }
.nav-link {
    color: #d4d4d8;
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.08); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.14); color: #fff; font-weight: 600; }
.nav-link.new-deploy { color: #fbbf24; font-weight: 600; }
.nav-link.new-deploy:hover { background: rgba(251,191,36,0.15); color: #fbbf24; }

/* Page content */
.page-content {
    flex: 1;
    padding: 2rem 1.5rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* Footer */
.site-footer {
    padding: 1rem 1.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--wa-color-neutral-500, #71717a);
    border-top: 1px solid var(--wa-color-neutral-200, #e4e4e7);
    background: var(--wa-color-surface-default, #f4f4f5);
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75em;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.status-pending    { background: #52525b; color: #fff; }
.status-partial    { background: #ea580c; color: #fff; }
.status-success    { background: #16a34a; color: #fff; }
.status-failed     { background: #dc2626; color: #fff; }
.status-stalled    { background: #d97706; color: #fff; }
.status-rolledback { background: #7c3aed; color: #fff; }
.status-preflight  { background: #0891b2; color: #fff; }
.status-preflightwarning { background: #d97706; color: #fff; }
.status-offline    { background: #52525b; color: #fff; }
.status-backup     { background: #2563eb; color: #fff; }
.status-deploying  { background: #2563eb; color: #fff; }
.status-online     { background: #16a34a; color: #fff; }
.status-cleanup    { background: #059669; color: #fff; }

/* Agent online/offline */
.agent-online  { color: #16a34a; font-weight: 700; }
.agent-offline { color: #dc2626; }

/* Status card accent */
.status-card {
    --card-accent: var(--wa-color-neutral-300, #d4d4d8);
    border-left: 4px solid var(--card-accent) !important;
}
.status-card.card-success          { --card-accent: #16a34a; }
.status-card.card-failed           { --card-accent: #dc2626; }
.status-card.card-deploying        { --card-accent: #2563eb; }
.status-card.card-stalled          { --card-accent: #d97706; }
.status-card.card-preflightwarning { --card-accent: #d97706; }

/* Data table */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th {
    text-align: left;
    padding: 0.6rem 0.9rem;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--wa-color-neutral-600, #52525b);
    border-bottom: 2px solid var(--wa-color-neutral-200, #e4e4e7);
    background: var(--wa-color-surface-raised, #fafafa);
}
.data-table td {
    padding: 0.7rem 0.9rem;
    border-bottom: 1px solid var(--wa-color-neutral-100, #f4f4f5);
    vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--wa-color-surface-raised, #fafafa); }
code {
    font-family: var(--wa-font-mono, monospace);
    font-size: 0.85em;
    background: var(--wa-color-neutral-100, #f4f4f5);
    padding: 1px 5px;
    border-radius: 4px;
}

/* Page header row */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-header h1, .page-header h2 { margin: 0; font-size: 1.5rem; font-weight: 700; }

/* Card table wrapper */
.card-table-wrap {
    overflow-x: auto;
    border-radius: 0 0 var(--wa-border-radius-m, 8px) var(--wa-border-radius-m, 8px);
}

/* Dialog form fields spacing */
wa-dialog .field-group { display: flex; flex-direction: column; gap: 1rem; }

/* Utility */
.text-muted { color: var(--wa-color-neutral-500, #71717a); }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.gap-2 { gap: 0.5rem; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.font-mono { font-family: var(--wa-font-mono, monospace); }
.w-full { width: 100%; }

/* ── Public pages (login, setup) ── */
.public-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background-color: #18181b;
    font-family: var(--wa-font-sans, system-ui, sans-serif);
}
.public-card {
    width: 100%;
    max-width: 420px;
    background: #27272a;
    border-radius: 14px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
    overflow: hidden;
}
.public-header {
    background: #09090b;
    padding: 2rem;
    text-align: center;
    border-bottom: 1px solid #3f3f46;
}
.public-header h1 {
    color: #fff;
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: 3px;
    margin: 0 0 0.25rem;
}
.public-header p {
    color: #a1a1aa;
    margin: 0;
    font-size: 0.875rem;
}
.public-body {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}
.public-body wa-input,
.public-body wa-button { width: 100%; }
.public-hint { color: #a1a1aa; margin: 0; font-size: 0.875rem; }
