:root {
    --bg: #fbfaf7;
    --panel: #ffffff;
    --ink: #1f2528;
    --muted: #697174;
    --line: #dedbd4;
    --accent: #202329;
    --accent-dark: #111318;
    --gold: #b88736;
    --mint: #e6f8e8;
    --mint-line: #c8eecf;
    --field: #ffffff;
    --danger: #d4485d;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    grid-template-columns: 260px 1fr;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, Arial, Helvetica, sans-serif;
}

.sidebar {
    min-height: 100vh;
    padding: 28px 20px;
    background: #20282b;
    color: #fff;
    display: flex;
    flex-direction: column;
}

.brand {
    margin-bottom: 32px;
    font-size: 20px;
    font-weight: 700;
}

nav {
    display: grid;
    gap: 8px;
}

nav a {
    color: #eef0ec;
    text-decoration: none;
    padding: 11px 12px;
    border-radius: 6px;
}

nav a:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 24px;
    color: #cfd7d2;
    font-size: 14px;
}

.sidebar-footer span {
    display: block;
    margin-bottom: 10px;
}

.sidebar-footer button {
    width: 100%;
    min-height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.content {
    padding: 34px 50px 110px;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 30px;
}

.page-header h1 {
    margin: 0 0 8px;
    font-size: 34px;
    line-height: 1.1;
    letter-spacing: 0;
}

.page-header p {
    max-width: 760px;
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}

.eyebrow {
    margin: 0 0 6px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: uppercase;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    border: 0;
    border-radius: 7px;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

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

.button.secondary {
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.stat-card {
    padding: 18px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 14px;
}

.stat-card strong {
    display: block;
    margin-top: 10px;
    font-size: 34px;
}

.panel {
    padding: 24px;
}

.panel h2 {
    margin: 0 0 14px;
    font-size: 20px;
}

.task-list {
    margin: 0;
    padding-left: 20px;
    color: var(--muted);
    line-height: 1.8;
}

.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}

.empty-state {
    max-width: 760px;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

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

.data-table th {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.data-table td span {
    display: block;
    margin-top: 5px;
    color: var(--muted);
    font-size: 13px;
}

.entity-form {
    position: relative;
    display: grid;
    gap: 30px;
    max-width: 1180px;
}

.form-page-header {
    max-width: 1180px;
}

.form-page-header h1 {
    margin: 0;
    font-size: 36px;
}

.form-page-header .button {
    margin-top: 2px;
}

.form-section {
    position: relative;
    border-color: var(--line);
    border-radius: 10px;
    box-shadow: 0 14px 34px rgba(31, 37, 40, 0.045);
}

.highlight-section {
    border-color: #ccefd3;
    background: linear-gradient(180deg, #e9faec 0%, #e4f7e8 100%);
}

.form-section h2 {
    margin: 0 0 22px;
    color: #2b3431;
    font-size: 16px;
    font-weight: 800;
}

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

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

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

.wide-grid {
    margin-top: 16px;
}

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

.entity-form label {
    display: grid;
    gap: 9px;
    color: #20272a;
    font-size: 13px;
    font-weight: 700;
}

.entity-form input,
.entity-form select,
.entity-form textarea {
    width: 100%;
    min-height: 44px;
    padding: 11px 13px;
    border: 1px solid #d8d9d6;
    border-radius: 7px;
    background: var(--field);
    color: var(--ink);
    font: inherit;
    box-shadow: 0 1px 2px rgba(31, 37, 40, 0.08);
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.entity-form input:disabled {
    background: #f3f3ef;
    color: #737b7e;
}

.entity-form input:focus,
.entity-form select:focus,
.entity-form textarea:focus {
    outline: none;
    border-color: #84c993;
    box-shadow: 0 0 0 3px rgba(132, 201, 147, 0.22), 0 1px 2px rgba(31, 37, 40, 0.08);
}

.entity-form textarea {
    resize: vertical;
}

.checkbox-field {
    align-content: end;
    grid-template-columns: auto 1fr;
    align-items: center;
    min-height: 68px;
    padding: 11px 12px;
    border: 1px solid rgba(95, 145, 105, 0.24);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.55);
}

.follow-up-card {
    position: absolute;
    top: 0;
    right: 0;
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 0 13px;
    border: 1px solid rgba(95, 145, 105, 0.25);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.72);
    color: #2f4236;
    box-shadow: 0 8px 18px rgba(31, 37, 40, 0.06);
}

.top-follow-up {
    top: 0;
    right: 0;
}

.follow-up-card input {
    width: 17px;
    min-height: 17px;
    height: 17px;
}

.checkbox-field input {
    width: 18px;
    min-height: 18px;
    height: 18px;
}

.auto-region-field {
    background: rgba(255, 255, 255, 0.72);
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.sticky-actions {
    position: sticky;
    bottom: 0;
    z-index: 5;
    align-items: center;
    justify-content: flex-end;
    margin: 8px -50px -110px;
    padding: 18px 50px;
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 -8px 24px rgba(31, 37, 40, 0.08);
    backdrop-filter: blur(8px);
}

.sticky-actions .button {
    min-width: 118px;
}

.clear-form-link {
    margin-right: auto;
    color: #1f6fd1;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.clear-form-link:hover {
    text-decoration: underline;
}

.required-mark {
    color: var(--danger);
}

.field-help {
    min-height: 20px;
    margin: 14px 0 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.field-help.error {
    color: #842631;
}

.field-help.warning {
    color: #8a5a12;
}

.field-help.success {
    color: #22543d;
}

.auth-page {
    display: grid;
    grid-template-columns: 1fr;
    place-items: center;
    padding: 24px;
    background: var(--bg);
}

.auth-shell {
    width: min(100%, 420px);
}

.login-panel {
    padding: 28px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.login-brand span {
    display: block;
    margin-bottom: 8px;
    color: var(--accent);
    font-weight: 700;
}

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

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

.login-form label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
}

.login-form input {
    width: 100%;
    min-height: 42px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--ink);
    font: inherit;
}

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

.alert.error {
    border: 1px solid #e3a7ad;
    background: #fff1f2;
    color: #842631;
}

.alert.success {
    border: 1px solid #9ac4aa;
    background: #f0fbf3;
    color: #22543d;
}

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

    .sidebar {
        min-height: auto;
    }

    nav {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    }

    .content {
        padding: 24px 24px 100px;
    }

    .page-header {
        display: block;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }

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

    .third-grid,
    .quarter-grid {
        grid-template-columns: 1fr;
    }

    .follow-up-card {
        position: static;
        margin: -4px 0 18px;
        width: fit-content;
    }

    .sticky-actions {
        margin: 0 -24px -100px;
        padding: 14px 24px;
    }
}

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