:root {
    color-scheme: light;
    --bg: #f4f6f5;
    --surface: #ffffff;
    --surface-soft: #eef3f1;
    --border: #d8dfdc;
    --text: #17201d;
    --muted: #65736e;
    --primary: #1d6b55;
    --primary-dark: #134c3d;
    --accent: #205c7a;
    --danger: #9d2f35;
    --warning: #8a6914;
    --shadow: 0 10px 30px rgba(22, 32, 29, .08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

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

button,
input,
select {
    font: inherit;
}

.topbar {
    min-height: 64px;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    white-space: nowrap;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: white;
}

.nav {
    display: flex;
    gap: 6px;
    flex: 1;
}

.nav a {
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--muted);
}

.nav a:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--muted);
}

.page {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 48px;
}

.page-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.page-heading h1,
.auth-panel h1,
.section-header h2 {
    margin: 0;
}

.page-heading h1 {
    font-size: 30px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

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

.metric,
.panel,
.auth-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.metric {
    padding: 18px;
    min-height: 104px;
}

.metric span {
    display: block;
    color: var(--muted);
    margin-bottom: 10px;
}

.metric strong {
    display: block;
    font-size: 28px;
}

.panel {
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

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

.filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) minmax(180px, .8fr) minmax(180px, .8fr) auto;
    gap: 12px;
    align-items: end;
}

.filter-bar.single {
    grid-template-columns: minmax(220px, 1fr) auto;
}

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

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

input,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--text);
    padding: 9px 11px;
}

input:focus,
select:focus {
    outline: 3px solid rgba(29, 107, 85, .16);
    border-color: var(--primary);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.check-row input {
    width: 16px;
    min-height: 16px;
}

.check-row span {
    margin: 0;
    font-weight: 400;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.button {
    min-height: 40px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 9px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

.button-primary {
    background: var(--primary);
    color: white;
}

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

.button-accent {
    background: var(--accent);
    color: white;
}

.button-accent:hover {
    background: #16445c;
}

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

.button-ghost:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.auth-shell {
    min-height: calc(100vh - 130px);
    display: grid;
    place-items: center;
}

.auth-panel {
    width: min(420px, 100%);
    padding: 28px;
    box-shadow: var(--shadow);
}

.auth-panel h1 {
    margin-bottom: 22px;
}

.form-error {
    margin: 0;
    color: var(--danger);
    font-weight: 700;
}

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

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

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

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

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    padding: 4px 8px;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.badge-ok {
    background: #e4f2ec;
    color: var(--primary-dark);
}

.badge-muted {
    background: #f3eedf;
    color: var(--warning);
}

.badge-danger {
    background: #f9e3e5;
    color: var(--danger);
}

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

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

.quick-bill-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    min-width: 188px;
}

.quick-bill-actions form {
    margin: 0;
}

.alert-success {
    margin-bottom: 14px;
    padding: 12px 14px;
    border: 1px solid #b7dfce;
    border-radius: 8px;
    background: #e7f6ef;
    color: var(--primary-dark);
    font-weight: 700;
}

.billing-layout {
    display: grid;
    grid-template-columns: minmax(260px, .9fr) minmax(320px, 1.1fr);
    gap: 16px;
}

.customer-summary h2 {
    font-size: 22px;
}

.details-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.details-list div {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.details-list dt {
    color: var(--muted);
    font-weight: 700;
}

.details-list dd {
    margin: 0;
}

.total-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    border-radius: 8px;
    background: var(--surface-soft);
}

.total-box span {
    color: var(--muted);
    font-weight: 700;
}

.total-box strong {
    font-size: 24px;
}

.empty,
.muted,
.subtext {
    color: var(--muted);
}

.subtext {
    display: block;
    margin-top: 4px;
    font-size: 12px;
}

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

.chip {
    min-height: 30px;
    padding: 6px 10px;
    border-radius: 8px;
    background: var(--surface-soft);
    color: var(--text);
}

.pagination-row {
    margin-top: 16px;
}

@media (max-width: 760px) {
    .topbar {
        align-items: stretch;
        flex-direction: column;
        padding: 12px 16px;
        gap: 12px;
    }

    .nav,
    .user-menu,
    .page-heading,
    .filter-actions {
        width: 100%;
    }

    .user-menu,
    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .nav {
        overflow-x: auto;
    }

    .page {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .filter-bar,
    .filter-bar.single,
    .billing-layout {
        grid-template-columns: 1fr;
    }

    .details-list div {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .filter-actions .button {
        flex: 1;
    }
}
