* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: #f5f6f7;
    color: #1f2428;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", sans-serif;
}

a {
    color: #176b52;
    text-decoration: none;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 220px 1fr;
}

.sidebar {
    background: #111816;
    color: #fff;
    padding: 22px 18px;
}

.brand {
    font-size: 18px;
    font-weight: 800;
    margin-bottom: 4px;
}

.workspace {
    color: #9fb0aa;
    font-size: 12px;
    margin-bottom: 26px;
}

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

.nav a {
    color: #d9e2df;
    padding: 10px 12px;
    border-radius: 8px;
    font-weight: 700;
}

.nav a.active,
.nav a:hover {
    background: #20352e;
    color: #fff;
}

.content {
    padding: 26px;
}

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

h1 {
    margin: 0;
    font-size: 28px;
}

.hint {
    margin-top: 6px;
    color: #6b7470;
    line-height: 1.6;
    font-size: 13px;
}

.panel {
    background: #fff;
    border: 1px solid #dde3e0;
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 18px;
}

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

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

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

.metric {
    background: #fff;
    border: 1px solid #dde3e0;
    border-radius: 8px;
    padding: 16px;
}

.metric-label {
    color: #69736f;
    font-size: 13px;
}

.metric-value {
    margin-top: 8px;
    font-size: 26px;
    font-weight: 850;
}

.form-row {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.field {
    display: grid;
    gap: 6px;
    margin-bottom: 12px;
}

label {
    font-size: 13px;
    font-weight: 750;
    color: #2f3835;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid #cad3cf;
    border-radius: 8px;
    background: #fff;
    padding: 10px 12px;
    font: inherit;
}

textarea {
    min-height: 230px;
    resize: vertical;
    line-height: 1.6;
}

.textarea-compact {
    min-height: 110px;
}

.input-sm {
    width: 160px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #cad3cf;
    border-radius: 8px;
    min-height: 40px;
    padding: 0 14px;
    background: #fff;
    color: #1f2428;
    font-weight: 800;
    cursor: pointer;
}

.btn-primary {
    background: #176b52;
    border-color: #176b52;
    color: #fff;
}

.btn-danger {
    background: #9f2d20;
    border-color: #9f2d20;
    color: #fff;
}

.action-row,
.form-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.form-actions {
    margin-bottom: 24px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.table th,
.table td {
    border-bottom: 1px solid #e5ebe8;
    padding: 10px 8px;
    text-align: left;
    vertical-align: top;
}

.table th {
    color: #5c6762;
    font-size: 12px;
    white-space: nowrap;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 3px 8px;
    background: #eef2f1;
    color: #52615b;
    font-size: 12px;
    font-weight: 800;
}

.badge-paid {
    background: #e0f2ea;
    color: #176b52;
}

.badge-warn {
    background: #fff0d9;
    color: #94610e;
}

.flash {
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 16px;
    background: #e8f3ee;
    color: #176b52;
    border: 1px solid #cfe8dc;
}

.flash.error {
    background: #fff0ed;
    color: #9f2d20;
    border-color: #facdc6;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.auth-box {
    width: min(440px, 100%);
    background: #fff;
    border: 1px solid #dde3e0;
    border-radius: 8px;
    padding: 24px;
}

.order-preview {
    border-top: 1px solid #e5ebe8;
    padding-top: 16px;
    margin-top: 16px;
}

.item-box {
    background: #f8faf9;
    border: 1px solid #dde3e0;
    border-radius: 8px;
    padding: 12px;
    margin-top: 10px;
}

.muted {
    color: #69736f;
}

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

    .sidebar {
        position: static;
    }

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

    .grid-2,
    .grid-4 {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .content {
        padding: 14px;
    }

    .sidebar {
        padding: 16px 14px;
    }

    .nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }

    .nav a {
        padding: 9px 8px;
        text-align: center;
        font-size: 13px;
    }

    .topbar {
        margin-bottom: 14px;
    }

    h1 {
        font-size: 24px;
    }

    h2 {
        font-size: 19px;
    }

    .panel,
    .metric,
    .auth-box {
        padding: 14px;
    }

    .form-row {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .input-sm,
    .form-row input,
    .form-row select,
    .form-row .btn,
    input[type="file"] {
        width: 100%;
        max-width: 100%;
    }

    .btn {
        width: 100%;
        min-height: 42px;
    }

    .action-row,
    .form-actions {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .responsive-table {
        border-collapse: separate;
        border-spacing: 0 10px;
    }

    .responsive-table thead {
        display: none;
    }

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

    .responsive-table tr {
        border: 1px solid #dde3e0;
        border-radius: 8px;
        padding: 10px 12px;
        background: #fff;
    }

    .responsive-table td {
        border-bottom: 0;
        padding: 7px 0;
        word-break: break-word;
    }

    .responsive-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 3px;
        color: #69736f;
        font-size: 12px;
        font-weight: 800;
    }

    .responsive-table td:first-child {
        padding-top: 0;
    }

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

    .edit-table input {
        width: 100%;
    }
}
