:root {
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --bg-body: #f8fafc;
    --bg-sidebar: #0f172a;
    --sidebar-hover: #1e293b;
    --sidebar-active: #1d4ed8;
    --text-main: #334155;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --card-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg-body); color: var(--text-main); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-hover); }
.layout { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar { width: 240px; background: var(--bg-sidebar); color: #f8fafc; padding: 24px 16px; display: flex; flex-direction: column; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s; z-index: 50; }
.sidebar h1 { margin: 0 0 32px; font-size: 18px; font-weight: 600; text-align: center; letter-spacing: 0.5px; color: #ffffff; padding-bottom: 16px; border-bottom: 1px solid #334155; }
.sidebar-section { margin: 24px 0 8px; padding: 0 12px; color: #94a3b8; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.sidebar a { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin-bottom: 4px; border-radius: 6px; color: #cbd5e1; font-size: 14px; font-weight: 500; transition: all 0.2s; }
.sidebar a.active { background: var(--sidebar-active); color: #ffffff; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.sidebar a:hover:not(.active) { background: var(--sidebar-hover); color: #ffffff; }
.nav-icon { width: 20px; height: 20px; text-align: center; flex: 0 0 20px; opacity: 0.8; }
.sidebar a.active .nav-icon { opacity: 1; }
.nav-label { flex: 1; }
.sidebar-pill { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 12px; font-size: 11px; line-height: 1.2; background: #ef4444; color: #ffffff; font-weight: 600; }

/* Mobile Overlay */
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.6); z-index: 40; backdrop-filter: blur(2px); transition: opacity 0.3s; opacity: 0; }
.sidebar-overlay.show { display: block; opacity: 1; }
.mobile-menu-btn { display: none; background: transparent; border: none; color: #334155; cursor: pointer; padding: 8px; margin-right: 12px; }

/* Main Area */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { padding: 16px 32px; background: #ffffff; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); display: flex; justify-content: space-between; align-items: center; z-index: 10; }
.topbar-left { display: flex; align-items: center; font-weight: 500; }
.container { padding: 32px; flex: 1; overflow-y: auto; }

/* Cards */
.card { background: #ffffff; border-radius: 8px; padding: 24px; box-shadow: var(--card-shadow); margin-bottom: 24px; border: 1px solid var(--border-color); }
.card-header { border-bottom: 1px solid var(--border-color); padding-bottom: 16px; margin-bottom: 20px; }
.card-title { font-size: 18px; font-weight: 600; color: #1e293b; margin: 0; }

/* Grid & Stats */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.stat { padding: 24px; border-radius: 8px; background: #ffffff; border: 1px solid var(--border-color); box-shadow: var(--card-shadow); display: flex; flex-direction: column; position: relative; overflow: hidden; }
.stat::before { content: ''; position: absolute; top: 0; left: 0; width: 4px; height: 100%; background: var(--primary); }
.stat-label { color: var(--text-muted); font-size: 14px; font-weight: 500; }
.stat strong { display: block; font-size: 28px; font-weight: 700; color: #0f172a; margin-top: 8px; }

/* Tables */
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--border-color); text-align: left; vertical-align: middle; font-size: 14px; }
th { background: #f8fafc; font-weight: 600; color: #475569; text-transform: uppercase; font-size: 12px; letter-spacing: 0.05em; border-top: 1px solid var(--border-color); }
tr:hover td { background-color: #f1f5f9; }
tr.row-muted td { background: #f8fafc; color: #94a3b8; }
tr.row-muted .badge { opacity: 0.9; }

/* Buttons */
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; transition: all 0.2s; }
.btn-primary { background: var(--primary); color: #ffffff; box-shadow: 0 1px 2px rgba(0,0,0,0.05); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: #dc2626; color: #ffffff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: #ffffff; border-color: #cbd5e1; color: #334155; }
.btn-secondary:hover { background: #f1f5f9; border-color: #94a3b8; }
.btn.loading { opacity: 0.7; cursor: not-allowed; pointer-events: none; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.form-group { margin-bottom: 20px; }
label { display: block; margin-bottom: 8px; font-weight: 500; color: #1e293b; font-size: 14px; }
input, select, textarea { width: 100%; padding: 10px 14px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; color: #334155; transition: border-color 0.2s, box-shadow 0.2s; background-color: #ffffff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1); }
textarea { min-height: 120px; resize: vertical; }

/* Alerts / Flash Messages */
.flash { padding: 16px; border-radius: 6px; margin-bottom: 24px; font-size: 14px; display: flex; align-items: center; border-left: 4px solid transparent; }
.flash-success { background: #ecfdf5; color: #065f46; border-color: #10b981; }
.flash-error { background: #fef2f2; color: #991b1b; border-color: #ef4444; }

/* Badges */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.badge-primary { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.badge-muted { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.badge-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.badge-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.muted { color: var(--text-muted); font-size: 13px; }

/* Segmented Control */
.segmented-control { display: inline-flex; background: #f1f5f9; padding: 4px; border-radius: 8px; border: 1px solid #e2e8f0; }
.segmented-control label { margin: 0; cursor: pointer; position: relative; }
.segmented-control input[type="radio"], .segmented-control input[type="checkbox"] { position: absolute; opacity: 0; width: 0; height: 0; }
.segmented-control span { display: inline-block; padding: 6px 16px; font-size: 14px; font-weight: 500; color: #475569; border-radius: 6px; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); user-select: none; }
.segmented-control input:hover:not(:checked) + span { color: #1e293b; background: #e2e8f0; }
.segmented-control input:checked + span { background: #ffffff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

/* Login / Install Cards */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; background: #f1f5f9; }
.login-card { width: 100%; max-width: 440px; background: #ffffff; border-radius: 12px; padding: 40px; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1); border: 1px solid var(--border-color); }
.install-card { max-width: 860px; }

/* Agent Login Specific */
.login-wrap.agent-login { background: radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 30%), radial-gradient(circle at bottom right, rgba(99, 102, 241, 0.18), transparent 26%), linear-gradient(180deg, #eef4ff 0%, #f8fafc 100%); }
.login-wrap.agent-login .login-card { max-width: 480px; background: rgba(255, 255, 255, 0.96); border: 1px solid rgba(148, 163, 184, 0.18); border-radius: 24px; padding: 32px; box-shadow: 0 24px 60px rgba(15, 23, 42, 0.12); backdrop-filter: blur(8px); }

/* Toast Notifications */
.toast-container { position: fixed; top: 24px; right: 24px; z-index: 9999; display: flex; flex-direction: column; gap: 12px; }
.toast { padding: 12px 20px; border-radius: 8px; color: white; font-size: 14px; font-weight: 500; box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); transform: translateX(120%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); display: flex; align-items: center; gap: 8px; }
.toast.show { transform: translateX(0); }
.toast-success { background: #10b981; }
.toast-error { background: #ef4444; }

@media (max-width: 768px) {
    .sidebar { position: fixed; left: -240px; top: 0; bottom: 0; transform: translateX(0); }
    .sidebar.sidebar-open { transform: translateX(240px); }
    .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
    .topbar { padding: 16px; }
    .container { padding: 16px; }
    .login-card { padding: 24px; border-radius: 20px; }
}
