* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: #f0f2f5; color: #333; min-height: 100vh; }

/* Login */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); }
.login-box { background: #fff; padding: 40px; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); width: 380px; max-width: 90vw; }
.login-box h1 { text-align: center; margin-bottom: 8px; font-size: 24px; color: #1a1a2e; }
.login-box .sub { text-align: center; color: #999; margin-bottom: 24px; font-size: 13px; }
.login-box input { width: 100%; padding: 12px; margin-bottom: 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px; outline: none; transition: border .2s; }
.login-box input:focus { border-color: #0f3460; }
.login-box button { width: 100%; padding: 12px; background: #0f3460; color: #fff; border: none; border-radius: 6px; font-size: 16px; cursor: pointer; transition: background .2s; }
.login-box button:hover { background: #1a4a8a; }
.login-msg { color: #e74c3c; text-align: center; margin-bottom: 12px; font-size: 13px; display: none; }

/* Layout */
.main-layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #1a1a2e; color: #fff; padding: 20px 0; flex-shrink: 0; }
.sidebar .logo { padding: 0 20px 20px; font-size: 18px; font-weight: bold; border-bottom: 1px solid rgba(255,255,255,0.1); margin-bottom: 12px; }
.sidebar .logo span { color: #4fc3f7; }
.sidebar a { display: block; padding: 12px 20px; color: rgba(255,255,255,0.7); text-decoration: none; font-size: 14px; cursor: pointer; transition: all .2s; }
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar .user-info { padding: 12px 20px; font-size: 12px; color: rgba(255,255,255,0.5); border-top: 1px solid rgba(255,255,255,0.1); margin-top: auto; }
.main-content { flex: 1; padding: 24px; overflow-y: auto; }

/* Cards */
.card { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.08); }
.card h3 { margin-bottom: 12px; font-size: 16px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #eee; font-size: 13px; }
th { background: #fafafa; color: #666; font-weight: 600; }
tr:hover td { background: #f8f9ff; }

/* Buttons */
.btn { padding: 8px 16px; border: none; border-radius: 4px; cursor: pointer; font-size: 13px; transition: all .2s; }
.btn-primary { background: #0f3460; color: #fff; }
.btn-primary:hover { background: #1a4a8a; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-success { background: #27ae60; color: #fff; }
.btn-default { background: #eee; color: #333; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn + .btn { margin-left: 6px; }

/* Status */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; }
.status-online { background: #27ae60; }
.status-offline { background: #ccc; }

/* Forms */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; margin-bottom: 4px; font-size: 13px; color: #666; }
.form-group input, .form-group textarea, .form-group select { width: 100%; padding: 8px 10px; border: 1px solid #ddd; border-radius: 4px; font-size: 13px; }
.form-group textarea { resize: vertical; min-height: 60px; }

/* Modal */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center; }
.modal-overlay.show { display: flex; }
.modal { background: #fff; border-radius: 8px; padding: 24px; width: 480px; max-width: 90vw; max-height: 80vh; overflow-y: auto; }
.modal h3 { margin-bottom: 16px; }
.modal-actions { margin-top: 16px; text-align: right; }

/* Page header */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h2 { font-size: 20px; }

/* Monitor */
.data-card { background: #fff; border-radius: 8px; padding: 16px; margin-bottom: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.06); border-left: 3px solid #27ae60; }
.data-card .time { font-size: 11px; color: #999; }
.data-card .payload { font-family: monospace; font-size: 12px; margin-top: 4px; white-space: pre-wrap; word-break: break-all; }

/* Tabs */
.tabs { display: flex; gap: 0; margin-bottom: 16px; border-bottom: 2px solid #eee; }
.tab { padding: 8px 20px; cursor: pointer; font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .2s; }
.tab:hover { color: #0f3460; }
.tab.active { color: #0f3460; border-bottom-color: #0f3460; font-weight: 600; }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Toast */
.toast { position: fixed; top: 20px; right: 20px; padding: 12px 20px; border-radius: 6px; color: #fff; font-size: 13px; z-index: 2000; opacity: 0; transition: opacity .3s; }
.toast.show { opacity: 1; }
.toast-success { background: #27ae60; }
.toast-error { background: #e74c3c; }

/* Device credential display */
.cred-box { background: #f8f9fa; border: 1px solid #ddd; border-radius: 6px; padding: 12px; font-family: monospace; font-size: 12px; margin: 8px 0; }
.cred-box div { margin: 4px 0; }
.cred-box span { color: #0f3460; font-weight: 600; }

@media (max-width: 768px) {
    .main-layout { flex-direction: column; }
    .sidebar { width: 100%; padding: 10px; display: flex; overflow-x: auto; }
    .sidebar .logo { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
    .sidebar a { padding: 8px 12px; }
}
