:root {
    --bg: #f5f0eb;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1a2e;
    --text: #2d2d2d;
    --text-light: #6b6b6b;
    --text-sidebar: #c4c4d4;
    --accent: #7947F8;
    --accent-hover: #6535e0;
    --accent-light: rgba(121, 71, 248, 0.1);
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: #e5e1dc;
    --radius: 10px;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --font: 'Poppins', sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* --- Login page --- */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-card .logo {
    width: 56px;
    height: 56px;
    background: var(--accent);
    color: #fff;
    font-size: 28px;
    font-weight: 700;
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

.login-card h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 4px;
}

.login-card .subtitle {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 28px;
}

.form-group {
    text-align: left;
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font);
    font-size: 14px;
    transition: border-color 0.2s;
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.login-error {
    display: none;
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    text-align: left;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { background: var(--bg); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { opacity: 0.85; }

.btn-success {
    background: var(--success);
    color: #fff;
}

/* --- Admin layout --- */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    color: var(--text-sidebar);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    margin-bottom: 32px;
}

.sidebar-header .logo {
    width: 36px;
    height: 36px;
    background: var(--accent);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-header span {
    font-size: 15px;
    font-weight: 600;
    color: #fff;
}

.sidebar-nav {
    list-style: none;
    flex: 1;
}

.sidebar-nav li {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.15s;
    border-left: 3px solid transparent;
}

.sidebar-nav li:hover {
    background: rgba(255,255,255,0.05);
}

.sidebar-nav li.active {
    background: rgba(121, 71, 248, 0.15);
    color: #fff;
    border-left-color: var(--accent);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer .user-info {
    font-size: 13px;
    color: var(--text-sidebar);
    margin-bottom: 8px;
}

.sidebar-footer .btn-logout {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.15);
    color: var(--text-sidebar);
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 12px;
    cursor: pointer;
    width: 100%;
    font-family: var(--font);
    transition: background 0.15s;
}

.sidebar-footer .btn-logout:hover {
    background: rgba(255,255,255,0.08);
}

/* --- Main content --- */
.main-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
}

.tab-content {
    display: none;
}
.tab-content.active {
    display: block;
}

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

.page-header h2 {
    font-size: 20px;
    font-weight: 600;
}

/* --- Tables --- */
.table-wrap {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

tbody td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

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

tbody tr:hover {
    background: var(--accent-light);
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.badge-active { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fef2f2; color: #991b1b; }
.badge-admin { background: #ede9fe; color: #5b21b6; }
.badge-user { background: #f0f9ff; color: #075985; }
.badge-viewer { background: #fef3c7; color: #92400e; }
.badge-tienda { background: #fce7f3; color: #9d174d; }

/* --- Modal --- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal-overlay.open {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px;
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
}

/* --- Toast --- */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: 12px 20px;
    font-size: 13px;
    animation: slideIn 0.3s ease;
    min-width: 280px;
}

.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* --- Filters bar --- */
.filters-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-light);
}

.filter-group select,
.filter-group input {
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: var(--font);
    font-size: 13px;
    outline: none;
}

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

/* --- Pagination --- */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    font-size: 13px;
    color: var(--text-light);
}

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

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar { display: none; }
    .main-content { padding: 16px; }
}
