:root {
    color-scheme: light;
    --ink: #17202a;
    --muted: #657487;
    --line: #d9e0e8;
    --surface: #ffffff;
    --canvas: #eef3f6;
    --accent: #0f766e;
    --accent-dark: #115e59;
    --accent-soft: #dff4ef;
    --nav: #22313f;
    --nav-muted: #aebbc9;
    --danger: #b42318;
    --warning: #946200;
}

* {
    box-sizing: border-box;
}

html {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--canvas);
}

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

button {
    min-height: 42px;
    border: 0;
    border-radius: 6px;
    padding: 0 18px;
    color: #ffffff;
    background: var(--accent);
    cursor: pointer;
}

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

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

.guest-shell,
.app-shell {
    min-height: 100vh;
}

.app-shell {
    display: grid;
    grid-template-columns: 248px minmax(0, 1fr);
    background: var(--canvas);
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.login-panel {
    width: min(100%, 420px);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 30px;
    background: var(--surface);
    box-shadow: 0 18px 44px rgba(21, 31, 42, 0.12);
}

.login-heading {
    margin-bottom: 24px;
}

.login-heading p,
.page-heading p,
.module-list header p {
    margin: 0 0 6px;
    color: var(--accent-dark);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

.login-heading h1,
.page-heading h1 {
    margin: 0;
    font-size: 1.65rem;
    line-height: 1.2;
}

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

.login-form label {
    color: var(--muted);
    font-size: 0.92rem;
    font-weight: 650;
}

.login-form input[type="email"],
.login-form input[type="password"] {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    color: var(--ink);
    background: #ffffff;
}

.login-form input:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(15, 118, 110, 0.16);
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    margin: 4px 0 8px;
}

.checkbox-row input {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
}

.form-error {
    margin: 2px 0 8px;
    color: var(--danger);
    font-size: 0.92rem;
}

.sidebar {
    min-height: 100vh;
    padding: 22px 18px;
    color: #ffffff;
    background: var(--nav);
}

.brand {
    display: block;
    padding: 2px 6px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand strong,
.brand span {
    display: block;
}

.brand strong {
    font-size: 1.05rem;
}

.brand span {
    color: var(--nav-muted);
    font-size: 0.86rem;
}

.sidebar-nav {
    display: grid;
    gap: 5px;
    margin-top: 22px;
}

.sidebar-nav a,
.sidebar-nav span {
    min-height: 40px;
    display: flex;
    align-items: center;
    border-radius: 6px;
    padding: 0 12px;
    color: var(--nav-muted);
    font-weight: 650;
}

.sidebar-nav a.active {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
}

.sidebar-group {
    display: grid;
    gap: 4px;
    margin-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 12px;
}

.sidebar-group strong {
    padding: 0 12px 4px;
    color: #ffffff;
    font-size: 0.78rem;
    text-transform: uppercase;
}

.sidebar-group span,
.sidebar-group a {
    min-height: 34px;
    padding-left: 20px;
    font-size: 0.92rem;
}

.user-shell .sidebar {
    background: #28465f;
}

.workspace {
    min-width: 0;
}

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

.topbar strong,
.topbar span {
    display: block;
}

.topbar span {
    color: var(--muted);
    font-size: 0.86rem;
}

.button-secondary {
    min-height: 38px;
    color: var(--ink);
    background: #f3f6f8;
}

.button-secondary:hover {
    background: #e7edf2;
}

.button-danger {
    min-height: 40px;
    color: #ffffff;
    background: var(--danger);
}

.button-danger:hover {
    background: #8f1c14;
}

.app-main {
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px;
}

.page-heading,
.module-list,
.data-panel,
.form-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    background: #ffffff;
}

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

.button-link {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    padding: 0 16px;
    color: #ffffff;
    font-weight: 700;
    background: var(--accent);
}

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

.button-link.secondary {
    color: var(--ink);
    background: #f3f6f8;
}

.button-link.secondary:hover {
    background: #e7edf2;
}

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

.heading-actions form {
    margin: 0;
}

.notice {
    margin-top: 18px;
    border: 1px solid #a7dbc8;
    border-radius: 8px;
    padding: 14px 18px;
    color: var(--accent-dark);
    background: var(--accent-soft);
    font-weight: 650;
}

.notice.danger {
    border-color: #f1b8b3;
    color: var(--danger);
    background: #fff0ef;
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.status-card {
    min-height: 168px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    background: #ffffff;
}

.status-card span {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 0.78rem;
    font-weight: 750;
}

.status-card.ready span {
    color: var(--accent-dark);
    background: var(--accent-soft);
}

.status-card.next span {
    color: var(--warning);
    background: #fff2c6;
}

.status-card h2,
.module-list h2 {
    margin: 14px 0 8px;
    font-size: 1.08rem;
    line-height: 1.25;
}

.status-card p,
.module-list p,
.module-row span {
    margin: 0;
    color: var(--muted);
}

.module-list,
.data-panel,
.form-panel {
    margin-top: 18px;
    padding: 0;
    overflow: hidden;
}

.form-panel {
    padding: 28px;
}

.record-form {
    display: grid;
    gap: 22px;
}

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

.record-form label {
    display: grid;
    gap: 7px;
}

.record-form label span {
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 700;
}

.record-form input,
.record-form select,
.record-form textarea {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 12px;
    color: var(--ink);
    background: #ffffff;
}

.record-form textarea {
    min-height: 112px;
    padding: 10px 12px;
    resize: vertical;
}

.record-form input:focus,
.record-form select:focus,
.record-form textarea:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(15, 118, 110, 0.16);
}

.record-form small {
    color: var(--danger);
    font-weight: 650;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
}

.detail-panel {
    margin-top: 18px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
    background: #ffffff;
}

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

.detail-grid div {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    background: #f9fbfc;
}

.detail-grid dt {
    margin: 0 0 5px;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 750;
    text-transform: uppercase;
}

.detail-grid dd {
    margin: 0;
    font-weight: 650;
    overflow-wrap: anywhere;
}

.detail-grid a {
    color: var(--accent-dark);
}

.detail-notes {
    margin-top: 22px;
    border-top: 1px solid var(--line);
    padding-top: 22px;
}

.detail-notes h2 {
    margin: 0 0 8px;
    font-size: 1.08rem;
}

.detail-notes p {
    margin: 0;
    color: var(--muted);
}

.module-list header,
.data-panel header {
    padding: 24px 28px;
    border-bottom: 1px solid var(--line);
}

.module-list h2,
.data-panel h2 {
    margin: 0;
    font-size: 1.22rem;
}

.data-panel header p {
    margin: 0 0 6px;
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0;
}

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

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

th,
td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

th {
    color: var(--muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0;
    background: #f7fafb;
}

td {
    color: var(--ink);
}

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

.table-actions a {
    min-height: 30px;
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 10px;
    color: var(--accent-dark);
    font-size: 0.9rem;
    font-weight: 700;
    background: #ffffff;
}

.table-actions a:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
}

.empty-state {
    padding: 34px 28px;
}

.empty-state h2 {
    margin: 0 0 8px;
    font-size: 1.12rem;
}

.empty-state p {
    margin: 0;
    color: var(--muted);
}

nav[role="navigation"] {
    padding: 16px 28px 22px;
}

nav[role="navigation"] > div:first-child {
    display: none;
}

nav[role="navigation"] > div:last-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: 0.9rem;
}

