:root {
    --color-primary: #0d5c2f;
    --color-primary-dark: #094321;
    --color-bg: #f4f6f5;
    --color-card: #ffffff;
    --color-border: #e0e3e1;
    --color-text: #1a1f1c;
    --color-muted: #6b7570;
    --color-error: #b3261e;
    --color-error-bg: #fbeae9;
    --color-success: #1e6b3c;
    --color-success-bg: #e7f5ec;
    --color-warning: #8a6100;
    --color-warning-bg: #fff6e0;
    --radius: 10px;
    --sidebar-width: 220px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    font-size: 16px;
    line-height: 1.5;
}

h1 { font-size: 1.4rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Auth ---------- */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1rem;
}
.auth-box {
    background: var(--color-card);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.07);
}
.auth-box h1 { text-align: center; margin-bottom: 1.5rem; }
.auth-box h1 span { color: var(--color-primary); }

/* ---------- Layout ---------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--color-primary);
    color: #fff;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar .brand { font-weight: 600; flex: 1; }
.topbar .logout-link { color: #fff; opacity: 0.85; }
.menu-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    display: none;
}

.layout { display: flex; min-height: calc(100vh - 52px); }

.sidebar {
    width: var(--sidebar-width);
    background: #fff;
    border-right: 1px solid var(--color-border);
    padding: 1rem 0;
    display: flex;
    flex-direction: column;
}
.sidebar a {
    padding: 0.65rem 1.25rem;
    color: var(--color-text);
}
.sidebar a:hover { background: var(--color-bg); text-decoration: none; }

.content {
    flex: 1;
    padding: 1.25rem;
    max-width: 1100px;
}

/* ---------- Components ---------- */
.card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
}
.tile {
    display: block;
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem 1rem;
    text-align: center;
    font-weight: 600;
    color: var(--color-text);
}
.tile:hover { border-color: var(--color-primary); text-decoration: none; }

.big-number { font-size: 2.2rem; font-weight: 700; color: var(--color-primary); margin: 0.25rem 0; }

form label {
    display: block;
    margin-bottom: 0.8rem;
    font-size: 0.9rem;
    color: var(--color-muted);
}
input, select, textarea {
    width: 100%;
    padding: 0.6rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
    margin-top: 0.25rem;
    background: #fff;
    color: var(--color-text);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

button {
    cursor: pointer;
    border: none;
    border-radius: 6px;
    padding: 0.65rem 1.1rem;
    background: var(--color-primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
}
button:hover { background: var(--color-primary-dark); }
.btn-small { padding: 0.4rem 0.7rem; font-size: 0.85rem; }
.btn-danger { background: var(--color-error); }
.btn-danger:hover { background: #8a1d17; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}
.alert-error { background: var(--color-error-bg); color: var(--color-error); }
.alert-success { background: var(--color-success-bg); color: var(--color-success); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); }

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

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin: 1rem 0;
    font-size: 0.9rem;
}
.pagination a { font-weight: 600; }
.pagination-disabled { color: var(--color-muted); }
.page-info { color: var(--color-muted); }

@media print {
    .topbar, .sidebar, .no-print, .alert { display: none !important; }
    .layout { display: block !important; }
    .content { padding: 0 !important; max-width: 100% !important; }
    body { background: #fff; }
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-card);
    border-radius: var(--radius);
    overflow: hidden;
}
th, td {
    text-align: left;
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
    font-size: 0.92rem;
}
th { background: var(--color-bg); font-weight: 600; }
tr:last-child td { border-bottom: none; }

/* ---------- Mobile ---------- */
@media (max-width: 780px) {
    .menu-toggle { display: block; }
    .sidebar {
        position: fixed;
        top: 52px;
        left: -100%;
        bottom: 0;
        z-index: 30;
        transition: left 0.2s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    .sidebar.open { left: 0; }
    .content { padding: 1rem 0.75rem; }
    th, td { white-space: normal; }
}
