/* Stock Management - light theme */
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
    --bg: #f4f6fb;
    --card: #ffffff;
    --border: #e5e7eb;
    --text: #1f2937;
    --muted: #6b7280;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --purple: #8b5cf6;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-lg: 0 10px 25px rgba(16, 24, 40, 0.08);
    --sidebar: #0f172a;
    --sidebar-2: #0b1220;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif; background: #ffffff; color: var(--text); line-height: 1.6; }
.app { display: flex; min-height: 100vh; }

/* Sidebar (dark for contrast) */
.sidebar { width: 260px; background: linear-gradient(180deg, var(--sidebar-2) 0%, var(--sidebar) 100%); position: sticky; top: 0; height: 100vh; overflow-y: auto; flex-shrink: 0; }
.sidebar-header { padding: 1rem 1.25rem; border-bottom: 1px solid rgba(255,255,255,0.08); }
.logo { font-weight: 700; font-size: 1.125rem; letter-spacing: 0.02em; color: #fff; }
.logo span { color: #60a5fa; }
.brand { display: flex; align-items: center; gap: 0.65rem; }
.brand-logo { width: 42px; height: 42px; object-fit: contain; border-radius: 8px; flex-shrink: 0; }
.brand-text { min-width: 0; }
.brand-title { font-weight: 700; font-size: 1.125rem; letter-spacing: 0.02em; color: #fff; line-height: 1.2; }
.brand-sub { color: #93c5fd; font-size: 0.72rem; margin-top: 0.2rem; letter-spacing: 0.01em; }
.nav { padding: 0.75rem 0; }
.nav-group { margin-bottom: 1.1rem; }
.nav-title { padding: 0.5rem 1.25rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: #64748b; }
.nav-link { display: block; padding: 0.5rem 1.25rem; color: #cbd5e1; text-decoration: none; font-size: 0.92rem; border-left: 3px solid transparent; }
.nav-link:hover { background: rgba(59, 130, 246, 0.14); border-left-color: rgba(59, 130, 246, 0.8); color: #fff; }
.nav-link.active { background: rgba(59, 130, 246, 0.2); border-left-color: #3b82f6; color: #fff; font-weight: 600; }

/* Main */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #ffffff; }
.topbar { padding: 0.85rem 1.5rem; border-bottom: 1px solid var(--border); background: #ffffff; position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.topbar-left { display: flex; gap: 1rem; align-items: baseline; }
.topbar-actions { display: flex; gap: 1rem; align-items: center; }
.topbar-user { color: var(--text); font-weight: 600; }
.topbar-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.topbar-link:hover { text-decoration: underline; }
.page-title { font-size: 1.2rem; font-weight: 700; color: var(--text); }
.content { padding: 1.5rem; max-width: 1500px; margin: 0 auto; width: 100%; background: #ffffff; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
.card-header { padding: 0.9rem 1.1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card-title { font-size: 1rem; font-weight: 600; }
.card-body { padding: 1.1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }

/* Colored stat cards (light theme) */
.sc-blue { --tint: #eff6ff; --accent: #3b82f6; --accent-dark: #1d4ed8; }
.sc-green { --tint: #ecfdf5; --accent: #10b981; --accent-dark: #047857; }
.sc-purple { --tint: #f5f3ff; --accent: #8b5cf6; --accent-dark: #6d28d9; }
.sc-amber { --tint: #fffbeb; --accent: #f59e0b; --accent-dark: #b45309; }
.sc-red { --tint: #fef2f2; --accent: #ef4444; --accent-dark: #b91c1c; }
.sc-teal { --tint: #f0fdfa; --accent: #14b8a6; --accent-dark: #0f766e; }
.stat-card { border-radius: 14px; padding: 1.1rem 1.25rem; background: var(--tint, #f8fafc); border: 1px solid var(--border); border-left: 4px solid var(--accent, #3b82f6); box-shadow: var(--shadow); position: relative; overflow: hidden; color: var(--text); }
.stat-card .stat-label { color: var(--accent-dark, var(--text)); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.01em; }
.stat-card .stat-value { color: var(--text); font-size: 1.9rem; font-weight: 800; margin-top: 0.25rem; line-height: 1.1; }
.stat-card .stat-foot { margin-top: 0.5rem; font-size: 0.8rem; color: var(--muted); }
.stat-card .stat-icon { position: absolute; right: 1rem; top: 1rem; width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--accent, #3b82f6); color: #fff; box-shadow: 0 4px 10px rgba(16, 24, 40, 0.12); }
.stat-card .stat-icon svg { width: 20px; height: 20px; }
.trend-up { color: #047857; background: #d1fae5; padding: 0.1rem 0.45rem; border-radius: 999px; font-weight: 700; font-size: 0.78rem; }
.trend-down { color: #b91c1c; background: #fee2e2; padding: 0.1rem 0.45rem; border-radius: 999px; font-weight: 700; font-size: 0.78rem; }
.stat-link { color: var(--accent, #3b82f6); font-weight: 600; text-decoration: none; }
.stat-link:hover { text-decoration: underline; }

/* legacy stat variants kept for compatibility */
.stat-card.warning { --tint: #fffbeb; --accent: #f59e0b; --accent-dark: #b45309; }
.stat-card.danger { --tint: #fef2f2; --accent: #ef4444; --accent-dark: #b91c1c; }
.stat-card.success { --tint: #ecfdf5; --accent: #10b981; --accent-dark: #047857; }

/* Forms */
form .row { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: 0.35rem; }
label { font-size: 0.85rem; color: var(--muted); font-weight: 500; }
input, select, textarea { padding: 0.5rem 0.6rem; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); font-size: 0.92rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); }

/* Sectioned forms */
.form-section { margin-bottom: 1.1rem; padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: 10px; background: #fbfcfe; }
.form-section:last-of-type { margin-bottom: 0; }
.form-section-title { font-size: 0.8rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--primary-dark); margin-bottom: 0.75rem; display: flex; align-items: center; gap: 0.5rem; }
.form-section-title .step { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 0.72rem; }
.stock-readout { display: inline-flex; align-items: baseline; gap: 0.4rem; padding: 0.5rem 0.75rem; border-radius: 8px; background: #eff6ff; border: 1px solid #bfdbfe; color: var(--primary-dark); font-weight: 700; font-size: 1.1rem; min-height: 40px; }
.stock-readout .unit { font-size: 0.78rem; font-weight: 500; color: var(--muted); }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.5rem 0.9rem; border-radius: 8px; border: 1px solid transparent; background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%); color: #fff; text-decoration: none; font-size: 0.92rem; cursor: pointer; font-weight: 500; }
.btn:hover { filter: brightness(1.05); }
.btn.secondary { background: #f1f5f9; border-color: var(--border); color: var(--text); }
.btn.secondary:hover { background: #e9eef5; }
.btn.danger { background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%); }
.btn.success { background: linear-gradient(180deg, #10b981 0%, #059669 100%); }
.btn.small { padding: 0.32rem 0.6rem; font-size: 0.82rem; border-radius: 6px; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th { text-align: left; padding: 0.65rem 0.8rem; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--border); background: #f8fafc; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody td { padding: 0.6rem 0.8rem; border-bottom: 1px solid #f1f5f9; color: var(--text); }
tbody tr:hover { background: #f8fafc; }
.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }

/* Alerts */
.alert { padding: 0.7rem 0.9rem; border-radius: 8px; border: 1px solid var(--border); margin-bottom: 1rem; }
.alert-success { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.alert-danger { border-color: #fecaca; background: #fef2f2; color: #991b1b; }

.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: flex-end; margin-bottom: 1rem; }
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
tfoot th { padding: 0.6rem 0.8rem; border-top: 2px solid var(--border); background: #f8fafc; }

/* Dashboard */
.dash-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.dash-2col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 1rem; align-items: start; }
.dash-2col-even { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.dash-3col { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 0.9rem; align-items: stretch; }
.dash-3col .card-body { padding: 0.8rem; }
.dash-3col .card-header { padding: 0.65rem 0.85rem; }
.dash-3col .card-title { font-size: 0.92rem; }
.dash-3col .chart-box { height: 180px; }
.dash-3col .quick-actions { grid-template-columns: repeat(2, 1fr); gap: 0.55rem; }
.dash-3col .qa-btn { padding: 0.7rem 0.35rem; font-size: 0.76rem; gap: 0.3rem; }
.dash-3col .qa-icon { width: 34px; height: 34px; font-size: 0.95rem; }
.chart-box { position: relative; width: 100%; height: 300px; }
.chart-box.sm { height: 260px; }
.card-tools { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; }
.card-tools select, .card-tools input { padding: 0.3rem 0.45rem; font-size: 0.78rem; border-radius: 6px; }
.card-tools input[type="date"] { width: auto; }
@media (max-width: 1100px) { .dash-4 { grid-template-columns: repeat(2, 1fr); } .dash-2col, .dash-2col-even { grid-template-columns: 1fr; } }
@media (max-width: 820px) { .dash-3col { grid-template-columns: 1fr; } }
@media (max-width: 620px) { .dash-4 { grid-template-columns: 1fr; } }

/* Quick actions */
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.9rem; }
.qa-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem; padding: 1.1rem 0.6rem; border-radius: 12px; border: 1px solid var(--border); background: #fff; text-decoration: none; color: var(--text); font-weight: 600; font-size: 0.88rem; transition: all 0.15s; box-shadow: var(--shadow); text-align: center; }
.qa-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.qa-icon { width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 1.3rem; color: #fff; }
.qa-blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.qa-green { background: linear-gradient(135deg, #10b981, #059669); }
.qa-purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.qa-amber { background: linear-gradient(135deg, #f59e0b, #d97706); }
@media (max-width: 700px) { .quick-actions { grid-template-columns: repeat(2, 1fr); } }

/* Badges */
.badge { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-cash { background: #dcfce7; color: #166534; }
.badge-upi { background: #dbeafe; color: #1e40af; }
.badge-card { background: #ede9fe; color: #5b21b6; }
.badge-credit { background: #fef3c7; color: #92400e; }
.badge-ok { background: #dcfce7; color: #166534; }
.badge-low { background: #fef3c7; color: #92400e; }
.badge-out { background: #fee2e2; color: #991b1b; }

.topbar-left > div { display: flex; flex-direction: column; gap: 0.15rem; }
.topbar .topbar-date { color: var(--muted); font-size: 0.85rem; font-weight: 600; }


/* Billing / new bill */
.bill-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem 1rem; margin-bottom: 0.9rem; }
.bill-grid.two { grid-template-columns: 1fr 1fr; }
.autocomplete-wrap { position: relative; }
.suggestions { position: absolute; z-index: 30; left: 0; right: 0; top: 100%; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); max-height: 280px; overflow-y: auto; display: none; }
.suggestion-item { padding: 0.5rem 0.7rem; cursor: pointer; border-bottom: 1px solid #f1f5f9; font-size: 0.9rem; display: flex; gap: 0.4rem; align-items: baseline; }
.suggestion-item:last-child { border-bottom: 0; }
.suggestion-item:hover { background: #f8fafc; }
.suggestion-item .muted { color: var(--muted); font-weight: 400; }
.suggestion-item .sug-right { margin-left: auto; color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.check-inline { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; color: var(--text); }
.bill-table { min-width: 900px; }
.bill-table th, .bill-table td { padding: 0.45rem 0.5rem; vertical-align: top; }
.cell-input { width: 78px; padding: 0.3rem 0.4rem; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; text-align: right; }
.bill-table .item-name { font-weight: 600; }
.bill-table .item-cat { font-size: 0.72rem; color: var(--muted); }
.bill-table .item-sku { font-size: 0.72rem; color: #94a3b8; }
.bill-table .item-stock { font-size: 0.72rem; color: #64748b; font-weight: 600; }
.bill-table .item-stock.low { color: #b91c1c; background: #fee2e2; border-radius: 4px; padding: 0 4px; display: inline-block; }
.cell-input.input-invalid { border-color: #dc3545; background: #fdecea; color: #b91c1c; font-weight: 700; }
.btn.small.danger { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; padding: 0.15rem 0.5rem; }
.bill-summary { display: grid; grid-template-columns: 1.6fr 1fr; gap: 1.25rem; align-items: start; }
.bill-totals { background: #f8fafc; border: 1px solid var(--border); border-radius: 12px; padding: 0.9rem 1rem; }
.tot-row { display: flex; justify-content: space-between; padding: 0.3rem 0; font-size: 0.9rem; }
.tot-row.big { border-top: 2px solid var(--border); margin-top: 0.3rem; padding-top: 0.5rem; font-weight: 700; font-size: 1rem; }
@media (max-width: 900px) {
    .bill-grid, .bill-grid.two { grid-template-columns: 1fr; }
    .bill-summary { grid-template-columns: 1fr; }
}
