*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; font-size: 14px; color: #111827; background: #f9fafb; }

/* ── Login ── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; padding: 36px 32px; width: 340px; box-shadow: 0 4px 16px rgba(0,0,0,.07); }
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-icon { font-size: 32px; }
.login-logo h1 { font-size: 20px; font-weight: 700; margin-top: 6px; }
.login-logo p { color: #9ca3af; font-size: 13px; margin-top: 4px; }
.login-hint { text-align: center; color: #9ca3af; font-size: 12px; margin-top: 14px; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.form-group input { width: 100%; border: 1px solid #d1d5db; border-radius: 6px; padding: 9px 12px; font-size: 14px; outline: none; transition: border-color .15s; }
.form-group input:focus { border-color: #25d366; box-shadow: 0 0 0 3px rgba(37,211,102,.12); }
.error-msg { color: #ef4444; font-size: 12px; margin-bottom: 10px; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; border: none; transition: opacity .15s; }
.btn:hover { opacity: .85; }
.btn-primary { background: #25d366; color: #fff; }
.btn-danger  { background: #ef4444; color: #fff; }
.btn-secondary { background: #fff; color: #374151; border: 1px solid #d1d5db; }
.btn-full { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }
.btn-link { background: none; border: none; color: #ef4444; cursor: pointer; font-size: 12px; padding: 0; }

/* ── Layout ── */
.layout { display: flex; height: 100vh; overflow: hidden; }

/* ── Sidebar ── */
.sidebar { width: 160px; background: #fff; border-right: 1px solid #e5e7eb; display: flex; flex-direction: column; padding: 20px 12px; flex-shrink: 0; }
.sidebar-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; margin-bottom: 24px; padding: 0 4px; }
.sidebar-brand .logo-icon { font-size: 22px; }
.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 6px; color: #6b7280; text-decoration: none; font-size: 13px; font-weight: 500; cursor: pointer; background: none; border: none; width: 100%; text-align: left; }
.nav-item:hover { background: #f3f4f6; color: #111827; }
.nav-item.active { background: #f0fdf4; border: 1px solid #bbf7d0; color: #15803d; font-weight: 600; }
.nav-reset { color: #ef4444; margin-top: 8px; }
.nav-reset:hover { background: #fef2f2; }
.sidebar-footer { border-top: 1px solid #f3f4f6; padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.sidebar-user { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.sidebar-user span { font-size: 12px; color: #6b7280; }

/* ── Main content ── */
.main-content { flex: 1; overflow-y: auto; padding: 28px 32px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-header h2 { font-size: 18px; font-weight: 700; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-connected    { background: #f0fdf4; color: #15803d; }
.badge-qr           { background: #fefce8; color: #854d0e; }
.badge-disconnected { background: #f3f4f6; color: #6b7280; }
.count-badge { background: #f3f4f6; color: #6b7280; border-radius: 12px; padding: 2px 8px; font-size: 12px; font-weight: 600; margin-left: 8px; }

/* ── QR ── */
.qr-container { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 40px; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px; max-width: 360px; gap: 16px; }
#qr-image { width: 200px; height: 200px; border-radius: 6px; }
#qr-hint { color: #6b7280; font-size: 13px; text-align: center; }

/* ── Table ── */
.table-wrap { background: #fff; border: 1px solid #e5e7eb; border-radius: 10px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
thead { background: #f9fafb; }
th { padding: 10px 12px; text-align: left; font-size: 12px; font-weight: 600; color: #374151; border-bottom: 1px solid #e5e7eb; }
td { padding: 10px 12px; font-size: 13px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }
.query-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-msg { text-align: center; color: #9ca3af; padding: 32px; }
.status-pill { display: inline-block; background: #dbeafe; color: #1d4ed8; border-radius: 4px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.delete-row-btn { background: none; border: none; cursor: pointer; color: #9ca3af; font-size: 15px; }
.delete-row-btn:hover { color: #ef4444; }

/* ── Modals ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card { background: #fff; border-radius: 12px; padding: 28px 28px 24px; width: 340px; box-shadow: 0 8px 32px rgba(0,0,0,.12); text-align: center; }
.modal-icon { font-size: 28px; margin-bottom: 10px; }
.modal-card h3 { font-size: 16px; font-weight: 700; margin-bottom: 8px; }
.modal-card p { color: #6b7280; font-size: 13px; line-height: 1.5; margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; justify-content: center; }
