:root {
    --bg: #f4f5f3;
    --surface: #ffffff;
    --surface-soft: #f8f8f6;
    --text: #1e2420;
    --muted: #667069;
    --line: #dde2dd;
    --accent: #204d3a;
    --accent-dark: #17392b;
    --danger: #a53b34;
    --warning: #8a6516;
    --success: #24633f;
    --radius: 14px;
    --shadow:
        0 1px 2px rgba(25, 35, 29, .04),
        0 8px 24px rgba(25, 35, 29, .05);
}

* {
    box-sizing: border-box;
}

html {
    background: var(--bg);
}

body {
    margin: 0;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

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

a:hover {
    text-decoration: underline;
}

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

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: auto;
    background: #18251f;
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
}

.brand {
    padding: 0 10px 24px;
    border-bottom:
        1px solid
        rgba(255,255,255,.12);
}

.brand-name {
    font-size: 20px;
    font-weight: 760;
    letter-spacing: -.02em;
}

.brand-subtitle {
    margin-top: 3px;
    color:
        rgba(255,255,255,.62);
    font-size: 13px;
}

.nav {
    flex: 1;
    padding: 18px 0;
}

.nav-group + .nav-group {
    margin-top: 22px;
}

.nav-group-title {
    padding: 0 10px 7px;
    color:
        rgba(255,255,255,.46);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.nav-link {
    display: block;
    padding: 8px 10px;
    border-radius: 8px;
    color:
        rgba(255,255,255,.77);
    font-size: 14px;
}

.nav-link:hover {
    background:
        rgba(255,255,255,.07);
    color: #fff;
    text-decoration: none;
}

.nav-link.active {
    background:
        rgba(255,255,255,.12);
    color: #fff;
    font-weight: 650;
}

.sidebar-user {
    padding: 18px 10px 0;
    border-top:
        1px solid
        rgba(255,255,255,.12);
}

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

.sidebar-user span {
    color:
        rgba(255,255,255,.58);
    font-size: 12px;
    margin: 2px 0 8px;
    overflow-wrap: anywhere;
}

.sidebar-user .link-button {
    color:
        rgba(255,255,255,.75);
}

.main {
    min-width: 0;
}

.content {
    max-width: 1500px;
    margin: 0 auto;
    padding: 36px;
}

.mobile-header {
    display: none;
}

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

.page-header h1 {
    margin: 3px 0 5px;
    font-size:
        clamp(
            28px,
            3vw,
            38px
        );
    letter-spacing: -.035em;
    line-height: 1.1;
}

.page-header p {
    margin: 0;
    color: var(--muted);
    max-width: 720px;
}

.eyebrow {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
}

.header-actions,
.form-actions,
.toolbar {
    display: flex;
    gap: 9px;
    align-items: center;
    flex-wrap: wrap;
}

.button {
    appearance: none;
    border:
        1px solid transparent;
    border-radius: 9px;
    padding: 9px 14px;
    font-weight: 650;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    min-height: 40px;
}

.button:hover {
    text-decoration: none;
}

.button.primary {
    background: var(--accent);
    color: #fff;
}

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

.button.secondary {
    background:
        var(--surface);
    border-color:
        var(--line);
    color:
        var(--text);
}

.button.ghost {
    background: transparent;
    color:
        var(--muted);
}

.button.full {
    width: 100%;
}

.link-button {
    border: 0;
    background: none;
    padding: 0;
    cursor: pointer;
    color:
        var(--accent);
    font: inherit;
}

.link-button.danger {
    color:
        var(--danger);
}

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

.metric-card,
.panel,
.entity-form,
.table-wrap,
.toolbar {
    background:
        var(--surface);
    border:
        1px solid
        var(--line);
    border-radius:
        var(--radius);
    box-shadow:
        var(--shadow);
}

.metric-card {
    padding: 20px;
}

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

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: 30px;
    line-height: 1;
}

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

.panel {
    padding: 20px;
    min-width: 0;
}

.panel.span-2 {
    grid-column: span 2;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content:
        space-between;
    gap: 12px;
    margin-bottom: 15px;
}

.panel-header h2 {
    margin: 0;
    font-size: 17px;
    letter-spacing: -.015em;
}

.panel-header a {
    font-size: 13px;
}

.item-list {
    border-top:
        1px solid
        var(--line);
}

.item-row {
    display: flex;
    justify-content:
        space-between;
    gap: 16px;
    padding: 13px 2px;
    border-bottom:
        1px solid
        var(--line);
    color:
        var(--text);
}

.item-row:hover {
    text-decoration: none;
    background:
        var(--surface-soft);
}

.item-row.static:hover {
    background: transparent;
}

.item-row span {
    min-width: 0;
}

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

.item-row strong {
    font-size: 14px;
}

