:root {
    --bg: #f6f7f2;
    --surface: #ffffff;
    --surface-soft: #f0f5f1;
    --ink: #1f2a2e;
    --muted: #68757a;
    --line: #dfe7df;
    --green: #327a63;
    --green-dark: #225844;
    --teal: #2f7f8f;
    --amber: #b97a20;
    --blue: #386fa4;
    --red: #b84a4a;
    --violet: #6d5a9c;
    --shadow: 0 18px 42px rgba(31, 42, 46, .09);
    --radius: 8px;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(180deg, rgba(50, 122, 99, .08), transparent 260px),
        var(--bg);
}

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

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

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px;
    background: #fbfcf9;
    border-inline-end: 1px solid var(--line);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 50px;
    margin-bottom: 26px;
}

.brand-mark {
    display: grid;
    width: 44px;
    height: 44px;
    color: #fff;
    place-items: center;
    border-radius: var(--radius);
    background: linear-gradient(135deg, var(--green), var(--teal));
    box-shadow: var(--shadow);
}

.brand h1 {
    margin: 0;
    font-size: 18px;
    line-height: 1.2;
}

.brand p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 10px 12px;
    color: #435056;
    border-radius: var(--radius);
}

.nav-item:hover,
.nav-item.active {
    color: var(--green-dark);
    background: #e8f2ed;
}

.nav-icon {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    border-radius: 7px;
    background: rgba(47, 127, 143, .11);
}

.main-area {
    min-width: 0;
    padding: 22px 28px 88px;
}

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

.topbar-title h2 {
    margin: 0;
    font-size: clamp(22px, 3vw, 34px);
    line-height: 1.15;
}

.topbar-title p {
    margin: 6px 0 0;
    color: var(--muted);
}

.topbar-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
}

.language-switch {
    display: inline-flex;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
}

.language-switch a {
    padding: 8px 10px;
    color: var(--muted);
    font-size: 13px;
}

.language-switch a.active {
    color: #fff;
    background: var(--green);
}

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

.page-header h2,
.page-header h3 {
    margin: 0;
}

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

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

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

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

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

.card,
.person-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 24px rgba(31, 42, 46, .05);
}

.card,
.panel {
    padding: 18px;
}

.stat-card {
    min-height: 112px;
    padding: 18px;
    border-top: 4px solid var(--green);
}

.stat-card:nth-child(2) { border-top-color: var(--teal); }
.stat-card:nth-child(3) { border-top-color: var(--amber); }
.stat-card:nth-child(4) { border-top-color: var(--blue); }
.stat-card:nth-child(5) { border-top-color: var(--violet); }
.stat-card:nth-child(6) { border-top-color: var(--red); }

.stat-label {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 14px;
}

.stat-value {
    margin: 0;
    font-size: 30px;
    font-weight: 800;
}

.person-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.person-card {
    padding: 14px;
}

.person-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 58px;
    height: 58px;
    flex: 0 0 auto;
    overflow: hidden;
    border-radius: 50%;
    border: 3px solid #edf4ef;
    background: #eef4f2;
}

.avatar.lg {
    width: 112px;
    height: 112px;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.person-name {
    margin: 0;
    font-size: 17px;
    line-height: 1.3;
}

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

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 9px 14px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 700;
    line-height: 1.2;
}

.btn.primary {
    color: #fff;
    background: var(--green);
}

.btn.primary:hover {
    background: var(--green-dark);
}

.btn.secondary {
    color: var(--green-dark);
    background: #e8f2ed;
}

.btn.ghost {
    color: var(--ink);
    background: var(--surface);
    border-color: var(--line);
}

.btn.danger {
    color: #fff;
    background: var(--red);
}

.btn.small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

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

.field {
    display: grid;
    gap: 7px;
}

.field.full {
    grid-column: 1 / -1;
}

.field label {
    color: #334146;
    font-weight: 700;
    font-size: 14px;
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    color: var(--ink);
    border: 1px solid #ccd8d2;
    border-radius: var(--radius);
    background: #fff;
}

.textarea {
    min-height: 120px;
    resize: vertical;
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: 3px solid rgba(47, 127, 143, .18);
    border-color: var(--teal);
}

.table-wrap {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

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

.table th,
.table td {
    padding: 13px 14px;
    text-align: start;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.table th {
    color: var(--muted);
    font-size: 13px;
    background: #f7faf7;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 9px;
    color: #334146;
    border-radius: 999px;
    background: #edf2ef;
    font-size: 12px;
    font-weight: 800;
}

.badge.green { color: #155a43; background: #dff1e9; }
.badge.amber { color: #75500e; background: #f5e8cd; }
.badge.blue { color: #275784; background: #dfeefa; }
.badge.red { color: #8b2d2d; background: #f5dddd; }
.badge.violet { color: #5a438b; background: #eadff6; }

.alert {
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
}

.alert.success {
    color: #155a43;
    background: #e5f4ec;
    border-color: #bfe5d3;
}

.alert.error {
    color: #8b2d2d;
    background: #f8e4e4;
    border-color: #edc3c3;
}

.alert.warning {
    color: #75500e;
    background: #faefd9;
    border-color: #f1d49f;
}

.filters {
    display: grid;
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    gap: 10px;
    align-items: end;
}

.profile-head {
    display: flex;
    align-items: center;
    gap: 20px;
}

.progress {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e4ebe5;
}

.progress span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--green), var(--teal));
}

.tree-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 12px;
}

.tree-canvas {
    overflow: auto;
    min-height: 62vh;
    padding: 22px;
    background:
        linear-gradient(#edf2ef 1px, transparent 1px),
        linear-gradient(90deg, #edf2ef 1px, transparent 1px),
        #fbfcf9;
    background-size: 32px 32px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.tree-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px;
    min-width: 720px;
}

.tree-card {
    background: rgba(255, 255, 255, .94);
}

.key-value {
    display: grid;
    gap: 10px;
}

.key-value div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}

.key-value dt {
    color: var(--muted);
}

.key-value dd {
    margin: 0;
    font-weight: 700;
    text-align: end;
}

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

.login-card {
    width: min(100%, 430px);
    padding: 28px;
    background: rgba(255, 255, 255, .94);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.mobile-nav {
    display: none;
}

.pagination {
    margin-top: 16px;
}

@media (max-width: 1080px) {
    .grid.four,
    .grid.three {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

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

    .sidebar {
        display: none;
    }

    .main-area {
        padding: 16px 14px 92px;
    }

    .topbar,
    .page-header,
    .profile-head {
        align-items: stretch;
        flex-direction: column;
    }

    .topbar-actions {
        justify-content: flex-start;
    }

    .grid.two,
    .grid.three,
    .grid.four,
    .form-grid,
    .filters {
        grid-template-columns: 1fr;
    }

    .mobile-nav {
        position: fixed;
        z-index: 30;
        right: 0;
        bottom: 0;
        left: 0;
        display: grid;
        grid-template-columns: repeat(5, 1fr);
        gap: 4px;
        padding: 8px;
        background: rgba(255, 255, 255, .97);
        border-top: 1px solid var(--line);
        box-shadow: 0 -12px 28px rgba(31, 42, 46, .08);
    }

    .mobile-nav a {
        display: grid;
        min-height: 54px;
        place-items: center;
        color: var(--muted);
        border-radius: var(--radius);
        font-size: 12px;
        font-weight: 700;
    }

    .mobile-nav a.active {
        color: var(--green-dark);
        background: #e8f2ed;
    }
}
