:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --panel-soft: #f8fafc;
    --line: #e5eaf2;
    --text: #172033;
    --muted: #667085;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #eff6ff;
    --green: #16a34a;
    --green-soft: #ecfdf3;
    --amber: #d97706;
    --amber-soft: #fffbeb;
    --red: #dc2626;
    --red-soft: #fef2f2;
    --shadow: 0 18px 50px rgba(18, 32, 60, 0.08);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

code {
    padding: 2px 6px;
    border-radius: 6px;
    background: #eef2f7;
    color: #344054;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 32px;
    background:
        linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(22, 163, 74, 0.05)),
        var(--bg);
}

.login-shell {
    width: min(1080px, 100%);
    display: grid;
    grid-template-columns: minmax(340px, 420px) 1fr;
    gap: 20px;
}

.login-panel,
.login-visual,
.panel,
.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-panel {
    padding: 34px;
}

.login-brand,
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    font-weight: 800;
}

.login-brand h1,
.topbar h1,
.panel h2 {
    margin: 0;
}

.login-brand h1 {
    font-size: 28px;
}

.login-brand p,
.panel-header p,
.login-meta,
.eyebrow,
.metric-label,
.muted-cell {
    color: var(--muted);
}

.stack-form {
    display: grid;
    gap: 16px;
    margin-top: 28px;
}

.stack-form.tight {
    margin-top: 0;
    gap: 12px;
}

.stack-form label,
.inline-form label {
    display: grid;
    gap: 7px;
    color: #344054;
    font-weight: 650;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid #d7deea;
    border-radius: 8px;
    background: white;
    color: var(--text);
    padding: 10px 12px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
    resize: vertical;
}

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

.btn {
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 750;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--primary-soft);
    color: var(--primary-dark);
    border-color: #bfdbfe;
}

.btn-secondary:hover {
    border-color: var(--primary);
}

.btn-ghost {
    background: transparent;
    border-color: var(--line);
    color: #475467;
}

.btn-danger {
    background: var(--red-soft);
    border-color: #fecaca;
    color: var(--red);
}

.btn-wide {
    width: 100%;
}

.login-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.login-meta span,
.status-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 26px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 750;
}

.login-meta span {
    background: var(--panel-soft);
    border: 1px solid var(--line);
}

.login-visual {
    padding: 24px;
    display: grid;
    align-items: stretch;
}

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

.visual-grid article {
    min-height: 160px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 20px;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
}

.visual-grid article:first-child {
    grid-row: span 2;
}

.visual-grid strong {
    display: block;
    margin-top: 18px;
    font-size: 34px;
    color: var(--primary);
}

.visual-grid p {
    color: #475467;
    line-height: 1.7;
}

.alert {
    margin-top: 20px;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    line-height: 1.6;
}

.alert-danger {
    background: var(--red-soft);
    border-color: #fecaca;
    color: #991b1b;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 22px;
    background: #ffffff;
    border-right: 1px solid var(--line);
}

.sidebar-brand strong {
    font-size: 18px;
}

.nav-list {
    display: grid;
    gap: 8px;
}

.nav-list a {
    padding: 11px 12px;
    border-radius: 8px;
    color: #475467;
    font-weight: 700;
}

.nav-list a:hover,
.nav-list a.active {
    color: var(--primary-dark);
    background: var(--primary-soft);
}

.sidebar .btn {
    margin-top: auto;
}

