@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Plus+Jakarta+Sans:wght@500;600;700;800&display=swap');

/* ─── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --navy:        #0d1b2e;
  --navy-mid:    #1a2e4a;
  --navy-light:  #243b55;
  --orange:      #f47c20;
  --orange-dark: #d4670f;
  --orange-subtle: rgba(244,124,32,.1);
  --white:       #ffffff;
  --off-white:   #f5f7fa;
  --grey-light:  #e8ecf0;
  --grey-mid:    #b0bac6;
  --grey-text:   #6b7a8d;
  --red:         #e53935;
  --green:       #2e7d32;
  --shadow:      0 2px 12px rgba(13,27,46,.12);
  --shadow-lg:   0 4px 24px rgba(13,27,46,.18);
  --shadow-card: 0 1px 3px rgba(13,27,46,.06), 0 4px 14px rgba(13,27,46,.09);
  --radius:    12px;
  --radius-sm:  8px;
  --font-display: 'Plus Jakarta Sans', 'Segoe UI', system-ui, sans-serif;
  --font-body:    'Inter', 'Segoe UI', system-ui, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--off-white);
  color: var(--navy);
  font-size: 14px;
  line-height: 1.55;
}

/* ─── Display font: applied to headings, UI labels, buttons ────────────────── */
.brand-name, .card-header h3, .section-header, .modal-header h3,
.login-header h1, .service-card-header h2, .action-bar h2,
.tab-btn, .btn, .nav-info .badge .value, .form-group label {
  font-family: var(--font-display);
}

