* { box-sizing: border-box; margin: 0; padding: 0; }

.hidden { display: none !important; }

:root {
    --bg: #0b0719;
    --surface: #12102a;
    --surface2: #1c1840;
    --border: rgba(139,92,246,.18);
    --accent: #7c3aed;
    --accent-h: #6d28d9;
    --danger: #ef4444;
    --danger-h: #dc2626;
    --success: #10b981;
    --text: #e2e0f0;
    --muted: #8b87a8;
    --radius: 12px;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    min-height: 100vh;
}

/* ── LOGIN ── */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px 36px;
    width: 100%;
    max-width: 380px;
    text-align: center;
}

.login-logo-img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    margin-bottom: 12px;
}

.login-logo {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 6px;
}

.login-sub {
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 28px;
}

.login-card input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 14px;
    margin-bottom: 12px;
    outline: none;
    transition: border-color .2s;
}

.login-card input:focus { border-color: var(--accent); }

.btn-login {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background .2s;
    margin-top: 4px;
}

.btn-login:hover { background: var(--accent-h); }

.btn-back {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 16px;
    font-size: 13px;
    color: var(--muted);
    text-decoration: none;
    transition: color .2s;
}

.btn-back:hover { color: var(--text); }

.login-error {
    color: #f87171;
    font-size: 13px;
    margin-top: 12px;
    min-height: 18px;
}

/* ── LAYOUT ── */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
}

.sidebar-logo {
    font-size: 18px;
    font-weight: 800;
    padding: 0 20px 24px;
    background: linear-gradient(135deg, #a78bfa, #7c3aed);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.sidebar-logo span { display: block; font-size: 11px; color: var(--muted); -webkit-text-fill-color: var(--muted); font-weight: 400; margin-top: 2px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--muted);
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all .15s;
    font-size: 14px;
}

.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: #a78bfa; border-left-color: var(--accent); background: rgba(124,58,237,.1); }
.nav-item i { width: 16px; text-align: center; }

.sidebar-footer {
    margin-top: auto;
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.btn-logout {
    width: 100%;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid rgba(239,68,68,.3);
    background: transparent;
    color: #f87171;
    font-size: 13px;
    cursor: pointer;
    transition: all .2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-logout:hover { background: rgba(239,68,68,.1); }

.main {
    margin-left: 220px;
    flex: 1;
    padding: 32px;
    max-width: 960px;
}

/* ── PAGE HEADER ── */
.page-header {
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 22px;
    font-weight: 700;
}

.page-header p { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ── CARD ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i { color: var(--accent); }

/* ── FORM ROW ── */
.form-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.form-row input, .form-row select {
    flex: 1;
    min-width: 120px;
    padding: 10px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 13px;
    outline: none;
    transition: border-color .2s;
}

.form-row input:focus, .form-row select:focus { border-color: var(--accent); }

/* ── BUTTONS ── */
.btn {
    padding: 10px 16px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all .15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: #a78bfa; }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid rgba(239,68,68,.3); }
.btn-danger:hover { background: rgba(239,68,68,.1); }

/* ── TABLE ── */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid var(--border); }

table { width: 100%; border-collapse: collapse; }

thead th {
    background: var(--surface2);
    padding: 11px 14px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .04em;
}

tbody tr { border-top: 1px solid var(--border); transition: background .1s; }
tbody tr:hover { background: rgba(255,255,255,.02); }
tbody td { padding: 10px 14px; vertical-align: middle; }

tbody td input {
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    padding: 5px 8px;
    width: 100%;
    outline: none;
    transition: border-color .15s;
}

tbody td input:focus { border-color: var(--accent); background: var(--surface2); }
tbody td input[type="date"] { min-width: 130px; }

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

/* ── TEXTAREA ── */
textarea {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface2);
    color: var(--text);
    font-size: 13px;
    line-height: 1.6;
    resize: vertical;
    min-height: 140px;
    outline: none;
    transition: border-color .2s;
    font-family: inherit;
}

textarea:focus { border-color: var(--accent); }

.save-row { display: flex; justify-content: flex-end; margin-top: 12px; }

/* ── FOTOS GRID ── */
.fotos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    margin-top: 4px;
}

.foto-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.foto-card img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
    background: #1a1840;
}

.foto-card-body {
    padding: 8px 10px;
    font-size: 11px;
    color: var(--muted);
}

.foto-card-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px 10px;
}

