:root {
    --blue: #0d6efd;
    --blue-dark: #0952c4;
    --bg: #f4f7fb;
    --text: #1f2937;
    --border: #e2e8f0;
    --green: #16a34a;
    --red: #dc2626;
}

* { box-sizing: border-box; }

html { overflow-x: hidden; }

body {
    margin: 0;
    font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow-x: hidden;
}

body.no-scroll { overflow: hidden; }

img, svg, video { max-width: 100%; height: auto; }

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

.mobile-topbar {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 900;
}

.hamburger-btn {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    cursor: pointer;
    padding: 0;
}
.hamburger-btn span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--blue-dark);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mobile-brand img { height: 24px; max-width: 100%; object-fit: contain; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 999;
}
.sidebar-overlay.show { display: block; }

.sidebar {
    width: 240px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1rem;
    color: var(--blue-dark);
    text-decoration: none;
    padding: 18px;
    border-bottom: 1px solid var(--border);
}
.sidebar .brand img { height: 28px; max-width: 100%; object-fit: contain; }

.side-nav { flex: 1; padding: 14px 10px; }
.nav-group { margin-bottom: 18px; }
.nav-group-title {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #94a3b8;
    font-weight: 700;
    padding: 0 10px;
    margin-bottom: 6px;
}
.side-nav > a {
    display: block;
    padding: 8px 10px;
    border-radius: 7px;
    color: #475569;
    text-decoration: none;
    font-size: .9rem;
    margin-bottom: 8px;
}
.nav-group a {
    display: block;
    padding: 8px 10px;
    border-radius: 7px;
    color: #475569;
    text-decoration: none;
    font-size: .9rem;
    margin-bottom: 2px;
}
.side-nav a:hover, .side-nav a.active { background: #eef2ff; color: var(--blue-dark); }
.side-nav a.nav-highlight { background: var(--blue); color: #fff; margin-bottom: 12px; }
.side-nav a.nav-highlight:hover { background: var(--blue-dark); color: #fff; }

.sidebar-user {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
    font-size: .85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}
.sidebar-user a { color: var(--red); text-decoration: none; }
.sidebar-user span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

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

@media (max-width: 900px) {
    .mobile-topbar { display: flex; }
    .app-shell { flex-direction: column; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 260px;
        max-width: 82vw;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 1000;
        box-shadow: 0 0 24px rgba(15, 23, 42, .18);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar .brand { display: none; }

    .side-nav { display: block; padding: 14px 10px; flex: 1; }
    .nav-group { display: block; margin-right: 0; }
    .nav-group-title { display: block; }
    .nav-group a, .side-nav > a { white-space: normal; margin-right: 0; }

    .sidebar-user { border-top: 1px solid var(--border); border-left: none; }
}

.container { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; width: 100%; }

@media (max-width: 640px) {
    .container { padding: 16px 14px 48px; }
}

.footer { text-align: center; color: #94a3b8; font-size: .82rem; padding: 20px; }

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

.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.page-head h1 { font-size: 1.4rem; margin: 0; }

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

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: .9rem; }
th { background: #f8fafc; font-weight: 600; color: #475569; }
tr:last-child td { border-bottom: none; }

/* Tabelas viram cards empilhados no mobile, sem cortar colunas */
@media (max-width: 700px) {
    table thead { display: none; }
    table, table tbody, table tr, table td { display: block; width: 100%; }
    table tr {
        margin-bottom: 12px;
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 4px 12px;
        background: #fff;
    }
    table tr:last-child { margin-bottom: 0; }
    table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        text-align: right;
        padding: 9px 2px;
    }
    table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #475569;
        text-align: left;
        flex-shrink: 0;
    }
    table td[data-label=""] { justify-content: flex-start; }
    table td[data-label=""]::before { content: none; }
    table tr:last-child td:last-child { border-bottom: none; }
}

.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 7px;
    border: none;
    background: var(--blue);
    color: #fff;
    text-decoration: none;
    font-size: .88rem;
    cursor: pointer;
}
.btn { min-height: 38px; }
.btn:hover { background: var(--blue-dark); }
.btn-secondary { background: #64748b; }
.btn-secondary:hover { background: #475569; }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--green); }
.btn-success:hover { background: #15803d; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-whatsapp { background: #25D366; }
.btn-whatsapp:hover { background: #1ea952; }

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

form .field { margin-bottom: 14px; }
label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 5px; color: #334155; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: .92rem;
    font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 1px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 700px) { .stats-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 460px) { .stats-grid { grid-template-columns: 1fr; } }

.item-card { margin-bottom: 12px; }
.item-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 10px; align-items: end; margin-bottom: 10px; }

@media (max-width: 640px) {
    .item-card {
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 14px;
        background: #f8fafc;
    }
    .item-row { grid-template-columns: 1fr; gap: 12px; margin-bottom: 0; }
    .item-row .remove-item { width: 100%; }
}

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge-pendente { background: #fef3c7; color: #92400e; }
.badge-enviado { background: #dbeafe; color: #1e40af; }
.badge-concluido { background: #dcfce7; color: #166534; }

.login-wrap { max-width: 380px; margin: 80px auto; }
.login-wrap .card { text-align: left; }
.login-wrap h1 { text-align: center; font-size: 1.3rem; }
@media (max-width: 460px) { .login-wrap { margin: 40px auto; } }

code { word-break: break-all; }

.approval-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    left: auto;
    background: #16a34a;
    color: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,.2);
    font-size: .9rem;
    font-weight: 600;
    z-index: 100;
    max-width: 320px;
}
@media (max-width: 640px) {
    .approval-toast { left: 14px; right: 14px; bottom: 14px; max-width: none; }
}

.empty { text-align: center; color: #94a3b8; padding: 40px 0; }
.flash {
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: 4px;
    font-weight: 500;
    animation: slideDown 0.3s ease-out;
}

.flash-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.flash-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* Adicione ao final do arquivo style.css */
.btn-secondary {
    background-color: #6c757d;
    color: white;
    border: none;
}

.btn-secondary:hover {
    background-color: #5a6268;
    color: white;
}

/* Estilo para o botão de busca junto ao campo */
.field .btn-secondary {
    margin-bottom: 0;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Filtros */
.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

@media (max-width: 768px) {
    .grid-3 {
        grid-template-columns: 1fr;
    }
}

.filter-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 7px;
    font-size: 0.92rem;
    font-family: inherit;
}

.filter-input:focus {
    outline: 2px solid var(--blue);
    outline-offset: 1px;
}

.actions-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 12px;
    align-items: center;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading {
    text-align: center;
    padding: 40px;
}

#loading div {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
