.view {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.view-max { max-width: 1400px; margin: 0 auto; }

/* ===== Login ===== */
.login-wrap {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 24px;
    padding: 24px;
    background:
        radial-gradient(ellipse at 20% 20%, rgb(20 184 166 / 0.12), transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgb(147 51 234 / 0.12), transparent 50%),
        var(--bg);
}
.login-card {
    width: min(92vw, 380px);
    padding: 32px 28px;
    border-radius: 24px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.7);
}
.logo-badge {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    font-weight: 800;
    color: #fff;
    margin: 0 auto;
    box-shadow: 0 15px 30px -10px rgb(20 184 166 / 0.5);
}
.role-btn {
    padding: 16px;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: var(--card);
    color: var(--text);
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: border-color 0.15s, transform 0.15s;
    font-family: inherit;
}
.role-btn:hover { border-color: var(--primary); transform: scale(1.02); }

/* ===== Nav ===== */
.nav {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    overflow-x: auto;
    flex-shrink: 0;
}
.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 16px;
    white-space: nowrap;
}
.nav-brand .mini {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 800;
    font-size: 14px;
}
.nav-tabs { display: flex; gap: 4px; }
.nav-tab {
    position: relative;
    overflow-x: auto;
}
.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    display: inline-block;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
.online-dot.offline { background: var(--error); animation: none; }

/* ===== POS ===== */
.view:has(#pos-root) { overflow: hidden; padding: 0; }
.mobile-only { display: none !important; }
@media (max-width: 900px) {
    .mobile-only { display: inline-flex !important; }
}

#pos-root { height: 100%; padding: 16px; gap: 12px; min-height: 0; }

.pos-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    grid-template-rows: minmax(0, 1fr);
    gap: 16px;
    height: 100%;
    min-height: 0;
}
@media (max-width: 900px) {
    .pos-grid { grid-template-columns: 1fr; }
}
.product-card {
    cursor: pointer;
    user-select: none;
}
.product-card.out { opacity: 0.35; pointer-events: none; }
.product-card .pname { font-weight: 700; font-size: 13px; }
.product-card .pprice { color: var(--primary); font-weight: 800; font-size: 15px; }
.product-card .pstock { font-size: 11px; color: var(--text-muted); }

.cart-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}
.cart-items {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.cart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgb(51 65 85 / 0.4);
}
.qty-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    font-weight: 800;
    cursor: pointer;
}
.qty-btn:hover { border-color: var(--primary); }

.cart-item-price { color: var(--primary); font-weight: 700; font-size: 12px; }
.cart-qty {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.cart-qty-input {
    width: 46px;
    height: 28px;
    border-radius: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    text-align: center;
    font-family: ui-monospace, Consolas, 'Cascadia Mono', monospace;
    font-weight: 700;
    font-size: 13px;
}
.cart-qty-input:focus { border-color: var(--primary); outline: none; }
.cart-round {
    width: 28px;
    height: 28px;
    border-radius: 9999px;
    background: var(--surface);
    border: 1px solid var(--border);
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.cart-round:hover:not(:disabled) { border-color: var(--primary); }
.cart-round:disabled { opacity: 0.3; cursor: not-allowed; }
.cart-round-x { background: rgb(244 63 94 / 0.2); border-color: transparent; color: #fb7185; font-size: 12px; }
.cart-round-x:hover:not(:disabled) { border-color: rgb(244 63 94 / 0.6); }

.summary-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
}

/* ===== Cart FAB (mobile) ===== */
.cart-fab {
    display: none;
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 600;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 12px 30px -8px rgb(0 0 0 / 0.6);
}
.cart-fab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--gradient);
    color: #fff;
    font-weight: 800;
    font-size: 13px;
}
.cart-fab-total { margin-left: auto; font-weight: 800; font-size: 15px; }

@media (max-width: 900px) {
    .summary-strip { display: none; }
    #pos-root { padding-bottom: 84px; }
    .cart-fab { display: flex; }
    #pos-cart-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        width: 100%;
        height: auto;
        max-height: 78vh;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -10px 40px -12px rgb(0 0 0 / 0.8);
        transform: translateY(105%);
        transition: transform 0.25s ease;
        z-index: 550;
    }
    #pos-cart-panel.cart-open { transform: translateY(0); }
}

