/* ============================================================
   PharmaCare — Modern UI Stylesheet v2.0
   ============================================================ */

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

/* --- CSS Variables --- */
:root {
    --primary:        #4f46e5;
    --primary-dark:   #3730a3;
    --primary-light:  #e0e7ff;
    --primary-xlight: #eef2ff;
    --primary-glow:   rgba(79,70,229,.18);

    --secondary:      #64748b;
    --success:        #10b981;
    --success-light:  #d1fae5;
    --warning:        #f59e0b;
    --warning-light:  #fef3c7;
    --danger:         #ef4444;
    --danger-light:   #fee2e2;
    --info:           #06b6d4;
    --info-light:     #cffafe;
    --purple:         #8b5cf6;
    --purple-light:   #ede9fe;
    --orange:         #f97316;
    --orange-light:   #ffedd5;

    --bg:             #f8fafc;
    --card-bg:        #ffffff;
    --text:           #0f172a;
    --text-muted:     #64748b;
    --text-light:     #94a3b8;
    --border:         #e2e8f0;
    --border-light:   #f1f5f9;

    --sidebar-bg:     #0f172a;
    --sidebar-width:      260px;
    --topbar-height:      62px;
    --bottom-nav-height:  60px;

    --shadow-xs:  0 1px 2px rgba(0,0,0,.05);
    --shadow-sm:  0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
    --shadow:     0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
    --shadow-md:  0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.05);
    --shadow-lg:  0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.06);
    --shadow-xl:  0 25px 50px -12px rgba(0,0,0,.18);

    --radius-xs:  6px;
    --radius-sm:  10px;
    --radius:     14px;
    --radius-lg:  18px;
    --radius-xl:  24px;
    --radius-2xl: 32px;

    --transition: all .2s cubic-bezier(.4,0,.2,1);
    --transition-slow: all .35s cubic-bezier(.4,0,.2,1);
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 14px;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    overflow: hidden;
    border-right: 1px solid rgba(255,255,255,.05);
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 22px 18px 18px;
    border-bottom: 1px solid rgba(255,255,255,.07);
    background: rgba(255,255,255,.02);
}

.brand-icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px var(--primary-glow);
}

.brand-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: #fff;
    letter-spacing: -.4px;
}

.brand-sub {
    font-size: .68rem;
    color: #475569;
    text-transform: uppercase;
    letter-spacing: .8px;
    font-weight: 500;
    margin-top: 1px;
}

/* Nav */
.sidebar-nav {
    flex: 1;
    padding: 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.sidebar-nav .nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 11px 13px;
    border-radius: var(--radius-sm);
    color: #64748b;
    font-size: .875rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.sidebar-nav .nav-item i {
    width: 18px;
    text-align: center;
    font-size: .95rem;
    flex-shrink: 0;
    transition: var(--transition);
}

.sidebar-nav .nav-item:hover {
    background: rgba(255,255,255,.06);
    color: #cbd5e1;
}

.sidebar-nav .nav-item.active {
    background: linear-gradient(135deg, rgba(79,70,229,.25), rgba(129,140,248,.15));
    color: #a5b4fc;
    border: 1px solid rgba(79,70,229,.3);
}

.sidebar-nav .nav-item.active i { color: #818cf8; }

.sidebar-nav .nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 20%; bottom: 20%;
    width: 3px;
    background: #818cf8;
    border-radius: 0 4px 4px 0;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 14px;
    border-top: 1px solid rgba(255,255,255,.07);
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255,255,255,.02);
}

.user-info { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }

.user-avatar {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: .82rem;
    flex-shrink: 0;
}

.user-name { font-size: .84rem; font-weight: 600; color: #e2e8f0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .7rem; color: #475569; text-transform: capitalize; margin-top: 1px; }

.logout-btn {
    width: 34px; height: 34px;
    border-radius: 9px;
    background: rgba(255,255,255,.06);
    color: #64748b;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: var(--transition);
    font-size: .85rem;
}

.logout-btn:hover { background: rgba(239,68,68,.2); color: #f87171; }

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 999;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.sidebar-overlay.show { display: block; }

/* ============================================================
   LAYOUT
   ============================================================ */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Bar */
.topbar {
    position: sticky; top: 0;
    height: var(--topbar-height);
    background: rgba(255,255,255,.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(226,232,240,.8);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 12px;
    z-index: 100;
    box-shadow: 0 1px 0 rgba(0,0,0,.04), var(--shadow-xs);
}

.topbar-toggle {
    background: none; border: none;
    padding: 8px; border-radius: 10px;
    color: var(--text); cursor: pointer;
    font-size: 1.1rem;
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}
.topbar-toggle:hover { background: var(--bg); }

.topbar-title {
    flex: 1;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.3px;
}

.topbar-actions { display: flex; align-items: center; gap: 8px; }

.topbar-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--primary-xlight);
    color: var(--primary);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: .88rem;
    transition: var(--transition);
}
.topbar-btn:hover { background: var(--primary); color: #fff; transform: scale(1.05); }

.topbar-avatar {
    width: 34px; height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .8rem; cursor: pointer;
}

/* Main Content */
.main-content { flex: 1; padding: 22px 24px; padding-bottom: 32px; }

/* ============================================================
   BOTTOM NAV (Mobile)
   ============================================================ */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-height);
    background: rgba(255,255,255,.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1000;
    box-shadow: 0 -8px 24px rgba(0,0,0,.08);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bn-item {
    display: flex; flex-direction: column;
    align-items: center; gap: 3px;
    padding: 6px 8px;
    color: var(--text-light);
    font-size: .62rem; font-weight: 600;
    transition: var(--transition);
    border-radius: var(--radius-sm);
    text-transform: uppercase; letter-spacing: .5px;
    flex: 1; position: relative;
}

.bn-item i { font-size: 1.15rem; transition: var(--transition); }

.bn-item.active { color: var(--primary); }

.bn-item.active i {
    transform: translateY(-3px) scale(1.15);
    filter: drop-shadow(0 4px 6px var(--primary-glow));
}

.bn-item.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--primary);
}

