:root {
    --bg: #eef3fb;
    --surface: #ffffff;
    --surface-soft: #f7faff;
    --text: #0f172a;
    --muted: #64748b;
    --line: #dbe5f2;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-soft: #e8f0ff;
    --nav: #0f1f3a;
    --nav-soft: #172b4d;
    --danger-bg: #fff1f2;
    --danger: #b42318;
    --success-bg: #ecfdf3;
    --success: #067647;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, .12), transparent 34rem),
        var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

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

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

h1 {
    margin-bottom: 8px;
    font-size: clamp(28px, 4vw, 42px);
    letter-spacing: -.02em;
}

h2 {
    margin-bottom: 0;
    font-size: 22px;
}

h3 {
    margin-bottom: 0;
    font-size: 18px;
}

label {
    display: block;
    margin: 14px 0 7px;
    color: #43536b;
    font-size: 13px;
    font-weight: 800;
}

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

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 13px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}

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

select {
    min-width: 190px;
}

textarea {
    resize: vertical;
}

button,
.primary {
    border: 0;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    padding: 12px 18px;
    font-weight: 800;
    cursor: pointer;
    transition: background .18s ease, transform .18s ease;
}

button:hover,
.primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
}

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

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 24px;
    background: linear-gradient(180deg, var(--nav), var(--nav-soft));
    color: #fff;
}

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

.brand-mark,
.module-icon,
.sidebar-user span {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 14px;
    font-weight: 900;
}

.brand-mark {
    width: 48px;
    height: 48px;
    background: #fff;
    color: var(--primary);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .18);
}

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

.brand small {
    margin-top: 3px;
    color: #b9c7dc;
}

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

.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    border-radius: 12px;
    color: #dbe7ff;
    padding: 12px;
    text-decoration: none;
}

.side-nav a:hover,
.side-nav .active {
    background: rgba(255, 255, 255, .12);
    color: #fff;
}

.side-nav span {
    display: inline-grid;
    width: 28px;
    height: 28px;
    place-items: center;
    border-radius: 9px;
    background: rgba(255, 255, 255, .12);
    font-size: 12px;
    font-weight: 900;
}

.sidebar-user {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, .14);
    padding-top: 18px;
}

.sidebar-user span {
    width: 42px;
    height: 42px;
    background: rgba(255, 255, 255, .14);
}

.sidebar-user strong,
.sidebar-user small,
.sidebar-user a {
    display: block;
}

.sidebar-user small {
    color: #dbe7ff;
    font-size: 12px;
    margin-top: 2px;
}

.sidebar-user a {
    margin-top: 3px;
    color: #b9c7dc;
    font-size: 13px;
    text-decoration: none;
}

.content {
    width: min(1180px, calc(100% - 40px));
    margin: 0 auto;
    padding: 30px 0;
}

.topbar {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(340px, 520px);
    gap: 22px;
    align-items: end;
    margin-bottom: 20px;
}

.topbar-single {
    display: block;
}

.eyebrow {
    margin: 0 0 7px;
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .1em;
    text-transform: uppercase;
}

.subtitle,
.muted,
.small-note {
    color: var(--muted);
}

.subtitle {
    margin-bottom: 0;
    font-size: 16px;
}

.global-search {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, .82);
    padding: 14px;
    box-shadow: var(--shadow);
}

.global-search label {
    margin-top: 0;
}

.search-row,
.module-search {
    display: flex;
    gap: 10px;
}

.search-row input,
.module-search input {
    flex: 1;
    min-width: 0;
}

.module-search select {
    flex: 0 0 210px;
}

.clear-link {
    display: inline-block;
    margin-top: 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
}

.alert {
    border-radius: 14px;
    margin-bottom: 18px;
    padding: 13px 16px;
}

.alert p {
    margin: 0;
}

.alert p + p {
    margin-top: 6px;
}

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

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

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

.stat-card,
.module-card,
.panel {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, .94);
    box-shadow: var(--shadow);
}

.stat-card {
    border-radius: 16px;
    padding: 18px;
}

.stat-card span,
.stat-card small {
    display: block;
    color: var(--muted);
}

.stat-card span {
    font-size: 13px;
    font-weight: 800;
}

.stat-card strong {
    display: block;
    margin: 8px 0 4px;
    font-size: 31px;
    letter-spacing: -.03em;
}