/* ===== Tables / lists ===== */
.stack { display: flex; flex-direction: column; gap: 10px; }
.row-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

/* ===== Billetage counters ===== */
.note-counter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.counters-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}
@media (max-width: 640px) {
    .counters-grid { grid-template-columns: repeat(2, 1fr); }
}
.note-counter > .note-col {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== Admin panels (style de référence) ===== */
.adm-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 16px;
}
.adm-grid > .adm-col-6 { grid-column: span 6; }
@media (max-width: 1000px) {
    .adm-grid > .adm-col-6 { grid-column: span 12; }
}
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.4);
}
.panel-head {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}
.panel-body { padding: 16px 18px; }
.panel-title {
    font-weight: 800;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-title .ic { color: var(--primary); }
.panel-title .ic-rose { color: var(--error); }
.panel-title .ic-amber { color: var(--warning); }
.panel-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.icon-tile {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}
.icon-tile.teal { background: rgb(20 184 166 / 0.12); color: var(--primary); }
.icon-tile.purple { background: rgb(147 51 234 / 0.12); color: #c084fc; }
.icon-tile.amber { background: rgb(245 158 11 / 0.12); color: var(--warning); }
.icon-tile.rose { background: rgb(244 63 94 / 0.12); color: var(--error); }
.icon-tile.emerald { background: rgb(16 185 129 / 0.12); color: var(--success); }
.icon-tile.indigo { background: rgb(99 102 241 / 0.14); color: #818cf8; }
.icon-tile.sky { background: rgb(14 165 233 / 0.12); color: var(--info); }

.kpi-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
}
.kpi-card .kc-label { font-size: 11px; color: var(--text-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.4px; }
.kpi-card .kc-value { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; font-weight: 800; font-size: 19px; margin-top: 5px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }

.subtab {
    padding: 8px 16px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 800;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: background 0.15s, color 0.15s;
}
.subtab:hover { background: var(--card); color: var(--text); }
.subtab-active { background: var(--primary) !important; color: #fff !important; }

.btn-alert {
    background: rgb(245 158 11 / 0.1);
    border: 1px solid rgb(245 158 11 / 0.5);
    color: #fcd34d;
}
.btn-alert:hover:not(:disabled) { background: rgb(245 158 11 / 0.2); }
.btn-alert.btn-active { background: var(--warning); border-color: var(--warning); color: #0f172a; }

.select-slim {
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
}
.select-slim:focus { outline: none; border-color: var(--primary); }

.pill-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--error);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
}

/* ===== Print ===== */
@media print {
    body * { visibility: hidden; }
    #printable-receipt, #printable-receipt * { visibility: visible; }
    #printable-receipt {
        position: absolute;
        left: 0;
        top: 0;
        width: 80mm;
        background: white;
        color: black;
        font-family: 'Courier New', ui-monospace, monospace;
        font-size: 12px;
        padding: 5mm;
    }
}

.receipt-preview {
    font-family: 'Courier New', ui-monospace, monospace;
    font-size: 12px;
    line-height: 1.5;
    background: #fff;
    color: #000;
    border-radius: 8px;
    padding: 16px;
    white-space: pre-wrap;
}

.barcode-img { max-width: 180px; height: 46px; image-rendering: pixelated; }

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

.section-title {
    font-size: 16px;
    font-weight: 800;
    margin: 18px 0 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.search-input {
    padding: 10px 14px 10px 38px;
    border-radius: 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
    width: 100%;
}
.search-input:focus { outline: none; border-color: var(--primary); }
.search-wrap { position: relative; }
.search-wrap::before {
    content: '';
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-55%);
    width: 14px;
    height: 14px;
    border: 2px solid var(--text-muted);
    border-radius: 50%;
}
.search-wrap::after {
    content: '';
    position: absolute;
    left: 26px;
    top: calc(50% - 1px);
    width: 7px;
    height: 2px;
    background: var(--text-muted);
    transform: rotate(45deg);
    transform-origin: left center;
}