nav[role="navigation"] a,
nav[role="navigation"] span[aria-current="page"] span,
nav[role="navigation"] span[aria-disabled="true"] span {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 0 10px;
    background: #ffffff;
}

nav[role="navigation"] span[aria-current="page"] span {
    color: #ffffff;
    border-color: var(--accent);
    background: var(--accent);
}

.module-row {
    display: grid;
    grid-template-columns: minmax(220px, 0.85fr) minmax(0, 1.15fr);
    gap: 20px;
    padding: 18px 28px;
    border-bottom: 1px solid var(--line);
}

.module-row:last-child {
    border-bottom: 0;
}

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

    .sidebar {
        min-height: auto;
        padding: 16px;
    }

    .brand {
        padding-bottom: 14px;
    }

    .sidebar-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-top: 14px;
    }

    .login-panel {
        padding: 24px;
    }

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

    .topbar form,
    .topbar button {
        width: 100%;
    }

    .app-main {
        padding: 18px 16px;
    }

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

    .button-link {
        width: 100%;
    }

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

    .status-grid,
    .module-row,
    .form-grid,
    .detail-grid {
        grid-template-columns: 1fr;
    }

    .page-heading,
    .module-list header,
    .data-panel header {
        padding: 22px;
    }

    .module-row {
        gap: 6px;
        padding: 16px 22px;
    }

    th,
    td {
        padding: 13px 14px;
    }

    .empty-state {
        padding: 26px 22px;
    }

    .form-panel {
        padding: 22px;
    }

    .form-actions,
    .form-actions button {
        width: 100%;
    }
}