.stat-card.accent {
    background: linear-gradient(135deg, var(--primary), #38bdf8);
    color: #fff;
}

.stat-card.accent span,
.stat-card.accent small {
    color: rgba(255, 255, 255, .84);
}

.single-module {
    width: min(760px, 100%);
}

.wide-module {
    width: min(960px, 100%);
}

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

.action-card {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, .94);
    box-shadow: var(--shadow);
    color: var(--text);
    padding: 22px;
    text-decoration: none;
    transition: border-color .18s ease, transform .18s ease;
}

.action-card:hover {
    border-color: #b9c7dc;
    transform: translateY(-2px);
}

.action-card h2 {
    margin-bottom: 7px;
}

.action-card small {
    color: var(--muted);
}

.module-card,
.panel {
    border-radius: 18px;
    padding: 22px;
}

.register-module {
    position: sticky;
    top: 24px;
}

.module-heading,
.module-heading-left,
.results-heading {
    display: flex;
    align-items: center;
    gap: 12px;
}

.module-heading {
    margin-bottom: 18px;
}

.results-heading {
    justify-content: space-between;
}

.module-icon {
    width: 44px;
    height: 44px;
    background: var(--primary-soft);
    color: var(--primary);
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.upload-box {
    border: 1px dashed #b9c7dc;
    border-radius: 14px;
    margin-top: 16px;
    padding: 15px;
    background: var(--surface-soft);
}

.upload-box label {
    margin-top: 0;
}

.hint {
    color: var(--muted);
    font-size: 13px;
    margin: 8px 0 0;
}

.full-button,
.button-link {
    display: block;
    width: 100%;
    margin-top: 18px;
    text-align: center;
}

.button-link {
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    padding: 12px 18px;
    font-weight: 800;
    text-decoration: none;
}

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

.module-search {
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    margin: 18px 0;
    padding: 16px 0;
}

.result-badge {
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 900;
    white-space: nowrap;
}

.empty {
    border: 1px dashed #b9c7dc;
    border-radius: 14px;
    color: var(--muted);
    padding: 34px;
    text-align: center;
}

.document-list {
    display: grid;
    gap: 14px;
}

.document-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    background: #fff;
    padding: 16px;
    transition: border-color .18s ease, transform .18s ease;
}

.document-card:hover {
    border-color: #b9c7dc;
    transform: translateY(-1px);
}

.document-main {
    display: grid;
    gap: 12px;
}

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

.label {
    display: inline-block;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
    margin-bottom: 7px;
    padding: 6px 10px;
}

.document-card p {
    color: var(--muted);
    line-height: 1.55;
    margin-bottom: 0;
}

.document-card small {
    color: var(--muted);
    white-space: nowrap;
}

.document-actions {
    display: grid;
    justify-items: end;
    gap: 7px;
}

.document-actions a {
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
    padding: 6px 10px;
    text-decoration: none;
}

.attachments {
    display: grid;
    gap: 8px;
    margin-top: 14px;
}

.attachments a {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border-radius: 12px;
    background: var(--surface-soft);
    color: var(--primary);
    padding: 11px 12px;
    text-decoration: none;
}

.attachments a:hover {
    background: var(--primary-soft);
}

.attachments small {
    color: var(--muted);
    white-space: nowrap;
}

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

.auth-card {
    width: min(440px, 100%);
}

.auth-card h1 {
    margin-bottom: 18px;
}

.small-note {
    font-size: 14px;
    margin: 16px 0 0;
}

.user-list-card {
    margin-top: 18px;
}

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

.user-row {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #fff;
    padding: 13px 14px;
}

.user-row strong,
.user-row small {
    display: block;
}

.user-row small {
    color: var(--muted);
    margin-top: 3px;
}

.role-badge {
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 12px;
    font-weight: 900;
    padding: 7px 10px;
    white-space: nowrap;
}

.role-badge.admin {
    background: var(--success-bg);
    color: var(--success);
}

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

    .sidebar {
        position: static;
        min-height: auto;
        padding: 18px;
    }

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

    .sidebar-user {
        margin-top: 18px;
    }

    .topbar,
    .dashboard-actions {
        grid-template-columns: 1fr;
    }

    .register-module {
        position: static;
    }
}

@media (max-width: 760px) {
    .content {
        width: min(100% - 24px, 1180px);
        padding: 20px 0;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .form-grid,
    .search-row,
    .module-search,
    .attachments a,
    .document-title-row,
    .user-row {
        flex-direction: column;
        grid-template-columns: 1fr;
    }

    .document-actions,
    .user-row {
        align-items: flex-start;
        justify-items: start;
    }

    .side-nav {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .module-card,
    .panel {
        padding: 17px;
    }
}
