/* =========================================================
   Ferretería IA — Sistema de diseño
   Moderno, limpio, sin dependencias de compilación.
   Para cambiar el color de acento, edita --accent.
   ========================================================= */

:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --surface-2: #f5f5f5;
    --border: #ebebeb;
    --border-strong: #dcdcdc;

    --text: #0a0a0a;
    --text-2: #525252;
    --text-3: #8a8a8a;

    --accent: #f97316;
    --accent-hover: #ea580c;
    --accent-soft: #fff4ec;

    --success: #16a34a;
    --success-soft: #f0fdf4;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --info: #2563eb;
    --info-soft: #eff6ff;

    --radius-sm: 8px;
    --radius: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .04);
    --shadow: 0 4px 16px rgba(0, 0, 0, .06);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, .12);

    --sidebar-w: 240px;
    --topbar-h: 60px;
    --ease: cubic-bezier(.2, .8, .2, 1);
}

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

html, body { margin: 0; padding: 0; }

body {
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'cv11', 'ss01';
}

a { color: inherit; text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { flex-shrink: 0; }
[x-cloak] { display: none !important; }
[hidden] { display: none !important; }

::selection { background: var(--accent-soft); color: var(--accent-hover); }

/* ---------- Layout ---------- */

.app { display: flex; min-height: 100vh; }

.sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 50;
    transition: transform .3s var(--ease);
}

.sidebar-brand {
    height: var(--topbar-h);
    display: flex; align-items: center; gap: 10px;
    padding: 0 20px;
    font-weight: 600; font-size: 15px; letter-spacing: -.01em;
}

.brand-mark {
    width: 28px; height: 28px; border-radius: 8px;
    background: var(--text); color: #fff;
    display: grid; place-items: center;
}
.brand-mark svg { width: 15px; height: 15px; }
.brand-mascot { width: 26px; height: 27px; flex-shrink: 0; overflow: visible; }
.brand-dot { color: var(--accent); }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 12px 16px; }

.nav-group { margin-top: 10px; }
.nav-group:first-child { margin-top: 0; }

/* Títulos de grupo que se despliegan */
.nav-toggle {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    padding: 5px 10px; border: 0; border-radius: var(--radius-sm); background: none; cursor: pointer;
    font-size: 11px; font-weight: 500; color: var(--text-3); transition: background .15s, color .15s;
}
.nav-toggle:hover { background: var(--surface-2); color: var(--text-2); }
.nav-toggle svg { width: 14px; height: 14px; transition: transform .15s; transform: rotate(-90deg); }
.nav-toggle.open svg { transform: none; }
.nav-group > div { margin-top: 2px; }
.nav-label {
    display: block; padding: 0 10px 6px;
    font-size: 11px; font-weight: 500; color: var(--text-3);
}

.nav-item {
    display: flex; align-items: center; gap: 10px;
    height: 36px; padding: 0 10px; margin-bottom: 1px;
    border-radius: var(--radius-sm);
    color: var(--text-2); font-weight: 450; font-size: 13.5px;
    transition: background .15s, color .15s;
}
.nav-item svg { width: 18px; height: 18px; color: var(--text-3); transition: color .15s; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover svg { color: var(--text-2); }
.nav-item.active { background: var(--surface-2); color: var(--text); font-weight: 550; }
.nav-item.active svg { color: var(--accent); }

.sidebar-footer { padding: 8px 12px 12px; border-top: 1px solid var(--border); }

/* Reloj encima del usuario */
.clock { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 6px 8px 8px; cursor: default; }
.clock-time { font-size: 13px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.clock-date { font-size: 11.5px; color: var(--text-3); text-transform: capitalize; }

.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 8px; border-radius: var(--radius-sm);
    transition: background .15s;
}
.user-chip:hover { background: var(--surface-2); }
.user-chip .meta { flex: 1; min-width: 0; }
.user-chip .name { font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .sub { font-size: 12px; color: var(--text-3); }

.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--surface-2); color: var(--text-2);
    border: 1px solid var(--border);
    display: grid; place-items: center;
    font-size: 12px; font-weight: 600; text-transform: uppercase;
    flex-shrink: 0;
}

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 30;
    height: var(--topbar-h);
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 0 32px;
    background: rgba(250, 250, 250, .8);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 14px; font-weight: 550; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }

.content { padding: 32px; width: 100%; max-width: 1440px; margin: 0 auto; }

.icon-btn.menu-toggle { display: none; }

.overlay {
    position: fixed; inset: 0; z-index: 40;
    background: rgba(0, 0, 0, .3);
    opacity: 0; visibility: hidden;
    transition: opacity .25s, visibility .25s;
}
.overlay.show { opacity: 1; visibility: visible; }

@media (max-width: 1023px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.show { transform: none; }
    .main { margin-left: 0; }
    .icon-btn.menu-toggle { display: inline-grid; }
    .topbar { padding: 0 16px; }
    .content { padding: 20px 16px 40px; }
    .hide-mobile { display: none !important; }
}

/* ---------- Page header ---------- */

.page-head {
    display: flex; align-items: flex-end; justify-content: space-between;
    gap: 16px; flex-wrap: wrap;
    margin-bottom: 28px;
}
.page-head h1 { font-size: 24px; font-weight: 600; letter-spacing: -.025em; line-height: 1.2; }
.page-head p { color: var(--text-3); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section-title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.mono { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 12.5px; }
.nums { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-accent { color: var(--accent); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
.card-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border);
}
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); }
.card.flat-head .card-head { border-bottom: 0; padding-bottom: 4px; }

/* ---------- Stats ---------- */

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { padding: 20px; }
.stat-label { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 13px; }
.stat-label svg { width: 16px; height: 16px; }
.stat-value { font-size: 28px; font-weight: 600; letter-spacing: -.03em; margin-top: 10px; font-variant-numeric: tabular-nums; }
.stat-hint { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }

@media (max-width: 1023px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 480px) { .stat-value { font-size: 22px; } .stat { padding: 16px; } }

/* ---------- Grid helpers ---------- */

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main-side { grid-template-columns: minmax(0, 1fr) 340px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }
.span-2 { grid-column: span 2; }

@media (max-width: 1023px) {
    .grid-main-side, .grid-3 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .span-2 { grid-column: auto; }
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 38px; padding: 0 16px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-size: 13.5px; font-weight: 500; line-height: 1;
    white-space: nowrap;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .1s;
    user-select: none;
}
.btn:active { transform: scale(.98); }
.btn svg { width: 16px; height: 16px; }
.btn:disabled, .btn[disabled] { opacity: .5; pointer-events: none; }

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

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

.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

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

.btn-danger-ghost { background: transparent; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-soft); }

.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 44px; padding: 0 20px; font-size: 14.5px; }
.btn-block { width: 100%; }

.icon-btn {
    width: 34px; height: 34px; padding: 0;
    display: inline-grid; place-items: center;
    border-radius: var(--radius-sm); border: 0;
    background: transparent; color: var(--text-3);
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 13px; font-weight: 500; color: var(--text); }
.label .opt { color: var(--text-3); font-weight: 400; }
.help { font-size: 12.5px; color: var(--text-3); }
.error { font-size: 12.5px; color: var(--danger); }

