* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #1a56db; --primary-light: #e8effc; --primary-dark: #0f3a8e;
  --sidebar-bg: #0f172a; --sidebar-hover: #1e293b;
  --bg: #f1f5f9; --card: #ffffff; --text: #1e293b; --text-light: #64748b; --border: #e2e8f0;
  --success: #16a34a; --success-bg: #dcfce7; --warning: #d97706; --warning-bg: #fef3c7;
  --danger: #dc2626; --danger-bg: #fee2e2; --info: #2563eb; --info-bg: #dbeafe;
}
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif; background: var(--bg); color: var(--text); display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar { width: 260px; background: var(--sidebar-bg); color: #fff; display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-logo { padding: 20px 24px; padding-top: 40px; border-bottom: 1px solid rgba(255,255,255,0.1); -webkit-app-region: drag; }
.sidebar-logo h1 { font-size: 18px; font-weight: 700; color: #fff; }
.sidebar-logo span { font-size: 11px; color: #94a3b8; display: block; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section { padding: 8px 24px 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: #475569; margin-top: 8px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 10px 24px; cursor: pointer; transition: all 0.15s; color: #94a3b8; font-size: 14px; border-left: 3px solid transparent; }
.nav-item:hover { background: var(--sidebar-hover); color: #e2e8f0; }
.nav-item.active { background: rgba(26,86,219,0.15); color: #fff; border-left-color: var(--primary); }
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge { margin-left: auto; background: var(--danger); color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 10px; font-weight: 600; }
.sidebar-user { padding: 16px 24px; border-top: 1px solid rgba(255,255,255,0.1); display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.user-info { font-size: 13px; }
.user-info div:last-child { color: #64748b; font-size: 11px; }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.header { background: var(--card); border-bottom: 1px solid var(--border); padding: 16px 32px; padding-top: 40px; display: flex; align-items: center; justify-content: space-between; -webkit-app-region: drag; }
.header * { -webkit-app-region: no-drag; }
.header h2 { font-size: 20px; font-weight: 700; }
.header-breadcrumb { font-size: 12px; color: var(--text-light); }
.header-actions { display: flex; gap: 12px; align-items: center; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px; width: 280px; }
.search-box input { border: none; background: none; outline: none; font-size: 13px; width: 100%; }
.icon-btn { width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); display: flex; align-items: center; justify-content: center; cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--bg); }
.notif-dot { position: absolute; top: 6px; right: 6px; width: 8px; height: 8px; background: var(--danger); border-radius: 50%; }
.content { flex: 1; overflow-y: auto; padding: 24px 32px; }

/* KPI */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; margin-bottom: 28px; }
.kpi-card { background: var(--card); border-radius: 12px; padding: 20px 24px; border: 1px solid var(--border); }
.kpi-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.kpi-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.kpi-icon.blue { background: var(--info-bg); color: var(--info); }
.kpi-icon.green { background: var(--success-bg); color: var(--success); }
.kpi-icon.orange { background: var(--warning-bg); color: var(--warning); }
.kpi-icon.red { background: var(--danger-bg); color: var(--danger); }
.kpi-trend { font-size: 12px; font-weight: 600; display: flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; }
.kpi-trend.up { color: var(--success); background: var(--success-bg); }
.kpi-trend.down { color: var(--danger); background: var(--danger-bg); }
.kpi-value { font-size: 28px; font-weight: 800; margin-bottom: 2px; }
.kpi-label { font-size: 13px; color: var(--text-light); }

/* Grid layouts */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-bottom: 28px; }

/* Card */
.card { background: var(--card); border-radius: 12px; border: 1px solid var(--border); overflow: hidden; }
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.card-header h3 { font-size: 15px; font-weight: 700; }
.card-link { font-size: 13px; color: var(--primary); cursor: pointer; text-decoration: none; }
.card-body { padding: 20px; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-light); padding: 10px 16px; background: #f8fafc; border-bottom: 1px solid var(--border); font-weight: 600; }
td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
tr:last-child td { border-bottom: none; }
tr.clickable-row { cursor: pointer; }
tr.clickable-row:hover td { background: var(--primary-light); }
tr:hover td { background: #f8fafc; }

/* Status badges */
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 6px; font-size: 11px; font-weight: 600; }
.status-badge.active { background: var(--success-bg); color: var(--success); }
.status-badge.pending { background: var(--warning-bg); color: var(--warning); }
.status-badge.shipped { background: var(--info-bg); color: var(--info); }
.status-badge.cancelled { background: var(--danger-bg); color: var(--danger); }
.status-badge.low { background: var(--danger-bg); color: var(--danger); }
.status-badge.medium { background: var(--warning-bg); color: var(--warning); }
.status-badge.high { background: var(--success-bg); color: var(--success); }

/* Charts */
.chart-area { height: 220px; display: flex; align-items: flex-end; gap: 8px; padding: 20px; }
.chart-bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-bar { width: 100%; border-radius: 4px 4px 0 0; min-height: 4px; transition: height 0.3s; }
.chart-bar.primary { background: var(--primary); }
.chart-bar.secondary { background: #93c5fd; }
.chart-bar-label { font-size: 10px; color: var(--text-light); }
.chart-legend { display: flex; gap: 20px; padding: 0 20px 16px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-light); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; }

/* Donut */
.donut-chart { width: 160px; height: 160px; border-radius: 50%; position: relative; margin: 0 auto; }
.donut-center { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; }
.donut-center .value { font-size: 24px; font-weight: 800; }
.donut-center .label { font-size: 11px; color: var(--text-light); }
.donut-legend { margin-top: 16px; width: 100%; }
.donut-legend-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 12px; }
.donut-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

/* Buttons */
.btn { padding: 8px 18px; border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; display: inline-flex; align-items: center; gap: 6px; transition: all 0.15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-ai { background: linear-gradient(135deg, #7c3aed, #2563eb); color: #fff; }
.btn-ai:hover { background: linear-gradient(135deg, #6d28d9, #1d4ed8); }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab { padding: 10px 20px; font-size: 13px; font-weight: 600; color: var(--text-light); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Pages */
.page { display: none; }
.page.active { display: block; }

/* Filter bar */
.filter-bar { display: flex; gap: 12px; margin-bottom: 20px; align-items: center; flex-wrap: wrap; }
.filter-bar select, .filter-bar input[type="date"] { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: var(--card); }

/* Stats */
.stat-row { display: flex; gap: 16px; margin-bottom: 20px; }
.stat-box { flex: 1; background: var(--bg); border-radius: 10px; padding: 16px; text-align: center; }
.stat-box .val { font-size: 22px; font-weight: 800; }
.stat-box .lbl { font-size: 11px; color: var(--text-light); margin-top: 2px; }

/* Alert list */
.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 8px; font-size: 13px; }
.alert-item.warning { background: var(--warning-bg); }
.alert-item.danger { background: var(--danger-bg); }
.alert-item.info { background: var(--info-bg); }

/* Location */
.location-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.location-card { background: var(--bg); border-radius: 10px; padding: 16px; text-align: center; cursor: pointer; border: 2px solid transparent; transition: all 0.15s; }
.location-card:hover, .location-card.active { border-color: var(--primary); background: var(--primary-light); }
.location-card .loc-name { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.location-card .loc-count { font-size: 22px; font-weight: 800; color: var(--primary); }
.location-card .loc-label { font-size: 11px; color: var(--text-light); }

/* Product grid */
.product-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.product-card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; cursor: pointer; transition: all 0.15s; }
.product-card:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(26,86,219,0.1); }
.product-card .prod-cat { font-size: 10px; text-transform: uppercase; letter-spacing: 1px; color: var(--primary); font-weight: 700; margin-bottom: 6px; }
.product-card .prod-name { font-size: 14px; font-weight: 700; margin-bottom: 8px; }
.product-card .prod-code { font-size: 11px; color: var(--text-light); margin-bottom: 10px; }
.product-card .prod-price { font-size: 16px; font-weight: 800; color: var(--primary); }
.product-card .prod-stock { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; }

/* Form */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text-light); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-group input, .form-group select, .form-group textarea { width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.form-group textarea { height: 80px; resize: vertical; }

/* Modal */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 100; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: var(--card); border-radius: 16px; width: 620px; max-height: 85vh; overflow-y: auto; }
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { cursor: pointer; font-size: 20px; color: var(--text-light); background: none; border: none; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* Detail panel */
.detail-panel { animation: slideIn 0.2s ease; }
@keyframes slideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.detail-back { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--primary); cursor: pointer; margin-bottom: 16px; font-weight: 600; }
.detail-back:hover { text-decoration: underline; }
.detail-header-row { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.detail-title { font-size: 22px; font-weight: 800; }
.detail-subtitle { font-size: 13px; color: var(--text-light); margin-top: 4px; }
.info-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.info-item { }
.info-item .info-label { font-size: 11px; color: var(--text-light); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.info-item .info-value { font-size: 14px; font-weight: 600; }

/* Timeline */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 0; bottom: 0; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding-bottom: 20px; }
.timeline-item::before { content: ''; position: absolute; left: -20px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); border: 2px solid var(--card); }
.timeline-item.completed::before { background: var(--success); }
.timeline-item.current::before { background: var(--warning); box-shadow: 0 0 0 4px var(--warning-bg); }
.timeline-item .tl-title { font-size: 13px; font-weight: 600; }
.timeline-item .tl-time { font-size: 11px; color: var(--text-light); }
.timeline-item .tl-desc { font-size: 12px; color: var(--text-light); margin-top: 2px; }

/* AI Chat */
.ai-fab { position: fixed; bottom: 28px; right: 28px; width: 56px; height: 56px; border-radius: 50%; background: linear-gradient(135deg, #7c3aed, #2563eb); color: #fff; border: none; cursor: pointer; box-shadow: 0 4px 20px rgba(124,58,237,0.4); display: flex; align-items: center; justify-content: center; z-index: 90; transition: transform 0.2s; }
.ai-fab:hover { transform: scale(1.1); }
.ai-panel { position: fixed; bottom: 96px; right: 28px; width: 420px; height: 520px; background: var(--card); border-radius: 16px; box-shadow: 0 8px 40px rgba(0,0,0,0.15); z-index: 95; display: none; flex-direction: column; overflow: hidden; border: 1px solid var(--border); }
.ai-panel.open { display: flex; }
.ai-panel-header { padding: 16px 20px; background: linear-gradient(135deg, #7c3aed, #2563eb); color: #fff; display: flex; justify-content: space-between; align-items: center; }
.ai-panel-header h3 { font-size: 15px; font-weight: 700; }
.ai-panel-close { background: none; border: none; color: #fff; font-size: 20px; cursor: pointer; }
.ai-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.ai-msg { max-width: 85%; padding: 10px 14px; border-radius: 12px; font-size: 13px; line-height: 1.5; }
.ai-msg.bot { background: var(--bg); align-self: flex-start; border-bottom-left-radius: 4px; }
.ai-msg.user { background: var(--primary); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.ai-msg .ai-badge { display: inline-block; font-size: 10px; font-weight: 700; background: linear-gradient(135deg, #7c3aed, #2563eb); color: #fff; padding: 1px 6px; border-radius: 4px; margin-bottom: 4px; }
.ai-input-area { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; }
.ai-input-area input { flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; font-size: 13px; outline: none; }
.ai-input-area input:focus { border-color: var(--primary); }
.ai-input-area button { background: linear-gradient(135deg, #7c3aed, #2563eb); color: #fff; border: none; border-radius: 8px; padding: 10px 16px; cursor: pointer; font-weight: 600; font-size: 13px; }
.ai-suggestions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 12px; }
.ai-suggest-btn { background: var(--primary-light); color: var(--primary); border: 1px solid rgba(26,86,219,0.2); border-radius: 20px; padding: 5px 12px; font-size: 11px; cursor: pointer; font-weight: 600; }
.ai-suggest-btn:hover { background: var(--primary); color: #fff; }

/* AI Insight cards */
.ai-insight { background: linear-gradient(135deg, rgba(124,58,237,0.05), rgba(37,99,235,0.05)); border: 1px solid rgba(124,58,237,0.2); border-radius: 12px; padding: 16px 20px; margin-bottom: 20px; }
.ai-insight-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; font-weight: 700; color: #7c3aed; }
.ai-insight-body { font-size: 13px; line-height: 1.6; }
.ai-insight-body ul { padding-left: 16px; margin-top: 6px; }
.ai-insight-body li { margin-bottom: 4px; }
.ai-tag { display: inline-block; background: linear-gradient(135deg, #7c3aed, #2563eb); color: #fff; font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 4px; }

/* Forecast chart */
.forecast-bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin: 12px 0; }
.forecast-bar { flex: 1; border-radius: 4px 4px 0 0; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; }
.forecast-bar .fb-val { font-size: 9px; font-weight: 700; margin-bottom: 2px; }
.forecast-bar .fb-fill { width: 100%; border-radius: 4px 4px 0 0; }
.forecast-bar .fb-fill.actual { background: var(--primary); }
.forecast-bar .fb-fill.predicted { background: linear-gradient(to top, #7c3aed, #a78bfa); opacity: 0.7; }
.forecast-bar .fb-label { font-size: 9px; color: var(--text-light); margin-top: 4px; }

/* Surgery schedule */
.surgery-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); align-items: center; }
.surgery-item:last-child { border-bottom: none; }
.surgery-time { font-size: 12px; font-weight: 700; color: var(--primary); min-width: 50px; }
.surgery-info { flex: 1; }
.surgery-info .s-title { font-size: 13px; font-weight: 600; }
.surgery-info .s-detail { font-size: 11px; color: var(--text-light); }
.surgery-status { font-size: 11px; }

@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .location-grid { grid-template-columns: repeat(2, 1fr); }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: 1fr 1fr; }
}
