:root {
  --blue: #2563eb;
  --blue-light: #eff6ff;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --red: #dc2626;
  --red-light: #fef2f2;
  --yellow: #d97706;
  --yellow-light: #fffbeb;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-500: #6b7280;
  --gray-700: #374151;
  --gray-900: #111827;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  height: 100vh;
  overflow: hidden;
}

/* ── Screens ─────────────────────────────────────────────────── */
.screen { width: 100%; height: 100vh; }
.hidden { display: none !important; }

/* ── Login ───────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1d4ed8 0%, #0891b2 100%);
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 340px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.login-logo { font-size: 48px; margin-bottom: 12px; }
.login-card h1 { font-size: 22px; font-weight: 700; color: var(--gray-900); }
.login-card .subtitle { color: var(--gray-500); margin-bottom: 24px; font-size: 14px; }

.login-card form { display: flex; flex-direction: column; gap: 12px; }

.login-card input {
  padding: 12px 16px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 15px;
  outline: none;
  transition: border-color .2s;
}
.login-card input:focus { border-color: var(--blue); }

.login-card button {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.login-card button:hover { background: #1d4ed8; }
.error { color: var(--red); font-size: 13px; margin-top: 4px; }

/* ── App Layout ──────────────────────────────────────────────── */
#app-screen {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 220px;
  background: white;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  gap: 8px;
  flex-shrink: 0;
}

.sidebar-logo { font-size: 32px; text-align: center; margin-bottom: 16px; }

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  transition: background .15s, color .15s;
}
.nav-btn:hover { background: var(--gray-100); }
.nav-btn.active { background: var(--blue-light); color: var(--blue); }

.logout-btn {
  margin-top: auto;
  padding: 8px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  background: none;
  font-size: 13px;
  color: var(--gray-500);
  cursor: pointer;
}
.logout-btn:hover { background: var(--gray-100); }

.content {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

.tab { display: none; }
.tab.active { display: block; }

h2 { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
h3 { font-size: 16px; font-weight: 600; margin-bottom: 10px; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

/* ── Status card ─────────────────────────────────────────────── */
.status-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.status-indicator {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--gray-200);
}
.status-indicator.connected { background: var(--green); box-shadow: 0 0 0 4px var(--green-light); }
.status-indicator.connecting { background: var(--yellow); animation: pulse 1.2s infinite; }
.status-indicator.qr_ready  { background: var(--blue); animation: pulse 1.2s infinite; }
.status-indicator.disconnected { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ── QR ──────────────────────────────────────────────────────── */
.qr-img {
  display: block;
  margin: 0 auto 20px;
  width: 220px;
  height: 220px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
}
.info-text { text-align: center; color: var(--gray-500); margin-bottom: 12px; font-size: 14px; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn-primary {
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary:hover { background: #1d4ed8; }

.btn-secondary {
  background: white;
  color: var(--blue);
  border: 1.5px solid var(--blue);
  border-radius: var(--radius);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary:hover { background: var(--blue-light); }

.btn-danger {
  background: white;
  color: var(--red);
  border: 1.5px solid var(--red);
  border-radius: var(--radius);
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger:hover { background: var(--red-light); }

.btn-ghost {
  background: none;
  border: none;
  color: var(--gray-500);
  font-size: 14px;
  padding: 9px 18px;
  cursor: pointer;
  border-radius: var(--radius);
}
.btn-ghost:hover { background: var(--gray-100); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.gap-sm { gap: 8px; }
.flex-1 { flex: 1; }

/* ── Birthdays list ──────────────────────────────────────────── */
.tab-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.tab-header h2 { margin-bottom: 0; }

.search-bar { margin-bottom: 14px; }
.search-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  background: white;
}
.search-input:focus { border-color: var(--blue); }

.birthdays-list { display: flex; flex-direction: column; gap: 8px; }

.birthday-item {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow);
}
.birthday-item.inactive { opacity: .55; }

.birthday-date {
  min-width: 52px;
  text-align: center;
  background: var(--blue-light);
  color: var(--blue);
  border-radius: 8px;
  padding: 6px 8px;
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
}
.birthday-item.inactive .birthday-date { background: var(--gray-100); color: var(--gray-500); }

.birthday-info { flex: 1; }
.birthday-name { font-weight: 600; font-size: 15px; }
.birthday-status { font-size: 12px; color: var(--gray-500); }

.birthday-actions { display: flex; gap: 6px; }
.icon-btn {
  border: none;
  background: none;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 14px;
  transition: background .15s;
}
.icon-btn:hover { background: var(--gray-100); }

/* ── Form ────────────────────────────────────────────────────── */
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 500; color: var(--gray-700); }
input[type="text"],
input[type="time"],
textarea,
select {
  padding: 9px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  outline: none;
  font-family: inherit;
  background: white;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue); }
textarea { resize: vertical; }
.field-hint { font-size: 11px; color: var(--gray-500); font-weight: 400; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox-label { flex-direction: row; align-items: center; gap: 8px; font-size: 14px; }

/* ── Modal ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-card {
  background: white;
  border-radius: 14px;
  padding: 28px;
  width: 380px;
  max-width: calc(100vw - 32px);
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 25px 50px rgba(0,0,0,.2);
}

.modal-card h3 { font-size: 18px; }
#birthday-form { display: flex; flex-direction: column; gap: 12px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-900);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 200;
  box-shadow: var(--shadow-md);
  transition: opacity .3s;
}
.toast.success { background: var(--green); }
.toast.error   { background: var(--red); }

/* ── Misc ────────────────────────────────────────────────────── */
.text-muted { color: var(--gray-500); font-size: 14px; }
.small { font-size: 12px; }
.loading { color: var(--gray-500); padding: 20px; text-align: center; }
code { background: var(--gray-100); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

@media (max-width: 600px) {
  .sidebar { display: none; }
  .content { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
}
