:root {
    color-scheme: light;
    --bg: #f4f6f8;
    --panel: #ffffff;
    --text: #18212f;
    --muted: #627084;
    --line: #d9e0e8;
    --accent: #176b87;
    --accent-dark: #0f4f64;
    --sidebar: #ffffff;
    --sidebar-line: #d7dde5;
    --sidebar-text: #334155;
    --sidebar-active-bg: #e9f4f8;
    --sidebar-active-text: #0f4f64;
    --danger-bg: #fff1f1;
    --danger-text: #9f2424;
    --success-bg: #edf9f1;
    --success-text: #247a3a;
    --amber-bg: #fff7e8;
    --amber-text: #9a5b00;
    --blue-bg: #edf5ff;
    --blue-text: #1d5ca8;
    --teal-bg: #edf9f7;
    --teal-text: #156f66;
    --purple-bg: #f4efff;
    --purple-text: #6842b0;
    --slate-bg: #edf1f5;
    --slate-text: #536276;
    --shadow: 0 10px 30px rgba(24, 33, 47, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    line-height: 1.5;
}

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

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

.sidebar {
    background: var(--sidebar);
    border-right: 1px solid var(--sidebar-line);
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 28px 20px;
}

.user-card {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
}

.user-card-name {
    font-size: 18px;
    font-weight: 700;
}

.user-card-email {
    color: var(--muted);
    font-size: 14px;
    margin-top: 2px;
}

.role-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

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

.sidebar-label {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.sidebar-nav a {
    border-radius: 6px;
    color: var(--sidebar-text);
    padding: 10px 12px;
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.is-active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
}

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

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

.topbar {
    align-items: center;
    background: rgba(255, 255, 255, 0.92);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    min-height: 72px;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.brand {
    color: var(--text);
    font-size: 20px;
    font-weight: 700;
    text-decoration: none;
}

.topbar-kicker {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.topbar-title {
    font-size: 22px;
    font-weight: 700;
}

.topbar-meta {
    color: var(--muted);
    font-size: 14px;
}

.page {
    margin: 0 auto;
    max-width: 1240px;
    padding: 28px 24px 36px;
}

.panel,
.auth-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.inset-panel {
    padding: 20px;
}

.auth-shell {
    display: grid;
    min-height: calc(100vh - 128px);
    place-items: center;
}

.auth-panel {
    max-width: 420px;
    width: 100%;
}

h1 {
    font-size: 28px;
    margin: 0 0 8px;
}

p {
    color: var(--muted);
    margin: 0 0 20px;
}

.form {
    display: grid;
    gap: 10px;
}

label {
    color: var(--text);
    font-weight: 700;
}

input,
select,
textarea {
    border: 1px solid var(--line);
    border-radius: 6px;
    font: inherit;
    padding: 10px 12px;
    width: 100%;
}

textarea {
    resize: vertical;
}

button,
.button {
    background: var(--accent);
    border: 0;
    border-radius: 6px;
    color: #ffffff;
    cursor: pointer;
    display: inline-block;
    font: inherit;
    font-weight: 700;
    padding: 10px 14px;
    text-decoration: none;
}

button:hover,
.button:hover {
    background: var(--accent-dark);
}

button.danger {
    background: #b4232a;
}

button.danger:hover {
    background: #8f1d22;
}

.button.secondary {
    background: #e8eef3;
    color: var(--text);
}

.button.secondary:hover {
    background: #d8e2ea;
}

.link-button {
    background: transparent;
    color: var(--accent);
    font-weight: 400;
    padding: 0;
}

.link-button:hover {
    background: transparent;
    color: var(--accent-dark);
    text-decoration: underline;
}

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.dashboard-stack {
    display: grid;
    gap: 20px;
}

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

.metric-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    min-height: 108px;
    padding: 18px;
}

.metric-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
}

.metric-value {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 10px;
}

.filter-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: 2fr repeat(3, minmax(0, 1fr));
    margin-top: 12px;
}

.toolbar {
    align-items: end;
    display: grid;
    gap: 12px;
}

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

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

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

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

.wide-form {
    gap: 18px;
}

fieldset {
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 0;
    padding: 16px;
}

legend {
    font-weight: 700;
    padding: 0 6px;
}

.hint,
.muted {
    color: var(--muted);
    font-size: 14px;
}

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

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

.check-row {
    align-items: center;
    display: flex;
    gap: 8px;
    font-weight: 400;
}

.check-row input {
    width: auto;
}

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

.inline-assignment {
    display: grid;
    gap: 12px;
}

.top-gap {
    margin-top: 16px;
}

.summary-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin: 22px 0;
}

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

h2 {
    font-size: 20px;
    margin: 28px 0 10px;
}

.compound-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.compound-list span {
    background: #eef5f7;
    border: 1px solid #d4e4ea;
    border-radius: 6px;
    padding: 5px 8px;
}

.timeline {
    display: grid;
    gap: 12px;
    list-style: none;
    margin: 0;
    padding-left: 24px;
}

.timeline li {
    background: #fbfcfd;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    position: relative;
}

.timeline li::before {
    background: var(--accent);
    border-radius: 999px;
    content: "";
    height: 10px;
    left: -20px;
    position: absolute;
    top: 18px;
    width: 10px;
}

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

.comment-badges {
    margin-top: 6px;
}

.status-chip {
    border: 1px solid transparent;
    border-radius: 999px;
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    padding: 4px 9px;
}

.badge-slate {
    background: var(--slate-bg);
    border-color: #dce4ec;
    color: var(--slate-text);
}

.badge-green {
    background: var(--success-bg);
    border-color: #d9f0df;
    color: var(--success-text);
}

.badge-red {
    background: var(--danger-bg);
    border-color: #f1d7d7;
    color: var(--danger-text);
}

.badge-amber {
    background: var(--amber-bg);
    border-color: #f0dfb8;
    color: var(--amber-text);
}

.badge-blue {
    background: var(--blue-bg);
    border-color: #d4e3fb;
    color: var(--blue-text);
}

.badge-teal {
    background: var(--teal-bg);
    border-color: #d4ece7;
    color: var(--teal-text);
}

.badge-purple {
    background: var(--purple-bg);
    border-color: #e2d8fa;
    color: var(--purple-text);
}

.status-stack {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.table-meta {
    color: var(--muted);
    font-size: 13px;
}

.table-summary {
    margin-bottom: 14px;
}

.split-grid {
    display: grid;
    gap: 20px;
    grid-template-columns: 1.5fr 1fr;
}

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

.mini-item {
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

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

.mini-item-title {
    font-weight: 700;
}

.back-link {
    display: inline-block;
    margin-bottom: 16px;
    text-decoration: none;
}

.meta-list {
    display: grid;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.meta-list li {
    color: var(--muted);
    font-size: 13px;
}

.pagination {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 18px;
}

.pagination a {
    background: var(--slate-bg);
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    min-width: 38px;
    padding: 8px 10px;
    text-align: center;
    text-decoration: none;
}

.pagination a.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.error-inline {
    color: var(--danger-text);
    font-weight: 700;
}

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

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

.alert.error {
    background: var(--danger-bg);
    color: var(--danger-text);
}

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

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

th {
    color: var(--muted);
    font-size: 14px;
}

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

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--sidebar-line);
        padding: 20px;
    }

    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        padding: 16px 20px;
    }

    .section-heading {
        display: block;
    }

    .form-grid,
    .check-grid,
    .summary-grid,
    .check-grid.compact,
    .metric-grid,
    .filter-grid,
    .split-grid {
        grid-template-columns: 1fr;
    }
}
