:root {
    --bg-main: #f5f6f8;
    --bg-sidebar: #1e1e2d;
    --text-main: #1a1a27;
    --text-muted: #a1a5b7;
    --accent: #009ef7;
    --card-bg: #ffffff;
    --border: #e4e6ef;
    --success: #50cd89;
    --danger: #f1416c;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }

body { background-color: var(--bg-main); color: var(--text-main); font-size: 14px; }

/* Login Screen */
#login-screen { display: none; height: 100vh; align-items: center; justify-content: center; background: var(--bg-sidebar); }
#login-screen.active { display: flex; }
.login-box { background: var(--card-bg); padding: 40px; border-radius: 12px; width: 350px; text-align: center; box-shadow: 0 10px 30px rgba(0,0,0,0.1); }
.login-box h2 { margin-bottom: 24px; color: var(--text-main); }
.login-box input { width: 100%; padding: 12px; margin-bottom: 16px; border: 1px solid var(--border); border-radius: 6px; outline: none; }
.login-box button { width: 100%; padding: 12px; background: var(--accent); color: white; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; }
.login-box button:hover { background: #008be0; }
.error { color: var(--danger); margin-top: 10px; font-size: 13px; min-height: 15px;}

/* Layout */
#app-screen { display: none; min-height: 100vh; }
#app-screen.active { display: flex; }

.sidebar { width: 260px; background: var(--bg-sidebar); color: #fff; display: flex; flex-direction: column; }
.sidebar .logo { padding: 30px 20px; font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.sidebar .icon { color: var(--accent); }
.sidebar nav { flex: 1; padding: 20px 0; }
.nav-item { padding: 12px 20px; display: flex; align-items: center; gap: 12px; color: var(--text-muted); text-decoration: none; font-weight: 500; border-left: 3px solid transparent; transition: all 0.2s;}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,0.05); color: #fff; border-left-color: var(--accent); }
.logout { padding: 20px; border-top: 1px solid rgba(255,255,255,0.1); }
.logout a { color: var(--text-muted); text-decoration: none; }
.logout a:hover { color: #fff; }

.content { flex: 1; padding: 40px; overflow-y: auto; }
.tab-content { display: none; }
.tab-content.active { display: block; }

header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
header h1 { font-size: 24px; font-weight: 600; }
.date { color: var(--text-muted); font-weight: 500; }

/* KPI Cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 20px; margin-bottom: 30px; }
.kpi-card { background: var(--card-bg); padding: 24px; border-radius: 12px; box-shadow: 0 0 10px rgba(0,0,0,0.02); }
.kpi-title { color: var(--text-muted); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-value { font-size: 32px; font-weight: 700; margin: 10px 0 4px 0; color: var(--text-main); }
.kpi-sub { color: var(--text-muted); font-size: 13px; }

/* Charts & Tables */
.chart-container { background: var(--card-bg); padding: 24px; border-radius: 12px; box-shadow: 0 0 10px rgba(0,0,0,0.02); margin-bottom: 30px; }
.chart-container h3 { margin-bottom: 20px; font-size: 16px; color: var(--text-main); }

.table-container { background: var(--card-bg); border-radius: 12px; box-shadow: 0 0 10px rgba(0,0,0,0.02); overflow: hidden; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 16px 24px; border-bottom: 1px dashed var(--border); }
th { background: #fafafa; font-weight: 600; color: var(--text-muted); text-transform: uppercase; font-size: 12px; letter-spacing: 0.5px; }
tbody tr:hover { background: #fcfcfc; }
.badge { padding: 4px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.badge.human { background: rgba(80,205,137,0.1); color: var(--success); }
.badge.bot { background: rgba(241,65,108,0.1); color: var(--danger); }

.ua-cell { position: relative; cursor: help; }
.ua-text { display: block; max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); font-size: 11px; }
.ua-cell:hover::after { content: attr(data-title); position: absolute; bottom: 100%; left: 0; min-width: 200px; max-width: 350px; background: #1e1e2d; color: #fff; padding: 10px 14px; border-radius: 6px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); white-space: normal; word-break: break-word; z-index: 100; pointer-events: none; font-size: 12px; margin-bottom: 5px; }
.ua-cell:hover::before { content: ''; position: absolute; bottom: 100%; left: 20px; border: 6px solid transparent; border-top-color: #1e1e2d; z-index: 100; pointer-events: none; margin-bottom: -7px; }
.device-cell { line-height: 1.4; }

/* Buttons & Inputs */
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 10px 20px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.btn-secondary { background: #f5f8fa; color: var(--text-main); border: 1px solid var(--border); padding: 10px 20px; border-radius: 6px; font-weight: 600; cursor: pointer; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Modal */
.modal { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); align-items: center; justify-content: center; z-index: 100; }
.modal.active { display: flex; }
.modal-content { background: var(--card-bg); padding: 30px; border-radius: 12px; width: 450px; }
.modal-content h2 { margin-bottom: 20px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 500; font-size: 13px;}
.form-group input { width: 100%; padding: 10px; border: 1px solid var(--border); border-radius: 6px; outline: none; }
.form-group small { color: var(--text-muted); font-size: 12px; margin-top: 4px; display: block; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 30px; }

/* Toasts */
#toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #1e1e2d; color: #fff; padding: 12px 20px; border-radius: 6px; box-shadow: 0 4px 15px rgba(0,0,0,0.15); opacity: 0; transform: translateY(20px); animation: toast-in 0.3s forwards; display: flex; align-items: center; gap: 10px; font-weight: 500; font-size: 13px; }
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
@keyframes toast-in { to { opacity: 1; transform: translateY(0); } }

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #app-screen { flex-direction: column; }
    .sidebar { width: 100%; min-height: auto; padding: 15px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; }
    .sidebar nav { display: flex; flex-direction: row; width: 100%; overflow-x: auto; gap: 10px; margin: 15px 0; padding-bottom: 5px; }
    .nav-item { padding: 8px 12px; font-size: 13px; white-space: nowrap; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .content { padding: 15px; }
    .table-container { overflow-x: auto; white-space: nowrap; }
    .chart-container { padding: 15px; }
}
