:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d9e0ea;
    --primary: #155eef;
    --primary-dark: #0040c1;
    --danger: #b42318;
    --success: #067647;
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

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

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

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

.sidebar {
    background: #101828;
    color: #eef4ff;
    padding: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    font-weight: 700;
    line-height: 1.2;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #12b76a;
    color: #052e1a;
    font-weight: 800;
}

.nav {
    display: grid;
    gap: 6px;
}

.nav a,
.logout-button {
    display: block;
    width: 100%;
    border: 0;
    border-radius: 6px;
    padding: 10px 12px;
    background: transparent;
    color: #d0d5dd;
    text-align: left;
    font: inherit;
    cursor: pointer;
}

.nav a:hover,
.logout-button:hover {
    background: #1d2939;
    color: #ffffff;
}

.main {
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 64px;
    padding: 0 28px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.content {
    padding: 28px;
}

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

h1 {
    margin: 0 0 4px;
    font-size: 24px;
    letter-spacing: 0;
}

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

.active-filter {
    display: inline-flex;
    gap: 10px;
    align-items: center;
    margin-top: 8px;
    border-radius: 6px;
    padding: 6px 10px;
    background: #eef4ff;
    color: #3538cd;
    font-weight: 700;
}

.active-filter a {
    text-decoration: underline;
}

.grid {
    display: grid;
    gap: 16px;
}

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

.detail-grid {
    grid-template-columns: minmax(0, 1fr) 360px;
    align-items: start;
}

.admin-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
}

.metric,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
}

.metric span {
    display: block;
    color: var(--muted);
    margin-bottom: 10px;
}

.metric strong {
    font-size: 30px;
}

.metric-link {
    transition: border-color 0.15s ease, transform 0.15s ease;
}

.metric-link:hover {
    border-color: var(--primary);
    transform: translateY(-1px);
}

.panel-title {
    margin: 0 0 14px;
    font-size: 16px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    padding: 14px;
    margin-bottom: 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.column-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 12px;
    align-items: center;
    min-height: 38px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #ffffff;
}

.column-picker > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.column-picker .check-row {
    min-height: 24px;
    gap: 6px;
    color: var(--text);
    font-size: 12px;
    line-height: 1;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-width: 16px;
    min-height: 16px;
    margin: 0;
    padding: 0;
    border-radius: 4px;
    accent-color: var(--primary);
    cursor: pointer;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

input,
select,
textarea {
    min-height: 38px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 8px 10px;
    background: #ffffff;
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 8px 14px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

.button.secondary {
    background: #ffffff;
    border-color: var(--line);
    color: var(--text);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    background: #eef4ff;
    color: #344054;
    font-size: 12px;
    text-transform: uppercase;
}

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

.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 8px;
    background: #eef4ff;
    color: #3538cd;
    font-weight: 700;
    font-size: 12px;
}

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

.alert.error {
    background: #fef3f2;
    color: var(--danger);
}

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

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

.span-2 {
    grid-column: span 2;
}

.pagination {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 14px;
}

.detail-list {
    display: grid;
    grid-template-columns: 160px minmax(0, 1fr);
    gap: 10px 16px;
    margin: 0 0 18px;
}

.detail-list dt {
    color: var(--muted);
    font-weight: 700;
}

.detail-list dd {
    margin: 0;
}

.workflow-actions {
    display: grid;
    gap: 10px;
}

.workflow-actions .button {
    width: 100%;
}

.compact-form {
    margin-bottom: 16px;
}

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

.inline-user-form select,
.inline-user-form input[type="password"] {
    min-width: 150px;
}

.inline-user-form .button {
    min-height: 34px;
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    width: auto;
}

.check-row input {
    min-height: 0;
}

.auth-page {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(135deg, #101828, #1849a9);
}

.auth-card {
    width: min(420px, 100%);
    background: #ffffff;
    border-radius: 8px;
    padding: 28px;
}

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

    .metric-grid,
    .detail-grid,
    .admin-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .span-2 {
        grid-column: span 1;
    }
}
