/* Admin page overrides the gradient background with a flat bg */
html, body {
    background: var(--bg);
    font-size: 0.9rem;
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 80px 48px;
}

.hero {
    margin-bottom: 24px;
}

.hero-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.hero h1 {
    margin: 0 0 4px;
    font-family: "Sora", sans-serif;
    font-size: 1.5rem;
}

.hero p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.actions {
    gap: 8px;
    align-items: center;
}

/* Admin buttons override the common gradient */
.btn-primary,
.btn-secondary {
    padding: 9px 16px;
    border-radius: 8px;
    font-size: 0.87rem;
    transition: background 0.15s;
}

.btn-primary {
    background: var(--primary);
}

.btn-primary:hover {
    transform: none;
    filter: none;
    background: var(--primary-strong);
}

.btn-secondary:hover {
    background: #f0e8dc;
}

.btn-secondary:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Filters */
.filters {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 140px;
}

.filter-group label {
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.filter-group input,
.filter-group select {
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-size: 0.87rem;
    font-family: inherit;
    background: var(--bg);
    color: var(--text);
    outline: none;
    min-height: unset;
}

.filter-group input:focus,
.filter-group select:focus {
    border-color: var(--primary);
    box-shadow: none;
}

/* Error */
.error-banner {
    background: rgba(200, 50, 50, 0.08);
    border: 1px solid rgba(200, 50, 50, 0.25);
    color: #b52a2a;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-size: 0.87rem;
}

.error-banner.hidden { display: none; }

/* Table */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: auto;
    box-shadow: var(--shadow);
}

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

thead th {
    background: #f7f0e4;
    padding: 11px 14px;
    text-align: left;
    font-size: 0.76rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--line);
    transition: background 0.12s;
}

tbody tr:last-child { border-bottom: none; }

tbody tr:hover { background: #fdf6ec; }

tbody td {
    padding: 10px 14px;
    vertical-align: middle;
}

.loading-cell {
    text-align: center;
    color: var(--muted);
    padding: 32px !important;
}

.empty-cell {
    text-align: center;
    color: var(--muted);
    padding: 40px !important;
    font-style: italic;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    white-space: nowrap;
}

.badge-entidade {
    background: rgba(180, 106, 43, 0.12);
    color: #8f5221;
}

.badge-acao {
    background: rgba(60, 120, 200, 0.1);
    color: #2a5a9f;
}

.detail-btn {
    background: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 3px 8px;
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    color: var(--muted);
    transition: background 0.12s;
}

.detail-btn:hover {
    background: #f0e8dc;
    color: var(--text);
}

.timestamp {
    font-size: 0.82rem;
    color: var(--muted);
    white-space: nowrap;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    justify-content: flex-end;
}

.page-info {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 700;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--line);
    padding-bottom: 0;
}

.tab {
    padding: 9px 18px;
    border: none;
    border-radius: 8px 8px 0 0;
    background: transparent;
    font-family: inherit;
    font-size: 0.87rem;
    font-weight: 700;
    color: var(--muted);
    cursor: pointer;
    margin-bottom: -2px;
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

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

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-panel.hidden { display: none; }

/* Movement tipo badges */
.badge-tipo-entrada {
    background: rgba(34, 150, 80, 0.12);
    color: #1a7a45;
}

.badge-tipo-saida {
    background: rgba(200, 50, 50, 0.1);
    color: #b52a2a;
}

.badge-tipo-estorno {
    background: rgba(210, 120, 20, 0.12);
    color: #a05c10;
}

.badge-tipo-ajuste {
    background: rgba(60, 120, 200, 0.1);
    color: #2a5a9f;
}

.badge-item-tipo {
    background: rgba(100, 80, 60, 0.1);
    color: #5a4830;
    font-size: 0.72rem;
    margin-right: 5px;
}

.mov-item-desc {
    font-size: 0.85rem;
    color: var(--text);
}

.qty-cell {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

.qty-cell.muted {
    color: var(--muted);
}

/* Detail modal */
.detail-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
}

.detail-modal {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 20px 50px rgba(42, 36, 29, 0.22);
    max-width: 540px;
    width: 100%;
    padding: 24px;
}

.detail-modal h3 {
    margin: 0 0 14px;
    font-size: 1rem;
    color: var(--text);
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
}

.detail-modal-body {
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 0 0 16px;
    max-height: 340px;
    overflow-y: auto;
}

.detail-modal-close {
    width: 100%;
    padding: 9px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.87rem;
    cursor: pointer;
}

.detail-modal-close:hover { background: var(--primary-strong); }

/* Users tab */
.users-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

.users-panel-info {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
}

.badge-admin {
    background: rgba(34, 150, 80, 0.12);
    color: #1a7a45;
}

.badge-operador {
    background: rgba(100, 80, 60, 0.1);
    color: #5a4830;
}

.user-action-btn {
    background: none;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 3px 10px;
    font-size: 0.78rem;
    font-family: inherit;
    cursor: pointer;
    color: var(--muted);
    transition: background 0.12s, color 0.12s;
    margin-right: 4px;
}

.user-action-btn:hover {
    background: #f0e8dc;
    color: var(--text);
}

.user-action-btn.danger { color: #b52a2a; }
.user-action-btn.danger:hover { background: rgba(200, 50, 50, 0.08); color: #b52a2a; }
.user-action-btn:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

/* Checkbox in user modal */
.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.87rem;
    font-weight: 500;
    cursor: pointer;
    padding: 4px 0;
}

.check-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
    flex-shrink: 0;
}

@media (max-width: 768px) {
    .page { padding: 24px 20px 40px; }
    .filters { flex-direction: column; }
    .filter-group { min-width: unset; }
}
