:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --border: #e2e5ea;
    --text: #1d2330;
    --muted: #6b7280;
    --primary: #2f5bea;
    --primary-hover: #2449c4;
    --danger: #d63c3c;
    --ok: #1f9d55;
    --warn: #c27c0e;
    --sidebar: #161b26;
    --sidebar-text: #c9cfdb;
    --radius: 8px;
    --mono: ui-monospace, "Cascadia Code", Consolas, "SF Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .2rem 0; display: flex; align-items: center; gap: .6rem; }
h2 { font-size: 1.05rem; margin: 0 0 1rem; }
h1:focus { outline: none; }
code { font-family: var(--mono); font-size: .9em; background: #eef0f4; padding: 0 .25em; border-radius: 3px; }

/* Layout */
.shell { display: flex; min-height: 100vh; }
.sidebar {
    width: 210px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text);
    display: flex; flex-direction: column; padding: 1rem .75rem;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-top: 1.5rem; flex: 1; }
.sidebar nav a { color: var(--sidebar-text); padding: .5rem .75rem; border-radius: 6px; }
.sidebar nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.sidebar nav a.active { background: rgba(255,255,255,.12); color: #fff; }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; font-weight: 600; font-size: 1.05rem; padding: 0 .5rem; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; background: var(--primary); color: #fff; }
.brand-dark { color: var(--text); justify-content: center; margin-bottom: 1rem; }
.logout { display: flex; align-items: center; justify-content: space-between; padding: 0 .5rem; }
.logout .btn-link { color: var(--sidebar-text); }

.content { flex: 1; padding: 1.5rem 2rem 3rem; min-width: 0; max-width: 1400px; }

.page-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-header p { margin: .15rem 0 0; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.section-title { margin: 1.75rem 0 .75rem; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.form-section { padding: 1.25rem 1.5rem; margin-bottom: 1rem; }
.table-card { overflow-x: auto; }
.empty { text-align: center; padding: 3rem 1rem; }
.stat { padding: 1rem 1.25rem; display: flex; flex-direction: column; gap: .2rem; min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.span-2 { grid-column: span 2; }
@media (max-width: 900px) {
    .shell { flex-direction: column; }
    .sidebar { width: auto; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .content { padding: 1rem; }
}

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: .7rem 1rem; border-bottom: 1px solid var(--border); }
.table td { padding: .75rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfc; }
.row-paused td { background: #fbfaf5; }
.project-name { font-weight: 600; color: var(--text); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.nowrap .btn { margin-left: .25rem; }
.truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Forms */
.field { display: flex; flex-direction: column; gap: .3rem; margin-bottom: 1rem; }
.field > span { font-weight: 500; font-size: .88rem; }
input:not([type=checkbox]), select, textarea {
    font: inherit; padding: .5rem .65rem; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: var(--text); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47,91,234,.25); border-color: var(--primary); }
textarea { resize: vertical; }
.mono, .mono input, input.mono, textarea.mono { font-family: var(--mono); font-size: .86rem; }
.check { display: flex; align-items: center; gap: .5rem; margin: .25rem 0 .75rem; }
.inline { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.form-footer { display: flex; align-items: center; gap: .5rem; margin-top: 1.25rem; }
.spacer { flex: 1; }
.validation-message { color: var(--danger); font-size: .85rem; }
.invalid { border-color: var(--danger) !important; }

/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
    font: inherit; font-weight: 500; padding: .45rem .9rem; border-radius: 6px; cursor: pointer;
    border: 1px solid var(--border); background: #fff; color: var(--text); white-space: nowrap;
}
.btn:hover:not(:disabled) { background: #f2f4f7; text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-sm { padding: .25rem .55rem; font-size: .82rem; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #b92f2f; }
.btn-danger-outline { color: var(--danger); border-color: #f0c4c4; }
.btn-danger-outline:hover:not(:disabled) { background: #fdf1f1; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-link { border: none; background: none; padding: 0; color: var(--primary); cursor: pointer; font: inherit; }

/* Badges */
.badge { display: inline-block; padding: .12rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; white-space: nowrap; }
.badge-muted { background: #eef0f4; color: var(--muted); }
.badge-queued { background: #eef0f4; color: #4b5563; }
.badge-running { background: #e3ebff; color: var(--primary); animation: pulse 1.4s ease-in-out infinite; }
.badge-success { background: #e2f5ea; color: var(--ok); }
.badge-failed { background: #fbe6e6; color: var(--danger); }
.badge-aborted { background: #fdf0dc; color: var(--warn); }
.badge-paused { background: #f3ecd5; color: #8a6d12; }
@keyframes pulse { 50% { opacity: .55; } }

/* Alerts */
.alert { padding: .7rem 1rem; border-radius: 6px; margin-bottom: 1rem; border: 1px solid; cursor: default; }
.alert-ok { background: #ecf8f1; border-color: #bfe6cf; color: #146c3a; }
.alert-error { background: #fdf0f0; border-color: #f1c6c6; color: #a52a2a; }
.alert-warn { background: #fdf6e7; border-color: #f0dcae; color: #8a5a00; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.text-ok { color: var(--ok); }
.text-error { color: var(--danger); }

/* Log */
.log {
    background: #0f131b; color: #d6dbe4; font-family: var(--mono); font-size: .8rem; line-height: 1.5;
    padding: 1rem 1.25rem; border-radius: var(--radius); height: calc(100vh - 260px); min-height: 300px;
    overflow: auto; white-space: pre-wrap; word-break: break-word; margin: 0;
}

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login-card { width: 100%; max-width: 360px; padding: 2rem; }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "Ocorreu um erro."
    }
