:root {
    --bg: #050505;
    --bg-soft: #111111;
    --bg-panel: #171717;
    --bg-panel-2: #1f1f1f;
    --bg-guest: #0b0b0b;
    --surface: #ffffff;
    --surface-soft: #f5f5f5;
    --text: #171717;
    --text-soft: #666666;
    --text-inverse: #ffffff;
    --line: #d9d9d9;
    --line-strong: #cccccc;
    --ok: #2f7d57;
    --danger: #b64a4a;
    --warn: #9a7a2f;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.08);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
    margin: 0;
    font-family: "Urbanist", "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
}

a {
    color: #222222;
    text-decoration: none;
}

a:hover { color: #000000; }

h1, h2, h3, h4 {
    margin: 0 0 14px;
    font-family: "Urbanist", "Segoe UI", Arial, sans-serif;
    font-weight: 700;
    letter-spacing: 0;
}

p { margin: 0 0 12px; }

.app-body {
    background: linear-gradient(180deg, #060606 0%, #101010 160px, #f3f3f3 160px, #efefef 100%);
}

.guest-body {
    background: linear-gradient(180deg, #050505 0%, #111111 100%);
    color: var(--text-inverse);
}

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

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 270px;
    padding: 26px 18px 18px;
    background: #0a0a0a;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: column;
    gap: 18px;
    z-index: 40;
}

.sidebar__brand {
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__logo {
    width: 178px;
    max-width: 100%;
    height: auto;
}

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

.sidebar__link {
    display: block;
    padding: 9px 10px;
    color: rgba(255, 255, 255, 0.82);
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.16s ease, color 0.16s ease;
}

.sidebar__link:hover,
.sidebar__link.is-active {
    background: #1b1b1b;
    color: #ffffff;
}

.sidebar__footer {
    margin-top: auto;
    display: grid;
    gap: 12px;
}

.sidebar__user {
    padding: 12px 10px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar__user-name {
    color: #ffffff;
    font-weight: 700;
}

.sidebar__user-role {
    color: #cccccc;
    text-transform: capitalize;
    font-size: 12px;
}

.btn-sidebar {
    width: 100%;
    text-align: center;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 30;
}

.app-main {
    flex: 1;
    margin-left: 270px;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.mobile-topbar {
    display: none;
}

.container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 34px 28px 18px;
    width: 100%;
}

.card {
    margin-bottom: 22px;
    padding: 24px 24px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.card h2 {
    color: #111111;
    font-size: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line-strong);
}

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

th, td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    color: #111111;
    background: #f0f0f0;
    font-family: "Urbanist", "Segoe UI", Arial, sans-serif;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.form-row { margin-bottom: 16px; }

.form-row label {
    display: block;
    margin-bottom: 6px;
    color: #222222;
    font-weight: 700;
    font-size: 13px;
}

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=time], select, textarea {
    width: 100%;
    padding: 12px 13px;
    border: 1px solid var(--line-strong);
    background: #ffffff;
    color: var(--text);
    font-size: 14px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #8f8f8f;
    box-shadow: 0 0 0 3px rgba(204, 204, 204, 0.35);
}

textarea { min-height: 120px; resize: vertical; }

.form-row-inline {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 18px;
    border: 1px solid #111111;
    background: #111111;
    color: #ffffff;
    font-family: "Urbanist", "Segoe UI", Arial, sans-serif;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
}

.btn:hover {
    color: #ffffff;
    background: #000000;
}

.btn.secondary {
    background: #ffffff;
    color: #111111;
    border: 1px solid var(--line-strong);
    box-shadow: none;
}

.btn.secondary:hover {
    background: #f6f6f6;
    color: #000000;
}

.btn.danger {
    background: #8f2f2f;
    border-color: #8f2f2f;
}

.btn.small {
    min-height: 34px;
    padding: 8px 12px;
    font-size: 11px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge.in_attesa { background: var(--warn); }
.badge.approvata { background: var(--ok); }
.badge.respinta { background: var(--danger); }

.alert {
    padding: 13px 15px;
    margin-bottom: 18px;
    font-size: 14px;
    border: 1px solid transparent;
}

.alert.ok {
    background: rgba(47, 125, 87, 0.10);
    color: #16613d;
    border-color: rgba(47, 125, 87, 0.20);
}

.alert.error {
    background: rgba(182, 74, 74, 0.10);
    color: #8b2727;
    border-color: rgba(182, 74, 74, 0.18);
}

.guest-shell {
    min-height: 100vh;
    display: grid;
    grid-template-rows: 1fr auto;
    padding: 32px 18px 0;
}

.guest-main {
    width: min(100%, 460px);
    align-self: center;
    justify-self: center;
}

.login-wrap {
    max-width: none;
    margin: 0;
}

.login-wrap h1 {
    margin-bottom: 18px;
    color: #ffffff;
    text-align: left;
    font-size: clamp(32px, 6vw, 52px);
    line-height: 1;
    font-weight: 800;
}

.guest-body .card {
    background: #ffffff;
}

.guest-body .muted {
    color: #666666;
}

.muted {
    color: var(--text-soft);
    font-size: 13px;
}

.text-right { text-align: right; }
.mt-0 { margin-top: 0; }

.pwd-wrapper { position: relative; display: block; }
.pwd-wrapper input { padding-right: 84px; }

.pwd-toggle {
    position: absolute;
    right: 7px;
    top: 50%;
    transform: translateY(-50%);
    border: 1px solid var(--line);
    background: #f3f3f3;
    color: #111111;
    padding: 7px 11px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.pwd-toggle:hover { background: #e9e9e9; }

.nav-toggle {
    width: 44px;
    height: 44px;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    display: inline-flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 0 11px;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    height: 2px;
    background: #fff;
}

.mobile-topbar__brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-family: "Urbanist", "Segoe UI", Arial, sans-serif;
    font-size: 18px;
    font-weight: 700;
}

.mobile-topbar__brand img {
    width: 122px;
    max-width: 44vw;
    height: auto;
}

.site-footer {
    margin-top: auto;
    padding: 18px 28px 24px;
    color: #666666;
    font-size: 12px;
}

.site-footer__inner {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line-strong);
}

.site-footer--guest {
    color: #cccccc;
    width: 100%;
}

.site-footer--guest .site-footer__inner {
    border-top-color: rgba(255, 255, 255, 0.14);
}

@media (max-width: 1080px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.22s ease;
    }

    .app-main {
        margin-left: 0;
    }

    .mobile-topbar {
        position: sticky;
        top: 0;
        z-index: 20;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 18px;
        background: rgba(10, 10, 10, 0.96);
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    }

    .app-body.nav-open .sidebar {
        transform: translateX(0);
    }

    .app-body.nav-open .sidebar-backdrop {
        opacity: 1;
        pointer-events: auto;
    }

    .container {
        padding: 22px 16px 18px;
    }

    .site-footer {
        padding: 16px;
    }
}

@media (max-width: 820px) {
    .form-row-inline {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 20px 18px;
    }

    .card h2 {
        font-size: 20px;
    }

    table {
        min-width: 640px;
    }

    .site-footer__inner {
        flex-direction: column;
    }
}

@media (max-width: 560px) {
    .login-wrap h1 {
        font-size: 34px;
    }

    .btn {
        width: 100%;
    }

    .btn.small {
        width: auto;
    }

    .sidebar {
        width: min(86vw, 300px);
    }
}