.input, .select, .textarea {
    width: 100%; height: 40px; padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    font-size: 14px; color: var(--text);
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    box-shadow: var(--shadow-sm);
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.select {
    appearance: none; -webkit-appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%238a8a8a' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M8 9l4-4 4 4m0 6l-4 4-4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.input::placeholder, .textarea::placeholder { color: #a3a3a3; }
.input:hover, .select:hover, .textarea:hover { border-color: #c4c4c4; }
.input:focus, .select:focus, .textarea:focus {
    border-color: var(--text);
    box-shadow: 0 0 0 3px rgba(10, 10, 10, .06);
}
.input[readonly], .input:disabled { background: var(--surface-2); color: var(--text-2); }
.input-lg { height: 46px; font-size: 15px; }

.input-icon { position: relative; }
.input-icon > svg {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    width: 16px; height: 16px; color: var(--text-3); pointer-events: none;
}
.input-icon > .input { padding-left: 36px; }

.input-group { display: flex; }
.input-group .input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; height: 40px; }

.checkbox { width: 16px; height: 16px; accent-color: var(--text); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: minmax(0, 1fr); } }

.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
    text-align: left; white-space: nowrap;
    padding: 10px 20px;
    font-size: 12px; font-weight: 500; color: var(--text-3);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.table td {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: #fcfcfc; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
.table .row-actions { display: inline-flex; gap: 2px; opacity: .55; transition: opacity .15s; }
.table tr:hover .row-actions { opacity: 1; }
.table-compact td { padding: 10px 16px; }
.table-compact th { padding: 8px 16px; }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex; align-items: center; gap: 6px;
    height: 22px; padding: 0 8px;
    border-radius: 999px;
    font-size: 12px; font-weight: 500;
    background: var(--surface-2); color: var(--text-2);
    white-space: nowrap;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent-hover); }

/* ---------- Alerts ---------- */