/* ============================================================
   ALERT STRIPS (Fixed Mobile Layout)
   ============================================================ */
.alert-strip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: .84rem;
    font-weight: 500;
    margin-bottom: 10px;
    flex-wrap: wrap;
    position: relative;
    overflow: hidden;
}

.alert-strip::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 4px;
}

.alert-strip .alert-icon {
    flex-shrink: 0;
    width: 30px; height: 30px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: .9rem;
}

.alert-strip .alert-text {
    flex: 1;
    min-width: 180px;
    line-height: 1.4;
}

.alert-strip .alert-text strong { display: block; font-size: .88rem; }
.alert-strip .alert-text span { font-size: .8rem; opacity: .8; }

.alert-strip .alert-btn {
    flex-shrink: 0;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: .78rem;
    font-weight: 700;
    text-decoration: none;
    transition: var(--transition);
    white-space: nowrap;
    border: 1.5px solid currentColor;
}

.alert-strip.danger {
    background: linear-gradient(135deg, #fef2f2, #fff1f1);
    border: 1px solid #fecaca;
    color: #dc2626;
}
.alert-strip.danger::before { background: var(--danger); }
.alert-strip.danger .alert-icon { background: #fee2e2; color: #dc2626; }
.alert-strip.danger .alert-btn:hover { background: #dc2626; color: #fff; }

.alert-strip.warning {
    background: linear-gradient(135deg, #fffbeb, #fefce8);
    border: 1px solid #fde68a;
    color: #b45309;
}
.alert-strip.warning::before { background: var(--warning); }
.alert-strip.warning .alert-icon { background: #fef3c7; color: #b45309; }
.alert-strip.warning .alert-btn:hover { background: #b45309; color: #fff; }

/* ============================================================
   STAT CARDS (Modern Gradient Style)
   ============================================================ */
.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 18px 16px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: var(--transition-slow);
    position: relative;
    overflow: hidden;
    cursor: default;
}

.stat-card::after {
    content: '';
    position: absolute;
    right: -20px; bottom: -20px;
    width: 80px; height: 80px;
    border-radius: 50%;
    background: var(--stat-color, var(--primary));
    opacity: .05;
    transition: var(--transition-slow);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--stat-color, var(--primary));
}

.stat-card:hover::after { opacity: .1; transform: scale(1.2); }

.stat-icon {
    width: 50px; height: 50px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.35rem;
    flex-shrink: 0;
    background: var(--stat-bg, var(--primary-xlight));
    color: var(--stat-color, var(--primary));
    position: relative;
    z-index: 1;
    transition: var(--transition);
}

.stat-card:hover .stat-icon { transform: scale(1.08) rotate(-4deg); }

.stat-body { flex: 1; min-width: 0; position: relative; z-index: 1; }

.stat-value {
    font-size: 1.65rem;
    font-weight: 800;
    color: var(--text);
    line-height: 1;
    letter-spacing: -1.5px;
}

.stat-label {
    font-size: .75rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 5px;
    text-transform: uppercase;
    letter-spacing: .4px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
}

.card-header-custom {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--card-bg);
}

.card-header-custom .card-title {
    font-size: .875rem;
    font-weight: 700;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -.2px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-custom { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .86rem; }

.table-custom thead th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .7px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table-custom tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    color: var(--text);
    transition: background .15s;
}

.table-custom tbody tr:last-child td { border-bottom: none; }
.table-custom tbody tr:hover td { background: #f8faff; }

.row-danger td  { background: #fff8f8 !important; }
.row-warning td { background: #fffdf0 !important; }
.row-danger:hover td  { background: #fff0f0 !important; }
.row-warning:hover td { background: #fffadc !important; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: .7rem;
    letter-spacing: .2px;
}

.bg-success { background: var(--success) !important; }
.bg-warning { background: var(--warning) !important; }
.bg-danger  { background: var(--danger)  !important; }
.bg-primary { background: var(--primary) !important; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn { border-radius: var(--radius-sm); font-weight: 600; transition: var(--transition); letter-spacing: -.1px; }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    border: none;
    box-shadow: 0 2px 8px var(--primary-glow);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--primary-glow);
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #34d399);
    border: none;
    box-shadow: 0 2px 8px rgba(16,185,129,.2);
}
.btn-success:hover { transform: translateY(-1px); }

.btn-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    padding: 0; font-size: .82rem;
    border: none; cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover { transform: scale(1.1); }

/* ============================================================
   FORM CONTROLS
   ============================================================ */
.form-label {
    font-size: .78rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: .4px;
    color: var(--text-muted); margin-bottom: 6px;
}

.form-control, .form-select {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-size: .88rem;
    background: #fafafa;
    transition: var(--transition);
    font-family: inherit;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--card-bg);
    outline: none;
}

/* ============================================================
   SEARCH BOX
   ============================================================ */
.search-box { position: relative; }

.search-box input {
    padding-left: 40px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: #fafafa;
    height: 42px;
    font-size: .88rem;
    transition: var(--transition);
    width: 100%;
    font-family: inherit;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--card-bg);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box .search-icon {
    position: absolute; left: 13px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    pointer-events: none; font-size: .9rem;
}

/* ============================================================
   AUTOCOMPLETE DROPDOWN
   ============================================================ */
.autocomplete-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0; right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 500;
    max-height: 300px;
    overflow-y: auto;
    animation: dropIn .15s ease;
}

@keyframes dropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.autocomplete-item {
    padding: 10px 14px;
    cursor: pointer;
    display: flex; align-items: center;
    justify-content: space-between; gap: 10px;
    border-bottom: 1px solid var(--border-light);
    transition: var(--transition);
}

.autocomplete-item:last-child { border-bottom: none; }
.autocomplete-item:hover { background: var(--primary-xlight); }

.ac-name { font-weight: 600; font-size: .88rem; color: var(--text); }
.ac-meta { font-size: .76rem; color: var(--text-muted); margin-top: 2px; }
.ac-price { font-weight: 700; color: var(--primary); font-size: .9rem; white-space: nowrap; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    overflow: hidden;
}

.modal-header {
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff; border: none;
    padding: 18px 22px;
}

.modal-header .btn-close { filter: brightness(0) invert(1) opacity(.8); }
.modal-body { padding: 22px; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
    display: flex; align-items: center;
    justify-content: space-between;
    flex-wrap: wrap; gap: 12px;
    margin-bottom: 20px;
}

.page-header h1 {
    font-size: 1.35rem; font-weight: 800;
    color: var(--text); letter-spacing: -.5px;
}

/* ============================================================
   MEDICINE FILTER BAR
   ============================================================ */
.medicine-filter-bar {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    box-shadow: var(--shadow-xs);
}

.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }

.filter-pill {
    padding: 5px 13px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    font-size: .76rem; font-weight: 600;
    cursor: pointer; transition: var(--transition);
    color: var(--text-muted); background: var(--card-bg);
}

.filter-pill:hover { background: var(--primary-xlight); border-color: var(--primary); color: var(--primary); }
.filter-pill.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 2px 8px var(--primary-glow); }
.filter-pill.pill-danger.active { background: var(--danger); border-color: var(--danger); box-shadow: 0 2px 8px rgba(239,68,68,.25); }
.filter-pill.pill-warning.active { background: var(--warning); border-color: var(--warning); color: #fff; }

/* ============================================================
   FAB
   ============================================================ */
.fab {
    position: fixed;
    bottom: calc(var(--bottom-nav-height) + 16px);
    right: 20px;
    width: 52px; height: 52px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    color: #fff; border: none; cursor: pointer;
    font-size: 1.25rem;
    box-shadow: 0 6px 20px var(--primary-glow);
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition-slow); z-index: 200;
}

.fab:hover {
    transform: translateY(-3px) rotate(90deg);
    box-shadow: 0 10px 28px var(--primary-glow);
}

/* ============================================================
   BILLING PAGE
   ============================================================ */
.billing-layout {
    display: grid;
    grid-template-columns: 1fr 370px;
    gap: 18px;
    height: calc(100vh - var(--topbar-height) - 44px);
}

.billing-left { display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.billing-right { display: flex; flex-direction: column; overflow: hidden; }

.cart-wrapper {
    flex: 1; overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--card-bg);
    box-shadow: var(--shadow-xs);
}

.cart-table { width: 100%; border-collapse: collapse; }

.cart-table thead th {
    padding: 10px 12px;
    font-size: .72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: .6px;
    color: var(--text-muted); background: #f8fafc;
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0;
}

.cart-table tbody td {
    padding: 10px 12px; font-size: .87rem;
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
}

.cart-table tbody tr:last-child td { border-bottom: none; }
.cart-table tbody tr:hover td { background: #f8faff; }

.cart-empty {
    text-align: center; padding: 60px 20px; color: var(--text-muted);
}
.cart-empty i { font-size: 3rem; opacity: .15; display: block; margin-bottom: 12px; }

/* Qty Stepper */
.qty-stepper {
    display: inline-flex; align-items: center;
    border: 1.5px solid var(--border);
    border-radius: 10px; overflow: hidden;
}

.qty-btn {
    width: 28px; height: 28px;
    background: var(--bg); border: none; cursor: pointer;
    font-size: .95rem; color: var(--text);
    display: flex; align-items: center; justify-content: center;
    transition: var(--transition);
}

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

.qty-input {
    width: 36px; height: 28px; border: none;
    text-align: center; font-size: .86rem;
    font-weight: 700; color: var(--text);
    background: var(--card-bg);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    font-family: inherit;
}

.qty-input:focus { outline: none; background: var(--primary-xlight); }

/* Bill Panel */
.bill-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    display: flex; flex-direction: column;
    overflow: hidden; height: 100%;
    box-shadow: var(--shadow-sm);
}

.bill-panel-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, var(--primary-xlight), #f0f4ff);
}

.bill-panel-header h6 {
    font-weight: 800; font-size: .85rem;
    color: var(--primary); text-transform: uppercase;
    letter-spacing: .5px;
}

.bill-panel-body {
    padding: 14px; flex: 1; overflow-y: auto;
    display: flex; flex-direction: column; gap: 12px;
}

.bill-field label {
    font-size: .72rem; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase;
    letter-spacing: .5px; margin-bottom: 5px; display: block;
}

.bill-field input, .bill-field select {
    width: 100%; padding: 8px 11px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .88rem; color: var(--text);
    background: #fafafa; transition: var(--transition);
    font-family: inherit;
}

.bill-field input:focus, .bill-field select:focus {
    outline: none; border-color: var(--primary);
    background: var(--card-bg);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.bill-summary-line {
    display: flex; justify-content: space-between;
    align-items: center; padding: 6px 0;
    font-size: .86rem; color: var(--text-muted);
}

.bill-summary-line.total-line {
    border-top: 2px dashed var(--border);
    margin-top: 6px; padding-top: 12px;
    font-size: 1.05rem; font-weight: 800;
    color: var(--text);
}

.bill-panel-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    display: flex; gap: 8px;
    background: var(--bg);
}

.gst-toggle {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    background: var(--primary-xlight);
    border-radius: var(--radius-sm);
    cursor: pointer; font-size: .84rem;
    color: var(--primary); font-weight: 600;
    transition: var(--transition);
}

.gst-toggle:hover { background: var(--primary-light); }

/* ============================================================
   REORDER PAGE
   ============================================================ */
.reorder-card {
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 13px 14px;
    display: flex; align-items: center; gap: 12px;
    transition: var(--transition); cursor: pointer;
    box-shadow: var(--shadow-xs);
}

.reorder-card:hover { border-color: var(--primary); background: var(--primary-xlight); transform: translateX(3px); }
.reorder-card.selected { border-color: var(--primary); background: var(--primary-xlight); }

.reorder-check {
    width: 22px; height: 22px;
    border-radius: 7px; border: 2px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: transparent; transition: var(--transition); flex-shrink: 0;
}

.reorder-card.selected .reorder-check {
    background: var(--primary); border-color: var(--primary); color: #fff;
}

.reorder-info { flex: 1; min-width: 0; }
.reorder-name { font-weight: 700; font-size: .9rem; color: var(--text); }
.reorder-meta { font-size: .76rem; color: var(--text-muted); margin-top: 2px; }

.reorder-qty-input {
    width: 68px; padding: 6px 8px;
    border: 1.5px solid var(--border);
    border-radius: 8px; text-align: center;
    font-size: .88rem; font-weight: 700;
    color: var(--text); background: #fafafa;
    font-family: inherit; transition: var(--transition);
}

.reorder-qty-input:focus { outline: none; border-color: var(--primary); background: var(--card-bg); }

/* PO Preview */
.po-preview {
    background: #fff; border: 2px solid var(--border);
    border-radius: var(--radius); padding: 22px;
    font-family: 'Courier New', monospace;
}

.po-header { text-align: center; margin-bottom: 18px; }
.po-title { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.po-subtitle { font-size: .8rem; color: var(--text-muted); }

.po-table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: .86rem; }
.po-table th { border-bottom: 2px solid var(--text); padding: 8px; text-align: left; }
.po-table td { border-bottom: 1px dashed var(--border); padding: 8px; }

/* ============================================================
   REPORTS
   ============================================================ */
.report-summary-card {
    background: linear-gradient(135deg, var(--primary) 0%, #6366f1 50%, var(--purple) 100%);
    color: #fff; border-radius: var(--radius-lg);
    padding: 22px; box-shadow: 0 8px 24px var(--primary-glow);
    position: relative; overflow: hidden;
}

.report-summary-card::after {
    content: '';
    position: absolute; right: -20px; bottom: -20px;
    width: 100px; height: 100px;
    border-radius: 50%; background: rgba(255,255,255,.08);
}

.report-summary-card .rs-label { font-size: .75rem; opacity: .75; text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.report-summary-card .rs-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -1.5px; margin-top: 4px; }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center; padding: 48px 24px; color: var(--text-muted);
}

.empty-state i { font-size: 2.8rem; opacity: .18; display: block; margin-bottom: 14px; }
.empty-state h5 { font-weight: 700; color: var(--text); margin-bottom: 6px; font-size: .95rem; }
.empty-state p { font-size: .84rem; }

/* ============================================================
   PRINT (Thermal)
   ============================================================ */
@media print {
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }

    /* Hide everything except printBill and its ancestors */
    body > * { display: none !important; }
    .main-wrapper, .main-content { display: block !important; }
    .billing-layout, .topbar, .sidebar, .sidebar-overlay,
    .bottom-nav, .toast-container { display: none !important; }

    #printBill {
        display: block !important;
        position: fixed; top: 0; left: 0;
        width: 80mm; background: #fff; color: #000;
        font-family: 'Courier New', monospace;
        font-size: 11px; padding: 10px;
    }

    .thermal-bill { width: 100%; }
    .thermal-header { text-align: center; margin-bottom: 10px; }
    .thermal-header h2 { font-size: 14px; font-weight: bold; margin: 0; }
    .thermal-header p { font-size: 10px; margin: 2px 0; }
    .thermal-divider { border: none; border-top: 1px dashed #000; margin: 8px 0; }
    .thermal-table { width: 100%; border-collapse: collapse; font-size: 10px; }
    .thermal-table th { text-align: left; border-bottom: 1px solid #000; padding: 4px 2px; font-weight: bold; }
    .thermal-table td { padding: 3px 2px; vertical-align: top; }
    .thermal-table .col-qty { text-align: center; }
    .thermal-table .col-price, .thermal-table .col-total { text-align: right; }
    .thermal-totals { margin-top: 8px; }
    .thermal-total-row { display: flex; justify-content: space-between; font-size: 11px; padding: 2px 0; }
    .thermal-grand-total { font-weight: bold; font-size: 13px; border-top: 1px solid #000; padding-top: 4px; margin-top: 4px; }
    .thermal-footer { text-align: center; margin-top: 12px; font-size: 10px; }

    @page { margin: 0; size: 80mm auto; }
}

#printBill { display: none; }

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-light); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
body.login-page {
    background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 40%, #312e81 100%);
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
}

body.login-page::before {
    content: '';
    position: fixed; inset: 0;
    background-image:
        radial-gradient(ellipse at 20% 20%, rgba(79,70,229,.3) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139,92,246,.2) 0%, transparent 50%);
    pointer-events: none;
}

