:root {
    --bg: #f5f7fb;
    --panel: #ffffff;
    --text: #172033;
    --muted: #697386;
    --line: #dfe5ee;
    --primary: #1767c5;
    --primary-dark: #0f4f99;
    --accent: #169b8f;
    --danger: #c63838;
    --shadow: 0 12px 30px rgba(28, 42, 68, 0.09);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    letter-spacing: 0;
}

a {
    color: var(--primary);
    text-decoration: none;
}

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

input,
select,
textarea {
    margin-top: 7px;
    padding: 11px 12px;
    background: #fff;
    color: var(--text);
}

button,
.button {
    display: inline-flex;
    width: auto;
    min-height: 40px;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    font-weight: 700;
}

button:hover,
.button:hover {
    background: var(--primary-dark);
    color: #fff;
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 240px;
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 22px 18px;
    background: #111827;
    color: #fff;
}

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

.brand-mark,
.tool-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-weight: 800;
}

.sidebar nav {
    display: grid;
    gap: 7px;
}

.sidebar nav a,
.sidebar-user a {
    padding: 10px 12px;
    border-radius: 6px;
    color: #d8dee9;
}

.sidebar nav a.active,
.sidebar nav a:hover {
    background: #243044;
    color: #fff;
}

.sidebar-user {
    margin-top: auto;
    display: grid;
    gap: 5px;
    color: #d8dee9;
}

.sidebar-user span {
    color: #9ca8ba;
}

.shell {
    margin-left: 240px;
    padding: 30px;
}

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

.login-panel,
.panel,
.table-wrap,
.tool-card,
.empty {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.login-panel {
    width: min(420px, 100%);
    padding: 30px;
}

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

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

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

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

.page-head p {
    margin: 0 0 4px;
    color: var(--muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 12px;
}

.page-head h1 {
    margin: 0;
    font-size: 30px;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

.tool-card {
    min-height: 188px;
    display: grid;
    grid-template-rows: auto 1fr auto;
    gap: 16px;
    padding: 18px;
}

.tool-card h2 {
    margin: 0 0 8px;
    font-size: 20px;
}

.tool-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

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

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

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

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

.status {
    display: inline-flex;
    padding: 4px 9px;
    border-radius: 999px;
    background: #edf7f5;
    color: #11675f;
    font-size: 12px;
    font-weight: 700;
}

.panel {
    padding: 20px;
}

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

.form-grid label,
.access-list,
.wide,
.form-actions {
    min-width: 0;
}

.wide,
.access-list,
.form-actions {
    grid-column: 1 / -1;
}

.access-list {
    display: grid;
    gap: 10px;
    margin: 4px 0 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 6px;
}

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

.access-list label {
    display: flex;
    align-items: center;
    gap: 10px;
}

.access-list input {
    width: 18px;
    height: 18px;
    margin: 0;
}

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

.flash,
.empty {
    margin-bottom: 18px;
    padding: 14px 16px;
}

.flash.success {
    background: #edf7f5;
    border: 1px solid #b7ded8;
    color: #11675f;
}

.flash.error {
    background: #fff0f0;
    border: 1px solid #f0b7b7;
    color: var(--danger);
}

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

.empty.inline {
    margin: 0;
    box-shadow: none;
}

.module-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
}

.module-list,
.module-main,
.module-stats article {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.module-list {
    display: grid;
    align-content: start;
    overflow: hidden;
}

.module-row {
    display: grid;
    gap: 5px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--text);
}

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

.module-row.active,
.module-row:hover {
    background: #eef5fc;
}

.module-row span {
    color: var(--muted);
    font-size: 13px;
}

.module-empty {
    padding: 16px;
    color: var(--muted);
}

.module-main {
    min-height: 360px;
    padding: 16px;
}

.chat-thread {
    min-height: 280px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-bottom: 16px;
}

.bubble {
    max-width: min(520px, 90%);
    padding: 11px 13px;
    border-radius: 8px;
    line-height: 1.4;
}

.bubble.other {
    align-self: flex-start;
    background: #eef2f6;
}

.bubble.mine {
    align-self: flex-end;
    background: #dff2ef;
}

.chat-compose {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.chat-compose input {
    margin-top: 0;
}

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

.module-stats article {
    padding: 18px;
}

.module-stats span {
    display: block;
    color: var(--muted);
    margin-bottom: 8px;
}

.module-stats strong {
    font-size: 30px;
}

@media (max-width: 820px) {
    .sidebar {
        position: static;
        width: auto;
        min-height: auto;
    }

    .shell {
        margin-left: 0;
        padding: 20px;
    }

    .page-head {
        align-items: flex-start;
        flex-direction: column;
    }

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

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