/* ─── Animations ────────────────────────────────────────────────────────────── */
@keyframes spin     { to { transform: rotate(360deg); } }
@keyframes fadeUp   { from { opacity:0; transform:translateY(16px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn   { from { opacity:0; }                             to { opacity:1; } }
@keyframes shimmer  { 0% { background-position:-600px 0; } 100% { background-position:600px 0; } }
@keyframes pulseDot { 0%,100% { transform:scale(1); }  50% { transform:scale(1.2); } }

/* ─── Scrollbar ─────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--grey-light); }
::-webkit-scrollbar-thumb { background: var(--navy-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--navy-mid); }

/* ─── Top Nav / Header ──────────────────────────────────────────────────────── */
.top-nav {
  background: var(--navy);
  background-image: linear-gradient(180deg, rgba(255,255,255,.04) 0%, transparent 100%);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  height: 60px;
  border-bottom: 2px solid rgba(244,124,32,.35);
  box-shadow: 0 2px 16px rgba(13,27,46,.28);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-box {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.logo-box img {
  height: 40px;
  width: auto;
  display: block;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
  letter-spacing: -.2px;
}

.brand-sub {
  font-size: 10px;
  color: rgba(255,255,255,.35);
  font-weight: 500;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.nav-info {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--grey-mid);
}

.nav-info .badge {
  background: rgba(255,255,255,.07);
  color: var(--grey-mid);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: background .18s;
}

.nav-info .badge:hover { background: rgba(255,255,255,.12); }

.nav-info .badge .label { color: rgba(255,255,255,.42); font-size: 11px; }
.nav-info .badge .value { color: var(--white); font-weight: 600; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background .18s, transform .12s, box-shadow .18s, border-color .18s;
  white-space: nowrap;
}

.btn:hover  { transform: translateY(-1px); }
.btn:active { transform: scale(.97) translateY(0); }

.btn-primary {
  background: var(--orange);
  color: var(--white);
}
.btn-primary:hover { background: var(--orange-dark); box-shadow: 0 4px 16px rgba(244,124,32,.42); }

.btn-secondary {
  background: var(--navy-light);
  color: var(--white);
}
.btn-secondary:hover { background: var(--navy-mid); }

.btn-outline {
  background: transparent;
  color: var(--white);
  border: 1px solid rgba(255,255,255,.3);
}
.btn-outline:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.6); }

.btn-danger {
  background: var(--red);
  color: var(--white);
}
.btn-danger:hover { background: #c62828; }

.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 12px 28px;
  font-size: 15px;
  border-radius: var(--radius);
}

.btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

/* ─── Cards / Panels ────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(13,27,46,.06);
  overflow: hidden;
}

.card-header {
  background: var(--navy);
  background-image: linear-gradient(135deg, var(--navy-mid) 0%, var(--navy) 100%);
  border-left: 4px solid var(--orange);
  color: var(--white);
  padding: 13px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header h3 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .1px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-header .badge-count {
  background: var(--orange);
  color: var(--white);
  border-radius: 20px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
}

.card-body { padding: 20px; }

/* ─── Forms ─────────────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--grey-text);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--grey-light);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--navy);
  background: var(--white);
  transition: border-color .18s, box-shadow .18s, background .15s;
  font-family: var(--font-body);
}

.form-control:focus {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3.5px rgba(244,124,32,.14);
  background: #fffdf9;
}

select.form-control {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7a8d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
  line-height: 1.55;
}

/* ─── Alert ─────────────────────────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.alert-error   { background: #fff5f5; border: 1px solid #ffcdd2; color: #c62828; }
.alert-success { background: #f1f8e9; border: 1px solid #c5e1a5; color: #2e7d32; }
.alert-info    { background: #e3f2fd; border: 1px solid #90caf9; color: #1565c0; }

/* ─── Tables ────────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  background: var(--navy);
  color: rgba(255,255,255,.8);
  padding: 11px 14px;
  text-align: left;
  font-family: var(--font-display);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  white-space: nowrap;
  border-bottom: 2px solid rgba(244,124,32,.35);
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--grey-light);
  vertical-align: middle;
  color: var(--navy);
}

tr:last-child td { border-bottom: none; }

tbody tr:nth-child(even) td { background: rgba(245,247,250,.65); }
tr:hover td { background: #fff8f2; transition: background .12s; }
tr.active td { background: #fff3e6; border-left: 3px solid var(--orange); }

.empty-state {
  padding: 36px 24px;
  text-align: center;
  color: var(--grey-text);
  font-size: 13px;
  animation: fadeIn .3s ease both;
}

.empty-state .icon { font-size: 32px; margin-bottom: 8px; filter: grayscale(.5) opacity(.6); }

/* ─── Skeleton loader ───────────────────────────────────────────────────────── */
.skeleton-cell {
  display: inline-block;
  height: 13px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--grey-light) 25%, #e0e4e8 50%, var(--grey-light) 75%);
  background-size: 600px 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.skeleton-cell--wide  { width: 75%; }
.skeleton-cell--med   { width: 50%; }
.skeleton-cell--short { width: 28%; }

/* ─── Login Page ────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background-color: var(--navy);
  background-image:
    radial-gradient(circle, rgba(255,255,255,.055) 1px, transparent 1px),
    linear-gradient(135deg, rgba(244,124,32,.09) 0%, transparent 50%, rgba(255,255,255,.03) 100%),
    linear-gradient(160deg, #0d1b2e 0%, #1a2e4a 55%, #0f2240 100%);
  background-size: 28px 28px, 100% 100%, 100% 100%;
}

/* Orange glow orb — top right */
.login-page::before {
  content: '';
  position: absolute;
  top: -120px; right: -80px;
  width: 420px; height: 420px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(244,124,32,.16) 0%, transparent 70%);
  pointer-events: none;
}

.login-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow:
    0 4px 6px rgba(13,27,46,.08),
    0 14px 36px rgba(13,27,46,.24),
    0 32px 64px rgba(13,27,46,.16);
  width: 100%;
  max-width: 420px;
  overflow: hidden;
  animation: fadeUp .45s cubic-bezier(.22,1,.36,1) both;
}

.login-header {
  background: linear-gradient(160deg, var(--navy-mid) 0%, var(--navy) 100%);
  padding: 32px 32px 26px;
  text-align: center;
  border-bottom: 3px solid var(--orange);
  position: relative;
  overflow: hidden;
}

/* Inner shimmer highlight */
.login-header::after {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 140px; height: 140px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.07) 0%, transparent 70%);
  pointer-events: none;
}

.login-header .logo-box {
  margin: 0 auto 14px;
  justify-content: center;
}

.login-header .logo-box img { height: 60px; }

.login-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -.3px;
}

.login-header p {
  font-size: 13px;
  color: rgba(255,255,255,.48);
  margin-top: 5px;
}

.login-body {
  padding: 28px 32px 32px;
}

/* ─── Select Service Page ───────────────────────────────────────────────────── */
.service-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--off-white);
}

.service-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  background-image: radial-gradient(circle, rgba(13,27,46,.055) 1px, transparent 1px);
  background-size: 24px 24px;
}

.service-card {
  background: var(--white);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(13,27,46,.13), 0 24px 48px rgba(13,27,46,.08);
  width: 100%;
  max-width: 460px;
  overflow: hidden;
  animation: fadeUp .4s cubic-bezier(.22,1,.36,1) both;
}

