:root {
    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --text: #14213d;
    --muted: #5f6b7a;
    --primary: #0b6e4f;
    --primary-strong: #084c3f;
    --accent: #f4a261;
    --danger: #c44536;
    --warn: #d89f2a;
    --ok: #2a9d8f;
    --border: #d9e1ea;
    --shadow: 0 10px 28px rgba(20, 33, 61, 0.08);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: linear-gradient(180deg, #f7fafc 0%, #edf2f7 100%);
    color: var(--text);
    font-family: "Segoe UI", "Noto Sans", "Helvetica Neue", sans-serif;
}

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

.app-shell {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px 28px;
}

.top-nav {
    background: linear-gradient(135deg, #1f3a5f 0%, #0d2845 100%);
    color: #fff;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

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

.brand-title {
    margin: 0;
    font-size: 1.1rem;
}

.brand-sub {
    margin: 0;
    opacity: 0.75;
    font-size: 0.78rem;
}

.menu-toggle {
    display: none;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: 10px;
    min-height: 44px;
    min-width: 44px;
    padding: 8px 12px;
    cursor: pointer;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-link {
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.85);
    display: inline-flex;
    align-items: center;
    font-weight: 600;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
}

.page-head {
    margin: 10px 0 14px;
}

.page-title {
    margin: 0;
    font-size: 1.4rem;
}

.page-note {
    margin: 6px 0 0;
    color: var(--muted);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 12px;
    margin: 14px 0 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--shadow);
}

.stat-label {
    margin: 0;
    color: var(--muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    margin: 8px 0 0;
    font-size: 1.35rem;
    font-weight: 700;
}

.layout-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
}

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
    padding: 16px;
}

.panel-title {
    margin: 0 0 12px;
    font-size: 1.05rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

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

label {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
}

input,
select,
button {
    font: inherit;
}

input,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
}

.form-note {
    margin: 2px 0 0;
    font-size: 0.75rem;
    color: var(--muted);
}

.btn {
    border: none;
    border-radius: 10px;
    min-height: 44px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

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

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

.btn.muted {
    background: #e8edf4;
    color: var(--text);
}

.btn.muted:hover {
    background: #dde5ef;
}

.btn.warn {
    background: var(--accent);
    color: #2c1a0f;
}

.btn.small {
    min-height: 36px;
    padding: 8px 10px;
    font-size: 0.84rem;
}

.btn.link {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.toolbar-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-btn {
    border: 1px solid var(--border);
    border-radius: 999px;
    min-height: 38px;
    padding: 8px 12px;
    background: #fff;
    color: var(--text);
    cursor: pointer;
    font-weight: 600;
}

.filter-btn.active {
    background: #1f3a5f;
    border-color: #1f3a5f;
    color: #fff;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

.responsive-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.responsive-table th,
.responsive-table td {
    border-bottom: 1px solid var(--border);
    padding: 10px 8px;
    vertical-align: top;
}

.responsive-table thead th {
    text-align: left;
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--surface-2);
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.code {
    font-family: "Fira Mono", "Consolas", monospace;
    font-size: 0.82rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: 0.76rem;
    font-weight: 700;
}

.badge.in {
    background: rgba(42, 157, 143, 0.18);
    color: #085f55;
}

.badge.low {
    background: rgba(216, 159, 42, 0.18);
    color: #704c00;
}

.badge.out,
.badge.pending {
    background: rgba(196, 69, 54, 0.15);
    color: #7a1f14;
}

.badge.paid {
    background: rgba(42, 157, 143, 0.18);
    color: #085f55;
}

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.empty {
    text-align: center;
    padding: 22px;
    color: var(--muted);
    border: 1px dashed var(--border);
    border-radius: 12px;
    background: #fafcff;
}

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

.page-label {
    color: var(--muted);
    font-weight: 600;
}

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

.summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
}

.summary-label {
    margin: 0;
    font-size: 0.76rem;
    color: var(--muted);
    text-transform: uppercase;
}

.summary-value {
    margin: 7px 0 0;
    font-size: 1rem;
    font-weight: 700;
}

@media (max-width: 1024px) and (min-width: 641px) {
    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .hide-tablet {
        display: none;
    }

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

@media (max-width: 640px) {
    .app-shell {
        padding: 0 10px 20px;
    }

    .menu-toggle {
        display: inline-flex;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 8px;
        right: 8px;
        background: #0d2845;
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 12px;
        padding: 8px;
        z-index: 20;
        flex-direction: column;
        align-items: stretch;
    }

    body.nav-open .nav-links {
        display: flex;
    }

    .nav-link {
        width: 100%;
        justify-content: center;
    }

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

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

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

    .toolbar {
        align-items: stretch;
    }

    .toolbar-row {
        width: 100%;
    }

    .toolbar-row input {
        width: 100%;
    }

    .responsive-table thead {
        display: none;
    }

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

    .responsive-table tr {
        margin-bottom: 0.9rem;
        border: 1px solid var(--border);
        border-radius: 12px;
        background: #fff;
        overflow: hidden;
        box-shadow: var(--shadow);
    }

    .responsive-table td {
        border-bottom: 1px solid #eef3f8;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 11px 12px;
        text-align: right;
    }

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

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

    .row-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .btn {
        width: 100%;
    }

    .pagination {
        flex-direction: column;
        gap: 8px;
    }

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