:root {
    --bg: #f3f5fa;
    --panel: #ffffff;
    --accent: #0064b4;
    --accent-soft: #e2f0ff;
    --accent2: #009688;
    --danger: #c62828;
    --text: #222;
    --muted: #6b7280;
    --border: #d1d5db;
    --shadow: 0 2px 6px rgba(15, 23, 42, .08);
    --radius: 10px;
    --radius-sm: 6px;
    --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Reset / Core */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font);
    background: radial-gradient(circle at top left, #e0edff, #f3f5fa 45%);
    color: var(--text);
}

/* Topbar */
.topbar {
    background: linear-gradient(120deg, var(--accent), #00396b);
    color: #fff;
    box-shadow: 0 4px 8px rgba(15, 23, 42, .25);
}

.topbar-inner {
    max-width: 1120px;
    margin: 0 auto;
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo-circle {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    background: #ffca28;
    color: #263238;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .7);
}

.topbar-title {
    font-weight: 700;
    font-size: 17px;
}

.topbar-subtitle {
    font-size: 12px;
    opacity: .9;
}

.topbar-nav a {
    color: #e3f2fd;
    text-decoration: none;
    margin-left: 12px;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 999px;
    transition: background .15s ease, color .15s ease;
}

.topbar-nav a:hover {
    background: rgba(255, 255, 255, .15);
}

.topbar-nav .nav-logout {
    background: rgba(0, 0, 0, .2);
}

/* Layout */
.container {
    max-width: 1120px;
    margin: 22px auto 40px;
    padding: 0 18px;
}

.footer {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    padding: 12px 0 18px;
}

/* Cards */
.card {
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 18px 18px;
    margin-bottom: 18px;
    border: 1px solid rgba(148,163,184,.25);
}

.card h2 {
    margin-top: 0;
    font-size: 18px;
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

/* Filters */
.filters form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-end;
}

.filters input[type="text"],
.filters select {
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 14px;
    min-width: 150px;
    background: #f9fafb;
}

.filters-actions {
    display: flex;
    gap: 6px;
}

/* Buttons */
button,
input[type="submit"],
a.button {
    border: none;
    border-radius: var(--radius-sm);
    background: var(--accent);
    color: #fff;
    padding: 7px 13px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .18);
    transition: background .15s ease, transform .05s ease, box-shadow .15s ease;
}

button:hover,
input[type="submit"]:hover,
a.button:hover {
    background: #00519a;
    transform: translateY(-1px);
    box-shadow: 0 3px 7px rgba(15,23,42,.25);
}

.button-light {
    background: #eef2ff;
    color: #1e293b;
}

.button-light:hover {
    background: #e0e7ff;
}

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

.button-danger:hover {
    background: #b71c1c;
}

.button-small {
    padding: 4px 8px;
    font-size: 13px;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

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

th, td {
    padding: 8px 6px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

th {
    background: var(--accent-soft);
    font-weight: 600;
    font-size: 13px;
    color: #1f2937;
}

tbody tr:nth-child(even) td {
    background: #f9fafb;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}

.badge-green {
    background: #e6f4ea;
    color: #137333;
}

.badge-red {
    background: #fce8e6;
    color: #c5221f;
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px 18px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 4px;
}

.form-group-full {
    grid-column: 1 / -1;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group textarea {
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 14px;
    background: #f9fafb;
}

.form-group textarea {
    min-height: 70px;
    resize: vertical;
}

.checkbox-inline {
    font-size: 14px;
    color: #374151;
}

.form-actions {
    margin-top: 10px;
    display: flex;
    gap: 8px;
}

/* Flash messages */
.flash {
    padding: 8px 10px;
    margin-bottom: 10px;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.flash-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.flash-ok {
    background: #ecfdf3;
    color: #166534;
    border: 1px solid #bbf7d0;
}

/* Totals list */
.totals-list {
    list-style: none;
    padding-left: 0;
    margin: 10px 0 0;
}

.totals-list li {
    margin-bottom: 2px;
}

/* Login */
.login-body {
    background: radial-gradient(circle at top, #dbeafe, #eef2ff 45%, #f9fafb);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-wrapper {
    max-width: 380px;
    width: 100%;
    padding: 0 16px;
}

.login-card {
    background: #ffffff;
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(15,23,42,.18);
    padding: 20px;
    border: 1px solid rgba(148,163,184,.35);
}

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

.login-header .logo-circle {
    margin: 0 auto 8px;
}

.login-header h1 {
    margin: 0;
    font-size: 20px;
}

.login-header p {
    margin: 4px 0 10px;
    font-size: 13px;
    color: var(--muted);
}

.login-form .form-group {
    margin-bottom: 8px;
}

.login-form input {
    width: 100%;
}

.login-form .form-actions {
    margin-top: 12px;
}

.login-form button {
    width: 100%;
}

.login-footnote {
    margin-top: 10px;
    font-size: 11px;
    color: var(--muted);
    text-align: center;
}

/* RESPONSIVE FIXES */
@media (max-width: 720px) {

    .filters form {
        flex-direction: column;
        width: 100%;
    }

    .filters input,
    .filters select {
        width: 100%;
    }

    button,
    a.button,
    input[type="submit"] {
        width: 100%;
    }

    table th, table td {
        padding: 6px 4px;
        font-size: 13px;
    }

    .card {
        padding: 14px;
    }

    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .topbar-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .topbar-nav a {
        margin-left: 0;
    }
    .card-warning {
    border-left: 4px solid #c62828;
    background: #fff5f5;
}

}
