:root {
    --bg: #f4f1e9;
    --panel: #ffffff;
    --ink: #1f2822;
    --muted: #647067;
    --line: #ded9cc;
    --brand: #2f7d57;
    --brand-dark: #1f5d40;
    --warn: #a64d1f;
    --danger: #a93636;
    --soft: #eef6f1;
    --shadow: 0 14px 34px rgba(31, 41, 35, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.45;
}

.page {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
    padding: 24px 0 48px;
}

.topbar,
.section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
}

.topbar {
    margin-bottom: 18px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 4px;
    font-size: clamp(28px, 5vw, 44px);
    letter-spacing: 0;
}

h2 {
    margin-bottom: 4px;
    font-size: 20px;
}

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

.quick-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

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

.metric,
.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric {
    padding: 15px;
}

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

.metric strong {
    display: block;
    margin-top: 7px;
    font-size: clamp(20px, 3vw, 30px);
}

.metric.pending strong {
    color: var(--warn);
}

.metric.profit strong {
    color: var(--brand-dark);
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 18px;
    align-items: start;
}

.side-stack {
    display: grid;
    gap: 18px;
}

.panel {
    padding: 18px;
}

.section-head {
    margin-bottom: 14px;
}

.section-head p {
    margin-bottom: 0;
}

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

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

label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    padding: 9px 10px;
}

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

.actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 14px;
}

.actions.split {
    justify-content: space-between;
}

.actions.split > div {
    display: flex;
    gap: 10px;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    border: 0;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 9px 14px;
    text-decoration: none;
    white-space: nowrap;
}

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

.button.secondary,
button.secondary {
    background: #e8ede9;
    color: var(--ink);
}

.button.danger {
    background: var(--danger);
}

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

.icon-button {
    width: 36px;
    min-width: 36px;
    height: 36px;
    min-height: 36px;
    padding: 0;
}

.notice {
    margin-bottom: 18px;
    border-radius: 8px;
    padding: 12px 14px;
    background: var(--soft);
    border: 1px solid #c8dfd2;
    color: var(--brand-dark);
}

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

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

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 11px 9px;
    text-align: left;
    vertical-align: middle;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.num {
    text-align: right;
    white-space: nowrap;
}

.status {
    display: inline-flex;
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
}

.status.paid {
    background: #dff2e7;
    color: #1f6c47;
}

.status.pending {
    background: #fff0d9;
    color: #8a4b13;
}

.row-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.empty {
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: #fffaf0;
}

.calc-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid #c8dfd2;
    border-radius: 8px;
    background: var(--soft);
    padding: 12px 14px;
}

.calc-preview span {
    color: var(--muted);
    font-weight: 700;
}

.calc-preview strong {
    color: var(--brand-dark);
    font-size: 22px;
}

.customer-list,
.mini-list {
    display: grid;
    gap: 10px;
}

.customer-item,
.mini-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

.customer-item:last-child,
.mini-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.customer-item span,
.mini-item span {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

.mini-item {
    align-items: flex-start;
}

.mini-item p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.mini-money {
    margin-left: auto;
    font-weight: 700;
    white-space: nowrap;
}

.modal {
    width: min(560px, calc(100% - 24px));
    max-height: calc(100dvh - 32px);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(18, 24, 20, 0.25);
    padding: 18px;
}

.modal::backdrop {
    background: rgba(25, 31, 27, 0.48);
}

.modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.modal-head p {
    margin-bottom: 0;
}

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

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

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

@media (max-width: 700px) {
    .page {
        width: min(100% - 20px, 1240px);
        padding-top: 16px;
    }

    .topbar,
    .section-head,
    .actions.split {
        align-items: stretch;
        flex-direction: column;
    }

    .quick-actions,
    .section-head button,
    .actions,
    .actions.split > div,
    .actions button {
        width: 100%;
    }

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

    .summary,
    .side-stack,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .panel {
        padding: 14px;
    }

    .table-wrap {
        overflow: visible;
    }

    .responsive-table,
    .responsive-table thead,
    .responsive-table tbody,
    .responsive-table th,
    .responsive-table td,
    .responsive-table tr {
        display: block;
        min-width: 0;
        width: 100%;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tr {
        border: 1px solid var(--line);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 10px;
        background: #fff;
    }

    .responsive-table td {
        display: flex;
        justify-content: space-between;
        gap: 14px;
        border-bottom: 1px solid var(--line);
        padding: 8px 0;
        text-align: right;
    }

    .responsive-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-weight: 700;
        text-align: left;
    }

    .responsive-table td:first-child,
    .responsive-table td:nth-child(2) {
        display: block;
        text-align: left;
    }

    .responsive-table td:first-child::before,
    .responsive-table td:nth-child(2)::before {
        display: block;
        margin-bottom: 2px;
    }

    .responsive-table td:last-child {
        border-bottom: 0;
    }

    .row-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .row-actions form,
    .row-actions button {
        width: 100%;
    }

    .modal {
        width: calc(100% - 18px);
        padding: 14px;
    }
}
