:root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --text: #1f2430;
    --muted: #6b7280;
    --border: #e5e7eb;
    --sidebar: #111827;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #2563eb;
    --accent: #2563eb;
    --green: #16a34a;
    --red: #dc2626;
    --purple: #7c3aed;
    --amber: #d97706;
    --radius: 10px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

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

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

.nav-toggle {
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 1100;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: var(--sidebar);
    color: #fff;
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.nav-toggle:hover { background: #1f2937; }

.nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 999;
}

.sidebar {
    width: 230px;
    flex-shrink: 0;
    background: var(--sidebar);
    color: var(--sidebar-text);
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    transition: width .2s ease;
}

/* Desktop: collapsed via toggle button (hidden by default only when this class is present) */
html.desktop-nav-collapsed .sidebar {
    width: 0;
    min-width: 0;
    padding: 0;
    overflow: hidden;
    border: none;
}
html.desktop-nav-collapsed .sidebar > * {
    display: none;
}

.sidebar .brand {
    font-size: 1.2rem;
    font-weight: 700;
    color: #fff;
    padding: 0 20px 20px 60px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    margin-bottom: 10px;
    white-space: nowrap;
}

.sidebar nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar nav a {
    color: var(--sidebar-text);
    padding: 12px 20px;
    text-decoration: none;
    font-size: .95rem;
    border-left: 3px solid transparent;
}

.sidebar nav a:hover { background: rgba(255,255,255,.06); }

.sidebar nav a.active {
    background: rgba(37,99,235,.15);
    border-left-color: var(--sidebar-active);
    color: #fff;
    font-weight: 600;
}

.sidebar .spacer { flex: 1; }

.sidebar .logout {
    padding: 12px 20px;
    color: #f87171;
    font-size: .9rem;
}

.content { flex: 1; padding: 28px 34px; max-width: 1200px; }

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 22px;
}

.page-header h1 { margin: 0; font-size: 1.5rem; }

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.card h2 { margin-top: 0; font-size: 1.05rem; }

.grid-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    border-top: 4px solid var(--accent);
}

.stat.green { border-top-color: var(--green); }
.stat.red { border-top-color: var(--red); }
.stat.blue { border-top-color: var(--accent); }
.stat.purple { border-top-color: var(--purple); }
.stat.amber { border-top-color: var(--amber); }

.stat .label { color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.5rem; font-weight: 700; margin-top: 6px; }
.stat .sub { color: var(--muted); font-size: .82rem; margin-top: 4px; }

form .form-row {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

form .field { flex: 1; min-width: 160px; display: flex; flex-direction: column; gap: 6px; }

label { font-size: .85rem; color: var(--muted); font-weight: 600; }

input[type=text], input[type=number], input[type=date], input[type=password], select {
    padding: 9px 11px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 16px;
    background: #fff;
    color: var(--text);
    width: 100%;
}

input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.btn {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 7px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
}

.btn:hover { background: #1d4ed8; }
.btn.secondary { background: #e5e7eb; color: var(--text); }
.btn.secondary:hover { background: #d1d5db; }
.btn.danger { background: var(--red); }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 5px 11px; font-size: .82rem; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f9fafb; }

.badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
}
.badge.activ { background: #dcfce7; color: #166534; }
.badge.incheiat { background: #f3f4f6; color: #6b7280; }
.badge.viitor { background: #fef3c7; color: #92400e; }
.badge.ok { background: #dcfce7; color: #166534; }
.badge.atentie { background: #fef3c7; color: #92400e; }
.badge.urgent { background: #fee2e2; color: #991b1b; }

.alert-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: .88rem;
}
.alert-row.ok { background: #f0fdf4; }
.alert-row.atentie { background: #fffbeb; }
.alert-row.urgent { background: #fef2f2; }

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

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: .9rem; }
.alert.error { background: #fee2e2; color: #991b1b; }
.alert.success { background: #dcfce7; color: #166534; }

.empty { color: var(--muted); padding: 20px 0; text-align: center; }

.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #111827, #1f2937);
    padding: 20px;
}

.login-box {
    background: #fff;
    padding: 36px 34px;
    border-radius: 14px;
    width: 100%;
    max-width: 320px;
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-box h1 { margin: 0 0 6px; font-size: 1.4rem; }
.login-box p.sub { color: var(--muted); margin: 0 0 22px; font-size: .88rem; }
.login-box .btn { width: 100%; margin-top: 6px; }

.hint {
    color: var(--muted);
    font-size: .78rem;
    margin-top: 16px;
    line-height: 1.4;
}

@media (max-width: 800px) {
    .layout { flex-direction: column; }

    /* Sidebar devine un sertar ascuns implicit, deschis prin butonul ☰ */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 250px;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform .25s ease;
        padding: 20px 0;
        overflow-y: auto;
    }

    html.mobile-nav-open .sidebar {
        transform: translateX(0);
    }

    html.mobile-nav-open .nav-backdrop {
        display: block;
    }

    .sidebar .brand {
        padding: 44px 16px 12px;
        margin-bottom: 8px;
        font-size: 1.05rem;
        white-space: normal;
    }

    .content { padding: 16px; padding-top: 68px; }

    .page-header h1 { font-size: 1.25rem; }

    .card { padding: 16px; }

    form .form-row { gap: 10px; margin-bottom: 12px; }
    form .field { min-width: 100%; }

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

    .btn { padding: 11px 18px; }
    .btn.small { padding: 8px 13px; }

    table { font-size: .84rem; }
    th, td { padding: 8px 6px; }

    .actions { width: 100%; }
    .actions form { flex: 1; }
    .actions .btn { flex: 1; text-align: center; }
}