.service-card-header {
  background: linear-gradient(135deg, var(--navy-mid) 0%, var(--navy) 100%);
  border-bottom: 3px solid var(--orange);
  padding: 24px 28px;
}

.service-card-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--white);
  letter-spacing: -.2px;
}

.service-card-header p {
  font-size: 13px;
  color: rgba(255,255,255,.48);
  margin-top: 4px;
}

.service-card-body { padding: 28px 24px; }

.service-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* ─── Messaging Page ────────────────────────────────────────────────────────── */
.msg-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.msg-body {
  flex: 1;
  display: grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: auto 1fr auto;
  gap: 0;
  overflow: hidden;
  padding: 0;
}

/* Left panel */
.left-panel {
  grid-row: 1 / 4;
  background: var(--white);
  border-right: 1px solid var(--grey-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: fadeIn .35s ease both;
}

.left-panel-section {
  border-bottom: 1px solid var(--grey-light);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.left-panel-section.unread-section {
  flex: 1 1 auto;
  min-height: 180px;
  max-height: 50%;
}

.left-panel-section.history-section {
  flex: 1 1 auto;
  min-height: 120px;
  max-height: 50%;
}

.section-header {
  background: var(--navy-mid);
  color: var(--white);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-left: 3px solid var(--orange);
}

.section-header .badge-count {
  background: var(--orange);
  color: var(--white);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 11px;
}

.scroll-inner {
  overflow-y: auto;
  flex: 1;
}

/* Message list items */
.msg-list-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--grey-light);
  cursor: pointer;
  transition: background .18s, border-left-color .18s;
  display: flex;
  flex-direction: column;
  gap: 3px;
  border-left: 3px solid transparent;
  padding-left: 14px;
}

.msg-list-item:hover { background: #fdf8f4; border-left-color: rgba(244,124,32,.4); }
.msg-list-item.active { background: #fff3e5; border-left-color: var(--orange); }

.msg-list-item .mobile { font-weight: 700; font-size: 13px; color: var(--navy); font-family: var(--font-display); }
.msg-list-item .svc   { font-size: 11px; color: var(--grey-text); }
.msg-list-item .dt    { font-size: 11px; color: var(--grey-mid); }
.msg-list-item .agent { font-size: 11px; color: var(--orange); font-weight: 600; }

/* Right / main area */
.right-panel {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--off-white);
  animation: fadeUp .4s .06s cubic-bezier(.22,1,.36,1) both;
}

/* Mobile search bar */
.mobile-search-bar {
  background: var(--white);
  border-bottom: 1px solid var(--grey-light);
  padding: 12px 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(13,27,46,.04);
}

.mobile-search-bar .form-control {
  flex: 1;
  margin: 0;
}

/* Chat window */
.chat-window {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--off-white);
  background-image: radial-gradient(circle, rgba(13,27,46,.04) 1px, transparent 1px);
  background-size: 20px 20px;
}

.chat-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey-text);
  font-size: 14px;
  text-align: center;
  flex-direction: column;
  gap: 8px;
}

.chat-placeholder .icon { font-size: 48px; opacity: .25; }

/* Bubbles */
.bubble-wrap {
  display: flex;
  flex-direction: column;
  max-width: 70%;
  gap: 3px;
  animation: fadeIn .22s ease both;
}

.bubble-wrap.inbound  { align-self: flex-start; align-items: flex-start; }
.bubble-wrap.outbound { align-self: flex-end;   align-items: flex-end; }

.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.bubble-wrap.inbound .bubble {
  background: var(--white);
  border: 1px solid var(--grey-light);
  color: var(--navy);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
}

.bubble-wrap.outbound .bubble {
  background: linear-gradient(135deg, var(--navy-mid) 0%, var(--navy) 100%);
  color: var(--white);
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(13,27,46,.22);
  font-family: var(--font-display);
  font-weight: 500;
}

.bubble-meta {
  font-size: 10px;
  color: var(--grey-text);
  padding: 0 4px;
}

/* Message compose area */
.compose-area {
  background: var(--white);
  border-top: 2px solid var(--grey-light);
  padding: 14px 18px 16px;
  flex-shrink: 0;
  box-shadow: 0 -2px 12px rgba(13,27,46,.06);
}

.compose-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  gap: 8px;
}

/* Character counter — pill */
#char-count, .compose-toolbar .char-count {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .2px;
  background: var(--off-white);
  border: 1px solid var(--grey-light);
  border-radius: 12px;
  padding: 3px 10px;
  color: var(--grey-text);
}
#char-count.warn, .compose-toolbar .char-count.warn { background:#fff8f0; border-color:rgba(244,124,32,.3); color:var(--orange); }
#char-count.over, .compose-toolbar .char-count.over { background:#fff5f5; border-color:rgba(229,57,53,.3);   color:var(--red); }

