/* ============================================================
   Apio Sagrado — Admin Panel CSS
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700;800&display=swap');

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

:root {
    --green:        #1f553d;
    --green-dark:   #163d2c;
    --green-light:  #e8f5ee;
    --green-mid:    #2d7a56;
    --accent:       #a3e635;
    --warn:         #f59e0b;
    --danger:       #ef4444;
    --danger-light: #fee2e2;
    --bg:           #f0f4f1;
    --surface:      #ffffff;
    --border:       #e2ebe5;
    --text:         #1a2e23;
    --muted:        #6b8070;
    --sidebar-w:    240px;
    --radius:       10px;
    --radius-lg:    16px;
    --shadow:       0 1px 4px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.06);
    --shadow-lg:    0 8px 32px rgba(0,0,0,.10);
    --transition:   .2s ease;
}

body {
    font-family: 'Poppins', system-ui, sans-serif;
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    line-height: 1.5;
}

a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Layout ───────────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--green-dark);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}

.sidebar__brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 28px 20px 22px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    background:
        linear-gradient(to bottom, rgba(22,61,44,.82) 0%, rgba(22,61,44,.96) 100%),
        url('https://images.unsplash.com/photo-1542838132-92c53300491e?auto=format&fit=crop&w=280&q=70') center/cover no-repeat;
    text-align: center;
    position: relative;
}

.sidebar__logo {
    font-size: 22px;
    background: rgba(163,230,53,.15);
    width: 38px;
    height: 38px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.sidebar__logo-img {
    height: 72px;
    width: auto;
    filter: drop-shadow(0 3px 10px rgba(0,0,0,.35));
}

.sidebar__name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .03em;
}
.sidebar__tagline {
    font-size: 10px;
    color: rgba(163,230,53,.8);
    font-weight: 600;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-top: -4px;
}

.sidebar__nav {
    flex: 1;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    color: rgba(255,255,255,.6);
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius);
    transition: background var(--transition), color var(--transition);
}
.nav-link:hover  { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
.nav-link--active { background: rgba(163,230,53,.15); color: #a3e635; font-weight: 600; }

.notif-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 9px;
    margin-left: auto;
    line-height: 1;
    animation: badgePop .3s ease;
}
@keyframes badgePop {
    0%   { transform: scale(0); }
    70%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.sidebar__footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,.08);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.sidebar__user-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar__avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: rgba(163,230,53,.25);
    color: #a3e635;
    font-size: 15px;
    font-weight: 800;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.sidebar__user   { font-size: 13px; font-weight: 600; color: #fff; }
.sidebar__rol    { align-self: flex-start; margin-top: 2px; }
.sidebar__logout { font-size: 12px; color: rgba(255,255,255,.4); transition: color var(--transition); }
.sidebar__logout:hover { color: #ef4444; text-decoration: none; }
.nav-link__icon  { font-size: 15px; }

/* ═══════════════════════════════════════════════════════════
   MAIN
   ═══════════════════════════════════════════════════════════ */
