/* ═══════════════════════════════════════════════════════════════
   PIAF Sistema — Estilos globales
   ═══════════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────── */
:root {
    --color-bg:        #1a1a1a;
    --color-surface:   #242424;
    --color-surface2:  #2e2e2e;
    --color-border:    #333333;
    --color-text:      #f0f0f0;
    --color-muted:     #888888;
    --color-primary:   #e8192c;
    --color-primary-h: #c4152a;
    --color-success:   #22c55e;
    --color-warning:   #f59e0b;
    --color-danger:    #e8192c;
    --color-info:      #3b82f6;
    --topbar-h:        56px;
    --radius:          8px;
    --shadow:          0 2px 12px rgba(0,0,0,0.4);
    --transition:      0.18s ease;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--color-bg);
    background-image: url('../img/backdashboardpiaf.jpg');
    background-size: cover;
    background-position: center top;
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: var(--color-text);
    line-height: 1.55;
    min-height: 100vh;
}

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

img { max-width: 100%; }

/* ── Layout ─────────────────────────────────────────────────── */
.main-wrapper {
    margin-top: var(--topbar-h);
    min-height: calc(100vh - var(--topbar-h));
    display: flex;
    flex-direction: column;
    background: rgba(20, 20, 20, 0.72);
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-h);
    background: rgba(18, 18, 18, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255,255,255,0.07);
    display: flex;
    align-items: center;
    z-index: 100;
    padding: 0 24px;
    overflow: hidden;
}

.topbar::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--color-primary);
    pointer-events: none;
}

.topbar-logo {
    display: flex;
    align-items: center;
    margin-right: 20px;
    padding-right: 20px;
    border-right: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
    text-decoration: none;
}

.topbar-logo img {
    width: 170px;
    height: 28px;
    display: block;
    flex-shrink: 0;
}

.logo-piaf {
    font-size: 1rem;
    font-weight: 800;
    color: var(--color-primary);
    letter-spacing: 0.25em;
    text-transform: uppercase;
    font-family: 'Inter', sans-serif;
    line-height: 1;
}

.topbar-nav {
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 7px 14px;
    color: var(--color-muted);
    font-size: 0.82rem;
    font-weight: 500;
    border-radius: 6px;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.nav-link:hover {
    color: var(--color-text);
    background: rgba(255,255,255,0.05);
    text-decoration: none;
}

.nav-link.active {
    color: #fff;
    background: var(--color-primary);
}

.nav-link svg { flex-shrink: 0; opacity: 0.8; }
.nav-link.active svg { opacity: 1; }

.topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
    padding-left: 20px;
    border-left: 1px solid rgba(255,255,255,0.08);
}

.user-name {
    font-size: 0.82rem;
    color: var(--color-muted);
    font-weight: 500;
}

/* ── Top Header (page title row debajo del topbar) ──────────── */
.top-header {
    padding: 14px 28px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.header-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-infobar {
    display: flex;
    align-items: center;
    gap: 20px;
    justify-content: flex-end;
}

.infobar-dolar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--color-muted);
}

.infobar-dolar strong {
    color: var(--color-text);
    font-weight: 600;
}

.infobar-dot {
    color: var(--color-border);
    font-size: 0.7rem;
}

.infobar-weather {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: var(--color-muted);
    padding-left: 16px;
    border-left: 1px solid var(--color-border);
}

.infobar-weather strong {
    color: var(--color-text);
    font-weight: 600;
}

.weather-icon {
    font-size: 1rem;
    line-height: 1;
}

.header-title h1 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: -0.02em;
}

.header-date {
    font-size: 0.85rem;
    color: var(--color-text);
    font-weight: 500;
    text-transform: capitalize;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--color-muted);
    text-decoration: none;
    transition: color var(--transition);
    margin-bottom: 4px;
}
.back-link:hover { color: var(--color-text); text-decoration: none; }

.header-user {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* ── Main Content ───────────────────────────────────────────── */
.main-content {
    padding: 20px 28px 28px;
    flex: 1;
}

/* ── Secciones ──────────────────────────────────────────────── */
.section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 20px;
    opacity: 0.8;
}

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

.section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
}

.section-refresh {
    font-size: 0.8rem;
    color: var(--color-muted);
}