/* Templates button — pill/chip */
#template-btn {
  background: var(--off-white);
  color: var(--navy);
  border: 1.5px solid var(--grey-light);
  border-radius: 20px;
  font-size: 12px;
  font-family: var(--font-display);
  font-weight: 600;
  transition: background .18s, border-color .18s, box-shadow .18s;
}
#template-btn:hover {
  background: #fff3e5;
  border-color: var(--orange);
  color: var(--orange-dark);
  box-shadow: 0 2px 6px rgba(244,124,32,.15);
  transform: none;
}

.compose-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.compose-input-row textarea {
  flex: 1;
  min-height: 70px;
  max-height: 160px;
}

/* Send button */
#send-btn {
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.1px;
  box-shadow: 0 2px 8px rgba(244,124,32,.32);
}
#send-btn:hover { box-shadow: 0 4px 16px rgba(244,124,32,.46); }

/* ─── Modals ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(13,27,46,.55);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal-overlay.open .modal {
  animation: fadeUp .3s cubic-bezier(.22,1,.36,1) both;
}

.modal {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  background: var(--navy);
  background-image: linear-gradient(135deg, var(--navy-mid) 0%, var(--navy) 100%);
  color: var(--white);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-header h3 { font-size: 15px; font-weight: 700; letter-spacing: -.1px; }

.modal-close {
  background: none;
  border: none;
  color: var(--grey-mid);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  transition: color .15s;
}

.modal-close:hover { color: var(--white); }

.modal-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.template-btn {
  background: var(--off-white);
  border: 1px solid var(--grey-light);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  color: var(--navy);
  line-height: 1.55;
  transition: background .15s, border-color .15s;
  width: 100%;
  font-family: var(--font-body);
}

.template-btn:hover {
  background: #fff8f2;
  border-color: var(--orange);
}

/* ─── Spinner ────────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: var(--white);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: middle;
}

.spinner--dark {
  border: 2px solid rgba(13,27,46,.15);
  border-top-color: var(--navy);
}

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 72px;
  right: 20px;
  z-index: 999;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-display);
  color: var(--white);
  box-shadow: 0 4px 20px rgba(0,0,0,.22);
  transform: translateX(120%);
  transition: transform .3s ease;
  max-width: 340px;
}

.toast.show { transform: translateX(0); }
.toast.success { background: linear-gradient(135deg, #2e7d32 0%, #388e3c 100%); border-left: 4px solid #81c784; }
.toast.error   { background: linear-gradient(135deg, #c62828 0%, #d32f2f 100%); border-left: 4px solid #ef9a9a; }

/* ─── Ghost button ───────────────────────────────────────────────────────────── */
.btn-ghost {
  background: transparent;
  color: var(--navy);
  border: 1px solid var(--grey-mid);
  font-weight: 600;
  font-family: var(--font-display);
}
.btn-ghost:hover { background: var(--off-white); border-color: var(--navy-light); }

/* ─── Bulk history drilldown links ──────────────────────────────────────────── */
.bulk-hist-link {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-display);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: background .15s;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.bulk-hist-link--success { color: var(--green); }
.bulk-hist-link--success:hover { background: #f1f8e9; }
.bulk-hist-link--fail { color: var(--red); }
.bulk-hist-link--fail:hover { background: #fff5f5; }

/* ─── Admin page ─────────────────────────────────────────────────────────────── */
.admin-page { display: flex; flex-direction: column; min-height: 100vh; background: var(--off-white); }
.admin-content {
  flex: 1;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 20px;
  animation: fadeUp .38s cubic-bezier(.22,1,.36,1) both;
}

/* Tab bar */
.tab-bar {
  display: flex;
  gap: 2px;
  margin-bottom: 24px;
  border-bottom: 2px solid var(--grey-light);
}

.tab-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  color: var(--grey-text);
  padding: 11px 20px;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s, background .15s;
  letter-spacing: -.1px;
  border-radius: 6px 6px 0 0;
}
.tab-btn:hover  { color: var(--navy); background: rgba(13,27,46,.04); }
.tab-btn.active { color: var(--orange); border-bottom-color: var(--orange); }

/* Tab sections */
.tab-section        { display: none; }
.tab-section.active {
  display: block;
  animation: fadeUp .28s cubic-bezier(.22,1,.36,1) both;
}

/* Action bar above tables */
.action-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.action-bar h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -.1px;
}
.action-bar .btn-group { display: flex; gap: 8px; }

