/* ═══════════════════════════════════════════════════════════
   ASTRAL ENGINE — DESIGN SYSTEM v2 — TECHNICAL MINIMAL
   dark-first · monospace data · sharp edges · no gradients
   ═══════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    color-scheme: dark;
    --bg:            #0d1117;
    --bg-elevated:   #161b22;
    --bg-overlay:    #1c2128;
    --bg-strong:     #1c2128;
    --border:        #30363d;
    --border-subtle: #21262d;
    --text:          #e6edf3;
    --text-muted:    #7d8590;
    --text-strong:   #f0f6fc;
    --muted:         #7d8590;
    --accent:        #58a6ff;
    --accent-dim:    rgba(88,166,255,.12);
    --green:         #3fb950;
    --green-dim:     rgba(63,185,80,.14);
    --yellow:        #d29922;
    --yellow-dim:    rgba(210,153,34,.14);
    --red:           #f85149;
    --red-dim:       rgba(248,81,73,.14);
    --purple:        #8957e5;
    --radius:        4px;
    --radius-sm:     3px;
    --font:          -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    --mono:          ui-monospace, 'SFMono-Regular', 'Cascadia Code', 'JetBrains Mono', monospace;
    --nav-h:         48px;
    --shadow:        none;
    --button-text:   #0d1117;
    --accent-strong: #79b8ff;
}

[data-theme='light'] {
    color-scheme: light;
    --bg:            #f6f8fa;
    --bg-elevated:   #ffffff;
    --bg-overlay:    #eaeef2;
    --bg-strong:     #eaeef2;
    --border:        #d0d7de;
    --border-subtle: #eaeef2;
    --text:          #1f2328;
    --text-muted:    #636c76;
    --text-strong:   #010409;
    --muted:         #636c76;
    --accent:        #0969da;
    --accent-dim:    rgba(9,105,218,.10);
    --green:         #1a7f37;
    --green-dim:     rgba(26,127,55,.12);
    --yellow:        #7d4e00;
    --yellow-dim:    rgba(125,78,0,.10);
    --red:           #cf222e;
    --red-dim:       rgba(207,34,46,.12);
    --purple:        #6e40c9;
    --button-text:   #ffffff;
    --accent-strong: #0550ae;
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
p { color: var(--text-muted); font-size: 13px; margin: 0; }
strong { color: var(--text-strong); font-weight: 600; }
pre { font-family: var(--mono); }
button, a, input, select, textarea { font: inherit; }
img { max-width: 100%; display: block; }
.app-shell { transition: background-color 100ms, color 100ms; }

/* ── Navigation ────────────────────────────────────────────── */
.app-nav-shell {
    position: sticky;
    top: 0;
    z-index: 40;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
}
.app-nav {
    width: min(1440px, calc(100vw - 48px));
    margin: 0 auto;
    height: var(--nav-h);
    display: flex;
    align-items: center;
    gap: 16px;
}
.app-brand {
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-strong);
    letter-spacing: -0.02em;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.app-brand:hover { color: var(--accent); text-decoration: none; }
.app-nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}
.app-nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.app-nav-link {
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 12px;
    font-family: var(--mono);
    text-decoration: none;
    transition: background 80ms, color 80ms;
}
.app-nav-link:hover {
    background: var(--bg-elevated);
    color: var(--text);
    text-decoration: none;
}

/* ── Flash messages ────────────────────────────────────────── */
.flash-stack {
    width: min(1440px, calc(100vw - 48px));
    margin: 10px auto;
    display: grid;
    gap: 6px;
}
.flash-message {
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    font-size: 12px;
    font-family: var(--mono);
}
.flash-message--success { border-color: var(--green); color: var(--green); }
.flash-message--error   { border-color: var(--red);   color: var(--red); }
.flash-message--info    { border-color: var(--accent); color: var(--accent); }

/* ── Page layouts ──────────────────────────────────────────── */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 0;
}
.dashboard-layout {
    width: min(1440px, calc(100vw - 48px));
    margin: 0 auto;
    padding: 24px 0 64px;
}
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}
.dashboard-header h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-strong);
    font-family: var(--mono);
    letter-spacing: -0.02em;
}
.dashboard-subtitle {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
    font-family: var(--mono);
}
.dashboard-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* ── Grid ──────────────────────────────────────────────────── */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    align-items: start;
}
.dashboard-grid--two {
    grid-template-columns: 2fr 1fr;
    margin-top: 10px;
}
.dashboard-grid--two .panel--wide { grid-column: auto; }

/* ── Panels ────────────────────────────────────────────────── */
.panel {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}
.panel--hero {
    grid-column: span 2;
    display: grid;
    gap: 14px;
}
.panel--wide   { grid-column: span 3; }
.panel--stacked { display: grid; align-content: start; gap: 12px; }

.panel h2, .panel h3 {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-family: var(--mono);
}
.panel p { font-size: 12px; font-family: var(--mono); }

