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

:root {
    --sidebar-w: 260px;
    --sidebar-collapsed: 70px;
    --sidebar-bg: #1e293b; /* Keeping the improved charcoal sidebar */
    --sidebar-hover: rgba(255,255,255,.05);
    --sidebar-active-bg: #714b67; /* Classic Odoo Purple */
    --sidebar-text: #94a3b8;
    --topbar-h: 60px;
    --primary: #714b67; /* Classic Odoo Primary */
    --primary-dark: #5a3c52;
    --primary-light: rgba(113,75,103,.15);
    --bottom-nav-h: 60px;
    --success: #017e84; /* Odoo Teal */
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --bg: #f8fafc;
    --card: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --muted: #64748b;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 4px 6px -1px rgba(0,0,0,.1);
    --shadow-md: 0 10px 15px -3px rgba(0,0,0,.1);
    --transition: .15s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 12.6px; }
body {
    font-family: 'Inter', system-ui, sans-serif;
    color: var(--text);
    background: var(--bg);
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden; /* Fix global horizontal scrolling */
}
a { text-decoration: none; color: inherit; }

/* ════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════ */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    height: 100vh;
    height: 100dvh;
    position: fixed;
    top: 0; left: 0;
    z-index: 300;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: env(safe-area-inset-top, 0px);
    transition: transform .25s cubic-bezier(.4,0,.2,1), width .2s;
}

.sidebar-brand {
    height: 80px; 
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,.05);
    flex-shrink: 0;
    background: #0c1222; /* Darker header for sidebar */
    transition: all 0.2s;
}