.alert {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; margin-bottom: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 13.5px;
}
.alert svg { width: 18px; height: 18px; margin-top: 1px; }
.alert-success { background: var(--success-soft); border-color: #dcfce7; color: #166534; }
.alert-danger { background: var(--danger-soft); border-color: #fee2e2; color: #991b1b; }
.alert-warning { background: var(--warning-soft); border-color: #fef3c7; color: #92400e; }
.alert-info { background: var(--info-soft); border-color: #dbeafe; color: #1e40af; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }

/* ---------- Empty state ---------- */

.empty { text-align: center; padding: 56px 20px; }
.empty-icon {
    width: 44px; height: 44px; margin: 0 auto 14px;
    border-radius: 12px; background: var(--surface-2); color: var(--text-3);
    display: grid; place-items: center;
}
.empty-icon svg { width: 20px; height: 20px; }
.empty h3 { font-size: 14.5px; font-weight: 600; }
.empty p { color: var(--text-3); margin-top: 4px; font-size: 13.5px; }
.empty .btn { margin-top: 16px; }

/* ---------- Toolbar / filters ---------- */

.toolbar {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.toolbar .input-icon { flex: 1; min-width: 200px; max-width: 360px; }

/* ---------- Barra de filtros compacta (historial) ---------- */
.fbar { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.fgrow { flex: 1; }

.seg { display: inline-flex; gap: 1px; padding: 2px; background: var(--surface-2); border-radius: 8px; }
.seg a {
    height: 26px; padding: 0 10px; display: inline-flex; align-items: center; border-radius: 6px;
    font-size: 12.5px; color: var(--text-2); white-space: nowrap; transition: background .12s, color .12s;
}
.seg a:hover { color: var(--text); }
.seg a.active { background: var(--surface); color: var(--text); font-weight: 550; box-shadow: var(--shadow-sm); }

.fbtn {
    display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 10px;
    border: 1px solid var(--border); border-radius: 8px; background: transparent;
    color: var(--text-2); font-size: 12.5px; white-space: nowrap; transition: background .12s, color .12s, border-color .12s;
}
.fbtn:hover { background: var(--surface-2); color: var(--text); }
.fbtn svg { width: 14px; height: 14px; color: var(--text-3); }
.fbtn.on { border-color: var(--border-strong); color: var(--text); background: var(--surface-2); }
.fbtn .count { min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--text); color: #fff; font-size: 10.5px; display: inline-grid; place-items: center; }

.fsearch { position: relative; }
.fsearch > svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--text-3); pointer-events: none; }
.fsearch input[type="search"] {
    height: 30px; width: 180px; padding: 0 8px 0 28px; border: 1px solid var(--border); border-radius: 8px;
    background: transparent; font-size: 12.5px; color: var(--text); outline: none;
    transition: width .2s var(--ease), border-color .15s, background .15s;
}
.fsearch input[type="search"]:focus { width: 250px; border-color: var(--border-strong); background: var(--surface); }
.fsearch input[type="search"]::placeholder { color: var(--text-3); }

.fclear { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 6px; font-size: 12.5px; color: var(--text-3); border-radius: 8px; }
.fclear:hover { color: var(--text); background: var(--surface-2); }
.fclear svg { width: 13px; height: 13px; }

.fpop { position: relative; }
.pop {
    position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; min-width: 250px; padding: 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.pop.right { left: auto; right: 0; min-width: 290px; }
.pop label, .pop-title { display: block; font-size: 11.5px; color: var(--text-3); margin: 0 0 4px; }
.pop .input { height: 32px; font-size: 13px; box-shadow: none; }
.pop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pop-group + .pop-group { margin-top: 12px; }
.pills { display: flex; flex-wrap: wrap; gap: 4px; }
.pills a {
    height: 26px; padding: 0 10px; display: inline-flex; align-items: center; border: 1px solid var(--border);
    border-radius: 999px; font-size: 12.5px; color: var(--text-2); white-space: nowrap; transition: background .12s, color .12s;
}
.pills a:hover { background: var(--surface-2); color: var(--text); }
.pills a.active { background: var(--text); border-color: var(--text); color: #fff; }

@media (max-width: 640px) {
    .fsearch { flex: 1 1 100%; order: 5; }
    .fsearch input[type="search"], .fsearch input[type="search"]:focus { width: 100%; }
    .pop { min-width: 0; width: min(290px, calc(100vw - 48px)); }
}

/* Resultados del buscador de clientes (punto de venta) */
.cust-results {
    position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius);
    box-shadow: var(--shadow); max-height: 280px; overflow-y: auto;
}
.cust-results .msg { padding: 10px 12px; font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cust-results button { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 12px; text-align: left; font-size: 13.5px; background: transparent; border: 0; cursor: pointer; }
.cust-results button + button { border-top: 1px solid var(--border); }
.cust-results button:hover { background: var(--surface-2); }

.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: var(--radius-sm); }
.tab {
    height: 30px; padding: 0 12px; border-radius: 6px; border: 0;
    background: transparent; color: var(--text-2); font-size: 13px; font-weight: 500;
    display: inline-flex; align-items: center;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Pagination (Laravel) ---------- */

.pagination-wrap { padding: 14px 20px; border-top: 1px solid var(--border); }
.pagination-wrap nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pagination-wrap nav p { font-size: 13px; color: var(--text-3); }
.pagination-wrap svg { width: 16px; height: 16px; }
.pagination-wrap a, .pagination-wrap span[aria-current] span, .pagination-wrap span[aria-disabled] span {
    font-size: 13px;
}

/* ---------- Dropdown ---------- */

.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 6px); z-index: 60;
    min-width: 200px; padding: 4px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.dropdown-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 10px; border-radius: 6px; border: 0; background: none;
    font-size: 13.5px; color: var(--text-2); text-align: left;
}
.dropdown-item:hover { background: var(--surface-2); color: var(--text); }
.dropdown-item svg { width: 16px; height: 16px; color: var(--text-3); }
.dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; }
.dropdown-head { padding: 8px 10px 6px; }

/* ---------- Modal ---------- */

.modal-backdrop {
    position: fixed; inset: 0; z-index: 100;
    background: rgba(0, 0, 0, .35);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    animation: fade-in .15s ease-out;
}
.modal {
    width: 100%; max-width: 520px; max-height: calc(100vh - 32px);
    display: flex; flex-direction: column;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    animation: pop-in .2s var(--ease);
}
.modal-lg { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; }
.modal-head h3 { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 24px; border-top: 1px solid var(--border); }

@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---------- Lists ---------- */

.list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px; border-bottom: 1px solid var(--border);
}
.list-item:last-child { border-bottom: 0; }
.list-item .meta { flex: 1; min-width: 0; }
.list-item .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .sub { font-size: 12.5px; color: var(--text-3); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; font-size: 13.5px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; font-weight: 500; text-align: right; }

.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }

/* ---------- Misc ---------- */

.thumb {
    width: 40px; height: 40px; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
    object-fit: cover; display: grid; place-items: center; color: var(--text-3);
    flex-shrink: 0; overflow: hidden;
}
.thumb svg { width: 18px; height: 18px; }

.kbd {
    display: inline-flex; align-items: center; height: 20px; padding: 0 6px;
    border: 1px solid var(--border); border-radius: 5px; background: var(--surface);
    font-size: 11px; color: var(--text-3); font-family: inherit;
}

.fade-up { animation: fade-up .35s var(--ease) both; }
@keyframes fade-up { from { opacity: 0; transform: translateY(6px); } }

.spinner {
    width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid currentColor; border-right-color: transparent;
    animation: spin .6s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Auth ---------- */

.auth { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); }
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: 48px 24px; }
.auth-box { width: 100%; max-width: 380px; margin: 0 auto; }
.auth-box h1 { font-size: 26px; font-weight: 600; letter-spacing: -.03em; margin-top: 32px; }
.auth-box > p { color: var(--text-3); margin-top: 6px; margin-bottom: 28px; }
.auth-aside {
    background: var(--surface-2);
    border-left: 1px solid var(--border);
    display: flex; flex-direction: column; justify-content: space-between;
    padding: 48px;
    position: relative; overflow: hidden;
}
.auth-aside::before {
    content: ''; position: absolute; inset: 0;
    background-image:
        linear-gradient(var(--border) 1px, transparent 1px),
        linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 48px 48px;
    mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse at center, #000 20%, transparent 75%);
}
.auth-aside > * { position: relative; }
.auth-quote { font-size: 28px; font-weight: 500; letter-spacing: -.03em; line-height: 1.25; max-width: 440px; }
.auth-quote span { color: var(--text-3); }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth-aside { display: none; } }

