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

/* Login */
.login-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: #1a1d27; padding: 2rem; border-radius: 12px; text-align: center; width: 360px; }
.login-box h1 { font-size: 1.5rem; margin-bottom: 0.25rem; }
.login-box p { color: #94a3b8; margin-bottom: 1.5rem; font-size: 0.9rem; }
.login-box input { width: 100%; padding: 0.75rem; border: 1px solid #334155; border-radius: 8px; background: #0f1117; color: #e2e8f0; font-size: 0.95rem; margin-bottom: 1rem; }
.login-box input:focus { outline: none; border-color: #6366f1; }
.login-box button { width: 100%; padding: 0.75rem; background: #6366f1; color: white; border: none; border-radius: 8px; font-size: 0.95rem; cursor: pointer; }
.login-box button:hover { background: #5558e6; }
.divider { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0; color: #475569; font-size: 0.8rem; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: #334155; }
#tg-widget { margin-bottom: 0.75rem; min-height: 40px; display: flex; justify-content: center; }
.error { color: #f87171; margin-top: 0.5rem; font-size: 0.85rem; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar { width: 220px; background: #1a1d27; padding: 1.5rem 1rem; display: flex; flex-direction: column; }
.sidebar h2 { font-size: 1.1rem; margin-bottom: 1.5rem; }
.sidebar nav { flex: 1; }
.sidebar nav a { display: block; padding: 0.5rem 0.75rem; color: #94a3b8; text-decoration: none; border-radius: 6px; margin-bottom: 0.25rem; font-size: 0.9rem; }
.sidebar nav a:hover, .sidebar nav a.active { background: #2d3143; color: #e2e8f0; }
.sidebar-footer { margin-top: 1rem; }
.btn-sm { padding: 0.4rem 1rem; background: #334155; color: #e2e8f0; border: none; border-radius: 6px; cursor: pointer; font-size: 0.85rem; }
.btn-sm:hover { background: #475569; }

.content { flex: 1; padding: 2rem; overflow-y: auto; }
.content h2 { margin-bottom: 1.5rem; }
.content h3 { margin-bottom: 1rem; color: #cbd5e1; }

/* Cards */
.card-list { display: flex; flex-direction: column; gap: 0.5rem; }
.chat-card { background: #1a1d27; border-radius: 8px; padding: 1rem 1.25rem; cursor: pointer; display: flex; justify-content: space-between; align-items: center; transition: background 0.15s; }
.chat-card:hover { background: #2d3143; }
.chat-card .chat-name { font-weight: 600; }
.chat-card .chat-meta { color: #64748b; font-size: 0.85rem; }
.chat-card .chat-status { display: flex; gap: 0.5rem; }
.chat-card .badge { padding: 0.15rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.badge-on { background: #065f46; color: #6ee7b7; }
.badge-off { background: #450a0a; color: #fca5a5; }

/* Detail panel */
.detail-panel { margin-top: 1.5rem; background: #1a1d27; border-radius: 12px; padding: 1.5rem; }
.detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; }
.detail-header h3 { margin-bottom: 0; }
.back-btn { background: none; border: none; color: #6366f1; cursor: pointer; font-size: 0.9rem; }
.back-btn:hover { text-decoration: underline; }
.module-section { margin-bottom: 1.5rem; padding-bottom: 1.5rem; border-bottom: 1px solid #2d3143; }
.module-section:last-child { border-bottom: none; }
.module-section h4 { margin-bottom: 0.75rem; color: #94a3b8; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.form-row { display: flex; gap: 0.75rem; align-items: flex-end; margin-bottom: 0.75rem; flex-wrap: wrap; }
.form-row label { font-size: 0.85rem; color: #94a3b8; display: block; margin-bottom: 0.25rem; }
.form-row input, .form-row textarea, .form-row select { padding: 0.45rem 0.75rem; border: 1px solid #334155; border-radius: 6px; background: #0f1117; color: #e2e8f0; font-size: 0.85rem; }
.form-row textarea { width: 100%; min-height: 80px; resize: vertical; }
.form-row input:focus, .form-row textarea:focus, .form-row select:focus { outline: none; border-color: #6366f1; }
.form-row select { min-width: 120px; }
.btn { padding: 0.45rem 1rem; border: none; border-radius: 6px; cursor: pointer; font-size: 0.85rem; }
.btn-primary { background: #6366f1; color: white; }
.btn-primary:hover { background: #5558e6; }
.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-green { background: #059669; color: white; }
.btn-green:hover { background: #047857; }
.toggle { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.toggle-switch { width: 40px; height: 22px; background: #334155; border-radius: 11px; position: relative; transition: background 0.2s; }
.toggle-switch.on { background: #6366f1; }
.toggle-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; background: white; border-radius: 50%; transition: left 0.2s; }
.toggle-switch.on::after { left: 20px; }

/* Sync */
.sync-section { background: #1a1d27; border-radius: 12px; padding: 1.5rem; margin-bottom: 1.5rem; }
.sync-form { display: flex; gap: 1rem; align-items: flex-end; }
.sync-form select { padding: 0.5rem 0.75rem; border: 1px solid #334155; border-radius: 6px; background: #0f1117; color: #e2e8f0; font-size: 0.85rem; min-width: 200px; }
.sync-form select:focus { outline: none; border-color: #6366f1; }
.sync-card { background: #1a1d27; border-radius: 8px; padding: 1rem 1.25rem; display: flex; justify-content: space-between; align-items: center; }
.sync-card .sync-info { font-size: 0.9rem; }
.sync-card .sync-master { color: #6366f1; }
.sync-card .arrow { color: #64748b; margin: 0 0.5rem; }

/* List items */
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid #2d3143; }
.list-item:last-child { border-bottom: none; }
.list-item .item-info { font-size: 0.9rem; }
.list-item .item-meta { color: #64748b; font-size: 0.8rem; }

/* Toast */
.toast { position: fixed; bottom: 1.5rem; right: 1.5rem; padding: 0.75rem 1.25rem; background: #065f46; color: #6ee7b7; border-radius: 8px; font-size: 0.85rem; z-index: 1000; animation: fadeIn 0.3s; }
.toast.error { background: #450a0a; color: #fca5a5; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
