:root {
    --app-bg: #f6f8fb;
    --app-surface: #ffffff;
    --app-border: #dbe3ea;
    --app-text: #18212f;
    --app-muted: #647084;
    --app-sidebar: #1f2a37;
    --app-sidebar-muted: #9aa8ba;
    --app-primary: #0f766e;
    --app-primary-dark: #115e59;
    --app-blue: #2563eb;
    --app-amber: #b45309;
    --app-green: #15803d;
    --app-red: #b91c1c;
}

* {
    letter-spacing: 0;
}

[x-cloak] {
    display: none !important;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--app-bg);
    color: var(--app-text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
    color: inherit;
}

.app-shell {
    min-height: 100vh;
    display: flex;
}

.auth-shell {
    display: grid;
    place-items: center;
}

.app-sidebar {
    width: 280px;
    min-height: 100vh;
    padding: 24px 18px;
    background: var(--app-sidebar);
    color: #ffffff;
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-100%);
    transition: transform 160ms ease;
    z-index: 1040;
}

.app-sidebar.is-open {
    transform: translateX(0);
}

.app-backdrop {
    position: fixed;
    inset: 0;
    background: rgb(15 23 42 / 45%);
    z-index: 1030;
}

.app-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--app-primary);
    color: #ffffff;
    font-weight: 800;
    text-decoration: none;
}

.brand-name {
    color: #ffffff;
    text-decoration: none;
    font-weight: 750;
}

.brand-caption,
.sidebar-foot,
.topbar-kicker,
.metric-note,
.metric-label,
.panel-heading p,
.learning-row span {
    color: var(--app-muted);
}

.brand-caption,
.sidebar-foot {
    color: var(--app-sidebar-muted);
    font-size: 0.85rem;
}

.app-nav {
    display: grid;
    gap: 4px;
}

.app-nav-link {
    min-height: 42px;
    display: flex;
    align-items: center;
    padding: 9px 12px;
    border-radius: 8px;
    color: #dbe5f0;
    text-decoration: none;
    font-weight: 650;
}

.app-nav-link:hover,
.app-nav-link.active {
    background: rgb(255 255 255 / 10%);
    color: #ffffff;
}

.sidebar-foot {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

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

.app-topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--app-border);
    background: rgb(255 255 255 / 92%);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.topbar-kicker {
    font-size: 0.75rem;
    font-weight: 750;
    text-transform: uppercase;
}

.topbar-title {
    font-size: 1.05rem;
    font-weight: 750;
}

.topbar-actions {
    display: none;
    gap: 8px;
}

.app-content {
    width: min(100%, 1480px);
    margin: 0 auto;
    padding: 28px 18px 44px;
}

.auth-shell .app-main,
.auth-shell .app-content {
    width: 100%;
}

.auth-page {
    min-height: calc(100vh - 72px);
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(100%, 430px);
    padding: 24px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface);
    box-shadow: 0 16px 36px rgb(31 42 55 / 10%);
}

.auth-heading {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.auth-heading h1 {
    margin: 0;
    font-size: 1.55rem;
    font-weight: 800;
}

.auth-mark {
    flex: 0 0 auto;
}

.auth-form {
    display: grid;
    gap: 16px;
}

.auth-help,
.auth-secondary-action {
    color: var(--app-muted);
    font-size: 0.92rem;
}

.auth-help {
    margin: -6px 0 0;
}

.auth-secondary-action {
    margin-top: 18px;
    text-align: center;
}

.auth-secondary-action a {
    color: var(--app-primary-dark);
    font-weight: 650;
    text-decoration: none;
}

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

.page-heading {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--app-primary-dark);
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.page-heading h1 {
    margin: 0;
    font-size: clamp(1.7rem, 3vw, 2.4rem);
    font-weight: 800;
}

.page-summary {
    max-width: 760px;
    margin: 8px 0 0;
    color: var(--app-muted);
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.metric-card,
.dashboard-panel {
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: var(--app-surface);
    box-shadow: 0 10px 24px rgb(31 42 55 / 6%);
}

.metric-card {
    min-height: 136px;
    padding: 18px;
    display: grid;
    align-content: space-between;
    gap: 8px;
}

.metric-card strong {
    font-size: 2rem;
    line-height: 1;
}

.metric-label {
    font-size: 0.8rem;
    font-weight: 800;
    text-transform: uppercase;
}

.metric-note {
    font-size: 0.9rem;
}

.dashboard-panel {
    padding: 18px;
}

.panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.panel-heading h2 {
    margin: 0;
    font-size: 1.05rem;
    font-weight: 800;
}

.panel-heading p {
    margin: 4px 0 0;
    font-size: 0.92rem;
}

.pipeline-board {
    display: grid;
    grid-template-columns: repeat(4, minmax(180px, 1fr));
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.pipeline-column {
    min-height: 230px;
    padding: 12px;
    border: 1px solid #e5ebf2;
    border-radius: 8px;
    background: #f9fbfd;
}

.pipeline-title {
    margin-bottom: 10px;
    font-size: 0.82rem;
    font-weight: 800;
    color: #42526a;
    text-transform: uppercase;
}

.pipeline-item {
    min-height: 54px;
    display: flex;
    align-items: center;
    padding: 10px;
    margin-bottom: 8px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #ffffff;
    font-weight: 650;
}

.toggle-list,
.learning-list,
.build-list,
.status-stack {
    display: grid;
    gap: 12px;
}

.learning-row,
.build-row,
.status-row,
.status-details div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--app-border);
    border-radius: 8px;
    background: #fbfcfe;
}

.learning-row {
    align-items: flex-start;
    flex-direction: column;
}

.build-list {
    margin-top: 14px;
}

.status-dot {
    width: 9px;
    height: 9px;
    display: inline-block;
    margin-right: 7px;
    border-radius: 50%;
    background: var(--app-muted);
}

.status-dot-success {
    background: var(--app-green);
}

.status-dot-danger {
    background: var(--app-red);
}

.status-details {
    display: grid;
    gap: 10px;
    margin: 0;
}

.status-details dt {
    color: var(--app-muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.status-details dd {
    margin: 0;
    font-weight: 700;
}

.htmx-request {
    opacity: 0.68;
}

.btn-primary {
    --bs-btn-bg: var(--app-primary);
    --bs-btn-border-color: var(--app-primary);
    --bs-btn-hover-bg: var(--app-primary-dark);
    --bs-btn-hover-border-color: var(--app-primary-dark);
}

@media (min-width: 640px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .topbar-actions {
        display: flex;
    }
}

@media (min-width: 992px) {
    .app-sidebar {
        position: sticky;
        transform: none;
    }

    .app-main {
        width: calc(100% - 280px);
    }

    .app-content {
        padding: 34px 32px 56px;
    }
}

@media (min-width: 1200px) {
    .metric-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
