* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
    background: #f5f6fa;
    color: #1f2937;
}

a {
    color: inherit;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 18px 24px;
    background: #111827;
    color: #fff;
}

.topbar h1 {
    margin: 0 0 4px;
    font-size: 22px;
}

.topbar p {
    margin: 0;
    color: #cbd5e1;
    font-size: 14px;
}

.container {
    width: min(1180px, calc(100% - 24px));
    margin: 18px auto 48px;
}

.panel {
    background: #fff;
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 18px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.panel-title {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.panel-title h2 {
    margin: 0 0 4px;
    font-size: 19px;
}

.muted {
    color: #6b7280;
    font-size: 13px;
    margin: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.stat-card {
    background: #fff;
    border-radius: 16px;
    padding: 18px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    border: 1px solid #eef2f7;
}

.stat-card.total {
    border-color: #111827;
}

.stat-label {
    color: #6b7280;
    font-size: 14px;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.bill-form {
    display: grid;
    grid-template-columns: 1.1fr 1fr 1fr 1fr;
    gap: 14px;
}

.bill-form .wide {
    grid-column: span 3;
}

.form-actions {
    display: flex;
    align-items: end;
}

label {
    display: block;
    font-size: 13px;
    margin-bottom: 6px;
    color: #374151;
    font-weight: 600;
}

input,
select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 10px;
    height: 40px;
    padding: 0 11px;
    background: #fff;
    outline: none;
}

input:focus,
select:focus {
    border-color: #111827;
    box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.08);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #111827;
    text-decoration: none;
    cursor: pointer;
    font-weight: 700;
    white-space: nowrap;
}

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

.btn.ghost {
    background: transparent;
    color: #fff;
    border-color: rgba(255, 255, 255, 0.35);
}

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

.btn.full {
    width: 100%;
}

.small-btn {
    min-height: 32px;
    padding: 0 10px;
    border-radius: 8px;
    font-size: 12px;
}

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

.filter-row select,
.filter-row input {
    width: auto;
    min-width: 160px;
}

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

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

th,
td {
    padding: 12px 10px;
    border-bottom: 1px solid #eef2f7;
    text-align: left;
    vertical-align: top;
    font-size: 14px;
}

th {
    color: #6b7280;
    font-weight: 800;
    background: #f9fafb;
}

.money {
    font-weight: 800;
}

.small {
    font-size: 12px;
    line-height: 1.65;
    color: #4b5563;
}

.empty {
    text-align: center;
    color: #6b7280;
    padding: 32px;
}

.row-muted {
    background: #f9fafb;
    color: #6b7280;
}

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

.badge.ok {
    background: #dcfce7;
    color: #166534;
}

.badge.warn {
    background: #fef3c7;
    color: #92400e;
}

.alert {
    border-radius: 12px;
    padding: 12px 14px;
    margin-bottom: 14px;
    font-size: 14px;
}

.alert.success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert.danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: radial-gradient(circle at top, #e5e7eb, #f8fafc);
}

.login-card {
    width: min(420px, 100%);
    background: #fff;
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.12);
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 24px;
}

.login-card h2 {
    margin: 18px 0 10px;
    font-size: 16px;
}

.login-card form {
    margin-top: 18px;
}

.login-card input {
    margin-bottom: 12px;
}

.inline-form {
    margin: 0;
}

@media (max-width: 760px) {
    .topbar {
        padding: 14px;
    }

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

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

    .bill-form .wide {
        grid-column: span 1;
    }

    .form-actions .btn {
        width: 100%;
    }

    .filter-row select,
    .filter-row input,
    .filter-row .btn {
        width: 100%;
    }
}


.link-row {
    margin-top: 14px;
    text-align: center;
    font-size: 14px;
}

.link-row a {
    color: #111827;
    font-weight: 700;
}