/* ---------- Print ---------- */

@media print {
    .sidebar, .topbar, .overlay, .no-print { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; }
    body { background: #fff; }
}

/* ---------- Pager ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); }
.pager .btn-sm { min-width: 32px; padding: 0 10px; }

/* ---------- POS / selector de productos ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.pos-catalog { display: flex; flex-direction: column; min-height: 0; }
.pos-side { position: sticky; top: calc(var(--topbar-h) + 16px); display: flex; flex-direction: column; max-height: calc(100vh - var(--topbar-h) - 48px); }
.pos-side .cart-body { flex: 1; overflow-y: auto; min-height: 120px; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px; padding: 16px; }
.pick-card {
    display: flex; flex-direction: column; text-align: left;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 0; overflow: hidden; cursor: pointer; user-select: none;
    transition: border-color .15s, box-shadow .15s, transform .1s;
}
.pick-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.pick-card:active { transform: scale(.985); }
.pick-card .pick-img { height: 96px; background: var(--surface-2); display: grid; place-items: center; color: #c4c4c4; overflow: hidden; }
.pick-card .pick-img img { width: 100%; height: 100%; object-fit: cover; }
.pick-card .pick-img svg { width: 22px; height: 22px; }
.pick-card .pick-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.pick-card .pick-name { font-size: 13px; font-weight: 500; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 34px; }
.pick-card .pick-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 6px; }
.pick-card .pick-price { font-weight: 600; font-variant-numeric: tabular-nums; }
.pick-card.disabled { opacity: .45; pointer-events: none; }

.cart-line { display: flex; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.cart-line:last-child { border-bottom: 0; }
.cart-line .meta { flex: 1; min-width: 0; }
.cart-line .name { font-size: 13.5px; font-weight: 500; line-height: 1.3; }
.cart-line .sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.cart-line .end { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }

.qty { display: inline-flex; align-items: center; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; height: 28px; }
.qty button { width: 28px; height: 100%; border: 0; background: var(--surface); color: var(--text-2); display: grid; place-items: center; }
.qty button:hover { background: var(--surface-2); color: var(--text); }
.qty button svg { width: 13px; height: 13px; }
.qty input, .qty span { width: 38px; height: 100%; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); text-align: center; font-size: 13px; font-weight: 500; outline: none; font-variant-numeric: tabular-nums; display: grid; place-items: center; background: var(--surface); }
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; }

.mini-input { height: 28px; width: 84px; padding: 0 8px; border: 1px solid var(--border-strong); border-radius: 6px; font-size: 13px; text-align: right; outline: none; font-variant-numeric: tabular-nums; background: var(--surface); }
.mini-input:focus { border-color: var(--text); }

.total-row { display: flex; align-items: baseline; justify-content: space-between; }
.total-row .amount { font-size: 26px; font-weight: 600; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }

@media (max-width: 1023px) {
    .pos { grid-template-columns: minmax(0, 1fr); }
    .pos-side { position: static; max-height: none; }
    .pick-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); padding: 12px; gap: 8px; }
}

/* ---------- Settings sections ---------- */
.settings-section { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 32px; padding: 28px 0; border-top: 1px solid var(--border); }
.settings-section:first-of-type { border-top: 0; padding-top: 0; }
.settings-section h2 { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.settings-section > div:first-child p { color: var(--text-3); font-size: 13.5px; margin-top: 4px; }
@media (max-width: 900px) { .settings-section { grid-template-columns: minmax(0, 1fr); gap: 16px; } }

.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 999px; transition: background .2s; cursor: pointer; }
.switch span::before { content: ''; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; box-shadow: var(--shadow-sm); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--text); }
.switch input:checked + span::before { transform: translateX(16px); }