.panel-hero__content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}
.hero-badge {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    color: var(--accent);
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ── KPI strip ─────────────────────────────────────────────── */
.kpi-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 10px;
}
.kpi-card {
    padding: 14px 16px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    border-radius: var(--radius);
    display: grid;
    gap: 4px;
}
.kpi-card strong {
    font-family: var(--mono);
    font-size: 24px;
    font-weight: 700;
    color: var(--text-strong);
    line-height: 1;
}
.kpi-card span {
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-muted);
}
.kpi-card--ready    { border-left-color: var(--green); }
.kpi-card--pending  { border-left-color: var(--yellow); }
.kpi-card--critical { border-left-color: var(--red); }
.kpi-card--neutral  { border-left-color: var(--accent); }

/* ── Eyebrow / labels ──────────────────────────────────────── */
.eyebrow, .activity-kicker {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

/* ── Buttons ───────────────────────────────────────────────── */
.primary-button,
.ghost-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    cursor: pointer;
    font-size: 12px;
    font-family: var(--mono);
    font-weight: 600;
    transition: background 80ms, border-color 80ms, color 80ms;
    white-space: nowrap;
    border: 1px solid transparent;
}
.primary-button {
    padding: 7px 14px;
    background: var(--accent);
    color: var(--button-text);
    border-color: var(--accent);
}
.primary-button:hover {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
    color: var(--button-text);
    text-decoration: none;
}
.ghost-button {
    padding: 6px 12px;
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.ghost-button:hover {
    background: var(--bg-overlay);
    color: var(--text);
    border-color: var(--border);
    text-decoration: none;
}
.ghost-link {
    color: var(--accent);
    font-size: 12px;
    font-family: var(--mono);
    text-decoration: none;
}
.ghost-link:hover { text-decoration: underline; }

/* ── Section heading ───────────────────────────────────────── */
.section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* ── Stats row ─────────────────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}
.stat-card {
    padding: 12px 14px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: grid;
    gap: 4px;
}
.stat-card strong { font-family: var(--mono); font-size: 20px; line-height: 1; }
.stat-card span   { font-family: var(--mono); font-size: 11px; color: var(--text-muted); }

/* ── Activity grid ─────────────────────────────────────────── */
.activity-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}
.activity-card {
    padding: 12px 14px;
    background: var(--bg-overlay);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: grid;
    gap: 4px;
}
.activity-card strong { font-family: var(--mono); font-size: 18px; line-height: 1.1; }
.activity-card p { font-family: var(--mono); font-size: 11px; }

/* ── Milestone list ────────────────────────────────────────── */
.milestone-list { display: grid; gap: 0; }
.milestone-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 9px 0;
    border-bottom: 1px solid var(--border-subtle);
    background: none;
}
.milestone-item:first-child { padding-top: 0; }
.milestone-item:last-child  { border-bottom: none; padding-bottom: 0; }
.milestone-dot {
    width: 6px;
    height: 6px;
    margin-top: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    flex: 0 0 auto;
}
.milestone-item strong { display: block; font-size: 12px; margin-bottom: 2px; }
.milestone-item p { font-size: 11px; font-family: var(--mono); }
.milestone-item div { min-width: 0; }

.milestone-dot--critical,
.milestone-dot--high,
.milestone-dot--failed    { background: var(--red); }
.milestone-dot--medium,
.milestone-dot--pending,
.milestone-dot--running   { background: var(--yellow); }
.milestone-dot--low,
.milestone-dot--succeeded { background: var(--green); }

/* ── Detail / metric list ──────────────────────────────────── */
.detail-list, .metric-list { display: grid; gap: 0; }
.detail-list div, .metric-list div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 12px;
}
.detail-list div:last-child,
.metric-list div:last-child { border-bottom: none; }
.detail-list span, .metric-list span {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    flex-shrink: 0;
}
.detail-list strong, .metric-list strong {
    font-family: var(--mono);
    font-size: 12px;
    text-align: right;
}

/* ── Tables ────────────────────────────────────────────────── */
.client-table-wrap { overflow: auto; }
.client-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}
.client-table th {
    text-align: left;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    white-space: nowrap;
}
.client-table td {
    text-align: left;
    padding: 9px 12px;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: middle;
}
.client-table tr:last-child td { border-bottom: none; }
.client-table td span {
    display: block;
    font-family: var(--mono);
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}
.client-table tr:hover td { background: var(--bg-overlay); }
.client-table td strong { font-size: 13px; }

/* ── Status pills ──────────────────────────────────────────── */
.status-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 700;
    background: transparent;
    white-space: nowrap;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.status-pill--ready,
.status-pill--active,
.status-pill--resolved,
.status-pill--succeeded {
    border-color: var(--green);
    color: var(--green);
    background: var(--green-dim);
}
.status-pill--pending,
.status-pill--onboarding,
.status-pill--acknowledged,
.status-pill--running {
    border-color: var(--yellow);
    color: var(--yellow);
    background: var(--yellow-dim);
}
.status-pill--disabled,
.status-pill--paused,
.status-pill--failed,
.status-pill--critical,
.status-pill--canceled,
.status-pill--high {
    border-color: var(--red);
    color: var(--red);
    background: var(--red-dim);
}
.status-pill--unknown {
    border-color: var(--border);
    color: var(--text-muted);
}
.status-pill--medium,
.status-pill--low {
    border-color: var(--yellow);
    color: var(--yellow);
    background: var(--yellow-dim);
}