.foto-ordem { font-size: 11px; color: var(--muted); }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--muted);
    font-size: 13px;
}

.empty-state i { font-size: 32px; margin-bottom: 10px; display: block; opacity: .4; }

/* ── TOAST ── */
.toast {
    position: fixed;
    bottom: 24px; right: 24px;
    background: var(--success);
    color: #fff;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,.3);
    z-index: 9999;
    transition: opacity .3s;
}

.toast.error { background: var(--danger); }
.toast.hide { opacity: 0; pointer-events: none; }

/* ── BADGE COUNT ── */
.badge {
    background: rgba(124,58,237,.25);
    color: #a78bfa;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    margin-left: 6px;
}

/* ── UPLOAD ── */
.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 36px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    position: relative;
}

.upload-area:hover, .upload-area.drag-over {
    border-color: var(--accent);
    background: rgba(124,58,237,.06);
}

.upload-area i {
    font-size: 36px;
    color: var(--accent);
    margin-bottom: 10px;
    display: block;
}

.upload-area p { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.upload-area span { font-size: 12px; color: var(--muted); }

.upload-area input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.upload-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

.upload-preview-item {
    position: relative;
    width: 100px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--surface2);
    border: 1px solid var(--border);
}

.upload-preview-item img {
    width: 100%;
    height: 75px;
    object-fit: cover;
    display: block;
}

.upload-preview-item .up-status {
    font-size: 11px;
    padding: 4px 6px;
    text-align: center;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-preview-item.done .up-status { color: var(--success); }
.upload-preview-item.error .up-status { color: var(--danger); }

.upload-preview-item .up-bar {
    height: 3px;
    background: var(--accent);
    width: 0%;
    transition: width .3s;
}

@media (max-width: 640px) {
    .app {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
        height: auto;
        position: sticky;
        top: 0;
        z-index: 100;
        padding: 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
        display: flex;
        flex-direction: row;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        background: var(--surface);
    }
    .sidebar::-webkit-scrollbar {
        display: none;
    }
    .sidebar-logo {
        display: none;
    }
    .nav-item {
        flex: 0 0 auto;
        padding: 14px 16px;
        border-left: none;
        border-bottom: 3px solid transparent;
        white-space: nowrap;
        font-size: 13px;
    }
    .nav-item.active {
        border-left-color: transparent;
        border-bottom-color: var(--accent);
    }
    .sidebar-footer {
        margin-top: 0;
        padding: 10px 16px;
        border-top: none;
        display: flex;
        align-items: center;
        margin-left: auto;
    }
    .btn-logout {
        padding: 8px 12px;
        font-size: 0;
        gap: 0;
    }
    .btn-logout i {
        font-size: 14px;
        margin: 0;
    }
    .main {
        margin-left: 0;
        padding: 12px;
    }

    /* Cards com padding reduzido */
    .card {
        padding: 16px;
        margin-bottom: 14px;
        border-radius: 10px;
    }

    .card-title {
        font-size: 14px;
        margin-bottom: 14px;
    }

    /* Page header menor */
    .page-header {
        margin-bottom: 16px;
    }

    .page-header h1 {
        font-size: 18px;
    }

    /* Botões adaptados */
    .btn {
        padding: 9px 13px;
        font-size: 12px;
    }

    /* Grid de fotos com cards menores */
    .fotos-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
        gap: 10px;
    }

    .foto-card img {
        height: 90px;
    }

    /* Upload area compacta */
    .upload-area {
        padding: 24px 16px;
    }

    .upload-area i {
        font-size: 28px;
    }

    /* Form rows empilham */
    .form-row {
        flex-direction: column;
        gap: 8px;
    }

    .form-row input,
    .form-row select {
        min-width: 0;
        width: 100%;
    }

    /* Tabelas com fonte menor */
    thead th,
    tbody td {
        padding: 8px 10px;
        font-size: 12px;
    }

    .actions-cell {
        flex-direction: column;
        gap: 4px;
    }

    /* Toast no rodapé */
    .toast {
        right: 12px;
        bottom: 12px;
        left: 12px;
        right: 12px;
        text-align: center;
    }
}
