:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --in: #d1fae5;
  --in-text: #065f46;
  --out: #dbeafe;
  --out-text: #1e40af;
  --danger: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

.hidden { display: none !important; }

/* ---------- Login ---------- */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}

.brand { text-align: center; margin-bottom: 24px; }
.brand-logo {
  font-size: 36px;
  width: 68px;
  height: 68px;
  line-height: 68px;
  margin: 0 auto 12px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
}
.brand h1 { margin: 0; font-size: 22px; }
.brand p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 14px 0 6px;
}

form input {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 15px;
}
form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

button[type="submit"], .btn {
  width: 100%;
  padding: 12px;
  margin-top: 18px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
button[type="submit"]:hover, .btn:hover { background: var(--primary-dark); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.error {
  margin-top: 14px;
  color: var(--danger);
  font-size: 14px;
  text-align: center;
}

.auth-footer { margin-top: 22px; text-align: center; font-size: 12px; color: var(--muted); }

/* ---------- App ---------- */
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
}
.topbar-brand { font-weight: 700; font-size: 17px; }
.topbar-user { display: flex; align-items: center; gap: 12px; }
.user-number { color: var(--muted); font-size: 14px; }
.btn-ghost {
  width: auto;
  margin: 0;
  padding: 8px 14px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
}
.btn-ghost:hover { background: var(--bg); }

.app-main {
  max-width: 720px;
  margin: 0 auto;
  padding: 26px 18px 60px;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.list-header h2 { margin: 0; font-size: 20px; }
.list-header .btn {
  width: auto;
  margin: 0;
  padding: 9px 16px;
  font-weight: 500;
}
#list-status { color: var(--muted); font-size: 14px; margin: 6px 0 18px; }

.message-list { display: flex; flex-direction: column; gap: 12px; }

.message {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
}
.message-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.badge {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}
.badge-in { background: var(--in); color: var(--in-text); }
.badge-out { background: var(--out); color: var(--out-text); }
.message-meta { font-size: 13px; color: var(--muted); }
.message-text {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.message-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
}