/* ── Terminal ──────────────────────────────────────────────── */
.terminal-output { display: grid; gap: 8px; }
.terminal-pre {
    margin: 0;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #010409;
    color: #adbac7;
    overflow: auto;
    font-family: var(--mono);
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
    min-height: 40px;
}
.terminal-pre--stderr { color: var(--red); }

/* ── Forms ─────────────────────────────────────────────────── */
.app-form-grid  { display: grid; gap: 16px; }
.app-form-row   { display: grid; gap: 10px; }
.app-form-row--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.app-form-row--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.app-form-field  { display: grid; gap: 6px; }
.app-form-field label {
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
}
.app-input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    outline: none;
    font-family: var(--mono);
    font-size: 13px;
    transition: border-color 80ms;
}
.app-input:focus       { border-color: var(--accent); }
.app-input::placeholder { color: var(--text-muted); }
select.app-input       { cursor: pointer; }
textarea.app-input     { resize: vertical; min-height: 80px; }
.app-textarea          { resize: vertical; }
.app-check-field {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-family: var(--mono);
    color: var(--text);
    cursor: pointer;
}
.app-checkbox { accent-color: var(--accent); width: 14px; height: 14px; }
.app-checkbox-grid {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
.app-checkbox-grid label {
    display: flex;
    gap: 8px;
    align-items: center;
    border: 1px solid var(--border);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--bg);
    font-size: 12px;
    font-family: var(--mono);
    cursor: pointer;
}
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}
.form-feedback { font-size: 12px; font-family: var(--mono); color: var(--text-muted); }

/* errorlist from Django form validation */
.errorlist { list-style: none; margin: 2px 0 0; }
.errorlist li { font-family: var(--mono); font-size: 11px; color: var(--red); }

/* ── Empty states ──────────────────────────────────────────── */
.empty-state {
    padding: 24px 16px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
}
.empty-state h3 { font-size: 13px; font-family: var(--mono); color: var(--text-muted); margin-bottom: 6px; font-weight: 600; }
.empty-state p  { font-size: 12px; font-family: var(--mono); }
.empty-state--inline { padding: 10px 0; }
.empty-state--inline p { font-family: var(--mono); font-size: 12px; }

/* ── Auth page ─────────────────────────────────────────────── */
.auth-card {
    width: min(100%, 360px);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px 28px;
}
.auth-logo {
    width: min(100%, 160px);
    margin: 0 auto 24px;
    display: block;
    filter: brightness(0) invert(1);
    opacity: 0.85;
}
[data-theme='light'] .auth-logo { filter: none; opacity: 1; }
.auth-form {
    display: grid;
    gap: 10px;
    margin-top: 8px;
}
.field-group { display: grid; }
.auth-input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    outline: none;
    font-family: var(--mono);
    font-size: 13px;
    transition: border-color 80ms;
}
.auth-input:focus       { border-color: var(--accent); }
.auth-input::placeholder { color: var(--text-muted); }

/* ── Theme toggle ──────────────────────────────────────────── */
.theme-toggle {
    padding: 5px 10px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-family: var(--mono);
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 80ms, color 80ms;
}
.theme-toggle:hover { background: var(--bg-elevated); color: var(--text); }
.theme-toggle__track {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1.5px solid currentColor;
    flex-shrink: 0;
}
.theme-toggle__label { font-size: 11px; }
.theme-toggle-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
}
.theme-toggle-wrap--auth-bottom {
    justify-content: flex-end;
    margin-top: 14px;
}
.theme-toggle-wrap--page-corner {
    position: fixed;
    right: 20px;
    bottom: 20px;
    width: auto;
    z-index: 30;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .kpi-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .dashboard-grid--two { grid-template-columns: 1fr; }
    .activity-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
    :root { --nav-h: auto; }
    .app-nav { flex-wrap: wrap; padding: 10px 0; gap: 10px; height: auto; }
    .app-nav-links { flex-wrap: wrap; gap: 4px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .panel--hero, .panel--wide { grid-column: span 1; }
    .stats-row, .activity-grid { grid-template-columns: 1fr; }
    .app-form-row--2, .app-form-row--3 { grid-template-columns: 1fr; }
    .kpi-strip { grid-template-columns: 1fr 1fr; }
    .dashboard-header { flex-direction: column; align-items: flex-start; }
    .dashboard-layout { width: min(100vw - 24px, 100%); }
    .app-checkbox-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .kpi-strip { grid-template-columns: 1fr; }
    .dashboard-actions { flex-wrap: wrap; }
    .auth-card { padding: 24px 16px; }
    .flash-stack { width: min(100vw - 24px, 100%); }
}