.login-card {
    background: rgba(255,255,255,.97);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 38px;
    width: 100%; max-width: 410px;
    position: relative; z-index: 1;
    border: 1px solid rgba(255,255,255,.6);
}

.login-logo { text-align: center; margin-bottom: 28px; }

.login-logo .logo-icon {
    width: 64px; height: 64px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--primary), #818cf8);
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 14px;
    box-shadow: 0 8px 24px var(--primary-glow);
}

.login-logo h1 {
    font-size: 1.5rem; font-weight: 800;
    color: var(--text); letter-spacing: -.5px;
}

.login-logo p { color: var(--text-muted); font-size: .86rem; margin-top: 3px; }

.login-btn {
    width: 100%; padding: 13px;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    color: #fff; border: none;
    border-radius: var(--radius-sm);
    font-size: .95rem; font-weight: 700;
    cursor: pointer; transition: var(--transition-slow);
    box-shadow: 0 4px 14px var(--primary-glow);
    letter-spacing: -.2px; font-family: inherit;
}

.login-btn:hover {
    background: linear-gradient(135deg, var(--primary-dark), var(--primary));
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--primary-glow);
}

.input-icon-group { position: relative; }
.input-icon-group .input-icon {
    position: absolute; left: 13px; top: 50%;
    transform: translateY(-50%); color: var(--text-light); pointer-events: none;
}
.input-icon-group input { padding-left: 40px; }

