:root {
    color-scheme: light;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #18212b;
    background: #f2f4f7;
}

* { box-sizing: border-box; }
body { margin: 0; }
nav {
    min-height: 64px;
    padding: 0 28px;
    display: flex;
    align-items: center;
    gap: 22px;
    background: #111820;
    color: white;
}
nav a { color: white; }
.spacer { flex: 1; }
.saas-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: inherit;
    font-weight: 750;
    white-space: nowrap;
}
.saas-brand img {
    width: 54px;
    height: 54px;
    display: block;
    flex: 0 0 auto;
}
.saas-brand strong { font: inherit; }
main { max-width: 1180px; margin: 0 auto; padding: 32px 24px; }
header, .log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
}
h1, h2 { margin-top: 0; }
.eyebrow {
    margin: 0 0 6px;
    color: #667085;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.muted { color: #667085; }
.card, .login-card {
    background: white;
    border: 1px solid #d9dee6;
    border-radius: 12px;
    box-shadow: 0 5px 18px rgba(16, 24, 40, .05);
}
.card { padding: 20px; margin: 20px 0; }
.workers { display: grid; gap: 16px; }
.worker {
    padding: 20px;
    display: grid;
    grid-template-columns: minmax(180px, .8fr) minmax(320px, 2.2fr) auto;
    gap: 24px;
    align-items: center;
    border: 1px solid #e2e6eb;
    border-radius: 10px;
}
.worker h2 { margin-bottom: 6px; }
.worker p { margin: 0; }
.status-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 7px;
    border-radius: 50%;
    background: #d92d20;
}
.running .status-dot { background: #12b76a; }
.needs-restart {
    border-color: #fdb022;
    background: #fffaf0;
}
.needs-restart .status-dot { background: #f79009; }
.worker-warning {
    margin-top: 8px !important;
    color: #b54708;
    font-size: 13px;
}
dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 5px 12px;
    margin: 0;
    font-size: 13px;
}
dt { color: #667085; }
dd { margin: 0; font-family: Consolas, monospace; }
.worker dd {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
button {
    padding: 9px 13px;
    border: 0;
    border-radius: 6px;
    background: #175cd3;
    color: white;
    cursor: pointer;
    font-weight: 650;
}
button.secondary { background: #344054; }
button.danger { background: #b42318; }
button.ghost { background: #e8eef8; color: #174ea6; }
button:disabled {
    cursor: not-allowed;
    opacity: .55;
}
.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 13px;
    border-radius: 6px;
    background: #e8eef8;
    color: #174ea6;
    font-weight: 650;
    text-decoration: none;
}
.connection { color: #667085; }
.connection.online { color: #067647; }
.connection.pending { color: #b54708; }
.connection.offline { color: #b42318; }
pre {
    min-height: 360px;
    max-height: 540px;
    margin: 16px 0 0;
    padding: 16px;
    overflow: auto;
    border-radius: 8px;
    background: #101820;
    color: #d7e4ec;
    white-space: pre-wrap;
    font: 13px/1.55 Consolas, monospace;
}
.live-toggle { white-space: nowrap; }
.segmented-control {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
}
.segmented-control button {
    border-radius: 0;
    background: transparent;
    color: #344054;
}
.segmented-control button.active {
    background: #175cd3;
    color: white;
}
.log-header {
    flex-wrap: wrap;
}
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.login-card { width: min(420px, 100%); padding: 34px; }
.login-card .saas-brand {
    margin-bottom: 16px;
    color: #111820;
}
.login-card .saas-brand strong {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}
.login-card label { display: grid; gap: 7px; margin: 18px 0; }
.login-card input {
    width: 100%;
    padding: 11px;
    border: 1px solid #cbd1d9;
    border-radius: 6px;
    font: inherit;
}
.totp-qr {
    display: grid;
    place-items: center;
    margin: 18px 0;
    padding: 14px;
    border: 1px solid #d9dee6;
    border-radius: 8px;
    background: #fff;
}
.totp-qr img {
    width: min(236px, 100%);
    height: auto;
    image-rendering: pixelated;
}
.totp-manual { margin: 12px 0; }
.totp-manual summary {
    cursor: pointer;
    color: #175cd3;
    font-weight: 650;
}
.alert {
    padding: 10px 12px;
    border-radius: 6px;
    background: #fee4e2;
    color: #b42318;
}
.notice {
    padding: 10px 12px;
    border-radius: 6px;
    background: #d1fadf;
    color: #05603a;
}
.user-form {
    display: grid;
    grid-template-columns: 1fr 1fr 1.4fr auto;
    gap: 12px;
    align-items: end;
}
.user-form label { display: grid; gap: 6px; }
.user-form input,
.user-row input,
.company-form input,
.company-form textarea,
.company-form select {
    min-width: 0;
    max-width: 100%;
    padding: 9px;
    border: 1px solid #cbd1d9;
    border-radius: 6px;
    font: inherit;
}
.user-list { display: grid; gap: 10px; }
.user-row {
    display: grid;
    grid-template-columns: 1fr 1.4fr auto auto;
    gap: 16px;
    align-items: center;
    padding: 14px;
    border: 1px solid #e2e6eb;
    border-radius: 8px;
    font-size: 13px;
}
.user-row > div:first-child { display: grid; gap: 4px; }
.user-row span { color: #667085; }
.company-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    align-items: end;
}
.company-form label { display: grid; gap: 6px; }
.company-form label.full,
.company-form .company-actions,
.company-form .form-section-title { grid-column: 1 / -1; }
.form-section-title {
    margin: 8px 0 0;
    padding-top: 12px;
    border-top: 1px solid #e2e6eb;
    color: #344054;
    font-size: 14px;
}
.form-section-title:first-of-type {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}
.company-form textarea { resize: vertical; }
.inline-check {
    display: flex !important;
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 8px;
}
.company-list { display: grid; gap: 12px; }
.company-editor {
    border: 1px solid #e2e6eb;
    border-radius: 8px;
    background: #fff;
}
.company-editor summary {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(120px, .7fr) 90px minmax(220px, 1fr);
    gap: 14px;
    align-items: center;
    padding: 14px;
    cursor: pointer;
}
.company-editor code {
    color: #175cd3;
    font-family: Consolas, monospace;
}
.company-stats,
.company-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 14px;
}
.company-stats {
    padding: 0 14px 14px;
    color: #667085;
    font-size: 13px;
}
.company-editor .company-form,
.inline-danger-form,
.agent-certificate-panel,
.agent-summary,
.deployment-summary {
    margin: 0;
    padding: 14px;
    border-top: 1px solid #e2e6eb;
}
.inline-danger-form { background: #fff8f8; }
.inline-action-form {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid #e2e6eb;
}
.deploy-log-panel {
    margin: 0;
    padding: 14px;
    border-top: 1px solid #e2e6eb;
    background: #f8fafc;
}
.deploy-log-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
}
.deploy-log-header span {
    color: #475467;
    font-size: 13px;
}
.deploy-log-panel pre {
    min-height: 240px;
    max-height: 420px;
}
.mode-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
    margin: 0 0 12px;
    padding: 10px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 8px;
    background: #f8fafc;
}
.mode-banner span {
    color: #667085;
    font-size: 13px;
    font-weight: 700;
}
.mode-banner strong {
    padding: 3px 8px;
    border-radius: 999px;
    background: #d1fadf;
    color: #05603a;
    font-size: 13px;
}
.mode-banner small {
    color: #475467;
}
.deployment-summary {
    grid-template-columns: minmax(160px, auto) 1fr;
    font-size: 13px;
}
.agent-summary {
    grid-template-columns: minmax(150px, auto) 1fr;
    background: #f8fafc;
    font-size: 13px;
}
.agent-summary dd {
    white-space: normal;
    overflow-wrap: anywhere;
}
.agent-certificate-panel h3 {
    margin: 0 0 12px;
}
.compact-table {
    width: 100%;
    margin-bottom: 14px;
    border-collapse: collapse;
    font-size: 13px;
}
.compact-table th,
.compact-table td {
    padding: 7px 8px;
    border-bottom: 1px solid #edf0f3;
    text-align: left;
    vertical-align: top;
}
.compact-table td {
    overflow-wrap: anywhere;
}
.table-action-form {
    margin: 0;
}
.table-action-form button {
    padding: 6px 9px;
}
.agent-certificate-list {
    display: grid;
    gap: 14px;
}
.agent-card {
    padding: 14px;
    border: 1px solid #e4e7ec;
    border-radius: 8px;
    background: #fff;
}
.agent-card h3,
.agent-card h4,
.agent-card p {
    margin: 0;
}
.agent-card h4 {
    margin-top: 14px;
    margin-bottom: 8px;
}
.agent-card-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    margin-bottom: 12px;
}
.agent-card-header p,
.chip-list {
    color: #475467;
}
.chip-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.deployment-summary dd {
    white-space: normal;
    overflow-wrap: anywhere;
}
.inline-status {
    display: inline-flex;
    margin-left: 8px;
    padding: 2px 7px;
    border-radius: 999px;
    background: #eef2f6;
    color: #475467;
    font: 12px/1.4 system-ui, sans-serif;
}
.inline-status.online {
    background: #d1fadf;
    color: #05603a;
}
.inline-status.warning {
    background: #fef0c7;
    color: #93370d;
}
.inline-status.danger {
    background: #fee4e2;
    color: #b42318;
}
@media (max-width: 850px) {
    .worker { grid-template-columns: 1fr; }
    .actions { justify-content: flex-start; }
    nav span:not(.spacer) { display: none; }
    .user-form, .user-row { grid-template-columns: 1fr; }
    .company-editor summary { grid-template-columns: 1fr; }
}
