:root {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #ffffff;
    --surface-muted: #f9fafb;
    --text: #111827;
    --muted: #6b7280;
    --subtle: #9ca3af;
    --line: #e5e7eb;
    --line-strong: #d1d5db;
    --brand: #111827;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-soft: #eff6ff;
    --error: #b91c1c;
    --error-soft: #fef2f2;
    --success: #047857;
    --success-soft: #ecfdf5;
    --warning: #b45309;
    --warning-soft: #fffbeb;
    --sidebar-width: 272px;
}

* {
    box-sizing: border-box;
}

body.app-body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.45;
}

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

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

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

h1 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: 0;
    line-height: 1.2;
    margin-bottom: 8px;
}

h2 {
    font-size: 16px;
    font-weight: 650;
    letter-spacing: 0;
    margin-bottom: 12px;
}

h3 {
    font-size: 14px;
    font-weight: 650;
    letter-spacing: 0;
    margin-bottom: 8px;
}

.admin-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    background: var(--surface-muted);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 20px 16px;
    position: sticky;
    top: 0;
}

.brand {
    align-items: center;
    color: var(--brand);
    display: inline-flex;
    font-weight: 700;
    gap: 10px;
}

.brand:hover {
    color: var(--brand);
}

.brand-mark {
    align-items: center;
    background: #111827;
    border-radius: 8px;
    color: white;
    display: inline-flex;
    height: 32px;
    justify-content: center;
    width: 32px;
}

.brand-mark svg {
    height: 20px;
    width: 20px;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
    margin-top: 28px;
}

.sidebar-footer {
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.workspace-switcher {
    border-top: 1px solid var(--line);
    margin-top: auto;
    padding-top: 14px;
}

.workspace-switcher label,
.mobile-workspace-switcher label {
    gap: 6px;
}

.workspace-switcher span,
.mobile-workspace-switcher span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.workspace-switcher select,
.mobile-workspace-switcher select {
    min-height: 34px;
}

.nav-link {
    align-items: center;
    border-radius: 8px;
    color: #374151;
    display: flex;
    font-size: 14px;
    font-weight: 600;
    gap: 10px;
    min-height: 36px;
    padding: 8px 10px;
}

.nav-link:hover {
    background: #f3f4f6;
    color: var(--text);
}

.nav-link.active {
    background: #eef2ff;
    color: #1e40af;
}

.nav-button {
    background: transparent;
    border: 0;
    cursor: pointer;
    font: inherit;
    width: 100%;
}

.icon {
    flex: 0 0 auto;
    height: 18px;
    width: 18px;
}

.content-shell {
    min-width: 0;
}

.gateway-bar {
    align-items: center;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid var(--line);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    display: flex;
    gap: 16px;
    min-height: 56px;
    padding: 10px 24px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.gateway-brand {
    color: var(--text);
    flex: 0 0 auto;
    font-size: 14px;
    font-weight: 800;
}

.gateway-brand:hover {
    color: var(--text);
}

.gateway-nav {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 0;
}

.gateway-link {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 6px;
    color: #374151;
    display: inline-flex;
    font-size: 12px;
    font-weight: 750;
    min-height: 30px;
    padding: 5px 9px;
}

.gateway-link:hover {
    background: var(--surface-muted);
    border-color: var(--line);
    color: var(--text);
}

.gateway-link.active {
    background: var(--text);
    border-color: var(--text);
    color: white;
}

.gateway-context {
    align-items: center;
    color: var(--muted);
    display: flex;
    flex: 0 0 auto;
    gap: 10px;
    margin-left: auto;
    white-space: nowrap;
}

.gateway-context span {
    font-size: 12px;
    font-weight: 650;
}

.gateway-profile {
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    color: #374151;
    font-size: 12px;
    font-weight: 750;
    padding: 5px 10px;
}

.gateway-profile:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.gateway-context form {
    margin: 0;
}

.gateway-context-form label {
    align-items: center;
    display: flex;
    gap: 6px;
}

.gateway-context-form label > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.gateway-context-form select {
    appearance: none;
    background: white;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: #374151;
    font: inherit;
    font-size: 12px;
    font-weight: 750;
    min-height: 30px;
    max-width: 190px;
    min-width: 132px;
    overflow: hidden;
    padding: 5px 28px 5px 9px;
    text-overflow: ellipsis;
}

.gateway-context-form select[name="workspaceSlug"] {
    width: 150px;
}

.gateway-context-form select[name="projectSlug"] {
    width: 190px;
}

.gateway-context button {
    background: white;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: #374151;
    cursor: pointer;
    font: inherit;
    font-size: 12px;
    font-weight: 750;
    min-height: 30px;
    padding: 5px 9px;
}

.gateway-context button:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.mobile-header {
    align-items: center;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    display: none;
    justify-content: space-between;
    min-height: 58px;
    padding: 0 16px;
}

.mobile-nav {
    border-bottom: 1px solid var(--line);
    display: none;
    gap: 8px;
    overflow-x: auto;
    padding: 8px 12px;
}

.mobile-workspace-switcher {
    background: white;
    border-bottom: 1px solid var(--line);
    display: none;
    padding: 10px 12px;
}

.page {
    margin: 0 auto;
    max-width: 1920px;
    padding: 36px 0 48px;
    width: 95%;
}

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

.page-header {
    align-items: flex-start;
    display: flex;
    gap: 20px;
    justify-content: space-between;
    margin-bottom: 24px;
}

.header-actions {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.page-subtitle {
    color: var(--muted);
    margin-bottom: 0;
}

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0;
    margin-bottom: 6px;
}

.muted {
    color: var(--muted);
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
}

.section-title-row {
    align-items: flex-start;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 16px;
}

.metric-pill {
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--muted);
    display: inline-flex;
    font-size: 12px;
    font-weight: 750;
    padding: 5px 9px;
}

.manager-metrics {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 18px;
}

.metric-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 6px;
    min-height: 116px;
    padding: 16px;
}