/* ── KPI Cards ──────────────────────────────────────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px 22px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
    transition: transform var(--transition), box-shadow var(--transition);
    position: relative;
    overflow: hidden;
}

.kpi-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

.kpi-card:has(.kpi-icon-total)::before    { background: var(--color-primary); }
.kpi-card:has(.kpi-icon-delivery)::before { background: var(--color-info); }
.kpi-card:has(.kpi-icon-takeaway)::before { background: var(--color-warning); }
.kpi-card:has(.kpi-icon-revenue)::before  { background: var(--color-success); }

.kpi-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0,0,0,0.5);
}

.kpi-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.kpi-icon-total    { background: rgba(232, 25, 44, 0.12); color: var(--color-primary); }
.kpi-icon-delivery { background: rgba(59, 130, 246, 0.12); color: var(--color-info); }
.kpi-icon-takeaway { background: rgba(245, 158, 11, 0.12); color: var(--color-warning); }
.kpi-icon-revenue  { background: rgba(34, 197, 94, 0.12); color: var(--color-success); }

.kpi-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.kpi-label {
    font-size: 0.7rem;
    color: var(--color-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
}

.kpi-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1;
    letter-spacing: -0.03em;
}

.kpi-value-sm {
    font-size: 1.45rem;
    letter-spacing: -0.02em;
}

/* ── Tabla ──────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.data-table th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}
.data-table th.text-right { text-align: right; }
.data-table th.text-center { text-align: center; }

.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    vertical-align: middle;
}

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

.data-table tbody tr:hover { background: var(--color-surface2); }

.data-table tfoot td {
    padding: 10px 14px;
    border-top: 1px solid var(--color-border);
}

.data-table .total-row td { font-size: 1rem; }

.text-right  { text-align: right; }
.text-center { text-align: center; }

/* Fila clickeable */
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: var(--color-surface2); }

/* Fila urgente (cola activa > 20 min) */
.row-urgent {
    background: rgba(232, 25, 44, 0.05) !important;
}
.row-urgent td { border-bottom-color: rgba(232, 25, 44, 0.1); }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-lg { padding: 5px 14px; font-size: 0.85rem; }