/* ============================================================
   RESPONSIVE — TABLET
   ============================================================ */
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-xl); }

    .main-wrapper { margin-left: 0; padding-bottom: var(--bottom-nav-height); }
    .main-content { padding: 16px 16px 24px; }

    .billing-layout { grid-template-columns: 1fr; height: auto; }
    .bill-panel { height: auto; }

    .page-header h1 { font-size: 1.15rem; }
    .stat-value { font-size: 1.4rem; }
}

/* ============================================================
   iOS-STYLE MOBILE UI  ≤ 767px
   ============================================================ */
@media (max-width: 767.98px) {

    /* ---- Global feel ---- */
    * { -webkit-tap-highlight-color: transparent; }

    body { font-size: 15px; background: #f2f2f7; }

    /* ---- Topbar ---- */
    .topbar {
        height: 54px;
        padding: 0 14px;
        background: rgba(242,242,247,.92);
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        border-bottom: .5px solid rgba(60,60,67,.2);
        box-shadow: none;
    }

    .topbar-title {
        font-size: 1.05rem;
        font-weight: 700;
        letter-spacing: -.4px;
    }

    .topbar-toggle {
        width: 38px; height: 38px;
        border-radius: 50%;
        background: rgba(120,120,128,.12);
        display: flex; align-items: center; justify-content: center;
    }

    .topbar-btn {
        width: 34px; height: 34px;
        border-radius: 50%;
        background: rgba(79,70,229,.12);
    }

    .topbar-avatar {
        width: 32px; height: 32px;
        border-radius: 50%;
    }

    /* ---- Main content ---- */
    .main-wrapper {
        padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    }

    .main-content {
        padding: 14px 14px 20px;
    }

    /* ---- iOS Bottom Navigation ---- */
    .bottom-nav {
        height: calc(60px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: rgba(249,249,249,.94);
        backdrop-filter: saturate(180%) blur(20px);
        -webkit-backdrop-filter: saturate(180%) blur(20px);
        border-top: .5px solid rgba(60,60,67,.2);
        box-shadow: 0 -1px 0 rgba(0,0,0,.06);
    }

    .bn-item {
        gap: 4px;
        padding: 8px 6px 4px;
        font-size: .6rem;
        letter-spacing: .3px;
        border-radius: 0;
        position: relative;
    }

    .bn-item i {
        font-size: 1.3rem;
        display: block;
        transition: transform .2s cubic-bezier(.34,1.56,.64,1);
    }

    .bn-item span {
        font-size: .6rem;
        font-weight: 500;
        display: block;
    }

    .bn-item.active i {
        transform: scale(1.15) translateY(-1px);
        filter: none;
    }

    .bn-item.active::after { display: none; }

    /* ---- Cards — iOS rounded ---- */
    .card {
        border-radius: 16px;
        border: none;
        box-shadow: 0 2px 12px rgba(0,0,0,.07);
    }

    .card-header-custom { padding: 14px 16px 12px; }

    /* ---- Stat cards — 2-column grid ---- */
    .stat-card {
        border-radius: 16px;
        border: none;
        padding: 16px 14px;
        box-shadow: 0 2px 10px rgba(0,0,0,.07);
    }

    .stat-icon { width: 46px; height: 46px; font-size: 1.1rem; border-radius: 13px; }
    .stat-value { font-size: 1.45rem; letter-spacing: -1px; }
    .stat-label { font-size: .7rem; }

    /* ---- Touch feedback on interactive elements ---- */
    .stat-card:active,
    .filter-pill:active,
    .reorder-card:active {
        transform: scale(.97);
        transition: transform .1s ease;
    }

    .btn:active,
    .btn-icon:active {
        transform: scale(.94) !important;
        transition: transform .1s ease !important;
    }

    .bn-item:active i { transform: scale(.9); }

    /* ---- Alert strips ---- */
    .alert-strip { border-radius: 14px; }

    /* ---- Filter bar — horizontal scroll ---- */
    .medicine-filter-bar {
        padding: 10px 14px;
        border-radius: 16px;
        border: none;
        box-shadow: 0 2px 8px rgba(0,0,0,.06);
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 8px;
    }

    .medicine-filter-bar::-webkit-scrollbar { display: none; }

    .medicine-filter-bar .search-box {
        flex: 0 0 auto;
        width: 100%;
        max-width: 100%;
        order: -1;
        flex-basis: 100%;
    }

    .filter-pills {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 6px;
        padding-bottom: 2px;
    }

    .filter-pills::-webkit-scrollbar { display: none; }

    .filter-pill {
        flex-shrink: 0;
        padding: 6px 14px;
        border-radius: 20px;
        font-size: .75rem;
        white-space: nowrap;
    }

    /* ---- Medicine table → card list on mobile ---- */
    #medTable thead { display: none; }

    #medTable tbody tr {
        display: block;
        background: #fff;
        margin-bottom: 10px;
        border-radius: 14px;
        box-shadow: 0 2px 8px rgba(0,0,0,.06);
        border: none;
        padding: 14px 16px;
        position: relative;
    }

    #medTable tbody tr:last-child { margin-bottom: 0; }

    #medTable tbody tr td {
        display: flex;
        padding: 3px 0;
        border: none;
        font-size: .875rem;
        align-items: center;
        justify-content: space-between;
    }

    /* Hide columns not needed on mobile */
    #medTable tbody tr td:nth-child(1),   /* # */
    #medTable tbody tr td:nth-child(3),   /* Batch */
    #medTable tbody tr td:nth-child(5),   /* Buy Price */
    #medTable tbody tr td:nth-child(7),   /* Tab Price */
    #medTable tbody tr td:nth-child(8)    /* Tabs/Strip */
    { display: none; }

    /* Medicine name — full width, bigger */
    #medTable tbody tr td:nth-child(2) {
        justify-content: flex-start;
        margin-bottom: 8px;
        padding-bottom: 10px;
        border-bottom: 1px solid #f1f5f9;
    }

    #medTable tbody tr td:nth-child(2) .fw-semibold {
        font-size: 1rem;
        font-weight: 700;
    }

    /* Expiry */
    #medTable tbody tr td:nth-child(4)::before { content: 'Expiry'; font-size: .72rem; color: #94a3b8; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }

    /* Strip Price */
    #medTable tbody tr td:nth-child(6)::before { content: 'Price'; font-size: .72rem; color: #94a3b8; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }

    /* Stock */
    #medTable tbody tr td:nth-child(9)::before { content: 'Stock'; font-size: .72rem; color: #94a3b8; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }

    /* Actions — full width row at bottom */
    #medTable tbody tr td:nth-child(10) {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid #f1f5f9;
        justify-content: flex-end;
        gap: 8px;
    }

    #medTable tbody tr td:nth-child(10) .btn-icon {
        width: 38px; height: 38px;
        border-radius: 10px;
        font-size: .9rem;
    }

    /* Row color states on mobile */
    #medTable tbody tr.row-danger { background: #fff5f5; }
    #medTable tbody tr.row-warning { background: #fffdf0; }

    /* ---- Form controls — larger touch targets ---- */
    .form-control, .form-select {
        height: 46px;
        padding: 10px 14px;
        font-size: .93rem;
        border-radius: 12px;
        border: 1.5px solid #e2e8f0;
        background: #fff;
    }

    .search-box input { height: 46px; border-radius: 12px; }

    /* ---- Modals — iOS bottom sheet ----
     * Strategy: don't touch .modal-dialog position at all.
     * Instead make the .modal overlay a flex-column that pushes
     * the dialog to the bottom. Bootstrap manages display:none/block
     * via JS — we only override when .show is present so close works.
     * ------------------------------------------------------------ */

    /* Overlay becomes flex-column, dialog pushed to bottom edge */
    .modal.show:not(#deleteModal) {
        display: flex !important;
        flex-direction: column !important;
        justify-content: flex-end !important;
        padding: 0 !important;
    }

    /* Dialog: full width, cancel Bootstrap's slide transform */
    .modal:not(#deleteModal) .modal-dialog {
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        /* Cancel modal-dialog-centered vertical flex/min-height */
        display: block !important;
        min-height: auto !important;
        /* Kill Bootstrap's translate(0,-50px) fade animation */
        transform: none !important;
        transition: none !important;
    }

    /* Content box: rounded top, capped height, internal scroll */
    .modal:not(#deleteModal) .modal-content {
        border-radius: 22px 22px 0 0 !important;
        max-height: 92vh;
        overflow-y: auto;
        border: none !important;
    }

    /* Spring slide-up when shown */
    .modal.show:not(#deleteModal) .modal-content {
        animation: mobileSheetIn .38s cubic-bezier(.34,1.12,.64,1) both;
    }

    /* Drag-handle pill on header */
    .modal:not(#deleteModal) .modal-header {
        padding-top: 28px;
        position: relative;
    }
    .modal:not(#deleteModal) .modal-header::before {
        content: '';
        position: absolute;
        top: 10px; left: 50%;
        transform: translateX(-50%);
        width: 36px; height: 4px;
        background: rgba(255,255,255,.35);
        border-radius: 2px;
    }

    /* Delete confirm — keep Bootstrap's centered popup (no sheet) */
    #deleteModal.modal.show {
        display: block !important;
        flex-direction: unset !important;
        justify-content: unset !important;
    }
    #deleteModal .modal-dialog {
        margin: auto !important;
        max-width: 300px !important;
        width: 90% !important;
        display: flex !important;
        min-height: calc(100% - 3.5rem) !important;
        transform: unset !important;
        transition: unset !important;
    }
    #deleteModal .modal-content {
        border-radius: 20px !important;
        max-height: none !important;
        align-self: center !important;
    }

    .modal-body { padding: 18px 16px; }

    /* ---- FAB ---- */
    .fab {
        bottom: calc(64px + env(safe-area-inset-bottom, 0px) + 12px);
        right: 16px;
        width: 54px; height: 54px;
        border-radius: 18px;
        box-shadow: 0 8px 24px rgba(79,70,229,.4);
    }

    /* ---- Toast — above bottom nav ---- */
    .toast-container {
        bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 12px) !important;
        right: 12px !important;
        left: 12px !important;
        width: auto !important;
    }

    .toast {
        border-radius: 14px;
        font-size: .88rem;
    }

    /* ---- Page header ---- */
    .page-header { margin-bottom: 14px; }
    .page-header h1 { font-size: 1.1rem; }

    /* ---- Billing on mobile ---- */
    .billing-layout { gap: 14px; }
    .bill-panel { border-radius: 16px; border: none; box-shadow: 0 2px 12px rgba(0,0,0,.07); }

    .cart-wrapper { border-radius: 16px; border: none; box-shadow: 0 2px 12px rgba(0,0,0,.07); }

    .bill-panel-footer { padding: 12px; gap: 10px; }
    .bill-panel-footer .btn { height: 46px; border-radius: 12px; font-size: .9rem; }

    /* ---- Cart — 2-column grid layout on mobile ---- */
    .cart-table thead { display: none; }

    .cart-table tbody tr {
        display: grid;
        grid-template-columns: 1fr auto;
        grid-template-rows: auto auto;
        gap: 10px 12px;
        padding: 14px 14px;
        border-bottom: 1px solid var(--border-light);
        align-items: center;
    }

    /* Medicine name — col1, row1 */
    .cart-table tbody td:nth-child(1) {
        grid-column: 1; grid-row: 1;
        padding: 0; border: none;
    }

    /* Qty stepper — col1, row2 */
    .cart-table tbody td:nth-child(2) {
        grid-column: 1; grid-row: 2;
        padding: 0; border: none;
        display: flex; align-items: center; gap: 8px;
    }

    /* Unit price — hidden on mobile */
    .cart-table tbody td:nth-child(3) { display: none; }

    /* Line total — col2, row2 */
    .cart-table tbody td:nth-child(4) {
        grid-column: 2; grid-row: 2;
        padding: 0; border: none;
        text-align: right;
        font-size: 1rem; font-weight: 700; color: var(--primary);
    }

    /* Remove button — col2, row1 */
    .cart-table tbody td:nth-child(5) {
        grid-column: 2; grid-row: 1;
        padding: 0; border: none;
        display: flex; justify-content: flex-end;
    }

    .cart-table tbody td:nth-child(5) .btn-icon {
        width: 34px; height: 34px; border-radius: 10px;
    }

    /* ---- Reports — card layout for sales table ---- */
    #salesTable thead { display: none; }

    #salesTable tbody tr {
        display: block;
        background: #fff;
        margin-bottom: 10px;
        border-radius: 14px;
        padding: 14px 16px;
        box-shadow: 0 1px 6px rgba(0,0,0,.06);
        border: none;
    }

    #salesTable tbody tr td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 3px 0;
        border: none;
        font-size: .875rem;
    }

    /* Invoice + time — full row, bigger */
    #salesTable tbody tr td:nth-child(1) {
        margin-bottom: 8px;
        padding-bottom: 10px;
        border-bottom: 1px solid #f1f5f9;
    }

    /* Items list — hide (too long) */
    #salesTable tbody tr td:nth-child(3) { display: none; }

    /* Customer label */
    #salesTable tbody tr td:nth-child(2)::before { content: 'Customer: '; font-size: .7rem; color: #94a3b8; font-weight: 600; text-transform: uppercase; }

    /* Payment label */
    #salesTable tbody tr td:nth-child(4)::before { content: 'Payment: '; font-size: .7rem; color: #94a3b8; font-weight: 600; text-transform: uppercase; }

    /* Total label */
    #salesTable tbody tr td:nth-child(5)::before { content: 'Total: '; font-size: .7rem; color: #94a3b8; font-weight: 600; text-transform: uppercase; }
    #salesTable tbody tr td:nth-child(5) { font-weight: 700; color: var(--success); }

    /* Actions row */
    #salesTable tbody tr td:nth-child(6) {
        margin-top: 10px;
        padding-top: 10px;
        border-top: 1px solid #f1f5f9;
        justify-content: flex-end;
        gap: 8px;
    }

    #salesTable tbody tr td:nth-child(6) .btn-icon {
        width: 38px; height: 38px; border-radius: 10px;
    }

    /* ---- Reports date filter — stack on mobile ---- */
    .reports-filter-form {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    .reports-filter-form > div { width: 100%; }
    .reports-filter-form input[type=date] { width: 100% !important; }
    .reports-filter-form .btn { width: 100%; justify-content: center; }
    .reports-filter-form .ms-auto { margin-left: 0 !important; }

    /* ---- Reports table responsive ---- */
    .table-responsive { border-radius: 0; }

    /* ---- Buttons min height for touch ---- */
    .btn-sm { min-height: 36px; }
    .btn:not(.btn-sm):not(.btn-icon) { min-height: 44px; }

    /* ---- Search box ---- */
    .search-box input { padding-left: 42px; }
    .search-box .search-icon { font-size: 1rem; }

    /* ---- Empty state ---- */
    .empty-state { padding: 40px 20px; }

    /* ---- Login ---- */
    .login-card { padding: 32px 22px; border-radius: 28px; }

}

