:root {
  --bg: #f3f5f8;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --primary: #0068ff;
  --primary-dark: #0052cc;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --success: #059669;
  --warn: #d97706;
  --border: #e5e7eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--primary);
  color: #fff;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.topbar h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

.btn-sm {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 13px;
}

.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 12px;
}

.filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.date-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.date-row .btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.input,
.select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  background: #fff;
  color: var(--text);
  font-family: inherit;
}

.summary-bar {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  padding: 8px 12px;
  background: #e8f1ff;
  border-radius: 10px;
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  cursor: pointer;
  transition: background-color 0.4s ease;
}

.card.flash-new {
  animation: flashNew 2s ease-out;
}

@keyframes flashNew {
  0% { background-color: #fef08a; }
  100% { background-color: #ffffff; }
}

.card.cancelled {
  background: var(--danger-bg);
  border-color: #fecaca;
}

.card.cancelled .trip-text {
  text-decoration: line-through;
  color: var(--muted);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  background: #eef2ff;
  color: #1d4ed8;
}

.badge-price {
  background: #ecfdf5;
  color: #047857;
}

.badge-cancel {
  background: var(--danger);
  color: #fff;
}

.badge-warn {
  background: #fef3c7;
  color: #b45309;
}

.group-label {
  font-size: 12px;
  color: var(--muted);
}

.sender-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}

.trip-text {
  font-size: 17px;
  font-weight: 600;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 6px 0 8px;
  color: #0f172a;
}

.line-reply {
  font-size: 14px;
  color: #374151;
  margin-top: 3px;
}

.line-note {
  margin-top: 6px;
  padding: 6px 10px;
  background: #fffbeb;
  border-left: 3px solid #f59e0b;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  color: #92400e;
}

.line-cancel {
  margin-top: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}

.modal-backdrop.open {
  display: flex;
}

.modal-sheet {
  background: #fff;
  width: 100%;
  max-width: 640px;
  border-radius: 18px 18px 0 0;
  padding: 18px;
  max-height: 85vh;
  overflow-y: auto;
}

.msg-box {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 8px;
}

.msg-meta {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
}

.section-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
}

.section-card h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

.status-banner {
  padding: 12px;
  border-radius: 10px;
  font-weight: 600;
  margin-bottom: 12px;
}

.status-connected { background: #ecfdf5; color: #065f46; }
.status-kicked { background: #fef2f2; color: #991b1b; border: 1px solid #f87171; }
.status-disconnected { background: #fffbeb; color: #92400e; }
.status-logged_out { background: #f3f4f6; color: #374151; }

.group-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}

.group-row:last-child { border-bottom: none; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 36px 16px;
}

/* Danh sách nhóm gọn */
.group-row-compact {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 4px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  font-size: 15px;
}
.group-row-compact:hover { background: #f6f8fb; }
.group-row-compact.on { background: #eefaf2; }
.group-row-compact input { width: 18px; height: 18px; flex: none; margin: 0; }
.group-row-compact .g-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.group-row-compact.on .g-name { font-weight: 600; }
.group-row-compact .g-mem { flex: none; font-size: 12px; color: var(--muted); }
