:root {
    --bg: #f6f7f5;
    --panel: #ffffff;
    --line: #d7ddd7;
    --text: #17201b;
    --muted: #647067;
    --accent: #045c43;
    --accent-2: #1f6f9b;
    --danger: #a93324;
}

* {
    box-sizing: border-box;
}

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

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 22px 16px;
    border-right: 1px solid var(--line);
    background: var(--panel);
}

.sidebar h1 {
    margin: 0 0 18px;
    font-size: 1.35rem;
}

.sidebar nav {
    display: grid;
    gap: 12px;
    margin-bottom: 24px;
}

.sidebar a {
    color: var(--text);
    text-decoration: none;
    padding: 10px;
    border-radius: 8px;
    background: rgba(4, 92, 67, 0.06);
}

.content {
    width: min(100%, 1440px);
    padding: clamp(14px, 2.4vw, 28px);
    margin: 0 auto;
}

.content--centered {
    grid-column: 1 / -1;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 16px;
    min-height: 100vh;
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: clamp(14px, 2vw, 20px);
    box-shadow: 0 8px 22px rgba(23, 32, 27, 0.05);
    margin-bottom: 16px;
}

.login-panel {
    width: min(420px, calc(100vw - 32px));
}

.content--centered .flash-stack {
    width: min(420px, calc(100vw - 32px));
}

.header-row,
.filter-row,
.button-row,
.action-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    display: grid;
    gap: 6px;
    min-width: 0;
}

.stat-card span,
.detail-grid span,
label span,
.muted {
    color: var(--muted);
}

.stat-card strong,
.detail-grid strong {
    font-size: 1.05rem;
    overflow-wrap: anywhere;
}

.split-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
    gap: 16px;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
    margin-bottom: 12px;
}

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

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

.wide {
    grid-column: 1 / -1;
}

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

input,
select,
button {
    width: 100%;
    max-width: 100%;
    border-radius: 8px;
    border: 1px solid var(--line);
    padding: 10px 11px;
    font: inherit;
}

button {
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

button:hover {
    transform: translateY(-1px);
    opacity: 0.95;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.55;
    transform: none;
}

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

button.btn-delete {
    background: #c0392b;
    color: #fff;
    padding: 5px 12px;
    min-height: unset;
    font-size: 0.8rem;
    border-radius: 8px;
}

button.btn-delete:hover {
    background: #96281b;
}

.button-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: var(--accent);
    color: #fff;
    text-decoration: none;
}

.button-link.is-disabled {
    pointer-events: none;
    opacity: 0.5;
}

.action-row {
    justify-content: flex-end;
    flex-wrap: wrap;
}

.button-row > *,
.action-row > * {
    flex: 0 1 auto;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-wrap {
    overflow-x: auto;
    max-width: 100%;
    border: 1px solid rgba(100, 112, 103, 0.16);
    border-radius: 8px;
}

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

th,
td {
    text-align: left;
    padding: 10px;
    border-bottom: 1px solid rgba(113, 102, 87, 0.18);
    white-space: nowrap;
    font-size: 0.92rem;
}

.log-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: grid;
    gap: 12px;
}

.log-list li {
    border-left: 3px solid var(--accent-2);
    padding-left: 12px;
    min-width: 0;
}

.log-list p {
    margin: 6px 0 0;
    overflow-wrap: anywhere;
}

.flash-stack {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
}

.flash {
    border-radius: 12px;
    padding: 12px 14px;
}

.flash-success {
    background: rgba(4, 92, 67, 0.12);
    color: var(--accent);
}

.flash-error {
    background: rgba(169, 51, 36, 0.12);
    color: var(--danger);
}

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

    .sidebar {
        position: static;
        height: auto;
        padding: 14px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .sidebar h1 {
        margin-bottom: 12px;
    }

    .sidebar nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 12px;
    }

    .sidebar form {
        margin: 0;
    }

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

    .header-row,
    .filter-row,
    .button-row,
    .action-row {
        flex-direction: column;
        align-items: stretch;
    }

    .button-row > *,
    .action-row > *,
    .button-link {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .content {
        padding: 10px;
    }

    .panel,
    .stat-card {
        padding: 12px;
    }

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

    h2,
    h3 {
        margin-top: 0;
    }

    th,
    td {
        padding: 8px;
        font-size: 0.85rem;
    }
}

@media print {
    body {
        background: #fff;
    }

    .shell {
        display: block;
    }

    .sidebar,
    .flash-stack,
    .no-print {
        display: none !important;
    }

    .content {
        padding: 0;
    }

    .panel {
        box-shadow: none;
        border: 1px solid #c9c9c9;
        break-inside: avoid;
    }

    table {
        font-size: 12px;
    }

    th,
    td {
        white-space: normal;
    }
}