/* ---- Small phones ≤ 390px ---- */
@media (max-width: 390px) {
    .main-content { padding: 12px 12px 18px; }
    .stat-value { font-size: 1.25rem; }
    .topbar { padding: 0 10px; }
    .medicine-filter-bar { padding: 8px 10px; }
    .filter-pill { font-size: .7rem; padding: 5px 11px; }
}

/* ---- Safe area support ---- */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom);
        height: calc(60px + env(safe-area-inset-bottom));
    }
    .main-wrapper {
        padding-bottom: calc(60px + env(safe-area-inset-bottom));
    }
    .fab {
        bottom: calc(60px + env(safe-area-inset-bottom) + 12px);
    }
}

/* ============================================================
   iOS SPRING ANIMATIONS & PAGE FEEL
   ============================================================ */

/* Smooth page entrance — opacity only, NO transform.
   transform on .main-content creates a stacking context that breaks
   position:fixed modals (they get clipped/repositioned relative to
   .main-content instead of the viewport). */
.main-content {
    animation: pageFadeIn .25s ease;
}

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

@keyframes mobileSheetIn {
    from { transform: translateY(60px); opacity: .4; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Sidebar smooth open */
.sidebar {
    transition: transform .32s cubic-bezier(.32,0,.67,0);
}
.sidebar.open {
    transition: transform .4s cubic-bezier(.34,1.08,.64,1);
}

/* FAB spring */
@keyframes fabPop {
    0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
    70%  { transform: scale(1.12) rotate(5deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}
.fab { animation: fabPop .5s cubic-bezier(.34,1.56,.64,1) forwards; }

/* Card hover lift — desktop only */
@media (min-width: 768px) {
    .reorder-card:hover { transform: translateX(4px); }
    .stat-card:hover    { transform: translateY(-4px); }
}

/* Smooth badge pulse for danger stock */
@keyframes pulseDanger {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.4); }
    50%       { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

.alert-strip.danger { animation: pulseDanger 2.5s ease infinite; }

/* ============================================================
   IMPROVED FORM — iOS style inputs
   ============================================================ */
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3.5px rgba(79,70,229,.15);
    outline: none;
}

/* Number input — hide spinner arrows for cleaner look */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] { -moz-appearance: textfield; }