.badge-yellow  { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge-green   { background: rgba(34, 197, 94, 0.15);  color: #22c55e; }
.badge-red     { background: rgba(232, 25, 44, 0.15);  color: #e8192c; }
.badge-gray    { background: rgba(136, 136, 136, 0.15); color: #888888; }
.badge-blue    { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }

/* Tipo de pedido */
.type-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.type-delivery  { background: rgba(59, 130, 246, 0.15); color: #3b82f6; }
.type-takeaway  { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }

.queue-col-header .type-badge {
    font-size: 2.5rem;
    padding: 8px 20px;
    border-radius: 8px;
    letter-spacing: 0.04em;
}

/* Encargado asignado */
.worker-badge {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
    background: rgba(139, 92, 246, 0.15);
    color: #8b5cf6;
}
.worker-none { color: #555; }

/* ── Cola activa: header + dos cards ───────────────────────────────────────── */
.queue-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding: 0 2px;
}

.queue-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.queue-card-delivery {
    border-top: 3px solid var(--color-info);
}

.queue-card-takeaway {
    border-top: 3px solid var(--color-warning);
}

.queue-col-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
    margin-bottom: 12px;
}

.queue-col-count {
    font-size: 0.8rem;
    color: var(--color-muted);
}

.order-card-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.order-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: border-color var(--transition);
}

.order-card:hover { border-color: var(--color-primary); }

.order-card-urgent {
    border-left: 3px solid var(--color-danger);
}

@keyframes glow-pulse {
    0%, 100% {
        box-shadow: 0 0 6px rgba(232, 25, 44, 0.4),
                    0 0 12px rgba(232, 25, 44, 0.2),
                    inset 0 0 0 1px rgba(232, 25, 44, 0.25);
        border-color: rgba(232, 25, 44, 0.5);
    }
    50% {
        box-shadow: 0 0 18px rgba(232, 25, 44, 0.85),
                    0 0 40px rgba(232, 25, 44, 0.4),
                    inset 0 0 0 1px rgba(232, 25, 44, 0.6);
        border-color: rgba(232, 25, 44, 1);
    }
}

.order-card-processing {
    border-color: var(--color-danger);
    animation: glow-pulse 1.8s ease-in-out infinite;
}

.order-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.order-card-num {
    font-size: 0.95rem;
    font-weight: 700;
}

.order-card-time {
    font-size: 0.82rem;
    color: var(--color-muted);
}

.order-card-client {
    font-size: 0.9rem;
    font-weight: 500;
}

.order-card-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.82rem;
    color: var(--color-muted);
}

.order-card-butcher {
    border-top: 1px solid var(--color-border);
    padding-top: 8px;
}

.order-card-butcher .butcher-select {
    width: 100%;
    background: rgba(139, 92, 246, 0.07);
    border: 1px solid rgba(139, 92, 246, 0.25);
    color: #c4b5fd;
    border-radius: var(--radius);
    padding: 5px 8px;
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
}

.order-card-butcher .butcher-select:focus {
    outline: none;
    border-color: #8b5cf6;
}

.order-card-butcher .driver-select,
.order-card-butcher .vuelta-select {
    width: 50%;
    background: rgba(251, 146, 60, 0.07);
    border: 1px solid rgba(251, 146, 60, 0.25);
    color: #fdba74;
    border-radius: var(--radius);
    padding: 5px 8px;
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
}
.order-card-butcher .driver-select:focus,
.order-card-butcher .vuelta-select:focus {
    outline: none;
    border-color: #f97316;
}
.driver-vuelta-row {
    display: flex;
    gap: 4px;
}

.order-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 2px;
}

.queue-day-group { margin-bottom: 16px; }
.queue-day-group:last-child { margin-bottom: 0; }

.queue-day-label {
    font-size: 1.5rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    margin-bottom: 8px;
    padding-left: 2px;
}

.queue-day-group[data-day="atrasado"] .queue-day-label {
    color: #e8192c;
}

/* ── Botones ─────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--color-primary-h); text-decoration: none; color: #fff; }

.btn-outline {
    background: transparent;
    color: var(--color-muted);
    border: 1px solid var(--color-border);
}
.btn-outline:hover { border-color: var(--color-text); color: var(--color-text); text-decoration: none; }
#btn-push.active { background: rgba(74,222,128,0.15); border-color: #4ade80; color: #4ade80; }

.btn-take {
    background: rgba(139, 92, 246, 0.12);
    color: #8b5cf6;
    border: 1px solid rgba(139, 92, 246, 0.35);
    padding: 5px 12px;
    font-size: 0.8rem;
    border-radius: var(--radius);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-take:hover { background: rgba(139, 92, 246, 0.25); }
.btn-take:disabled { opacity: 0.5; cursor: not-allowed; }

/* Botones de estado en detalle */
.status-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.btn-status {
    background: transparent;
    color: var(--color-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 9px 18px;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-status:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-status-active {
    background: var(--color-primary) !important;
    color: #fff !important;
    border-color: var(--color-primary) !important;
    cursor: default;
}

.btn-status:disabled { opacity: 0.6; cursor: default; }

/* ── Select de estado ───────────────────────────────────────── */
.status-select {
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.8rem;
    padding: 5px 8px;
    cursor: pointer;
    transition: border-color var(--transition);
}

.status-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* ── Filtros ─────────────────────────────────────────────────── */
.filters-form {}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}

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

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

.filter-group select,
.filter-group input[type="date"],
.filter-group input[type="text"] {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.875rem;
    padding: 8px 12px;
    min-width: 140px;
    transition: border-color var(--transition);
}

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

.filter-search input { min-width: 220px; }

.filter-actions {
    flex-direction: row;
    gap: 8px;
    align-items: flex-end;
}

/* ── Paginación ─────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    justify-content: center;
}

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

/* ── Detalle de pedido ──────────────────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 24px;
}

.detail-card {}

.detail-rows { display: flex; flex-direction: column; gap: 14px; }

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.detail-label {
    font-size: 0.8rem;
    color: var(--color-muted);
    font-weight: 500;
    min-width: 100px;
    flex-shrink: 0;
}

.detail-value {
    font-size: 0.875rem;
    color: var(--color-text);
    text-align: right;
}

/* Metas de items */
.item-metas {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.item-meta {
    font-size: 0.72rem;
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    border-radius: 4px;
    padding: 1px 6px;
    color: var(--color-muted);
}

/* ── Notas ──────────────────────────────────────────────────── */
.note-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 22px;
}

.note-textarea {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.875rem;
    padding: 12px 14px;
    resize: vertical;
    transition: border-color var(--transition);
}

.note-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.notes-list { display: flex; flex-direction: column; gap: 12px; }

.note-item {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    background: var(--color-bg);
}

.note-internal { border-left: 3px solid var(--color-muted); }
.note-customer { border-left: 3px solid var(--color-info); }

.note-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.note-author {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
}

.note-content {
    font-size: 0.875rem;
    color: var(--color-muted);
    line-height: 1.6;
}

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
    border-radius: var(--radius);
    padding: 12px 16px;
    font-size: 0.875rem;
    margin-bottom: 18px;
}

.alert-error {
    background: rgba(232, 25, 44, 0.1);
    border: 1px solid rgba(232, 25, 44, 0.3);
    color: #ff6b7a;
}

.alert-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #22c55e;
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--color-muted);
    font-size: 0.9rem;
}