.item-row small {
    color:
        var(--muted);
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-row time {
    color:
        var(--muted);
    font-size: 12px;
    flex: 0 0 auto;
}

.status-callout {
    border-left:
        3px solid
        var(--warning);
    background: #fbf8ef;
    padding: 13px 14px;
    border-radius: 8px;
}

.status-callout.good {
    border-left-color:
        var(--success);
    background: #f1f7f3;
}

.status-callout strong,
.status-callout span,
.status-callout small {
    display: block;
}

.status-callout span {
    margin: 5px 0;
}

.status-callout small {
    color:
        var(--muted);
}

.empty-state {
    color:
        var(--muted);
    text-align: center;
    padding: 38px 12px;
}

.empty-state.compact {
    padding: 18px 8px;
}

.toolbar {
    padding: 12px;
    margin-bottom: 14px;
    box-shadow: none;
}

.search-form {
    display: flex;
    gap: 8px;
    width:
        min(
            620px,
            100%
        );
}

.search-form input {
    flex: 1;
}

.table-wrap {
    overflow: auto;
}

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

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

th {
    background:
        var(--surface-soft);
    color:
        var(--muted);
    font-size: 11px;
    text-transform:
        uppercase;
    letter-spacing:
        .055em;
    position: sticky;
    top: 0;
}

tr:last-child td {
    border-bottom: 0;
}

.actions-column {
    width: 140px;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.row-actions form {
    display: inline;
}

.entity-form {
    padding: 22px;
}

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

.field {
    min-width: 0;
}

.field.wide {
    grid-column:
        span 2;
}

.field label {
    display: block;
    font-size: 13px;
    font-weight: 650;
    margin-bottom: 6px;
}

input,
select,
textarea {
    width: 100%;
    border:
        1px solid #cfd6d0;
    border-radius: 9px;
    background: #fff;
    color:
        var(--text);
    padding: 10px 11px;
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color:
        var(--accent);
    box-shadow:
        0 0 0 3px
        rgba(32,77,58,.09);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.checkbox-row {
    display:
        inline-flex !important;
    align-items: center;
    gap: 8px;
    font-weight:
        500 !important;
}

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

.form-actions {
    justify-content:
        flex-end;
    border-top:
        1px solid
        var(--line);
    margin-top: 24px;
    padding-top: 18px;
}

.stack-form {
    display: grid;
    gap: 14px;
}

.compact-form {
    box-shadow: none;
    border: 0;
    padding: 0;
}

.top-space {
    margin-top: 18px;
}

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

.flash {
    margin: 0 0 18px;
    padding: 12px 14px;
    border-radius: 9px;
    border: 1px solid;
}

.flash-success {
    color: #1f5938;
    background: #eff8f2;
    border-color: #cfe5d6;
}

.flash-error {
    color: #7e2d28;
    background: #fff2f1;
    border-color: #efcfcc;
}

.flash ul {
    margin: 8px 0 0;
}

.active-work {
    display: flex;
    gap: 12px;
    align-items:
        flex-start;
    padding: 14px;
    background: #f1f7f3;
    border-radius: 10px;
}

.active-work p {
    margin: 4px 0;
    color:
        var(--muted);
}

.active-work small {
    color:
        var(--muted);
}

.running-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background:
        var(--success);
    margin-top: 6px;
    box-shadow:
        0 0 0 5px
        rgba(36,99,63,.1);
    flex: 0 0 auto;
}

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

.login-card {
    width:
        min(
            430px,
            100%
        );
    background: #fff;
    border:
        1px solid
        var(--line);
    border-radius: 18px;
    padding: 34px;
    box-shadow:
        var(--shadow);
}

.login-brand {
    color:
        var(--accent);
    font-weight: 800;
}

.login-card h1 {
    margin: 8px 0 4px;
    font-size: 30px;
    letter-spacing: -.03em;
}

.login-card > p {
    margin: 0 0 24px;
}

@media (
    max-width: 1100px
) {

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

}

@media (
    max-width: 820px
) {

    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        z-index: 50;
        left: 0;
        top: 0;
        transform:
            translateX(-105%);
        width: 280px;
        transition:
            transform .2s ease;
        box-shadow:
            12px 0 40px
            rgba(0,0,0,.18);
    }

    .sidebar.open {
        transform:
            translateX(0);
    }

    .mobile-header {
        display: flex;
        position: sticky;
        top: 0;
        z-index: 20;
        background:
            rgba(
                244,
                245,
                243,
                .94
            );
        backdrop-filter:
            blur(10px);
        border-bottom:
            1px solid
            var(--line);
        padding: 10px 16px;
        align-items: center;
        gap: 12px;
    }

    .menu-button {
        border:
            1px solid
            var(--line);
        background: #fff;
        border-radius: 8px;
        padding: 7px 10px;
    }

    .content {
        padding:
            22px 16px 40px;
    }

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

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

    .panel.span-2 {
        grid-column:
            span 1;
    }

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

    .field.wide {
        grid-column:
            span 1;
    }

    .search-form {
        width: 100%;
        flex-wrap: wrap;
    }

    .search-form input {
        min-width: 100%;
    }
}