:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: system-ui, -apple-system, sans-serif; }

body { background-color: var(--bg-main); color: var(--text-main); height: 100vh; overflow: hidden; }

.app-container { display: flex; height: 100vh; }

/* Sidebar */
.sidebar { width: 280px; background-color: #1e293b; color: #fff; padding: 1.5rem; display: flex; flex-direction: column; gap: 1.2rem; }
.brand h2 { font-size: 1.25rem; font-weight: 700; color: #f8fafc; }
.brand span { font-size: 0.75rem; background: var(--primary); padding: 2px 6px; border-radius: 4px; }

.gemini-status-card { background: #334155; padding: 0.8rem; border-radius: var(--radius); font-size: 0.85rem; }
.status-badge { font-weight: bold; margin: 4px 0; display: inline-flex; align-items: center; gap: 5px; }
.status-badge.connected { color: #4ade80; }
.status-badge.error { color: #f87171; }
.status-badge.checking { color: #fbbf24; }

.nav-menu { display: flex; flex-direction: column; gap: 0.4rem; flex-grow: 1; overflow-y: auto; }
.nav-btn { text-align: left; background: transparent; border: none; color: #94a3b8; padding: 0.75rem 1rem; border-radius: var(--radius); cursor: pointer; font-size: 0.9rem; transition: all 0.2s; }
.nav-btn:hover, .nav-btn.active { background: #334155; color: #fff; font-weight: 600; }

.sidebar-footer { margin-top: auto; }

/* Main Content */
.main-content { flex-grow: 1; overflow-y: auto; padding: 2rem; background: var(--bg-main); position: relative; }
.tab-content { display: none; }
.tab-content.active { display: block; }

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; }

/* Metrics & Panels */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.metric-card { background: var(--bg-card); padding: 1.2rem; border-radius: var(--radius); border: 1px solid var(--border); display: flex; align-items: center; gap: 1rem; box-shadow: var(--shadow); }
.metric-icon { font-size: 2rem; }
.metric-value { font-size: 1.5rem; font-weight: bold; display: block; }
.metric-label { font-size: 0.85rem; color: var(--text-muted); }

.dashboard-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.panel { background: var(--bg-card); padding: 1.5rem; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }

/* Buttons & Inputs */
.btn-primary { background: var(--primary); color: white; border: none; padding: 0.6rem 1.2rem; border-radius: var(--radius); cursor: pointer; font-weight: 500; }
.btn-secondary { background: var(--secondary); color: white; border: none; padding: 0.6rem 1.2rem; border-radius: var(--radius); cursor: pointer; }
.btn-success { background: var(--success); color: white; border: none; padding: 0.6rem 1.2rem; border-radius: var(--radius); cursor: pointer; }
.btn-danger { background: var(--danger); color: white; border: none; padding: 0.6rem 1.2rem; border-radius: var(--radius); cursor: pointer; }
.btn-block { width: 100%; }
.btn-xs { padding: 4px 8px; font-size: 0.75rem; background: #475569; color: white; border: none; border-radius: 4px; cursor: pointer; }

.form-control { padding: 0.6rem; border: 1px solid var(--border); border-radius: var(--radius); font-size: 0.9rem; }
.form-group { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.form-row { display: flex; gap: 1rem; }
.form-row .form-group { flex: 1; }

/* Tables */
.table-responsive { overflow-x: auto; background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border); }
.data-table, .schedule-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; text-align: left; }
.data-table th, .data-table td, .schedule-table th, .schedule-table td { padding: 0.75rem; border-bottom: 1px solid var(--border); }
.data-table th { background: #f1f5f9; font-weight: 600; }

.schedule-table th { min-width: 100px; text-align: center; background: #f1f5f9; position: sticky; top: 0; }
.schedule-table td { text-align: center; font-size: 0.75rem; height: 50px; cursor: pointer; }
.cell-shift { padding: 4px; border-radius: 4px; font-weight: 600; display: block; }
.shift-M { background: #dbeafe; color: #1e40af; }
.shift-T { background: #fef3c7; color: #92400e; }
.shift-N { background: #e0e7ff; color: #3730a3; }
.shift-OFF { background: #f1f5f9; color: #94a3b8; }
.shift-ABS { background: #fee2e2; color: #991b1b; }

/* Badges */
.badge { padding: 3px 8px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; display: inline-block; }
.badge-success { background: #dcfce7; color: #166534; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* Stores Grid */
.stores-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }

/* Chat */
.chat-wrapper { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius); height: calc(100vh - 180px); display: flex; flex-direction: column; }
.chat-messages { flex-grow: 1; padding: 1.5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 1rem; }
.message { max-width: 80%; padding: 0.8rem 1.2rem; border-radius: var(--radius); font-size: 0.9rem; line-height: 1.4; }
.message.system { background: #f1f5f9; align-self: center; text-align: center; width: 100%; max-width: 100%; }
.message.user { background: var(--primary); color: white; align-self: flex-end; }
.message.assistant { background: #f8fafc; border: 1px solid var(--border); align-self: flex-start; }
.chat-input-form { padding: 1rem; border-top: 1px solid var(--border); display: flex; gap: 0.5rem; }
.chat-input-form input { flex-grow: 1; }

/* Modals */
.modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); justify-content: center; align-items: center; z-index: 1000; }
.modal.open { display: flex; }
.modal-content { background: white; padding: 2rem; border-radius: var(--radius); width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; }
.modal-large { max-width: 900px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }

/* Toast notifications */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 2000; }
.toast { padding: 1rem 1.5rem; background: #334155; color: white; border-radius: var(--radius); box-shadow: var(--shadow); font-size: 0.9rem; animation: fadeIn 0.3s forwards; }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

/* Timeline */
.timeline { display: flex; flex-direction: column; gap: 1rem; }
.timeline-item { background: var(--bg-card); padding: 1rem; border-left: 4px solid var(--primary); border-radius: 0 var(--radius) var(--radius) 0; box-shadow: var(--shadow); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Mobile Responsive */
@media (max-width: 768px) {
    .app-container { flex-direction: column; }
    .sidebar { width: 100%; height: auto; padding: 1rem; }
    .dashboard-panels { grid-template-columns: 1fr; }
    .main-content { padding: 1rem; }
}