@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #f1f3f6;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --text: #1a1f2b;
    --muted: #6b7382;
    --border: #e4e7ec;
    --accent: #2f6f4f;
    --accent-soft: #e7f2ec;
    --accent-hover: #24593f;
    --error: #c0392b;
    --error-soft: #fbeae8;
    --warn: #b8860b;
    --warn-soft: #fdf3dd;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}

a { color: inherit; }

/* ---------- Login ---------- */

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, #1f3d2e 0%, #2f6f4f 55%, #3f8a63 100%);
}

.login-card {
    background: var(--surface);
    border-radius: 16px;
    padding: 2.5rem 2.5rem 2.2rem;
    width: 340px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.login-card .mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    margin: 0 auto 0.4rem;
}

.login-card h1 {
    font-size: 1.15rem;
    margin: 0;
    text-align: center;
    font-weight: 600;
}

.login-card .subtitle {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    margin: -0.6rem 0 0.4rem;
}

.login-card label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 500;
}

.login-card input {
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.login-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.login-card button {
    margin-top: 0.4rem;
    padding: 0.65rem;
    border: none;
    border-radius: 8px;
    background: var(--accent);
    color: white;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s;
}

.login-card button:hover { background: var(--accent-hover); }

.error {
    color: var(--error);
    background: var(--error-soft);
    border-radius: 8px;
    padding: 0.5rem 0.7rem;
    font-size: 0.85rem;
    margin: 0;
}

/* ---------- App shell ---------- */

.shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: #16281f;
    color: #eaf1ec;
    display: flex;
    flex-direction: column;
    padding: 1.2rem 0.9rem;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0 0.4rem 1.4rem;
    font-weight: 700;
    font-size: 1rem;
}

.sidebar .brand .mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
}

.sidebar .nav-section {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #7fa08e;
    margin: 1rem 0.6rem 0.3rem;
    font-weight: 600;
}

.sidebar .nav-section:first-child { margin-top: 0; }

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.55rem 0.7rem;
    border-radius: 8px;
    text-decoration: none;
    color: #cfe0d6;
    font-size: 0.88rem;
    font-weight: 500;
    transition: background 0.15s, color 0.15s;
}

.sidebar nav a:hover { background: rgba(255, 255, 255, 0.06); color: white; }
.sidebar nav a.active { background: var(--accent); color: white; }
.sidebar nav a .icon { font-size: 1rem; width: 1.1rem; text-align: center; }

.sidebar .user-box {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 0.9rem;
    margin-top: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar .user-box .avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #2c4638;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.sidebar .user-box .who { flex: 1; min-width: 0; }
.sidebar .user-box .name { font-size: 0.85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .user-box .role { font-size: 0.72rem; color: #8ea89a; text-transform: capitalize; }

.sidebar .logout-form button {
    background: transparent;
    border: none;
    color: #8ea89a;
    cursor: pointer;
    font-size: 0.95rem;
    padding: 0.3rem;
    border-radius: 6px;
}

.sidebar .logout-form button:hover { color: white; background: rgba(255, 255, 255, 0.08); }

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 2rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar h1 { font-size: 1.25rem; margin: 0; font-weight: 600; }
.topbar .muted { color: var(--muted); font-size: 0.85rem; }

.content { padding: 1.8rem 2rem; max-width: 1100px; width: 100%; margin: 0 auto; flex: 1; }

/* ---------- Cards / stats ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 1rem;
    margin-bottom: 1.8rem;
}

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

.stat-card .label { color: var(--muted); font-size: 0.8rem; font-weight: 500; margin-bottom: 0.35rem; }
.stat-card .value { font-size: 1.7rem; font-weight: 700; }
.stat-card .value small { font-size: 0.9rem; color: var(--muted); font-weight: 500; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.4rem;
}

.card .card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.3rem;
    border-bottom: 1px solid var(--border);
}

.card .card-head h2 { font-size: 1rem; margin: 0; font-weight: 600; }
.card .card-body { padding: 1.3rem; }
.card .card-body.tight { padding: 0; }

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--surface-2); }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.8rem; }

/* ---------- Tables ---------- */

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

table.data th {
    text-align: left;
    padding: 0.6rem 1rem;
    background: var(--surface-2);
    color: var(--muted);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-bottom: 1px solid var(--border);
}

table.data td {
    padding: 0.65rem 1rem;
    border-bottom: 1px solid var(--border);
}

table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: var(--surface-2); }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    border-radius: 100px;
    font-size: 0.72rem;
    font-weight: 600;
}

.badge-ok { background: var(--accent-soft); color: var(--accent); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-error { background: var(--error-soft); color: var(--error); }
.badge-muted { background: var(--surface-2); color: var(--muted); }

/* ---------- Forms ---------- */

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1.1rem;
}

.form-row label { font-size: 0.85rem; font-weight: 500; color: var(--text); }
.form-row .hint { font-size: 0.78rem; color: var(--muted); }

.form-row input[type="text"],
.form-row input[type="month"],
.form-row input[type="file"],
.form-row select {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    background: white;
}

.empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--muted);
}

.empty-state .big-icon { font-size: 2rem; margin-bottom: 0.6rem; opacity: 0.6; }

.flash {
    border-radius: 8px;
    padding: 0.7rem 1rem;
    font-size: 0.88rem;
    margin-bottom: 1.2rem;
}

.flash-ok { background: var(--accent-soft); color: var(--accent-hover); }
.flash-error { background: var(--error-soft); color: var(--error); }
.flash-warn { background: var(--warn-soft); color: var(--warn); }
