body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0f172a;
  color: #e5e7eb;
}

/* Top bar */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #020617;
  border-bottom: 1px solid #1f2937;
}
.topbar .logo {
  font-weight: 700;
  font-size: 18px;
}
.topbar-right span {
  margin-right: 10px;
}

/* Auth page */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
}
.auth-card {
  background: #020617;
  padding: 24px;
  border-radius: 12px;
  width: 320px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
}
.auth-card h1 {
  margin-top: 0;
  margin-bottom: 12px;
}
.auth-card label {
  display: block;
  margin-top: 10px;
  font-size: 14px;
}
.auth-card input {
  width: 100%;
  margin-top: 4px;
  padding: 8px;
  border-radius: 6px;
  border: 1px solid #374151;
  background: #020617;
  color: #e5e7eb;
}
.auth-card button {
  margin-top: 16px;
  width: 100%;
  padding: 8px;
  border-radius: 6px;
  border: none;
  background: #3b82f6;
  color: white;
  font-weight: 600;
  cursor: pointer;
}
.alert.error {
  background: #7f1d1d;
  color: #fee2e2;
  padding: 8px;
  border-radius: 6px;
  margin-bottom: 8px;
}
.tabs {
  display: flex;
  margin-bottom: 12px;
}
.tab-btn {
  flex: 1;
  padding: 6px;
  border: none;
  background: #111827;
  color: #9ca3af;
  cursor: pointer;
}
.tab-btn.active {
  background: #1d4ed8;
  color: white;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: calc(100vh - 50px);
}

/* Search panel */
.search-panel {
  border-right: 1px solid #1f2937;
  padding: 10px;
  background: #020617;
  overflow-y: auto;
}
#search-form {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
#search-form input {
  flex: 1;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid #374151;
  background: #020617;
  color: #e5e7eb;
}
#search-form button {
  padding: 6px 10px;
  border-radius: 6px;
  border: none;
  background: #3b82f6;
  color: white;
  cursor: pointer;
}
#search-results {
  font-size: 13px;
}
.search-item {
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 6px;
  background: #111827;
}
.search-item-header {
  font-weight: 600;
  margin-bottom: 4px;
}
.search-item small {
  display: block;
  color: #9ca3af;
}
.search-item button {
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  border: none;
  background: #10b981;
  color: white;
  cursor: pointer;
}

/* Board */
.board {
  padding: 10px;
  overflow-x: auto;
}
.board-columns {
  display: flex;
  gap: 10px;
  min-width: 800px;
}
.column {
  flex: 1;
  background: #020617;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 70px);
}
.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.column-body {
  flex: 1;
  overflow-y: auto;
  border-radius: 8px;
  padding: 4px;
  background: #020617;
  border: 1px dashed #1e293b;
}

/* Cards */
.card {
  background: #111827;
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 6px;
  cursor: grab;
  border: 1px solid #1e293b;
}
/* Card with unread inbound SMS */
.card-unread-sms {
  background: #f9fafb;     /* white-ish */
  color: #020617;
}
.card-unread-sms .card-meta {
  color: #4b5563;
}

.card.dragging {
  opacity: 0.5;
}
.card-title {
  font-weight: 600;
  font-size: 13px;
}
.card-meta {
  font-size: 11px;
  color: #9ca3af;
}
.card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 11px;
}
.badge {
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
}
.badge-escalation { background: #f97316; color: #111827; }
.badge-watching   { background: #3b82f6; }
.badge-urgent     { background: #ef4444; }
.badge-handled    { background: #22c55e; }
.timer {
  font-family: monospace;
}

/* Modal (responsive, one main scroll) */
.modal.hidden { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15,23,42,0.85);
}
.modal-dialog {
  position: relative;
  margin: 0;
  width: min(900px, 95vw);
  max-height: 90vh;
  background: #020617;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 15px 40px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-close {
  position: absolute;
  right: 10px;
  top: 8px;
  border: none;
  background: transparent;
  color: #9ca3af;
  font-size: 20px;
  cursor: pointer;
}
.modal-content {
  flex: 1;
  overflow-y: auto;
}
.modal-content h2 {
  margin-top: 0;
}

/* Details panel inside modal */
#modal-body {
  border: 1px solid #1f2937;
  padding: 8px;
  border-radius: 8px;
  font-size: 13px;
  background: #020617;
  margin-bottom: 8px;
}

/* Notes list */
#modal-notes {
  border: 1px solid #1f2937;
  padding: 6px;
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  max-height: 160px;
  overflow-y: auto;
}
.note-item {
  border-bottom: 1px solid #1f2937;
  padding: 4px 0;
}
#note-form textarea {
  width: 100%;
  margin-bottom: 4px;
  border-radius: 6px;
  border: 1px solid #374151;
  background: #020617;
  color: #e5e7eb;
}
#note-form button,
#btn-import-recordings,
#btn-refresh-ai {
  padding: 4px 8px;
  border-radius: 6px;
  border: none;
  background: #3b82f6;
  color: white;
  cursor: pointer;
  margin-right: 4px;
}

/* AI overview & recordings */
#ai-overview {
  background: #020617;
  border: 1px solid #1f2937;
  padding: 6px;
  border-radius: 8px;
  font-size: 12px;
  max-height: 150px;
  overflow-y: auto;
}
#recordings-list {
  font-size: 12px;
  margin-top: 6px;
}
.recording-item {
  border-bottom: 1px solid #1f2937;
  padding: 4px 0;
}

/* SMS thread styles */
#sms-thread {
  border: 1px solid #1f2937;
  border-radius: 8px;
  padding: 6px;
  font-size: 12px;
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 6px;
  background: #020617;
}
.sms-message {
  padding: 4px 6px;
  border-radius: 6px;
  margin-bottom: 4px;
}
.sms-out {
  background: #1d4ed8;
  text-align: left;
}
.sms-in {
  background: #374151;
  text-align: left;
}
.sms-meta {
  font-size: 10px;
  color: #e5e7eb;
  opacity: 0.8;
  margin-bottom: 2px;
}
.sms-body {
  font-size: 12px;
}
#sms-form textarea {
  width: 100%;
  margin-top: 4px;
  margin-bottom: 4px;
  border-radius: 6px;
  border: 1px solid #374151;
  background: #020617;
  color: #e5e7eb;
}
#sms-form button {
  padding: 4px 8px;
  border-radius: 6px;
  border: none;
  background: #10b981;
  color: white;
  cursor: pointer;
}