.metric-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.metric-card strong {
    font-size: 28px;
    line-height: 1;
}

.metric-card small {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.manager-actions {
    margin-bottom: 18px;
}

.action-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.action-grid form {
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: grid;
    gap: 10px;
    padding: 14px;
}

.action-grid p {
    margin-bottom: 0;
}

.manager-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: minmax(0, 1fr) minmax(280px, .65fr);
}

.table-subtext {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-top: 2px;
    max-width: 260px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-list {
    display: grid;
    min-width: 0;
    overflow: hidden;
}

.compact-list-row {
    align-items: flex-start;
    display: flex;
    gap: 14px;
    justify-content: space-between;
    min-width: 0;
    padding: 12px 0;
}

.compact-list-row + .compact-list-row {
    border-top: 1px solid var(--line);
}

.compact-list-row > div {
    min-width: 0;
}

.compact-list-row p {
    color: var(--muted);
    margin-bottom: 0;
    max-width: 560px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.quick-link-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.quick-link {
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    display: grid;
    gap: 6px;
    min-height: 92px;
    padding: 14px;
}

.quick-link:hover {
    border-color: var(--line-strong);
    color: var(--text);
}

.quick-link span {
    color: var(--muted);
    font-size: 12px;
}

.workspace-context-panel {
    align-items: center;
    display: flex;
    gap: 24px;
    justify-content: space-between;
    margin-bottom: 24px;
}

.workspace-context-panel h2 {
    margin-bottom: 2px;
}

.context-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(160px, 1fr));
    min-width: min(100%, 420px);
}

.context-grid div {
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.context-grid span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 650;
    margin-bottom: 4px;
}

.context-grid strong {
    display: block;
    overflow-wrap: anywhere;
}

.launcher-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.launcher-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--text);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 190px;
    padding: 18px;
}

.launcher-card:hover {
    border-color: var(--line-strong);
    box-shadow: 0 10px 24px rgba(17, 24, 39, .08);
    color: var(--text);
}

.launcher-card h2 {
    margin: 16px 0 8px;
}