/* ── Utilidades ─────────────────────────────────────────────── */
.text-muted  { color: var(--color-muted) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-sm     { font-size: 0.8rem; }

.order-link {
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
}
tr.order-row {
    cursor: pointer;
}
tr.order-row:hover td { background: var(--color-surface); }

/* ── Toast notifications ────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
}

.toast {
    background: var(--color-surface2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 12px 18px;
    font-size: 0.875rem;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 240px;
    max-width: 360px;
    animation: toast-in 0.25s ease;
}

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

@keyframes toast-in {
    from { transform: translateX(20px); opacity: 0; }
    to   { transform: translateX(0);   opacity: 1; }
}

@keyframes toast-out {
    from { transform: translateX(0);   opacity: 1; }
    to   { transform: translateX(20px); opacity: 0; }
}

.toast.removing { animation: toast-out 0.2s ease forwards; }

/* ── Responsive básico ──────────────────────────────────────── */
@media (max-width: 1200px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
    .main-wrapper { margin-left: 0; }
    .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .main-content { padding: 16px; }
    .top-header { padding: 16px 16px 0; }
    .filter-row { flex-direction: column; }
}

/* ── Loader overlay ──────────────────────────────────────────── */
#piaf-loader {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(12, 12, 12, 0.82);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 20px;
}
#piaf-loader.active { display: flex; }
#piaf-loader .loader-text {
    color: rgba(255,255,255,0.5);
    font-size: 13px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 500;
}
#piaf-loader svg { width: 220px; height: auto; }

/* ── Driver summary panel (pedidos delivery) ─────────────────────────────── */
.driver-summary-section { padding-bottom: 0; }
.driver-summary-cols {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}
.driver-summary-section {
    background: transparent;
    border: none;
    padding: 0;
    margin-bottom: 20px;
}
.driver-summary-col {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
}
.driver-summary-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border);
}
.driver-summary-name {
    font-weight: 600;
    font-size: 1rem;
    color: #fdba74;
}
.driver-summary-count {
    font-size: 0.78rem;
    color: var(--color-muted);
    background: rgba(255,255,255,0.05);
    padding: 2px 8px;
    border-radius: 20px;
}
.driver-day-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
    margin: 10px 0 6px;
}
.driver-order-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    font-size: 0.82rem;
}
.driver-order-row:last-child { border-bottom: none; }
.driver-order-client {
    flex: 1;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.driver-order-total {
    color: var(--color-muted);
    font-size: 0.78rem;
    white-space: nowrap;
}
.driver-empty {
    color: var(--color-muted);
    font-size: 0.82rem;
    text-align: center;
    padding: 20px 0;
}

/* ── Payment badges (order card) ─────────────────────────────────────────── */
.order-card-top-left {
    display: flex;
    align-items: center;
    gap: 8px;
}
.payment-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 20px;
    white-space: nowrap;
}
.payment-paid {
    background: rgba(34, 197, 94, 0.12);
    color: #4ade80;
    border: 1px solid rgba(34, 197, 94, 0.25);
}
.payment-domicilio {
    background: rgba(255,255,255,0.05);
    color: #888;
    border: 1px solid rgba(255,255,255,0.1);
}
.payment-piaf {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.payment-pending {
    background: rgba(245, 158, 11, 0.1);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.25);
}
.order-card-pending {
    border-left: 3px solid #f59e0b !important;
}
.btn-take-pending {
    font-size: 0.78rem;
    color: #f59e0b;
    opacity: 0.7;
    font-style: italic;
}
.order-card-future-date {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.12);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.25);
    letter-spacing: 0.02em;
}
.vuelta-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    background: rgba(251, 146, 60, 0.15);
    color: #fdba74;
    border: 1px solid rgba(251, 146, 60, 0.3);
    vertical-align: middle;
    margin-left: 3px;
}