.main-content {
    min-width: 0;
    padding: 26px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.eyebrow {
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 800;
}

.topbar h1 {
    font-size: 26px;
}

.topbar-actions,
.filter-bar,
.inline-form {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.date-input {
    width: 156px;
}

.stat-grid {
    display: grid;
    gap: 14px;
    margin-bottom: 18px;
}

.stat-grid.five {
    grid-template-columns: repeat(5, minmax(150px, 1fr));
}

.stat-grid.four {
    grid-template-columns: repeat(4, minmax(160px, 1fr));
}

.stat-grid.three {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
}

.stat-card {
    min-height: 112px;
    padding: 18px;
}

.stat-card span {
    color: var(--muted);
    font-weight: 700;
}

.stat-card strong {
    display: block;
    margin-top: 14px;
    font-size: 34px;
}

.stat-card.success strong {
    color: var(--green);
}

.stat-card.danger strong {
    color: var(--red);
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(340px, 0.8fr);
    gap: 18px;
    margin-bottom: 18px;
}

.detail-grid {
    grid-template-columns: minmax(0, 1fr) minmax(340px, 0.8fr);
}

.repository-grid {
    grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
}

.panel {
    padding: 18px;
    min-width: 0;
}

.panel.wide {
    min-height: 420px;
}

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

.panel-header.compact {
    align-items: center;
}

.panel-header h2 {
    font-size: 17px;
}

.panel-header p {
    margin: 6px 0 0;
    line-height: 1.6;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

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

.data-table th {
    background: #f8fafc;
    color: #475467;
    font-size: 12px;
    text-transform: uppercase;
}

.data-table tbody tr:hover {
    background: #fbfdff;
}

.person-cell {
    display: grid;
    gap: 4px;
}

.person-cell strong {
    font-size: 14px;
}

.person-cell span,
.subtle {
    color: var(--muted);
    font-size: 12px;
}

.score-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 54px;
    min-height: 32px;
    padding: 5px 10px;
    border-radius: 999px;
    background: #eef2ff;
    color: #3730a3;
    font-weight: 850;
}

.status-tag.green,
.status-tag.approved,
.status-tag.valid {
    color: #166534;
    background: var(--green-soft);
}

.status-tag.yellow,
.status-tag.pending {
    color: #92400e;
    background: var(--amber-soft);
}

.status-tag.red,
.status-tag.invalid,
.status-tag.rejected,
.status-tag.danger {
    color: #991b1b;
    background: var(--red-soft);
}

.status-tag.neutral {
    color: #475467;
    background: #f2f4f7;
}

.status-tag.ssh {
    color: #1d4ed8;
    background: #eff6ff;
}

.status-tag.token {
    color: #166534;
    background: var(--green-soft);
}

.status-tag.none {
    color: #475467;
    background: #f2f4f7;
}

.summary-box,
.rich-box {
    min-height: 240px;
    margin: 0;
    padding: 14px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #fbfdff;
    white-space: pre-wrap;
    line-height: 1.75;
    overflow: auto;
}

.rich-box {
    min-height: 180px;
}

.inline-form {
    align-items: stretch;
}

.inline-form input[type="text"] {
    min-width: 220px;
    flex: 1;
}

.check-row {
    display: flex !important;
    grid-template-columns: none !important;
    flex-direction: row;
    align-items: center;
    gap: 8px !important;
    font-weight: 700;
}

.check-row input {
    width: 16px;
    height: 16px;
}

.repo-list,
.record-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.repo-item,
.record-item {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel-soft);
    padding: 12px;
    display: grid;
    gap: 6px;
}

.repo-item strong,
.record-item strong {
    color: #24324a;
}

.record-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 12px;
}

.form-grid-2,
.form-grid-3 {
    display: grid;
    gap: 10px;
}

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

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

.form-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.repository-table {
    min-width: 940px;
}

.compact-table {
    min-width: 620px;
}

.kanban-board {
    display: grid;
    grid-template-columns: repeat(3, minmax(250px, 1fr));
    gap: 14px;
    align-items: start;
}

.compact-kanban {
    grid-template-columns: repeat(3, minmax(220px, 1fr));
}

.kanban-column {
    min-height: 360px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
    overflow: hidden;
}

.kanban-column header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
    background: #ffffff;
}

.kanban-column header strong {
    font-size: 14px;
}

.kanban-column header span {
    display: inline-grid;
    place-items: center;
    min-width: 26px;
    height: 26px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 800;
}

.kanban-dropzone {
    min-height: 310px;
    display: grid;
    align-content: start;
    gap: 10px;
    padding: 12px;
}

.task-card {
    border: 1px solid #dce5f2;
    border-radius: 8px;
    background: #ffffff;
    padding: 12px;
    box-shadow: 0 10px 24px rgba(18, 32, 60, 0.06);
}

.task-card:active {
    cursor: grabbing;
}

.task-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.task-card strong {
    line-height: 1.45;
}

.task-card p {
    margin: 8px 0;
    color: #475467;
    line-height: 1.6;
}

.task-link {
    display: inline-flex;
    margin-top: 10px;
    color: var(--primary-dark);
    font-weight: 750;
}

.empty-column {
    min-height: 84px;
    display: grid;
    place-items: center;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    color: var(--muted);
}

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

.task-detail-title {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.status-tag.todo {
    color: #475467;
    background: #eef2f7;
}

.status-tag.doing {
    color: #1d4ed8;
    background: #eff6ff;
}

.status-tag.done {
    color: #166534;
    background: var(--green-soft);
}

.status-tag.low {
    color: #475467;
    background: #f2f4f7;
}

.status-tag.medium {
    color: #92400e;
    background: var(--amber-soft);
}

.status-tag.high {
    color: #991b1b;
    background: var(--red-soft);
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    max-width: min(440px, calc(100vw - 48px));
    padding: 13px 16px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    color: white;
    background: #111827;
    z-index: 20;
}

.toast.danger {
    background: var(--red);
}

.toast.success {
    background: var(--green);
}

@media (max-width: 1180px) {
    .stat-grid.five,
    .stat-grid.four,
    .stat-grid.three {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .content-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 820px) {
    .login-shell {
        grid-template-columns: 1fr;
    }

    .login-visual {
        display: none;
    }

    .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .topbar {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions,
    .filter-bar,
    .inline-form {
        width: 100%;
    }

    .topbar-actions > *,
    .filter-bar > *,
    .inline-form > * {
        flex: 1 1 160px;
    }

    .kanban-board,
    .compact-kanban,
    .form-grid-2,
    .form-grid-3 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .login-page,
    .main-content {
        padding: 16px;
    }

    .login-panel,
    .panel,
    .stat-card {
        padding: 16px;
    }

    .stat-grid.five,
    .stat-grid.four,
    .stat-grid.three {
        grid-template-columns: 1fr;
    }

    .topbar h1 {
        font-size: 22px;
    }
}