.brand-icon {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.brand-name  { font-size: 16px; font-weight: 700; color: #fff; }
.brand-version { font-size: 10px; color: rgba(255,255,255,0.4); }

.sidebar-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px 0 16px; }
.sidebar-scroll::-webkit-scrollbar { width: 3px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

.nav-group-label {
    padding: 16px 16px 5px;
    font-size: 10px; font-weight: 700;
    letter-spacing: 1.2px; text-transform: uppercase;
    color: #334155;
    white-space: nowrap; overflow: hidden;
}

.nav-link {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 16px;
    color: var(--sidebar-text);
    font-size: 12.6px; font-weight: 400;
    transition: background .1s;
    white-space: nowrap;
}
.nav-link:hover  { background: var(--sidebar-hover); color: #fff; }
.nav-link.active { background: var(--sidebar-active-bg); color: #fff; border-left: 3px solid rgba(255,255,255,.55); padding-left: 13px; }
.nav-link .icon { width: 18px; font-size: 16px; flex-shrink: 0; text-align: center; opacity: 0.8; }
.nav-link .nav-text { flex: 1; }

.sidebar-footer {
    border-top: 1px solid rgba(255,255,255,.06);
    padding: 10px;
    flex-shrink: 0;
}
.user-pill {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 8px; cursor: pointer;
    transition: background .15s; white-space: nowrap; overflow: hidden;
}
.user-pill:hover { background: var(--sidebar-hover); }
.user-avatar {
    width: 32px; height: 32px; border-radius: 8px; flex-shrink: 0;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 13px;
}
.user-info .name { font-size: 12.5px; font-weight: 600; color: #e2e8f0; }
.user-info .role { font-size: 11px; color: #475569; }

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 299;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* Sidebar compact mode (Desktop) */
body.sidebar-compact .sidebar { width: var(--sidebar-collapsed); }
body.sidebar-compact .brand-name, 
body.sidebar-compact .brand-version, 
body.sidebar-compact .nav-text, 
body.sidebar-compact .nav-group-label,
body.sidebar-compact .user-info,
body.sidebar-compact .user-pill .ms-auto { display: none !important; }
body.sidebar-compact .sidebar-brand { justify-content: center; padding: 0; }
body.sidebar-compact .nav-link { justify-content: center; padding: 10px; margin: 1px 8px; }
body.sidebar-compact .user-pill { justify-content: center; padding: 8px; }
body.sidebar-compact .main { margin-left: var(--sidebar-collapsed); width: calc(100% - var(--sidebar-collapsed)); }

/* ════════════════════════════════════════
   MAIN
════════════════════════════════════════ */
.main {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w)); /* Keep exact width, avoid blowing out viewport */
    flex: 1; display: flex; flex-direction: column;
    min-height: 100vh; transition: margin-left .2s, width .2s;
}

/* ════════════════════════════════════════
   TOPBAR
════════════════════════════════════════ */
.topbar {
    height: calc(var(--topbar-h) + env(safe-area-inset-top, 0px));
    background: var(--card);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center;
    padding: env(safe-area-inset-top, 0px) 20px 0; gap: 10px;
    position: sticky; top: 0; z-index: 200;
}

.hamburger {
    display: none;
    width: 36px; height: 36px;
    border: none; background: transparent;
    cursor: pointer; color: var(--text);
    border-radius: 8px; font-size: 18px;
    align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .15s;
}
.hamburger:hover { background: var(--bg); }

.breadcrumb {
    display: flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--muted); flex: 1;
    overflow: hidden;
}
.breadcrumb a { color: var(--muted); transition: color .15s; white-space: nowrap; }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { color: #cbd5e1; font-size: 11px; flex-shrink: 0; }
.breadcrumb .crumb-current { color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.icon-btn {
    width: 34px; height: 34px; border-radius: 8px;
    border: 1px solid var(--border); background: transparent;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); cursor: pointer; font-size: 15px;
    transition: var(--transition); position: relative;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.notif-dot {
    position: absolute; top: 7px; right: 7px;
    width: 7px; height: 7px;
    background: var(--danger); border-radius: 50%;
    border: 2px solid var(--card);
}
.divider-v { width: 1px; height: 20px; background: var(--border); margin: 0 2px; }
.topbar-user {
    display: flex; align-items: center; gap: 8px;
    padding: 4px 10px; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--border); transition: var(--transition);
}
.topbar-user:hover { background: var(--bg); }
.topbar-user .av {
    width: 28px; height: 28px; border-radius: 7px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-size: 12px; font-weight: 700;
}
.topbar-user .uname { font-size: 12.5px; font-weight: 600; }
.topbar-user .uname-short { display: none; }

/* ════════════════════════════════════════
   PAGE
════════════════════════════════════════ */
.page { padding: 20px; flex: 1; }

.page-header {
    display: flex; align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 20px; gap: 12px; flex-wrap: wrap;
}
.page-heading { font-size: 18px; font-weight: 700; letter-spacing: -.4px; }
.page-sub { font-size: 11.25px; color: var(--muted); margin-top: 3px; }

/* ════════════════════════════════════════
   STAT CARDS
════════════════════════════════════════ */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px; margin-bottom: 18px;
}
.stat-card {
    background: var(--card);
    border: 1px solid #dee2e6;
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    transition: background 0.1s;
    box-shadow: none;
}

.stat-card:hover {
    background: #fdfdfd;
    border-color: #ced4da;
}

.stat-body { flex: 1; min-width: 0; }
.stat-body .val { font-size: 18px; font-weight: 600; color: var(--primary); line-height: 1.2; }
.stat-body .lbl { font-size: 12.6px; color: #666; font-weight: 400; margin: 0; }

.stat-icon {
    width: 44px; height: 44px; border-radius: 4px;
    background: #f8f9fa !important; border: 1px solid #eee;
    color: var(--primary) !important; font-size: 20px;
}
.si-blue   { background: #eff6ff !important; color: #3b82f6 !important; border-color: #dbeafe !important; }
.si-green  { background: #d1fae5 !important; color: #10b981 !important; border-color: #a7f3d0 !important; }
.si-yellow { background: #fef3c7 !important; color: #f59e0b !important; border-color: #fde68a !important; }
.si-purple { background: #ede9fe !important; color: #6366f1 !important; border-color: #c4b5fd !important; }
.si-teal   { background: #ccfbf1 !important; color: #0d9488 !important; border-color: #99f6e4 !important; }

/* ════════════════════════════════════════
   CARD / TABLE
════════════════════════════════════════ */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card-header {
    padding: 13px 18px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 8px; background: var(--card);
}
.card-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-title > i { color: var(--primary); }
.card-body { padding: 18px; }

.filter-bar {
    padding: 11px 18px; border-bottom: 1px solid var(--border);
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    background: #fafafa;
}

.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table thead th {
    padding: 12px 15px; font-size: 11.7px; font-weight: 600;
    color: #444; background: #fdfdfd; 
    border-bottom: 2px solid #dee2e6; white-space: nowrap;
    text-transform: none; letter-spacing: 0;
}
.data-table tbody tr { border-bottom: 1px solid #f1f5f9; transition: background .1s; }
.data-table tbody tr:last-child { border-bottom: none; }
.data-table tbody tr:hover { background: #eef2f7; }
.data-table td { padding: 11px 14px; vertical-align: middle; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.overflow-auto { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ════════════════════════════════════════
   BUTTONS
════════════════════════════════════════ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 7px; font-size: 13px;
    font-weight: 500; cursor: pointer; border: 1px solid transparent;
    transition: var(--transition); line-height: 1; white-space: nowrap;
    font-family: 'Inter', sans-serif; touch-action: manipulation;
}
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; gap: 5px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; justify-content: center; border-radius: 6px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ghost { background: var(--card); color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); border-color: #cbd5e1; }
.btn-danger-soft { background: #fee2e2; color: var(--danger); border-color: #fecaca; }
.btn-danger-soft:hover { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-ghost-blue  { background: #eff6ff; color: var(--primary); border-color: #bfdbfe; }
.btn-ghost-blue:hover  { background: #dbeafe; }
.btn-success     { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #016068; border-color: #016068; }
.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.w-100 { width: 100%; justify-content: center; }

/* ════════════════════════════════════════
   BADGES
════════════════════════════════════════ */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 20px;
    font-size: 11.5px; font-weight: 600; white-space: nowrap;
    position: relative;
    cursor: default;
}
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-gray   { background: #f1f5f9; color: #475569; }
.badge-blue   { background: #dbeafe; color: #1e40af; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-info   { background: #dbeafe; color: #1e40af; }

/* ── Status Tooltip ── */
[data-tip] {
    position: relative;
}
[data-tip]::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #f8fafc;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.45;
    padding: 7px 11px;
    border-radius: 7px;
    white-space: normal;
    width: max-content;
    max-width: 220px;
    text-align: left;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s, transform .15s;
    transform: translateX(-50%) translateY(4px);
    z-index: 9999;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
[data-tip]::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1e293b;
    pointer-events: none;
    opacity: 0;
    transition: opacity .15s;
    z-index: 9999;
}
[data-tip]:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}
[data-tip]:hover::before {
    opacity: 1;
}
/* Cuando el badge está cerca del borde izquierdo, el tooltip no se corta */
[data-tip].tip-right::after  { left: 0;   transform: translateX(0) translateY(4px); }
[data-tip].tip-right:hover::after { transform: translateX(0) translateY(0); }
[data-tip].tip-right::before { left: 14px; }
[data-tip].tip-left::after   { left: auto; right: 0; transform: translateX(0) translateY(4px); }
[data-tip].tip-left:hover::after  { transform: translateX(0) translateY(0); }
[data-tip].tip-left::before  { left: auto; right: 14px; transform: none; }
.stock-pill {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 38px; padding: 3px 10px; border-radius: 20px;
    font-weight: 700; font-size: 12px;
}

/* ════════════════════════════════════════
   PRODUCT THUMB
════════════════════════════════════════ */
.prod-thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); }
.prod-thumb-ph {
    width: 38px; height: 38px; border-radius: 8px; background: #f1f5f9;
    border: 1px solid var(--border); display: flex; align-items: center; justify-content: center;
    color: #cbd5e1; font-size: 15px;
}
.prod-name { font-weight: 600; font-size: 13.5px; }

/* ════════════════════════════════════════
   FORMS
════════════════════════════════════════ */
.form-grid { display: grid; grid-template-columns: 1fr 320px; gap: 16px; align-items: start; }
.form-grid-inner { display: grid; gap: 16px; }

.form-section {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.form-section-head {
    padding: 12px 18px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px; background: #fafafa;
}
.form-section-head .icon { color: var(--primary); font-size: 14px; }
.form-section-title { font-size: 13px; font-weight: 600; }
.form-section-body { padding: 18px; display: grid; gap: 14px; }

.form-row   { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.form-group { display: grid; gap: 5px; }

.form-label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.req { color: var(--danger); }

.form-control, .form-select {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--border); border-radius: 7px;
    font-size: 13.5px; font-family: 'Inter', sans-serif;
    color: var(--text); background: var(--card);
    outline: none; transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none; appearance: none;
}
.form-select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2364748b' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-control:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(113,75,103,.18); }
.form-control.err { border-color: var(--danger); }
.form-control.err:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.18); }
.err-msg { font-size: 12px; color: var(--danger); }
.form-hint { font-size: 11.5px; color: var(--muted); }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── Mayúsculas automáticas en todos los campos de texto ── */
input[type="text"].form-control,
input:not([type]).form-control,
input[type="tel"].form-control,
input[type="search"].form-control,
textarea.form-control {
    text-transform: uppercase;
}
/* Excepción: campos marcados explícitamente como no-uppercase */
input[type="text"].no-upper,
input:not([type]).no-upper,
input[type="tel"].no-upper,
textarea.no-upper,
input[type="email"],
input[type="url"],
input[type="password"] {
    text-transform: none;
}

.input-addon { display: flex; }
.addon-text {
    padding: 9px 11px; background: #f8fafc;
    border: 1px solid var(--border); border-right: none;
    border-radius: 7px 0 0 7px; font-size: 13px; color: var(--muted);
    display: flex; align-items: center;
}
.input-addon .form-control { border-radius: 0 7px 7px 0; }

.img-drop {
    border: 2px dashed var(--border); border-radius: 8px;
    padding: 20px; text-align: center; color: var(--muted);
    cursor: pointer; transition: border-color .15s, background .15s;
}
.img-drop:hover { border-color: var(--primary); background: #eff6ff; }
.img-preview { width: 100%; border-radius: 8px; object-fit: cover; max-height: 160px; }

/* ════════════════════════════════════════
   SHOW / DETAIL
════════════════════════════════════════ */
.show-grid { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }

.detail-row { display: flex; border-bottom: 1px solid #f1f5f9; padding: 9px 0; gap: 12px; }
.detail-row:last-child { border-bottom: none; }
.detail-key { font-size: 12.5px; font-weight: 600; color: var(--muted); min-width: 120px; padding-top: 1px; flex-shrink: 0; }
.detail-val { font-size: 13.5px; }

.metrics-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.metric-box { background: #f8fafc; border: 1px solid var(--border); border-radius: 8px; padding: 14px; text-align: center; }
.metric-val { font-size: 19px; font-weight: 700; letter-spacing: -.4px; }
.metric-lbl { font-size: 11px; color: var(--muted); margin-top: 3px; font-weight: 500; }

/* ════════════════════════════════════════
   ALERTS
════════════════════════════════════════ */
.alert {
    padding: 11px 16px; border-radius: 8px; font-size: 13px; font-weight: 500;
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 18px; border: 1px solid transparent;
}
.alert-success { background: #d1fae5; color: #065f46; border-color: #a7f3d0; }
.alert-danger   { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.alert-warning  { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.alert-info     { background: #dbeafe; color: #1e40af; border-color: #bfdbfe; }
.alert-close { margin-left: auto; cursor: pointer; opacity: .6; font-size: 16px; background: none; border: none; color: inherit; }

/* ════════════════════════════════════════
   EMPTY STATE
════════════════════════════════════════ */
.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); }
.empty-state i { font-size: 38px; color: #cbd5e1; display: block; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ════════════════════════════════════════
   MOBILE BOTTOM NAV
════════════════════════════════════════ */
.bottom-nav {
    display: none;
    position: fixed; bottom: 0; left: 0; right: 0;
    height: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px));
    background: var(--card);
    border-top: 1px solid var(--border);
    z-index: 250;
    box-shadow: 0 -4px 12px rgba(0,0,0,.08);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav-inner { display: flex; height: var(--bottom-nav-h); }
.bottom-nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 3px; color: var(--muted); font-size: 10px;
    font-weight: 600; text-decoration: none; transition: color .15s;
    padding: 6px 0;
}
.bottom-nav-item i { font-size: 20px; }
.bottom-nav-item.active { color: var(--primary); }
.bottom-nav-item:active { background: var(--bg); }

/* ════════════════════════════════════════
   CARD FOOTER / PAGINATION
════════════════════════════════════════ */
.card-footer {
    padding: 12px 18px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,.01);
    border-radius: 0 0 var(--radius) var(--radius);
}
.pagination { display: flex; gap: 4px; margin-left: auto; }
.pagination .btn {
    min-width: 32px; height: 32px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
}
.pagination .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ════════════════════════════════════════
   UTILITIES
════════════════════════════════════════ */
.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.ms-auto { margin-left: auto; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }
.fw-600 { font-weight: 600; } .fs-12 { font-size: 12px; }
.text-muted { color: var(--muted); }
.d-none { display: none !important; }
.border-0 { border: none !important; }
.bg-transparent { background: transparent !important; }

/* ── Sidebar nav badges ── */
.nav-badge {
    font-size: 9px; font-weight: 700;
    padding: 2px 6px; border-radius: 10px;
    margin-left: auto; min-width: 18px;
    text-align: center; line-height: 1.4; color: #fff;
}

/* ── Custom confirm modal ── */
#confirmModal {
    display: none; position: fixed; inset: 0;
    background: rgba(15,23,42,.55); backdrop-filter: blur(3px);
    z-index: 3000; align-items: center; justify-content: center;
}
.confirm-box {
    background: var(--card); border-radius: 12px;
    padding: 24px 28px; max-width: 360px; width: 90%;
    box-shadow: var(--shadow-md);
}
.confirm-msg { font-size: 14px; font-weight: 500; margin-bottom: 20px; color: var(--text); }
.confirm-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ── Spinner keyframe (form loading state) ── */
@keyframes spin { to { transform: rotate(360deg); } }
code {
    font-size: 12px; background: #f1f5f9; padding: 2px 7px;
    border-radius: 4px; color: var(--primary);
    font-family: 'JetBrains Mono', 'Courier New', monospace; font-weight: 600;
}

/* ════════════════════════════════════════
   TABLET  (< 1024px)
════════════════════════════════════════ */
@media (max-width: 1024px) {
    .sidebar { width: var(--sidebar-collapsed); }
    .brand-name, .brand-version, .nav-text, .nav-group-label,
    .user-info, .user-pill .chevron { display: none; }
    .sidebar-brand { justify-content: center; padding: 0; }
    .nav-link { justify-content: center; margin: 2px 8px; padding: 10px; }
    .nav-link.active { border-left: none; padding-left: 10px; }
    .user-pill { justify-content: center; padding: 8px; }
    .main { margin-left: var(--sidebar-collapsed); width: calc(100% - var(--sidebar-collapsed)); }
    .topbar-user .uname { display: none; }
    .topbar-user .uname-short { display: block; font-size: 12px; font-weight: 600; }
    .form-grid { grid-template-columns: 1fr; }
    .show-grid  { grid-template-columns: 1fr; }
    .stats-row  { grid-template-columns: repeat(2, 1fr); }
    .dash-grid-top, .dash-grid-bottom { grid-template-columns: 1fr !important; }
}

/* ════════════════════════════════════════
   MOBILE  (< 640px)
════════════════════════════════════════ */
@media (max-width: 640px) {
    :root { --topbar-h: 52px; }

    /* Sidebar oculto, desliza desde la izquierda */
    .sidebar {
        width: var(--sidebar-w) !important;
        transform: translateX(-100%);
    }
    .sidebar.open { transform: translateX(0); }

    /* Restaurar texto en sidebar móvil */
    .brand-name, .brand-version, .nav-text, .nav-group-label,
    .user-info { display: block !important; }
    .sidebar-brand { justify-content: flex-start !important; padding: 0 16px !important; }
    .nav-link { justify-content: flex-start !important; padding: 9px 10px !important; margin: 1px 8px !important; }
    .user-pill { justify-content: flex-start !important; padding: 8px 10px !important; }
    .nav-group-label { display: block !important; }

    /* Main: sin margen lateral */
    .main { margin-left: 0 !important; width: 100% !important; }

    /* Mostrar hamburguesa */
    .hamburger { display: flex; }

    /* Ocultar breadcrumb largo y elementos del topbar */
    .breadcrumb .sep, .breadcrumb a:not(:last-of-type) { display: none; }
    .divider-v { display: none; }
    .topbar-user .uname-short { display: none; }
    .icon-btn.d-md-none { display: none; }

    /* Page con padding mínimo y espacio para bottom nav */
    .page { padding: 14px; padding-bottom: calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 14px); }

    /* Stats 2x2 */
    .stats-row { grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
    .stat-icon { width: 38px; height: 38px; font-size: 16px; }
    .stat-body .val { font-size: 18px; }
    .stat-card { padding: 12px 14px; gap: 10px; }

    /* Page header */
    .page-header { margin-bottom: 14px; }
    .page-heading { font-size: 17px; }

    /* Form cols → 1 col */
    .form-grid { grid-template-columns: 1fr !important; }
    .show-grid  { grid-template-columns: 1fr !important; }
    .form-row   { grid-template-columns: 1fr !important; }
    .form-row-3 { grid-template-columns: 1fr !important; }
    .metrics-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .metric-val { font-size: 16px; }

    /* Tabla: scroll horizontal */
    .data-table thead th { font-size: 10px; padding: 8px 10px; }
    .data-table td { padding: 10px 10px; }

    /* Filter bar vertical */
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-bar form { flex-direction: column !important; }
    .filter-bar .form-control,
    .filter-bar .form-select { width: 100% !important; }

    /* Card header */
    .card-header { padding: 11px 14px; }
    .card-body   { padding: 14px; }
    .form-section-body { padding: 14px; }

    /* Botones en header apilados */
    .page-header .btn .btn-text { display: none; }

    /* Bottom nav visible */
    .bottom-nav { display: block; }

    /* Hide topbar user on mobile */
    .topbar-user { display: none; }

    /* Sale form lines: managed entirely by form.php inline <style> (wrapper-div structure) */

    /* ── iOS Safari auto-zoom fix ──────────────────────────────────────────
       iOS zooms in on any focused input with font-size < 16px.
       Forcing 16px on all form controls prevents that annoyance globally.
    ─────────────────────────────────────────────────────────────────────── */
    input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]):not([type="submit"]):not([type="button"]):not([type="reset"]),
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ════════════════════════════════════════
   PRINT (vista pedido)
════════════════════════════════════════ */
@media print {
    .sidebar, .topbar, .page-header .btn,
    .card-header .btn, .bottom-nav { display: none !important; }
    .main { margin-left: 0 !important; }
    .page { padding: 0; }
    .show-grid { grid-template-columns: 1fr !important; }
}

/* ════════════════════════════════════════
   CHATTER — Historial de actividad
════════════════════════════════════════ */
.chatter-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chatter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-alt);
    flex-shrink: 0;
}

/* Feed scrollable */
.chatter-feed {
    flex: 1;
    overflow-y: auto;
    max-height: 520px;
    min-height: 80px;
    padding: 8px 0;
    scroll-behavior: smooth;
}

/* Estado vacío */
.chatter-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 32px 16px;
    color: var(--muted);
    font-size: 12px;
}
.chatter-empty i { font-size: 26px; opacity: .35; }

/* Entrada individual */
.chatter-entry {
    display: flex;
    gap: 10px;
    padding: 10px 14px;
    transition: background .15s;
}
.chatter-entry:hover { background: var(--bg); }

/* Punto de tipo (icono coloreado) */
.chatter-dot {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 1px;
}

/* Cuerpo del mensaje */
.chatter-body { flex: 1; min-width: 0; }

.chatter-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.chatter-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.chatter-user {
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}

.chatter-time {
    font-size: 11px;
    color: var(--muted);
    margin-left: auto;
    white-space: nowrap;
}

.chatter-msg {
    font-size: 13px;
    color: var(--text);
    line-height: 1.55;
    word-break: break-word;
}
.chatter-msg strong { color: var(--text); font-weight: 700; }
.chatter-msg em     { font-style: italic; color: var(--muted); }

/* Notas con fondo suave */
.chatter-msg-note {
    background: var(--bg-alt);
    border-radius: 8px;
    padding: 8px 12px;
    border: 1px solid var(--border);
}

/* Animación de nueva entrada */
.chatter-entry-new {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity .25s ease, transform .25s ease;
}
.chatter-entry-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Separador de fecha (future use) */
.chatter-date-sep {
    text-align: center;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .8px;
    color: var(--muted);
    padding: 6px 0;
    position: relative;
}
.chatter-date-sep::before {
    content: '';
    position: absolute;
    left: 16px; right: 16px;
    top: 50%;
    height: 1px;
    background: var(--border);
    z-index: 0;
}
.chatter-date-sep span {
    position: relative;
    z-index: 1;
    background: var(--surface);
    padding: 0 8px;
}

/* En desktop, la columna del chatter tiene ancho fijo */
/* Layout principal de detalle: documento | sidebar (opcional) | chatter 
   Diseño inspirado en Odoo Enterprise para máxima visibilidad.
*/
.doc-layout {
    display: flex;
    gap: 20px;
    align-items: start;
    width: 100%;
}

.doc-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.doc-aside {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chatter-col {
    width: 360px;
    flex-shrink: 0;
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    align-self: stretch;        /* ocupa toda la altura de la fila */
}

/* En pantallas de escritorio ancho */
@media (min-width: 1500px) {
    .chatter-col { width: 400px; }
}

/* En tablet: chatter ocupa ancho completo debajo del aside */
@media (max-width: 1280px) {
    .doc-layout { flex-wrap: wrap; }
    .doc-aside  { width: 100%; flex-direction: row; flex-wrap: wrap; gap: 12px; }
    .doc-aside > * { flex: 1; min-width: 220px; }
    .chatter-col {
        width: 100%;
        border-radius: 12px;
    }
    .chatter-feed { max-height: 320px; }
}

/* En móvil: columna única */
@media (max-width: 768px) {
    .doc-layout   { flex-direction: column; }
    .doc-aside    { flex-direction: column; }
    .doc-aside > * { min-width: unset; }
    .chatter-feed { max-height: 260px; }
}

/* ── SIDE PANEL (Generic tabbed sidebar) ────────────────── */
.side-panel {
    width: 340px;
    flex-shrink: 0;
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    align-self: stretch;
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 100px);
}

.side-panel-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    background: var(--bg);
    flex-shrink: 0;
}

.side-panel-tab {
    flex: 1;
    padding: 12px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--muted);
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all .15s;
}

.side-panel-tab:hover { color: var(--text); background: var(--card); }
.side-panel-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--card); }

.side-panel-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 16px;
}

.side-panel-body.hidden { display: none; }

/* Ajuste del chatter dentro de un side-panel */
.side-panel .chatter-card {
    flex: 1;
    min-height: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    background: transparent;
}

.side-panel .chatter-feed {
    flex: 1;
    min-height: 0;
    max-height: none;
    overflow-y: auto;
}

@media (max-width: 1100px) {
    .side-panel { width: 100%; position: static; max-height: none; }
}


/* ===================================================
   Dispatches — Bulk action bar
   =================================================== */
.bulk-bar {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px;
    display: none;
    align-items: center;
    gap: 20px;
    box-shadow: 0 10px 25px rgba(0,0,0,.3);
    z-index: 1000;
    animation: slideUpBar .3s ease-out;
}
@keyframes slideUpBar {
    from { bottom: -50px; opacity: 0; }
    to   { bottom: 20px;  opacity: 1; }
}
.bulk-bar select {
    background: rgba(255,255,255,.1);
    color: #fff;
    border: 1px solid rgba(255,255,255,.2);
    border-radius: 20px;
    padding: 4px 12px;
    height: 32px;
    font-size: 13px;
    outline: none;
}
.bulk-bar select option { background: #1e293b; color: #fff; }
.bulk-bar-divider { width: 1px; height: 20px; background: rgba(255,255,255,.2); }
.bulk-bar-label { font-size: 11px; text-transform: uppercase; opacity: .7; }

/* Overlay modal (roadmap, generic fullscreen overlay) */
.overlay-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.8);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}
.overlay-modal.is-open { display: flex; }
.overlay-modal-box {
    width: 400px;
    padding: 30px;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.overlay-modal-title {
    margin-top: 0;
    font-size: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.overlay-modal-sub {
    color: #64748b;
    font-size: 13px;
    margin-bottom: 25px;
}
.overlay-label {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    color: #94a3b8;
    display: block;
    margin-bottom: 5px;
}

/* Placeholder for non-selectable checkbox cells */
.check-placeholder {
    width: 13px; height: 13px;
    background: #f0f0f0;
    border-radius: 3px;
    margin: auto;
}

/* ════════════════════════════════════════
   VENTAS — MOBILE FIRST RESPONSIVE
════════════════════════════════════════ */

/* ── Visibility helpers ── */
@media (max-width: 768px) { .hide-on-mobile { display: none !important; } }
@media (min-width: 769px) { .show-on-mobile { display: none !important; } }

/* ── FAB — Floating Action Button ── */
.fab-btn {
    display: none;
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 22px;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 22px rgba(113,75,103,.45);
    z-index: 200;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: transform .15s, box-shadow .15s;
}
.fab-btn:hover, .fab-btn:active { transform: scale(1.08); box-shadow: 0 6px 30px rgba(113,75,103,.55); }
@media (max-width: 768px) { .fab-btn { display: flex; } }

/* ── Extra scroll clearance when a sticky bar is present ── */
@media (max-width: 768px) {
    body:has(.mob-action-bar) .page { padding-bottom: calc(var(--bottom-nav-h) + 80px) !important; }
}
@media (max-width: 960px) {
    body:has(.mob-form-bar) .page { padding-bottom: calc(var(--bottom-nav-h) + 80px) !important; }
}

/* ── Mobile action bar (show page: total + CTA) ── */
.mob-action-bar {
    display: none;
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 8px);
    left: 10px; right: 10px;
    z-index: 190;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
    box-shadow: 0 -2px 20px rgba(0,0,0,.12);
    align-items: center;
    gap: 12px;
}
.mob-action-bar .mob-total       { flex: 1; min-width: 0; }
.mob-action-bar .mob-total-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.mob-action-bar .mob-total-val   { font-size: 20px; font-weight: 800; color: var(--primary); line-height: 1.1; white-space: nowrap; }
@media (max-width: 768px) { .mob-action-bar { display: flex; } }

/* ── Sale info 2-col grid → 1-col on mobile ── */
.sale-info-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 640px) { .sale-info-grid { grid-template-columns: 1fr; } }

/* ── Sales list table → card rows on mobile ── */
@media (max-width: 768px) {
    .sales-list-table             { display: block; }
    .sales-list-table thead       { display: none; }
    .sales-list-table tbody       { display: block; }
    .sales-list-table tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 3px 10px;
        padding: 14px 16px;
        border-bottom: 1px solid var(--border);
        cursor: pointer;
        transition: background .12s;
    }
    .sales-list-table tbody tr:active { background: rgba(113,75,103,.06); }
    /* Nº pedido → row 1 col 1 */
    .sales-list-table tbody tr td:nth-child(1) { grid-row: 1; grid-column: 1; align-self: center; }
    /* Cliente → row 2 col 1 */
    .sales-list-table tbody tr td:nth-child(2) { grid-row: 2; grid-column: 1; align-self: center; font-size: 12px; }
    /* Total (col 8) → row 1 col 2 */
    .sales-list-table tbody tr td:nth-child(8) { grid-row: 1; grid-column: 2; text-align: right; align-self: center; }
    /* Estado (col 9) → row 2 col 2 */
    .sales-list-table tbody tr td:nth-child(9) { grid-row: 2; grid-column: 2; text-align: right; align-self: center; }
    /* Hide: almacén(3) fecha(4) venc(5) subtotal(6) iva(7) acciones(10) */
    .sales-list-table tbody tr td:nth-child(3),
    .sales-list-table tbody tr td:nth-child(4),
    .sales-list-table tbody tr td:nth-child(5),
    .sales-list-table tbody tr td:nth-child(6),
    .sales-list-table tbody tr td:nth-child(7),
    .sales-list-table tbody tr td:nth-child(10) { display: none; }
    /* Empty-state row: span full grid */
    .sales-list-table tbody tr td[colspan] { grid-column: 1 / -1; grid-row: 1; display: block; }
}

/* ── Sale form line items: stacked on small mobile ── */
/* Sale form ≤600px rules removed — handled by form.php inline <style> */

/* ── Mobile form sticky total bar ── */
.mob-form-bar {
    display: none;
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 8px);
    left: 10px; right: 10px;
    z-index: 190;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
    box-shadow: 0 -2px 20px rgba(0,0,0,.12);
    align-items: center;
    gap: 12px;
}
.mob-form-bar .mob-total       { flex: 1; min-width: 0; }
.mob-form-bar .mob-total-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.mob-form-bar .mob-total-val   { font-size: 18px; font-weight: 800; color: var(--primary); line-height: 1.1; white-space: nowrap; }
@media (max-width: 960px) { .mob-form-bar { display: flex; } }

/* ── Tablet: bigger touch targets across the board ── */
@media (min-width: 641px) and (max-width: 1024px) {
    .btn:not(.btn-xs):not(.btn-icon) { min-height: 40px; }
    .form-control, .form-select { min-height: 42px; font-size: 14px; }
    .data-table tbody tr td { padding: 12px 10px; font-size: 13px; }
    .tpv-img { width: 80px; height: 80px; }
    .tpv-qty-btn { width: 44px; height: 44px; font-size: 17px; }
}

/* ════════════════════════════════════════════════════════════
   MÓVIL GLOBAL (≤640px) — mejora todos los listados a la vez.
   Solo afecta a móvil; escritorio queda igual.
════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
    /* KPIs compactos: tiles verticales en 2 columnas */
    .stats-row {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        margin-bottom: 14px;
    }
    .stats-row .stat-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 11px 8px;
        gap: 4px;
        border-radius: 12px;
    }
    .stats-row .stat-icon,
    .stats-row .icon-box {
        width: 30px; height: 30px;
        font-size: 15px; border-radius: 9px;
    }
    .stats-row .stat-body { text-align: center; }
    .stats-row .val { font-size: 19px; font-weight: 800; line-height: 1; }
    .stats-row .lbl { font-size: 9.5px; line-height: 1.15; margin-top: 2px; }

    /* Filtros: campos a ancho completo, apilados */
    .filter-bar form { flex-direction: column; align-items: stretch !important; }
    .filter-bar .form-control,
    .filter-bar .form-select,
    .filter-bar input,
    .filter-bar select { width: 100% !important; max-width: 100% !important; min-width: 0 !important; }
    .filter-bar .btn { width: 100%; justify-content: center; }

    /* Cabecera de página compacta */
    .page-header { flex-wrap: wrap; gap: 10px; }
    .page-header .page-heading { font-size: 20px; }

    /* Tablas que no tengan versión de tarjetas: scroll horizontal suave */
    .overflow-auto { -webkit-overflow-scrolling: touch; }

    /* Paginación centrada y con espacio para tocar */
    .pagination .btn { min-width: 38px; min-height: 36px; }
}
