:root {
    --ml-teal-dark: #294754;
    --ml-teal-mid: #567483;
    --ml-cyan: #29b8d6;
    --ml-green: #afcb37;
    --ml-red: #de504e;
    --ml-bg: #f2f6f8;
    --ml-surface: rgba(255, 255, 255, 0.96);
    --ml-divider: rgba(41, 71, 84, 0.12);
    --ml-text: #1c1c1e;
    --ml-muted: #6f7d86;
    --ml-shadow: 0 12px 30px rgba(41, 71, 84, 0.1);
}

html,
body {
    min-height: 100%;
    margin: 0;
    font-family: "Montserrat", "Segoe UI", Arial, sans-serif;
    color: var(--ml-text);
    background: linear-gradient(180deg, #f9fcfd 0%, var(--ml-bg) 100%);
    -webkit-font-smoothing: antialiased;
}

.app-main .alert[role="alert"] {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 1600;
    width: min(460px, calc(100vw - 2.5rem));
    animation: alert-fade 7s ease forwards;
}

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

a:hover {
    color: var(--ml-teal-dark);
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    color: var(--ml-teal-dark);
    font-size: 1.55rem;
    font-weight: 800;
    line-height: 1.15;
}

h2 {
    color: var(--ml-teal-dark);
    font-size: 1rem;
    font-weight: 800;
}

.content {
    padding-top: 1rem;
}

.workspace-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.85rem;
}

.kicker {
    margin-bottom: 0.15rem;
    color: var(--ml-teal-mid);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.heading-actions,
.action-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.status-pill,
.role-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 1.85rem;
    padding: 0.25rem 0.65rem;
    border: 1px solid rgba(41, 184, 214, 0.22);
    border-radius: 999px;
    background: rgba(41, 184, 214, 0.1);
    color: var(--ml-teal-dark);
    font-size: 0.8rem;
    font-weight: 800;
}

.tool-panel,
.setup-panel,
.metric-card,
.agency-panel,
.pipeline-panel,
.card {
    border: 1px solid var(--ml-divider);
    border-radius: 8px;
    background: var(--ml-surface);
    box-shadow: var(--ml-shadow);
}

.tool-panel,
.setup-panel,
.agency-panel,
.pipeline-panel {
    padding: 1rem;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.7rem;
}

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

.section-title span,
.scope-note,
.field-note,
.compat-note,
.empty-note {
    color: var(--ml-muted);
    font-size: 0.82rem;
}

.compat-note,
.empty-note,
.scope-note {
    padding: 0.55rem 0.65rem;
    border-radius: 7px;
    background: rgba(41, 71, 84, 0.04);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.6rem 0.75rem;
}

.form-grid .wide {
    grid-column: 1 / -1;
}

.form-label {
    margin-bottom: 0.25rem;
    color: var(--ml-teal-dark);
    font-size: 0.78rem;
    font-weight: 800;
}

.form-control,
.form-select {
    min-height: 2.35rem;
    border: 1px solid rgba(41, 71, 84, 0.16);
    border-radius: 7px;
    padding: 0.45rem 0.65rem;
    background-color: rgba(255, 255, 255, 0.96);
    font-size: 0.9rem;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus,
.btn:focus {
    border-color: rgba(41, 184, 214, 0.62);
    box-shadow: 0 0 0 0.2rem rgba(41, 184, 214, 0.14);
}

.btn {
    min-height: 2.25rem;
    border-radius: 7px;
    padding: 0.42rem 0.75rem;
    font-size: 0.88rem;
    font-weight: 800;
}

.btn-sm {
    min-height: 1.95rem;
    padding: 0.25rem 0.55rem;
    font-size: 0.8rem;
}

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

.btn-primary:hover,
.btn-primary:focus {
    border-color: #24a8c4;
    background: #24a8c4;
    color: #fff;
}

.btn-outline-primary {
    border-color: var(--ml-cyan);
    color: var(--ml-teal-dark);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    border-color: var(--ml-cyan);
    background: rgba(41, 184, 214, 0.1);
    color: var(--ml-teal-dark);
}

.btn-outline-secondary,
.btn-secondary {
    border-color: rgba(41, 71, 84, 0.18);
}

.btn-outline-danger {
    border-color: var(--ml-red);
    color: #b43b39;
}

.btn-outline-danger:hover,
.btn-outline-danger:focus {
    border-color: var(--ml-red);
    background: rgba(222, 80, 78, 0.1);
    color: #9f3331;
}

.alert {
    border-radius: 8px;
    padding: 0.65rem 0.8rem;
    box-shadow: var(--ml-shadow);
}

@keyframes alert-fade {
    0%, 78% {
        opacity: 1;
        transform: translateY(0);
    }

    100% {
        opacity: 0;
        transform: translateY(8px);
        pointer-events: none;
    }
}

.metrics-row,
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.7rem;
}

.metrics-row {
    margin-bottom: 0.75rem;
}

.metric-card,
.metrics-grid > div {
    padding: 0.75rem;
}

.metric-label,
.metrics-grid span {
    display: block;
    color: var(--ml-muted);
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
}

.metric-card strong,
.metrics-grid strong {
    color: var(--ml-teal-dark);
    font-size: 1.25rem;
}

.table {
    --bs-table-bg: transparent;
    margin-bottom: 0;
}

.table thead th {
    color: var(--ml-muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
}

.validation-message {
    color: #b42318;
    font-size: 0.8rem;
}

.invalid {
    outline: 1px solid #e50000;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #26b050;
}

.blazor-error-boundary {
    padding: 1rem;
    border-radius: 8px;
    background: #b32121;
    color: #fff;
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

@media (max-width: 767.98px) {
    .workspace-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .tool-panel,
    .setup-panel,
    .agency-panel,
    .pipeline-panel {
        padding: 0.75rem;
    }
}