.file-input { font-size: 13px; color: var(--text-2); }
.file-input::file-selector-button {
    height: 32px; padding: 0 12px; margin-right: 10px;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer;
}
.file-input::file-selector-button:hover { background: var(--surface-2); }

.sticky-actions {
    position: sticky; bottom: 0; z-index: 20;
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 14px 0; margin-top: 8px;
    background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* ---------- Segmented & chips ---------- */
.segmented { display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; gap: 2px; padding: 3px; background: var(--surface-2); border-radius: var(--radius-sm); }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { height: 32px; display: grid; place-items: center; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; transition: background .15s, color .15s, box-shadow .15s; }
.segmented label:hover { color: var(--text); }
.segmented input:checked + label { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 12px 20px; border-bottom: 1px solid var(--border); }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 30px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 500; white-space: nowrap; transition: all .15s; }
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active { background: var(--text); border-color: var(--text); color: #fff; }

/* ---------- Panel del asistente ---------- */
.ai-panel {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 45;
    width: 400px; display: flex; flex-direction: column;
    background: var(--surface); border-left: 1px solid var(--border);
    transform: translateX(100%); transition: transform .3s var(--ease), box-shadow .3s;
}
.ai-panel-head { height: var(--topbar-h); flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 10px 0 16px; border-bottom: 1px solid var(--border); }
.ai-panel-body { flex: 1; min-height: 0; }
body.ai-open .ai-panel { transform: none; }
.main { transition: margin-right .3s var(--ease); }
.ai-no-anim .ai-panel, .ai-no-anim .main { transition: none !important; }

.ai-fab {
    position: fixed; right: 20px; bottom: 20px; z-index: 44;
    width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--border);
    background: var(--surface); box-shadow: var(--shadow-lg);
    display: grid; place-items: center; padding: 0;
    transition: transform .2s var(--ease), opacity .2s;
}
.ai-fab svg { width: 30px; height: 36px; }
.ai-fab:hover { transform: translateY(-2px) scale(1.04); }
body.ai-open .ai-fab { opacity: 0; pointer-events: none; transform: scale(.8); }
body.ai-open .ai-toggle { background: var(--surface-2); }

@media (min-width: 1280px) {
    body.ai-open .main { margin-right: 400px; }
}
@media (max-width: 1279px) {
    body.ai-open .ai-panel { box-shadow: var(--shadow-lg); }
}
@media (max-width: 640px) {
    .ai-panel { width: 100%; border-left: 0; }
}
