@import url('https://fonts.googleapis.com/css2?family=Lora:wght@500;600&family=Inter:wght@400;500;600&display=swap');

:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --border: #e5e0d8;
  --text: #2b2b28;
  --text-muted: #6f6a62;
  --accent: #3b6e64;
  --accent-dark: #2b514a;
  --accent-soft: #e7efec;
  --secondary: #7c6a8e;
  --danger: #b3543f;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', sans-serif;
  font-size: 15px;
}

h1, h2, h3, .brand {
  font-family: 'Lora', serif;
  font-weight: 600;
  color: var(--accent-dark);
}

a { color: var(--accent); }

button {
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  border: none;
  border-radius: var(--radius);
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 500;
  background: var(--accent);
  color: white;
  transition: background 0.15s ease;
}
button:hover { background: var(--accent-dark); }
button.secondary {
  background: transparent;
  color: var(--accent-dark);
  border: 1px solid var(--border);
}
button.secondary:hover { background: var(--accent-soft); }
button.danger { background: var(--danger); }
button.danger:hover { background: #8f3d2c; }

input, textarea, select {
  font-family: 'Inter', sans-serif;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  width: 100%;
  background: var(--surface);
  color: var(--text);
}
input:focus, textarea:focus, select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  display: block;
  margin-bottom: 4px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* --- Login --- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  width: 340px;
  text-align: center;
}
.login-card .brand { font-size: 22px; margin-bottom: 4px; }
.login-card p.tagline { color: var(--text-muted); margin-top: 0; margin-bottom: 24px; font-size: 13px; }
.login-card form { text-align: left; display: flex; flex-direction: column; gap: 12px; }
.error-msg { color: var(--danger); font-size: 13px; min-height: 18px; }

/* --- App shell --- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px;
  background: var(--accent-dark);
  color: #f3f1ec;
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
}
.sidebar .brand { color: white; font-size: 18px; margin-bottom: 8px; }
.user-info {
  color: #d9d3c7;
  font-size: 12.5px;
  padding-bottom: 20px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}
.user-info .name { color: white; font-weight: 500; display: block; margin-bottom: 2px; }
.user-info .badge {
  display: inline-block; margin-top: 4px; font-size: 11px; padding: 2px 8px;
  border-radius: 999px; background: rgba(255,255,255,0.15); color: #f3f1ec;
}
.sidebar nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar nav a {
  color: #d9d3c7;
  text-decoration: none;
  padding: 9px 12px;
  border-radius: var(--radius);
  font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.08); }
.sidebar nav a.active { background: rgba(255,255,255,0.14); color: white; font-weight: 500; }
.sidebar .logout { color: #d9d3c7; background: transparent; border: 1px solid rgba(255,255,255,0.2); }

.main {
  flex: 1;
  padding: 32px 40px;
  max-width: 980px;
}
.main header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
}
.status-pill.connected { background: var(--accent-soft); color: var(--accent-dark); }
.status-pill.qr_pending { background: #fbeed8; color: #9a6a1a; }
.status-pill.disconnected, .status-pill.initializing, .status-pill.not_initialized { background: #f4e2dd; color: var(--danger); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-muted); font-weight: 500; font-size: 13px; }
tr:last-child td { border-bottom: none; }

.day-group { margin-bottom: 22px; }
.day-group h3 { margin: 0 0 8px 0; font-size: 15px; text-transform: capitalize; }
.appt-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--surface);
}
.appt-time { font-weight: 600; color: var(--accent-dark); width: 52px; }
.appt-name { flex: 1; }
.appt-meta { color: var(--text-muted); font-size: 13px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-dark); }
.tag.done { background: #e5e0d8; color: var(--text-muted); }
.tag.cancelled { background: #f4e2dd; color: var(--danger); }
.send-reminder-row-btn { font-size: 12px; padding: 5px 10px; white-space: nowrap; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(30,26,22,0.4);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 380px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal h3 { margin-top: 0; }
.modal form { display: flex; flex-direction: column; gap: 12px; }
.modal .actions { display: flex; justify-content: space-between; margin-top: 8px; }

.empty-state { color: var(--text-muted); font-size: 14px; padding: 24px; text-align: center; }

.qr-box { text-align: center; }
.qr-box img { width: 220px; height: 220px; margin: 16px 0; border: 1px solid var(--border); border-radius: var(--radius); }

.backup-codes {
  font-family: monospace;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
  background: var(--accent-soft);
  padding: 14px;
  border-radius: var(--radius);
  margin: 12px 0;
  font-size: 14px;
}

.toolbar { display: flex; gap: 10px; margin-bottom: 18px; }
