:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --border: #e3e5e9;
  --text: #1b1e24;
  --muted: #6b7280;
  --accent: #2563eb;
  --bubble-in: #ffffff;
  --bubble-out: #dcf3d8;
  --bubble-internal: #fff7e0;
}

* { box-sizing: border-box; }

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

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

header.topbar {
  padding: 20px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
}

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

header.topbar h1 a {
  color: inherit;
  text-decoration: none;
}

.search-form {
  display: flex;
  gap: 8px;
  margin: 20px 0;
}

.search-form input[type="text"] {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 15px;
}

.search-form button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  font-size: 15px;
  cursor: pointer;
}

.summary-line {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}

table.contact-list {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

table.contact-list th, table.contact-list td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

table.contact-list tr:last-child td { border-bottom: none; }

table.contact-list a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.pagination {
  display: flex;
  gap: 8px;
  margin-top: 16px;
  align-items: center;
}

.pagination a, .pagination span {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
}

.contact-header {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.contact-header h2 { margin: 0 0 4px; font-size: 20px; }
.contact-header .phone { color: var(--muted); font-size: 14px; }
.contact-header .meta { margin-top: 8px; font-size: 13px; color: var(--muted); }
.contact-header .tags { margin-top: 8px; }
.tag {
  display: inline-block;
  background: #eef2ff;
  color: #3730a3;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  margin: 2px 4px 2px 0;
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bubble-row {
  display: flex;
}

.bubble-row.out { justify-content: flex-end; }
.bubble-row.in { justify-content: flex-start; }

.bubble {
  max-width: 75%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  white-space: pre-wrap;
  word-wrap: break-word;
  font-size: 14px;
  line-height: 1.4;
}

.bubble-row.in .bubble { background: var(--bubble-in); border-bottom-left-radius: 2px; }
.bubble-row.out .bubble { background: var(--bubble-out); border-bottom-right-radius: 2px; }

.bubble .media-label {
  display: block;
  font-style: italic;
  color: var(--muted);
  margin-bottom: 4px;
}

.bubble .timestamp {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

.ticket-divider {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  margin: 18px 0 4px;
  position: relative;
}

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

.back-link {
  display: inline-block;
  margin-bottom: 16px;
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
}