.main  { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar__title { font-size: 17px; font-weight: 700; }
.topbar__right { display: flex; align-items: center; gap: 16px; }
.topbar__date  { font-size: 12px; color: var(--muted); }
.topbar__site-link {
    font-size: 12px;
    font-weight: 600;
    color: var(--green);
    background: var(--green-light);
    padding: 5px 12px;
    border-radius: 99px;
    transition: background var(--transition);
}
.topbar__site-link:hover { background: #d0eedd; text-decoration: none; }

.content { padding: 24px; flex: 1; display: flex; flex-direction: column; gap: 20px; overflow-y: auto; }

/* ═══════════════════════════════════════════════════════════
   BADGES
   ═══════════════════════════════════════════════════════════ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .03em;
    text-transform: uppercase;
}
.badge--superadmin { background: #fef3c7; color: #92400e; }
.badge--admin      { background: #dbeafe; color: #1d4ed8; }
.badge--pendiente  { background: #fef9c3; color: #854d0e; }
.badge--procesando { background: #dbeafe; color: #1d4ed8; }
.badge--entregado  { background: #dcfce7; color: #166534; }
.badge--cancelado  { background: var(--danger-light); color: #991b1b; }

.pedido-row--pendiente  td:first-child { border-left: 3px solid var(--warn); }
.pedido-row--procesando td:first-child { border-left: 3px solid #3b82f6; }
.pedido-row--entregado  { opacity: .78; }
.pedido-row--cancelado  { opacity: .55; }

/* ═══════════════════════════════════════════════════════════
   STAT CARDS
   ═══════════════════════════════════════════════════════════ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    border-left: 4px solid var(--green);
    transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.stat-card__icon {
    width: 52px; height: 52px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.stat-card__icon--green  { background: rgba(31,85,61,.1); }
.stat-card__icon--warn   { background: rgba(245,158,11,.1); }
.stat-card__icon--blue   { background: rgba(59,130,246,.1); }
.stat-card__icon--purple { background: rgba(139,92,246,.1); }

.stat-card__body  { display: flex; flex-direction: column; gap: 4px; }
.stat-card__label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.stat-card__value { font-size: 32px; font-weight: 800; color: var(--green); line-height: 1; }

.stat-card--warn   { border-left-color: var(--warn); }
.stat-card--warn   .stat-card__value { color: var(--warn); }
.stat-card--blue   { border-left-color: #3b82f6; }
.stat-card--blue   .stat-card__value { color: #3b82f6; }
.stat-card--purple { border-left-color: #8b5cf6; }
.stat-card--purple .stat-card__value { color: #8b5cf6; }
.stat-card--online { border-left-color: #10b981; }
.stat-card--online .stat-card__value { color: #10b981; }
.stat-card__icon--online { background: #d1fae5; color: #059669; }
.stat-card--switcher { border-left-color: #f59e0b; }
.stat-card__icon--switcher { background: #fef3c7; color: #d97706; }

/* Toggle switch */
.price-toggle { display: inline-flex; align-items: center; cursor: pointer; margin-top: 6px; }
.price-toggle input { display: none; }
.price-toggle__track { width: 48px; height: 26px; background: #cbd5e1; border-radius: 100px; position: relative; transition: background .2s; }
.price-toggle input:checked + .price-toggle__track { background: #22c55e; }
.price-toggle__thumb { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.price-toggle input:checked + .price-toggle__track .price-toggle__thumb { transform: translateX(22px); }

/* ═══════════════════════════════════════════════════════════
   SECTIONS
   ═══════════════════════════════════════════════════════════ */
.section { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; }
.section__title { font-size: 14px; font-weight: 700; padding: 20px 22px 0; margin-bottom: 16px; }
.section__header { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 0; margin-bottom: 16px; }
.section__header .section__title { padding: 0; margin: 0; }

/* ═══════════════════════════════════════════════════════════
   TABLA
   ═══════════════════════════════════════════════════════════ */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead th {
    padding: 10px 16px;
    background: var(--bg);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.table tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #f7faf8; }
.table__empty { text-align: center; color: var(--muted); padding: 40px !important; }
.row--muted td { opacity: .45; }

/* ═══════════════════════════════════════════════════════════
   TOOLBAR
   ═══════════════════════════════════════════════════════════ */
.toolbar { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 0 22px 16px; }
.toolbar__filters { display: flex; align-items: center; gap: 8px; }

/* ═══════════════════════════════════════════════════════════
   BOTONES
   ═══════════════════════════════════════════════════════════ */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px; padding: 9px 18px; border-radius: var(--radius);
    border: 1.5px solid transparent; font-family: inherit;
    font-size: 13px; font-weight: 600; cursor: pointer;
    transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
    text-decoration: none; line-height: 1; white-space: nowrap;
}
.btn:hover   { transform: translateY(-1px); text-decoration: none; }
.btn:active  { transform: translateY(0); }
.btn--primary   { background: var(--green); color: #fff; }
.btn--primary:hover { background: var(--green-dark); box-shadow: 0 4px 12px rgba(31,85,61,.25); }
.btn--secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn--secondary:hover { background: var(--border); }
.btn--danger    { background: var(--danger); color: #fff; }
.btn--danger:hover { background: #dc2626; }
.btn--ghost     { background: transparent; color: var(--muted); border-color: var(--border); }
.btn--ghost:hover { background: var(--bg); color: var(--text); }
.btn--full      { width: 100%; }
.btn--sm        { padding: 5px 11px; font-size: 12px; }

/* ═══════════════════════════════════════════════════════════
   CAMPOS
   ═══════════════════════════════════════════════════════════ */
.field { display: flex; flex-direction: column; gap: 5px; }
.field__label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field__input {
    padding: 9px 12px; border: 1.5px solid var(--border);
    border-radius: var(--radius); font-family: inherit;
    font-size: 13px; color: var(--text); background: #fafcfb;
    transition: border-color var(--transition), box-shadow var(--transition); width: 100%;
}
.field__input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(31,85,61,.1); background: var(--surface); }
.field__input--sm { padding: 6px 10px; font-size: 12px; width: auto; }
.field__textarea  { resize: vertical; min-height: 80px; }
.field--full      { grid-column: 1 / -1; }
.field--check     { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
.field--actions   { display: flex; gap: 10px; align-items: center; }

/* ═══════════════════════════════════════════════════════════
   FORM GRID
   ═══════════════════════════════════════════════════════════ */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; padding: 0 22px 22px; }

/* ═══════════════════════════════════════════════════════════
   ALERTAS
   ═══════════════════════════════════════════════════════════ */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 500; margin-bottom: 16px; }
.alert--success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert--error   { background: var(--danger-light); color: #991b1b; border: 1px solid #fecaca; }
.alert--warn    { background: #fffbeb; color: #78350f; border: 1px solid #fde68a; display: flex; align-items: center; gap: 10px; }

/* ═══════════════════════════════════════════════════════════
   ACCIONES
   ═══════════════════════════════════════════════════════════ */
.actions     { display: flex; gap: 6px; align-items: center; }
.inline-form { display: inline-flex; gap: 6px; align-items: center; }

/* ═══════════════════════════════════════════════════════════
   LOGIN
   ═══════════════════════════════════════════════════════════ */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--green-dark) 0%, var(--green-mid) 100%);
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.login-card__brand {
    background: var(--green-dark);
    padding: 32px 32px 28px;
    text-align: center;
    border-bottom: 3px solid rgba(163,230,53,.3);
}
.login-card__logo  { font-size: 52px; display: block; margin-bottom: 12px; }
.login-card__title { font-size: 20px; font-weight: 800; color: #fff; }
.login-card__sub   { font-size: 12px; color: rgba(255,255,255,.5); margin-top: 4px; }

.login-form { padding: 28px 32px 32px; display: flex; flex-direction: column; gap: 16px; }

.field__password-wrap { position: relative; display: flex; align-items: center; }
.field__password-wrap .field__input { width: 100%; padding-right: 42px; }
.field__eye {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--muted);
    display: flex;
    align-items: center;
    padding: 4px;
    border-radius: 4px;
    transition: color var(--transition);
}
.field__eye:hover { color: var(--text); }

/* ═══════════════════════════════════════════════════════════
   TEMA OSCURO
   ═══════════════════════════════════════════════════════════ */
[data-theme="dark"] {
    --bg:          #0e1a11;
    --surface:     #172318;
    --border:      #253c2b;
    --text:        #dde8e0;
    --muted:       #7a9c85;
    --green-light: rgba(163,230,53,.08);
    --shadow:      0 1px 4px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    --shadow-lg:   0 8px 32px rgba(0,0,0,.5);
}

[data-theme="dark"] .table tbody tr:hover         { background: rgba(255,255,255,.04); }
[data-theme="dark"] .table thead th               { background: rgba(0,0,0,.2); color: var(--muted); }
[data-theme="dark"] .table tbody td               { border-bottom-color: var(--border); }
[data-theme="dark"] .field__input                 { background: #0e1a11; color: var(--text); border-color: var(--border); }
[data-theme="dark"] .field__input:focus           { background: var(--surface); }
[data-theme="dark"] .btn--secondary               { background: var(--surface); border-color: var(--border); color: var(--text); }
[data-theme="dark"] .btn--secondary:hover         { background: var(--border); }
[data-theme="dark"] .btn--ghost                   { border-color: var(--border); color: var(--muted); }
[data-theme="dark"] .btn--ghost:hover             { background: rgba(255,255,255,.06); color: var(--text); }
[data-theme="dark"] .topbar__site-link            { background: rgba(163,230,53,.1); color: #a3e635; }
[data-theme="dark"] .topbar__site-link:hover      { background: rgba(163,230,53,.18); }
[data-theme="dark"] .stat-card__icon--green       { background: rgba(31,85,61,.35); }
[data-theme="dark"] .stat-card__icon--warn        { background: rgba(245,158,11,.15); }
[data-theme="dark"] .stat-card__icon--blue        { background: rgba(59,130,246,.15); }
[data-theme="dark"] .stat-card__icon--purple      { background: rgba(139,92,246,.15); }
[data-theme="dark"] .quick-action:hover           { background: rgba(255,255,255,.05); }
[data-theme="dark"] .quick-action__icon           { background: rgba(163,230,53,.1); }
[data-theme="dark"] .db-warning                   { background: rgba(254,249,195,.06); border-color: rgba(253,224,71,.2); color: #fde68a; }
[data-theme="dark"] a                             { color: #7dd4a0; }
[data-theme="dark"] a:hover                       { color: #a3e635; }
[data-theme="dark"] .alert--success               { background: rgba(220,252,231,.08); color: #86efac; border-color: rgba(187,247,208,.15); }
[data-theme="dark"] .alert--error                 { background: rgba(239,68,68,.1); color: #fca5a5; border-color: rgba(252,165,165,.15); }
[data-theme="dark"] .badge--superadmin            { background: rgba(254,243,199,.1); color: #fcd34d; }
[data-theme="dark"] .badge--admin                 { background: rgba(219,234,254,.1); color: #93c5fd; }
[data-theme="dark"] .badge--pendiente             { background: rgba(254,249,195,.1); color: #fde68a; }
[data-theme="dark"] .badge--procesando            { background: rgba(219,234,254,.1); color: #93c5fd; }
[data-theme="dark"] .badge--entregado             { background: rgba(220,252,231,.1); color: #86efac; }
[data-theme="dark"] .badge--cancelado             { background: rgba(239,68,68,.1);   color: #fca5a5; }
[data-theme="dark"] .login-body                   { background: linear-gradient(135deg, #0a1510 0%, #0e1a11 100%); }
[data-theme="dark"] .login-card__brand            { background: #0a1510; }

/* ── Toggle de tema ───────────────────────────────────────── */
.theme-toggle {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px;
    transition: background var(--transition), transform var(--transition), border-color var(--transition);
    flex-shrink: 0;
}
.theme-toggle:hover { transform: scale(1.12); border-color: var(--green); }

/* ═══════════════════════════════════════════════════════════
   DASHBOARD
   ═══════════════════════════════════════════════════════════ */

/* Aviso DB no configurada */
.db-warning {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #fef9c3;
    border: 1px solid #fde047;
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    font-size: 13px;
    color: #713f12;
}
.db-warning__icon { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.db-warning__body a { color: #92400e; font-weight: 600; margin-left: 8px; }

/* Banner de bienvenida */
.welcome-banner {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-left: 4px solid var(--green);
    gap: 16px;
}
.welcome-banner__title { font-size: 17px; font-weight: 700; color: var(--text); }
.welcome-banner__sub   { font-size: 13px; color: var(--muted); margin-top: 3px; }

/* Grid de 2 columnas para tabla + acciones */
.dash-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    align-items: start;
}
.dash-grid__main { min-width: 0; }
.dash-grid__side { }

/* ═══════════════════════════════════════════════════════════
   GRÁFICOS DASHBOARD
   ═══════════════════════════════════════════════════════════ */
.charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
}
.chart-card {
    border-radius: 20px;
    padding: 24px;
    min-width: 0;
    overflow: hidden;
}
.chart-card--ventas {
    background: linear-gradient(135deg, #163d2c 0%, #1f553d 60%, #2d7a56 100%);
    box-shadow: 0 8px 32px rgba(22,61,44,.35);
}
.chart-card--top {
    background: var(--surface);
    border: 1.5px solid var(--border);
    box-shadow: var(--shadow);
}
.chart-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px;
}
.chart-card--ventas .chart-card__header { color: #fff; }
.chart-card__label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .06em;
    opacity: .6;
    margin-bottom: 2px;
}
.chart-card__title {
    font-size: 16px;
    font-weight: 700;
}
.chart-card--top .chart-card__title { color: var(--text); }
.chart-card__kpi {
    font-size: 22px;
    font-weight: 800;
    color: #a3e635;
    white-space: nowrap;
}
.chart-card__icon { font-size: 28px; }
.chart-card__body { position: relative; height: 200px; }
.chart-card__body canvas { width: 100% !important; height: 100% !important; }
.chart-empty {
    text-align: center;
    color: var(--muted);
    padding: 48px 0;
    font-size: 13px;
}

/* Ranking de productos */
.chart-top-list { display: flex; flex-direction: column; gap: 12px; }
.chart-top-item {
    display: flex;
    align-items: center;
    gap: 10px;
}
.chart-top-item__num {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--green-light);
    color: var(--green);
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.chart-top-item__info { flex: 1; min-width: 0; }
.chart-top-item__name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}
.chart-top-item__bar-wrap {
    height: 6px;
    border-radius: 99px;
    background: var(--bg);
    overflow: hidden;
}
.chart-top-item__bar {
    height: 100%;
    border-radius: 99px;
    transition: width .6s ease;
}
.chart-top-item__qty {
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
    white-space: nowrap;
}

/* Acciones rápidas */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px 16px;
}
.quick-action {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 10px;
    border-radius: var(--radius);
    transition: background var(--transition);
    text-decoration: none;
}
.quick-action:hover { background: var(--bg); text-decoration: none; }
.quick-action__icon {
    font-size: 22px;
    width: 40px; height: 40px;
    background: var(--green-light);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.quick-action--wa .quick-action__icon { background: #dcfce7; }
.quick-action__title { font-size: 13px; font-weight: 600; color: var(--text); }
.quick-action__sub   { font-size: 11px; color: var(--muted); margin-top: 1px; }

@media (max-width: 900px) {
    .dash-grid { grid-template-columns: 1fr; }
    .charts-grid { grid-template-columns: 1fr; }
    .chart-card__kpi { font-size: 18px; }
}

/* ═══════════════════════════════════════════════════════════
   IMAGEN RÁPIDA EN TABLA DE PRODUCTOS
   ═══════════════════════════════════════════════════════════ */
.prod-thumb {
    width: 40px; height: 40px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}
.prod-thumb--empty {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.prod-thumb__cam {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.45);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transition: opacity .18s;
    pointer-events: none;
}
form:hover .prod-thumb__cam { opacity: 1; }

/* ═══════════════════════════════════════════════════════════
   EMAILS
   ═══════════════════════════════════════════════════════════ */
.email-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    height: calc(100vh - 72px);
    background: var(--surface);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow);
}

/* Sidebar */
.email-sidebar {
    border-right: 1.5px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.email-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 16px 12px;
    border-bottom: 1.5px solid var(--border);
}
.email-sidebar__title { font-size: 15px; font-weight: 700; }
.email-sidebar__badge {
    font-size: 11px;
    font-weight: 700;
    background: var(--green);
    color: #fff;
    border-radius: 99px;
    padding: 2px 9px;
}
.email-connect-notice {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--muted);
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    padding: 8px 16px;
}
.email-connect-notice a { color: var(--green); font-weight: 600; }
.email-tabs {
    display: flex;
    border-bottom: 1.5px solid var(--border);
}
.email-tab {
    flex: 1;
    text-align: center;
    padding: 10px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    transition: all .15s;
    border-bottom: 2px solid transparent;
}
.email-tab:hover { color: var(--green); }
.email-tab--active { color: var(--green); border-bottom-color: var(--green); }

.email-list { overflow-y: auto; flex: 1; }

.email-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    position: relative;
    transition: background .15s;
}
.email-item:hover { background: var(--bg); }
.email-item--active { background: var(--green-light); }

/* No leído — aspecto destacado */
.email-item--unread {
    background: #f0faf5;
    border-left: 3px solid var(--green);
}
.email-item--unread .email-item__nombre { font-weight: 700; color: var(--text); }
.email-item--unread .email-item__asunto { font-weight: 700; color: var(--text); }
.email-item--unread .email-item__preview { color: #4b7a60; }

/* Leído — aspecto atenuado */
.email-item:not(.email-item--unread) {
    border-left: 3px solid transparent;
}
.email-item:not(.email-item--unread) .email-item__nombre { color: var(--muted); font-weight: 500; }
.email-item:not(.email-item--unread) .email-item__asunto { color: var(--muted); }
.email-item:not(.email-item--unread) .email-item__avatar { background: #b0bec5; }

.email-item__avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--green-mid);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.email-item__body { flex: 1; min-width: 0; }
.email-item__top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2px; }
.email-item__nombre { font-size: 13px; font-weight: 500; }
.email-item__fecha { font-size: 10px; color: var(--muted); }
.email-item__asunto { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.email-item__preview { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.email-item__dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--green);
    flex-shrink: 0;
    margin-top: 4px;
}

/* Viewer */
.email-viewer {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
.email-viewer__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 24px 28px 16px;
    border-bottom: 1.5px solid var(--border);
    gap: 16px;
}
.email-viewer__asunto { font-size: 17px; font-weight: 700; margin-bottom: 10px; }
.email-viewer__from { display: flex; align-items: center; gap: 10px; }
.email-viewer__avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: var(--green-mid);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.email-viewer__addr { font-size: 12px; color: var(--muted); margin-left: 4px; }
.email-viewer__fecha { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.email-viewer__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text);
    min-height: 0;
}
.email-viewer__body iframe {
    width: 100%;
    border: none;
    border-radius: 8px;
    background: #fff;
    display: block;
}
.email-text {
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.75;
    margin: 0;
}
.email-body-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    height: 160px;
    color: var(--muted);
    font-size: 13px;
}
.email-body-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Reply colapsable */
.email-reply-bar {
    border-top: 1.5px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}
.email-reply-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    text-align: left;
    transition: background var(--transition), color var(--transition);
}
.email-reply-toggle--highlight {
    background: linear-gradient(90deg, rgba(163,230,53,.12) 0%, transparent 100%);
    color: #3a7d44;
    border-top: 2px solid #a3e635;
}
.email-reply-toggle--highlight:hover { background: linear-gradient(90deg, rgba(163,230,53,.22) 0%, transparent 100%); color: #1f553d; }
.email-reply-toggle__dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: #a3e635;
    box-shadow: 0 0 6px #a3e635;
    flex-shrink: 0;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: .6; transform: scale(1.3); }
}
.email-reply-toggle__arrow { margin-left: auto; font-size: 10px; color: var(--muted); }
.email-reply-form { padding: 0 20px 16px; }

.email-reply-dest {
    font-size: 12px;
    color: var(--muted);
    background: var(--green-light);
    border-radius: 6px;
    padding: 6px 12px;
    margin-bottom: 10px;
}
.email-reply-dest strong { color: var(--green); }
.email-reply-dest__addr  { color: var(--muted); margin-left: 4px; }

.email-reply-templates {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    padding-top: 4px;
}
.email-reply-templates__label { font-size: 11px; color: var(--muted); font-weight: 600; margin-right: 2px; }
.tpl-btn {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 99px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    font-weight: 500;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.tpl-btn:hover { background: var(--green-light); border-color: var(--green); color: var(--green); }
.email-connect-tag {
    font-size: 11px;
    background: #fef3c7;
    color: #92400e;
    border-radius: 99px;
    padding: 2px 10px;
}
.email-reply__textarea {
    width: 100%;
    border-radius: 10px;
    border: 1.5px solid var(--border);
    padding: 12px;
    font-family: inherit;
    font-size: 13px;
    resize: none;
    background: var(--surface);
    color: var(--text);
    opacity: .6;
}
.email-reply__actions {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 10px;
}
.email-reply__hint { font-size: 11px; color: var(--muted); }

/* Empty state */
.email-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    gap: 10px;
    padding: 40px;
}
.email-empty__icon { font-size: 56px; opacity: .3; }
.email-empty h3 { font-size: 16px; font-weight: 700; color: var(--text); }
.email-empty p { font-size: 13px; text-align: center; }

/* ═══════════════════════════════════════════════════════════
   EMPLEADOS
   ═══════════════════════════════════════════════════════════ */
.emp-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.emp-card {
    display: flex;
    align-items: center;
    gap: 14px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 14px;
    padding: 14px 18px;
    flex-wrap: wrap;
    transition: box-shadow .2s;
}
.emp-card:hover { box-shadow: var(--shadow); }
.emp-card--inactivo { opacity: .55; }
.emp-card__avatar {
    width: 46px; height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--green-mid), var(--green));
    color: #fff;
    font-size: 18px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.emp-card__info { flex: 1; min-width: 140px; }
.emp-card__nombre { font-size: 14px; font-weight: 700; }
.emp-card__rol  { font-size: 11px; color: var(--muted); margin-top: 1px; }
.emp-card__tel  { font-size: 11px; color: var(--muted); margin-top: 2px; }

.emp-card__asist {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.emp-badge {
    font-size: 11px;
    font-weight: 600;
    border-radius: 99px;
    padding: 3px 10px;
}
.emp-badge--entrada { background: #d1fae5; color: #065f46; }
.emp-badge--salida  { background: #dbeafe; color: #1e40af; }
.emp-badge--ausente { background: #fee2e2; color: #991b1b; }
.emp-badge--horas   { background: #f3f4f6; color: #374151; }

.emp-card__actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

/* ── Email Config ─────────────────────────────────────────── */
.email-config-wrap { max-width: 680px; }

.email-status-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    border-radius: 14px;
    border: 2px solid;
}
.email-status-card--ok  { background: #f0faf4; border-color: #52b788; }
.email-status-card--off { background: #fffbeb; border-color: #fbbf24; }
.email-status-card__icon { font-size: 24px; }
.email-status-card__body { display: flex; flex-direction: column; font-size: 13px; }
.email-status-card__body strong { font-size: 14px; margin-bottom: 2px; }

.provider-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}
.provider-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 16px 12px;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: var(--surface);
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    transition: all .2s;
}
.provider-btn:hover { border-color: var(--green); background: var(--green-light); }
.provider-btn--active { border-color: var(--green); background: var(--green-light); color: var(--green); }
.provider-btn--manual { color: var(--muted); }

.email-config-form { display: flex; flex-direction: column; gap: 14px; }
.fields-advanced {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.ayuda-box {
    background: #f0f9ff;
    border: 1.5px solid #bae6fd;
    border-radius: 10px;
    padding: 14px 16px;
    font-size: 12px;
    line-height: 1.8;
    color: #0c4a6e;
}
.ayuda-box ol { padding-left: 18px; margin-top: 6px; }
.ayuda-box a { color: var(--green); }
.field__hint { font-size: 11px; font-weight: 500; color: var(--green); margin-left: 8px; cursor: pointer; }

/* ═══════════════════════════════════════════════════════════
   MODAL DE PEDIDO
   ═══════════════════════════════════════════════════════════ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 20px;
    backdrop-filter: blur(2px);
}
.modal-overlay--open { display: flex; }

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn .2s cubic-bezier(.34,1.56,.64,1);
}
@keyframes modalIn {
    from { opacity: 0; transform: scale(.94) translateY(12px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 22px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.modal__title { font-size: 16px; font-weight: 700; }
.modal__close {
    background: none;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 6px;
    transition: background var(--transition), color var(--transition);
}
.modal__close:hover { background: var(--bg); color: var(--text); }

.modal__body {
    overflow-y: auto;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.modal-loading { text-align: center; color: var(--muted); padding: 32px 0; }
.modal-error   { text-align: center; color: var(--danger); padding: 32px 0; }

/* Info grid (cliente, estado, notas) */
.modal-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
    background: var(--bg);
    border-radius: var(--radius);
    padding: 14px 16px;
}
.modal-info-row   { display: flex; flex-direction: column; gap: 2px; }
.modal-info-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.modal-info-val   { font-size: 13px; font-weight: 500; color: var(--text); }

/* Tabla de productos */
.modal-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.modal-table thead th {
    padding: 8px 10px;
    background: var(--bg);
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.modal-table tbody td { padding: 10px; border-bottom: 1px solid var(--border); }
.modal-table tbody tr:last-child td { border-bottom: none; }
.modal-td--num { text-align: right; }

.modal-table tfoot td {
    padding: 12px 10px;
    border-top: 2px solid var(--border);
}
.modal-total-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
}
.modal-total-val {
    text-align: right;
    font-size: 18px;
    font-weight: 800;
    color: var(--green);
}

/* Boton WA */
.modal-actions { display: flex; justify-content: flex-end; padding-top: 4px; }
.btn--wa-modal {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #25d366;
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    text-decoration: none;
    transition: background var(--transition), transform var(--transition);
}
.btn--wa-modal:hover { background: #1ebe5d; transform: translateY(-1px); text-decoration: none; color: #fff; }

/* Dark mode overrides para modal */
[data-theme="dark"] .modal-info-grid      { background: rgba(0,0,0,.25); }
[data-theme="dark"] .modal-table thead th { background: rgba(0,0,0,.2); }
[data-theme="dark"] .modal__close:hover   { background: rgba(255,255,255,.08); }