.launcher-card p {
    color: var(--muted);
}

.launcher-arrow {
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    margin-top: 18px;
}

.surface-list {
    border-bottom: 1px solid var(--line);
    border-top: 1px solid var(--line);
}

.login-shell {
    background: linear-gradient(180deg, #f9fafb 0%, #ffffff 45%);
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px;
}

.login-panel {
    max-width: 400px;
    width: 100%;
}

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

.form-stack, .form-grid {
    display: grid;
    gap: 14px;
}

.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.inline-form {
    align-items: center;
    display: flex;
    gap: 8px;
    margin: 0 0 8px;
}

.inline-form:last-child {
    margin-bottom: 0;
}

.inline-form .input {
    min-width: 150px;
    width: auto;
}

.settings-form {
    display: grid;
    gap: 0;
}

.form-section {
    border-top: 1px solid var(--line);
    display: grid;
    gap: 22px;
    grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
    padding: 22px 0;
}

.form-section:first-child {
    border-top: 0;
    padding-top: 0;
}

.form-section h2 {
    margin-bottom: 4px;
}

.field-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

label {
    display: grid;
    gap: 6px;
}

label span, .field-label {
    color: #374151;
    font-size: 13px;
    font-weight: 650;
}

input, textarea, select {
    background: white;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
    min-height: 34px;
    padding: 7px 10px;
    width: 100%;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
    outline: 0;
}

.input-small {
    min-height: 30px;
    padding: 5px 8px;
}

textarea {
    resize: vertical;
}

.wide, .span-full, .form-actions {
    grid-column: 1 / -1;
}

.stack-gap {
    margin-top: 18px;
}

.notice {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 18px;
    padding: 12px 14px;
}

.notice-error {
    background: var(--error-soft);
    border-color: #fecaca;
    color: var(--error);
}

.checkbox-row {
    align-content: center;
    align-items: center;
    display: flex;
    gap: 10px;
    min-height: 34px;
}

.checkbox-row input {
    min-height: 0;
    width: auto;
}

.button {
    align-items: center;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    font-size: 13px;
    font-weight: 650;
    gap: 8px;
    justify-content: center;
    min-height: 34px;
    padding: 7px 11px;
}

.button-small {
    font-size: 12px;
    min-height: 30px;
    padding: 5px 9px;
}

.button-primary {
    background: var(--text);
    color: white;
}

.button-primary:hover {
    background: #374151;
    color: white;
}

.button-ghost {
    background: white;
    border-color: var(--line-strong);
    color: #374151;
}

.button-ghost:hover {
    background: var(--surface-muted);
    color: var(--text);
}

.button-danger {
    background: var(--error);
    color: white;
}

.button-danger:hover {
    background: #7f1d1d;
    color: white;
}

.alert {
    border-radius: 6px;
    font-weight: 600;
    margin-bottom: 16px;
    padding: 10px 12px;
}

.alert-error {
    background: var(--error-soft);
    color: var(--error);
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
}

.table-wrap {
    overflow-x: auto;
}

.detail-grid {
    display: grid;
    gap: 14px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.detail-grid > div {
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 4px;
    padding: 0 0 12px;
}

.detail-grid span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.detail-grid strong {
    min-width: 0;
    overflow-wrap: anywhere;
}

.data-table {
    border-collapse: collapse;
    width: 100%;
}

.data-table th, .data-table td {
    border-bottom: 1px solid var(--line);
    padding: 10px 12px;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.data-table th {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.muted-cell {
    color: var(--muted);
    max-width: 360px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-pill {
    background: #eef2ff;
    border-radius: 999px;
    color: #3730a3;
    display: inline-flex;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    padding: 5px 8px;
}

.status-pill.success {
    background: var(--success-soft);
    color: var(--success);
}

.status-pill.warning {
    background: var(--warning-soft);
    color: var(--warning);
}

.grant-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-width: 520px;
}

.metrics {
    border-bottom: 1px solid var(--line);
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 24px;
}

.metric {
    border-left: 1px solid var(--line);
    padding: 16px;
}

.metric:first-child {
    border-left: 0;
    padding-left: 0;
}

.metric span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 600;
}

.metric strong {
    display: block;
    font-size: 22px;
    font-weight: 700;
    margin-top: 4px;
}

.finding-list {
    display: grid;
    gap: 10px;
}

.finding-group {
    display: grid;
    gap: 4px;
}

.action-row {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.section-heading {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 14px;
}

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

.split-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 20px;
}

.list-stack {
    border-bottom: 1px solid var(--line);
    border-top: 1px solid var(--line);
    display: grid;
}

.list-item {
    align-items: center;
    border-bottom: 1px solid var(--line);
    color: var(--text);
    display: flex;
    gap: 16px;
    justify-content: space-between;
    padding: 12px 0;
}

.list-item:last-child {
    border-bottom: 0;
}

.danger-zone {
    margin-top: 20px;
}

.delete-form {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 18px;
}

.code-textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 13px;
}

.standards-editor {
    min-height: 560px;
}

.finding {
    border-bottom: 1px solid var(--line);
    padding: 14px 0;
}

.finding:last-child {
    border-bottom: 0;
}

.finding-heading {
    align-items: center;
    display: flex;
    gap: 12px;
    justify-content: space-between;
}

.target-text {
    color: var(--text);
    display: inline-block;
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.empty-state {
    color: var(--muted);
    padding: 24px 0;
}

.metadata-list {
    display: grid;
    gap: 10px;
    margin: 0;
}

.metadata-list.compact {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 16px;
}

.metadata-list div {
    display: grid;
    gap: 12px;
    grid-template-columns: 130px minmax(0, 1fr);
}

.metadata-list dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.metadata-list dd {
    margin: 0;
    min-width: 0;
}

.path-text {
    overflow-wrap: anywhere;
}

.severity-grid {
    display: grid;
    gap: 10px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.severity-grid div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
}

.severity-grid span {
    color: var(--muted);
    display: block;
    font-size: 12px;
    font-weight: 650;
}

.severity-grid strong {
    display: block;
    font-size: 22px;
    margin-top: 4px;
}

.code-block {
    background: #111827;
    border-radius: 8px;
    color: #f9fafb;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.55;
    margin: 0;
    max-height: 520px;
    overflow: auto;
    padding: 14px;
    white-space: pre-wrap;
}

.inline-code {
    background: var(--surface-muted);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    line-height: 1.45;
    margin: 0;
    max-width: 420px;
    overflow: auto;
    padding: 8px;
    white-space: pre-wrap;
}

.standard-meta,
.standard-excerpt {
    display: block;
    margin-top: 2px;
}

.standard-excerpt {
    color: var(--muted);
    max-width: 620px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.editor-grid {
    align-items: start;
    grid-template-columns: minmax(0, 1.5fr) minmax(280px, .85fr);
}

@media (max-width: 920px) {
    .admin-shell {
        display: block;
    }

    .sidebar {
        display: none;
    }

    .gateway-bar {
        align-items: flex-start;
        flex-direction: column;
        gap: 8px;
        padding: 10px 12px;
        position: static;
    }

    .gateway-context {
        flex-wrap: wrap;
        margin-left: 0;
        white-space: normal;
    }

    .mobile-header,
    .mobile-nav {
        display: flex;
    }

    .page {
        padding: 28px 18px 40px;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .form-section {
        grid-template-columns: 1fr;
    }

    .workspace-context-panel {
        align-items: stretch;
        flex-direction: column;
    }

    .manager-metrics,
    .action-grid,
    .manager-grid,
    .quick-link-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .form-grid,
    .field-grid,
    .metrics,
    .context-grid,
    .split-grid,
    .severity-grid {
        grid-template-columns: 1fr;
    }

    .metadata-list div {
        grid-template-columns: 1fr;
        gap: 2px;
    }

    .metric,
    .metric:first-child {
        border-left: 0;
        border-top: 1px solid var(--line);
        padding: 14px 0;
    }

    .metric:first-child {
        border-top: 0;
    }
}