/* Services detail panel */
.services-panel { margin-top: 16px; display: none; }
.services-panel.visible { display: block; }
.services-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  flex-wrap: wrap;
  gap: 8px;
}
.services-panel-header h3 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
}

/* Admin badge */
.badge-admin {
  background: var(--orange);
  color: var(--white);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-display);
}

/* Message search filters */
.filter-bar {
  background: var(--white);
  border-radius: 12px;
  box-shadow: var(--shadow-card);
  border: 1px solid rgba(13,27,46,.06);
  padding: 16px 20px;
  margin-bottom: 20px;
}
.filter-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.filter-row .form-group { margin-bottom: 0; flex: 1; min-width: 140px; }
.filter-row .btn { flex-shrink: 0; }

/* Direction badge */
.dir-in, .dir-out {
  border-radius: 20px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-display);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.dir-in  { background: #e3f2fd; color: #1565c0; }
.dir-out { background: #f1f8e9; color: #2e7d32; }

/* Status badges */
.badge-active, .badge-inactive {
  border-radius: 20px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-display);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.badge-active   { background: #f1f8e9; color: #2e7d32; }
.badge-inactive { background: #fff5f5; color: #c62828; }

.badge-active::before   { content:''; width:5px; height:5px; border-radius:50%; background:#2e7d32; flex-shrink:0; }
.badge-inactive::before { content:''; width:5px; height:5px; border-radius:50%; background:#c62828; flex-shrink:0; }

/* Truncate long message bodies in table */
.msg-body-cell { max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Results cap notice */
.results-notice { font-size: 12px; color: var(--grey-text); margin-bottom: 10px; }

/* Report % change chips */
.rpt-pct-chip { display:inline-block; font-size:12px; font-weight:600; padding:2px 8px; border-radius:20px; }
.rpt-pct-up   { background:#f1f8e9; color:#2e7d32; }
.rpt-pct-down { background:#fff5f5; color:#c62828; }

/* ─── Date preset buttons ───────────────────────────────────────────────────── */
.date-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.date-preset-btn {
  padding: 4px 12px;
  border: 1.5px solid var(--grey-light);
  border-radius: 20px;
  background: var(--off-white);
  color: var(--grey-text);
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font-display);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.date-preset-btn:hover {
  border-color: var(--orange);
  color: var(--orange-dark);
  background: #fff8f2;
  transform: none;
}

.date-preset-btn.active {
  border-color: var(--orange);
  background: var(--orange);
  color: var(--white);
}

/* ─── Template modal sections ───────────────────────────────────────────────── */
.template-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--grey-text);
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--grey-light);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tmpl-entry {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--grey-light);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--off-white);
  transition: border-color .15s;
}

.tmpl-entry:hover { border-color: var(--orange); }

.tmpl-entry .template-use-btn {
  flex: 1;
  padding: 10px 13px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  color: var(--navy);
  font-family: var(--font-body);
  line-height: 1.4;
  transition: background .15s;
}

.tmpl-entry .template-use-btn:hover { background: #fff8f2; }

.tmpl-entry .template-actions {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--grey-light);
  flex-shrink: 0;
}

.tmpl-entry .template-act-btn {
  flex: 1;
  min-width: 32px;
  padding: 0 10px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--grey-light);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-display);
  transition: background .15s, color .15s;
  color: var(--grey-text);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tmpl-entry .template-act-btn:last-child { border-bottom: none; }
.tmpl-entry .template-act-btn:hover { background: var(--off-white); }
.tmpl-entry .template-act-btn.edit:hover  { color: var(--navy); background: #eef2ff; }
.tmpl-entry .template-act-btn.delete:hover { color: var(--red); background: #fff5f5; }

.tmpl-empty {
  color: var(--grey-text);
  font-size: 12px;
  font-style: italic;
  padding: 8px 4px 12px;
}

/* Report period label */
.rpt-period-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--grey-text);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .top-nav { padding: 0 14px; }
  .brand-name { font-size: 14px; }
  .brand-sub { display: none; }

  .msg-body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    overflow-y: auto;
  }

  .left-panel {
    grid-row: auto;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid var(--grey-light);
  }

  .right-panel {
    grid-column: 1;
    min-height: 55vh;
  }

  .msg-page { overflow-y: auto; height: auto; min-height: 100vh; }
  .bubble-wrap { max-width: 85%; }
}

/* ─── Reduced motion ─────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
