/* ===== Janus — Juno-branded ===== */

/* The Future — heading font */
@font-face { font-family: 'The Future'; src: url('/assets/fonts/TheFuture-Thin-C9aMkUU9.otf') format('opentype'); font-weight: 100; font-style: normal; }
@font-face { font-family: 'The Future'; src: url('/assets/fonts/TheFuture-ThinItalic-IF38eFBy.otf') format('opentype'); font-weight: 100; font-style: italic; }
@font-face { font-family: 'The Future'; src: url('/assets/fonts/TheFuture-Extralight-CxsQXBDK.otf') format('opentype'); font-weight: 200; font-style: normal; }
@font-face { font-family: 'The Future'; src: url('/assets/fonts/TheFuture-Light-Dwt75-c_.otf') format('opentype'); font-weight: 300; font-style: normal; }
@font-face { font-family: 'The Future'; src: url('/assets/fonts/TheFuture-Regular-Btl82Nsf.otf') format('opentype'); font-weight: 400; font-style: normal; }
@font-face { font-family: 'The Future'; src: url('/assets/fonts/TheFuture-Italic-Db0DXVN5.otf') format('opentype'); font-weight: 400; font-style: italic; }
@font-face { font-family: 'The Future'; src: url('/assets/fonts/TheFuture-Medium-BtYNwMWQ.otf') format('opentype'); font-weight: 500; font-style: normal; }
@font-face { font-family: 'The Future'; src: url('/assets/fonts/TheFuture-Bold-DAuySiOJ.otf') format('opentype'); font-weight: 700; font-style: normal; }
@font-face { font-family: 'The Future'; src: url('/assets/fonts/TheFuture-Black-D7ajIOoG.otf') format('opentype'); font-weight: 900; font-style: normal; }

/* Lato — body font */
@font-face { font-family: 'Lato'; src: local('Lato'), url('/assets/fonts/Lato-Light-hJCcuSzX.ttf') format('truetype'); font-weight: 300; font-style: normal; }
@font-face { font-family: 'Lato'; src: local('Lato'), url('/assets/fonts/Lato-Regular-BwLIet1C.ttf') format('truetype'); font-weight: 400; font-style: normal; }
@font-face { font-family: 'Lato'; src: local('Lato'), url('/assets/fonts/Lato-Italic-DOTKc3_v.ttf') format('truetype'); font-weight: 400; font-style: italic; }
@font-face { font-family: 'Lato'; src: local('Lato'), url('/assets/fonts/Lato-Bold-B5iD31kO.ttf') format('truetype'); font-weight: 700; font-style: normal; }
@font-face { font-family: 'Lato'; src: local('Lato'), url('/assets/fonts/Lato-BoldItalic-CT6m3OwA.ttf') format('truetype'); font-weight: 700; font-style: italic; }

:root {
  /* Janus brand colors — teal-forward, white-dominant */
  --primary: #009c9b;          /* Janus teal */
  --primary-hover: #008584;    /* Darker teal for hover */
  --primary-light: #e0f5f5;    /* Very light teal for backgrounds/info banners */
  --primary-pale: #f0fafa;     /* Even paler teal tint */

  --sidebar-bg: #ffffff;       /* White sidebar */
  --sidebar-hover: #f6f7f8;
  --sidebar-active: #009c9b;
  --sidebar-text: #414141;
  --sidebar-text-active: #009c9b;

  --topbar-bg: #fff;
  --topbar-border: #e7e7e7;
  --body-bg: #fafafa;
  --card-bg: #fff;

  --text-primary: #414141;
  --text-secondary: #505050;
  --text-muted: #8b8b8b;

  --border: #e7e7e7;
  --border-light: #f3f3f3;

  /* Status colors */
  --status-open: #f44336;
  --status-open-bg: #ffebee;
  --status-pending: #ff9800;
  --status-pending-bg: #fff8e1;
  --status-resolved: #009c9b;
  --status-resolved-bg: #e0f2f1;
  --status-closed: #9e9e9e;
  --status-closed-bg: #f3f3f3;

  /* Priority colors */
  --priority-low: #009c9b;
  --priority-medium: #0088ff;
  --priority-high: #ff9800;
  --priority-urgent: #f44336;

  /* Avatars */
  --avatar-bg: #f5c344;        /* Mustard yellow like Juno's user avatar */
  --avatar-text: #fff;

  /* Sentiment + info / warning surfaces. Used in:
     - KPI trends (Reports, KnowledgeBase) — green/red glyphs
     - Bulk action bar background (info)
     - Note conversations (warning)
     - Tag pills (info-tinted)
     Token names follow semantic intent, not hue. */
  --sentiment-positive: #10b981;
  --sentiment-negative: #ef4444;
  --info-bg: #EFF6FF;
  --info-border: #BFDBFE;
  --info-text: #2563EB;
  --warning-bg: #FFFBEB;
  --warning-border: #FDE68A;
  --warning-text: #92400E;

  --radius: 8px;
  --radius-sm: 4px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.03);
  --shadow: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.06);
  --transition: 0.15s ease;

  /* Spacing scale. Hand-rolled 4/8/12/16/24px ladder — most repeated
     padding/gap values across the app land on one of these. Components
     should prefer these tokens over literals so a single edit can
     re-tune the density of the whole app. */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 24px;

  --sidebar-width: 220px;
  --sidebar-collapsed: 60px;
  --topbar-height: 64px;
}

/* ===== Dark Mode ===== */
[data-theme="dark"] {
  --primary: #00b5b4;
  --primary-hover: #00cfce;
  --primary-light: #0f2e2e;
  --primary-pale: #0a1f1f;

  --sidebar-bg: #1a1a2e;
  --sidebar-hover: #252540;
  --sidebar-active: #00b5b4;
  --sidebar-text: #b0b0c0;
  --sidebar-text-active: #00b5b4;

  --topbar-bg: #16162b;
  --topbar-border: #2a2a45;
  --body-bg: #0f0f1a;
  --card-bg: #1a1a2e;

  --text-primary: #e0e0e8;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;

  --border: #2a2a45;
  --border-light: #1f1f35;

  --status-open-bg: #3a1515;
  --status-pending-bg: #3a2e10;
  --status-resolved-bg: #0e2e2e;
  --status-closed-bg: #1f1f25;

  --avatar-bg: #d4a530;

  --hover-bg: #252540;

  --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.4);
}

[data-theme="dark"] .modal, [data-theme="dark"] .modal-overlay .modal {
  background: #1a1a2e;
  color: var(--text-primary);
}

[data-theme="dark"] input, [data-theme="dark"] select, [data-theme="dark"] textarea {
  background: #252540;
  color: var(--text-primary);
  border-color: var(--border);
}

[data-theme="dark"] .ticket-table tr:hover,
[data-theme="dark"] .contacts-table tr:hover {
  background: #252540;
}

[data-theme="dark"] .list-card { background: var(--card-bg); }
[data-theme="dark"] .list-item { border-color: var(--border); }

[data-theme="dark"] .stat-card { background: var(--card-bg); border-color: var(--border); }
[data-theme="dark"] .stat-card.stat-resolved { background: #0e2e2e; border-color: #1a4a4a; }
[data-theme="dark"] .stat-card.stat-open { background: var(--card-bg); }
[data-theme="dark"] .stat-card.stat-pending { background: var(--card-bg); }
[data-theme="dark"] .stat-card.stat-closed { background: var(--card-bg); }
[data-theme="dark"] .filter-pill { background: var(--card-bg); border-color: var(--border); color: var(--text-primary); }
[data-theme="dark"] .filter-pill.active { background: var(--primary); color: #fff; }
[data-theme="dark"] .filter-select { background: var(--card-bg); color: var(--text-primary); border-color: var(--border); }

/* ===== Reset ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Lato', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--body-bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Headings — Lato by default, The Future only for brand */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Lato', sans-serif;
  font-weight: 600;
  color: var(--text-primary);
}

/* ===== Layout ===== */
.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--topbar-height) 1fr;
  max-width: 100vw;
  overflow-x: hidden;
  grid-template-areas:
    "topbar topbar"
    "sidebar main";
  min-height: 100vh;
}

/* ===== Top Bar ===== */
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--topbar-border);
  height: var(--topbar-height);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
}
.topbar-brand { display: flex; align-items: center; gap: 10px; color: var(--primary); }
.topbar-brand-logo { height: 28px; width: auto; }
.topbar-brand-text {
  font-family: 'The Future', 'Lato', sans-serif;
  font-weight: 700;
  font-size: 24px;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.topbar-center { flex: 1; max-width: 480px; margin: 0 24px; }
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--body-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  transition: border-color var(--transition);
}
.topbar-search:focus-within { border-color: var(--primary); }
.topbar-search svg { color: var(--text-muted); flex-shrink: 0; }
.topbar-search input {
  border: none;
  background: none;
  outline: none;
  font-size: 13px;
  width: 100%;
  color: var(--text-primary);
}
.topbar-search input::placeholder { color: var(--text-muted); }

.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: #fff;
  color: var(--primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.topbar-btn:hover { border-color: var(--primary); background: var(--primary-pale); }

.topbar-user {
  position: relative;
  cursor: pointer;
}
.avatar-sm {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--avatar-bg);
  color: var(--avatar-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}
.topbar-user-menu {
  display: none;
  position: absolute;
  right: 0;
  top: 44px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  z-index: 200;
}
.topbar-user-menu.open { display: block; }
.user-menu-header { padding: 12px 16px; }
.user-menu-header strong { display: block; font-size: 14px; }
.user-menu-header small { color: var(--text-secondary); font-size: 12px; }
.user-menu-item {
  display: block;
  padding: 10px 16px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 13px;
  transition: background var(--transition);
}
.user-menu-item:hover { background: var(--body-bg); }
.topbar-user-menu hr { border: none; border-top: 1px solid var(--border); }

/* ===== Sidebar ===== */
.sidebar {
  grid-area: sidebar;
  background: var(--sidebar-bg);
  padding: 24px 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  transition: width var(--transition);
}
.sidebar-nav { display: flex; flex-direction: column; gap: 4px; padding: 0 16px; }
.sidebar-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 0;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 15px;
  font-weight: 400;
  transition: all var(--transition);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.sidebar-link svg { display: none; }
.sidebar-link:hover { color: var(--primary); }
.sidebar-link.active {
  color: var(--sidebar-text-active);
  font-weight: 600;
  /* Subtle primary-tint background to give the active row weight beyond
     just the left bar. Same treatment is used by .admin-nav-item.active
     so the two sidebars feel like part of one app. */
  background: color-mix(in srgb, var(--primary) 6%, transparent);
}
.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: -16px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--primary);
}
.sidebar-label { opacity: 1; transition: opacity var(--transition); }

/* Sidebar Queues */
.sidebar-queues { display: flex; flex-direction: column; }
.sidebar-queues-toggle { position: relative; }
.sidebar-queues-chevron {
  margin-left: auto;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.sidebar-queues-chevron.open { transform: rotate(180deg); }
.sidebar-queue-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding-left: 12px;
}
.sidebar-queue-item {
  font-size: 13px !important;
  padding: 6px 8px !important;
  border-bottom: none !important;
}

/* ===== Main Content ===== */
.main-content {
  grid-area: main;
  overflow-y: auto;
  height: calc(100vh - var(--topbar-height));
  padding: 24px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.panel-header h2 { font-size: 20px; font-weight: 600; color: var(--text-primary); font-family: 'Lato', sans-serif; letter-spacing: 0; }
.panel-actions { display: flex; gap: 8px; }

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--primary-pale);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid var(--primary-light);
  cursor: pointer;
  transition: all var(--transition);
}
.stat-card:hover { border-color: var(--primary); }
.stat-card.stat-resolved { background: #f0faf5; border-color: #c8e6cd; }
.stat-number {
  font-family: 'Lato', sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.01em;
}
.stat-label { font-size: 14px; color: var(--text-primary); margin-top: 4px; font-weight: 500; }

/* ===== Filter Bar ===== */
.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}
.filter-tabs { display: flex; gap: 0; }
.filter-tab {
  padding: 7px 16px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-right: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.filter-tab:first-child { border-radius: 6px 0 0 6px; }
.filter-tab:last-child { border-radius: 0 6px 6px 0; border-right: 1px solid var(--border); }
.filter-tab:hover { background: var(--body-bg); }
.filter-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.filter-tab.active + .filter-tab { border-left-color: var(--primary); }

/* Juno-style filter pills with counts */
.filter-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.filter-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.filter-pill.active {
  background: var(--primary-pale);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}
.filter-pill-count {
  display: inline-block;
  min-width: 22px;
  padding: 0 7px;
  background: var(--body-bg);
  color: var(--text-secondary);
  border-radius: 11px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
  line-height: 18px;
}
.filter-pill.active .filter-pill-count {
  background: var(--primary);
  color: #fff;
}
.filter-controls { display: flex; gap: 8px; flex-wrap: wrap; }
/* vue-select needs an explicit width on its wrapper or it grows to fill the
   remaining flex space (made the dropdowns ~500px each before). Pin both
   width and flex-basis so they stay at 180px regardless of how much space
   the parent has, but still wrap to a new row at narrow viewports. */
.filter-vselect { width: 180px; flex: 0 0 180px; }
.filter-vselect .vs__dropdown-toggle {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  min-height: 36px;
  font-size: 13px;
}
.filter-vselect .vs__search,
.filter-vselect .vs__search::placeholder {
  color: var(--text-secondary);
  font-size: 13px;
}
.filter-select {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-primary);
  background: var(--card-bg);
  cursor: pointer;
  outline: none;
}
.filter-select:focus { border-color: var(--primary); }

/* ===== Ticket Table ===== */
.ticket-table-wrap {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.ticket-table {
  width: 100%;
  border-collapse: collapse;
}
.ticket-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--body-bg);
  border-bottom: 1px solid var(--border);
}
.ticket-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
  vertical-align: middle;
}
.ticket-table tr:last-child td { border-bottom: none; }
.ticket-table tr { cursor: pointer; transition: background var(--transition); }
.ticket-table tbody tr:hover { background: var(--primary-light); }

.ticket-subject {
  font-weight: 500;
  color: var(--text-primary);
  max-width: 400px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ticket-id { color: var(--primary); font-weight: 500; font-size: 12px; }
.ticket-requester { color: var(--text-secondary); font-size: 13px; }
.ticket-date { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* Status badges */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-open { background: var(--status-open-bg); color: var(--status-open); }
.badge-pending { background: var(--status-pending-bg); color: var(--status-pending); }
.badge-resolved { background: var(--status-resolved-bg); color: var(--status-resolved); }
.badge-closed { background: var(--status-closed-bg); color: var(--status-closed); }

/* Priority indicators */
.priority-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.priority-low { background: var(--priority-low); }
.priority-medium { background: var(--priority-medium); }
.priority-high { background: var(--priority-high); }
.priority-urgent { background: var(--priority-urgent); }

.priority-label { font-size: 13px; text-transform: capitalize; }

/* Assignee avatar in table */
.agent-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.agent-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ===== Ticket Detail ===== */
.ticket-detail-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0;
  min-height: calc(100vh - var(--topbar-height) - 48px);
}

.ticket-detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.btn-back {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.btn-back:hover { background: var(--body-bg); color: var(--text-primary); }
.ticket-detail-title { flex: 1; }
.ticket-detail-title .ticket-number {
  display: block;
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
  margin-bottom: 2px;
}
.ticket-detail-title h2 { font-size: 18px; font-weight: 600; }

/* Conversations */
.ticket-conversations {
  padding-right: 24px;
  display: flex;
  flex-direction: column;
}
.conversation-thread {
  /* Natural height — don't grow to fill the column. This keeps the reply
     action bar / composer right below the last message instead of pinned
     to the bottom of the viewport. Long threads still scroll the page. */
  flex: 0 1 auto;
  padding-bottom: 16px;
}
.convo-entry {
  display: flex;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
}
.convo-entry:last-child { border-bottom: none; }
.convo-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
  color: #fff;
}
.convo-avatar.agent { background: var(--primary); }
.convo-avatar.requester { background: #8B5CF6; }
.convo-content { flex: 1; min-width: 0; }
.convo-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.convo-author { font-weight: 600; font-size: 13px; }
.convo-time { color: var(--text-muted); font-size: 12px; }
.convo-badge-note {
  padding: 1px 8px;
  background: #FEF3C7;
  color: #92400E;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}
.convo-badge-private {
  padding: 1px 8px;
  background: #FEE2E2;
  color: #991B1B;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}
.convo-body {
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.convo-entry.note-entry {
  background: #FFFBEB;
  border: 1px solid #FDE68A;
  border-radius: var(--radius);
  margin: 8px 0;
  padding: 16px;
}

/* Reply box */
.reply-box {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: auto;
}
.reply-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

/* Properties panel */
.ticket-properties {
  padding: 20px 0 20px 24px;
  border-left: 1px solid var(--border);
  overflow-y: auto;
}
.ticket-properties h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}
.property-group {
  margin-bottom: 14px;
}
.property-group label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.prop-select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--card-bg);
  cursor: pointer;
  outline: none;
}
.prop-select:focus { border-color: var(--primary); }
.prop-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* Detail rows */
.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}
.detail-label { color: var(--text-secondary); }
.detail-value { color: var(--text-primary); font-weight: 500; }

/* Activity log */
.activity-log { max-height: 300px; overflow-y: auto; }
.activity-entry {
  display: flex;
  gap: 8px;
  padding: 8px 0;
  font-size: 12px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
}
.activity-entry:last-child { border-bottom: none; }
.activity-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 5px;
  flex-shrink: 0;
}
.activity-text { flex: 1; }
.activity-time { color: var(--text-muted); font-size: 11px; white-space: nowrap; }

/* ===== Tags ===== */
.tags-list { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 6px; }
.tag-pill {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px 8px; font-size: 11px; border-radius: 12px;
  background: #EFF6FF; color: #2563EB; border: 1px solid #BFDBFE;
  cursor: pointer; transition: background .15s;
}
.tag-pill:hover { background: #DBEAFE; }

/* ===== Dashboard KPI ===== */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.kpi-card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 20px;
}
.kpi-value { font-size: 28px; font-weight: 700; color: var(--text-primary); }
.kpi-label { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.kpi-trend { font-size: 12px; margin-top: 4px; }
.kpi-trend.up { color: #16a34a; }
.kpi-trend.down { color: #dc2626; }
.kpi-trend.neutral { color: #9CA3AF; }

/* ===== System Views ===== */
.system-views-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 0;
}
.system-view-btn {
  padding: 4px 12px; font-size: 12px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--card-bg);
  cursor: pointer; color: var(--text-secondary); transition: background .15s;
}
.system-view-btn:hover { background: #f3f4f6; }
.system-view-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.system-view-label {
  padding: 4px 12px; font-size: 12px; border-radius: 6px;
  border: 1px solid var(--border); background: #f9fafb;
  color: var(--text-muted);
}

/* ===== Contacts Table ===== */
.contacts-table-wrap {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  margin-right: 4px;
}
.contacts-table {
  width: 100%;
  border-collapse: collapse;
}
.contacts-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--body-bg);
  border-bottom: 1px solid var(--border);
}
.contacts-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.contacts-table tr:last-child td { border-bottom: none; }

/* ===== Admin Tabs ===== */
.admin-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}
.admin-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
}
.admin-tab:hover { color: var(--text-primary); }
.admin-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.admin-panel { }
.admin-panel.tab-hidden { display: none; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 8px;
  font-family: 'Lato', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: #fff;
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: #f44336; color: #fff; }
.btn-danger:hover { background: #d32f2f; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Admin "+ Add X" header button — previously redefined identically in 12
   admin components. Hoisted here so the visual + behaviour is owned in one
   place; component <style scoped> blocks should NOT redefine it. */
.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}
.btn-add:hover { opacity: 0.9; }

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Must beat the MJML editor's full-screen overlay (.mjml-editor uses
     z-index 1500). Anything below that and modals opened from inside
     the editor (e.g. the Raw HTML / Source modal) render behind the
     editor and look like the button does nothing. */
  z-index: 1600;
  animation: fadeIn 0.15s ease;
}
.modal {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 560px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-sm { width: 420px; }
/* Wide variant for code-editor / source-view modals that need most of
   the viewport. Used by the MJML editor's Raw HTML modal. */
.modal-lg {
  width: 1200px;
  height: calc(100vh - 48px);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px 24px; overflow: visible; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.required { color: var(--sentiment-negative); }
/* .form-input / .form-select / .form-textarea baseline lives in
   resources/css/app.css now — single canonical rule. Keep this comment
   so the next person finds it. */
.form-textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: #1F2937;
  color: #fff;
  border-radius: var(--radius);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  z-index: 2000;
  animation: slideUp 0.2s ease;
}
.toast.toast-error { background: #EF4444; }
.toast.toast-success { background: #10B981; }
@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ===== Empty states ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state svg { margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ===== Agents/Groups list ===== */
.list-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
}
.list-item:last-child { border-bottom: none; }
.list-item-left { display: flex; align-items: center; gap: 12px; }
.list-item-info strong { display: block; font-size: 13px; }
.list-item-info small { color: var(--text-secondary); font-size: 12px; }

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .ticket-detail-layout {
    grid-template-columns: 1fr;
  }
  .ticket-properties {
    border-left: none;
    border-top: 1px solid var(--border);
    padding: 16px 0 0 0;
  }
}

@media (max-width: 768px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "topbar"
      "main";
  }
  .sidebar {
    display: none;
    position: fixed;
    left: 0;
    top: var(--topbar-height);
    bottom: 0;
    width: var(--sidebar-width);
    z-index: 150;
  }
  .sidebar.mobile-open { display: block; }
  .topbar-menu-btn { display: block; }
  .topbar-btn-text { display: none; }
  .topbar-center { margin: 0 12px; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .form-row { grid-template-columns: 1fr; }
  .dashboard-panel { padding: 16px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-tabs { overflow-x: auto; }
  .topbar-center { display: none; } /* hide search bar on small mobile */
  .topbar-right { gap: 6px; }
  .topbar-right .topbar-btn { padding: 6px; }
  .ticket-table-wrap { overflow-x: auto; }
  .admin-tabs { overflow-x: auto; flex-wrap: nowrap; }
}

/* ===== Additional property controls ===== */
.prop-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}
.prop-checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--priority-urgent);
}

/* Emergency badge in ticket table */
.badge-emergency {
  display: inline-block;
  background: #fee2e2;
  color: #dc2626;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 10px;
  margin-top: 2px;
  width: fit-content;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* ===== Orgs admin panel ===== */
.orgs-section {
  margin-bottom: 20px;
}
.orgs-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.orgs-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}
.orgs-header small {
  display: block;
  font-size: 12px;
  margin-top: 4px;
  font-weight: normal;
  flex-basis: 100%;
}

.org-color-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid rgba(0,0,0,0.1);
}

.badge-count {
  display: inline-block;
  min-width: 22px;
  padding: 2px 8px;
  background: var(--status-pending);
  color: #fff;
  border-radius: 11px;
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

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

/* ===== People on ticket list ===== */
.people-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.people-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 12px;
  text-align: center;
  background: var(--body-bg);
  border-radius: var(--radius);
}
.people-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  background: var(--body-bg);
  border-radius: var(--radius);
  cursor: default;
  transition: background var(--transition);
}
.people-row:hover { background: var(--primary-pale); }
.people-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.people-info {
  flex: 1;
  min-width: 0;
}
.people-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.people-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-secondary);
}
.people-role {
  text-transform: capitalize;
  font-weight: 500;
}
.people-email {
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.people-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.people-badge-requester {
  background: var(--primary-light);
  color: var(--primary);
}
.people-badge-no-notify {
  background: #f3f3f3;
  color: var(--text-muted);
}

/* ===== CRM contact picker ===== */
.picker-wrap {
  position: relative;
}
.picker-input {
  width: 100%;
}
.picker-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 1100;
}
.picker-result {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background var(--transition);
}
.picker-result:last-child { border-bottom: none; }
.picker-result:hover { background: var(--primary-pale); }
.picker-result-added { opacity: 0.5; cursor: default; }
.picker-result-added:hover { background: transparent; }
.picker-result-unmapped { background: #fffbeb; cursor: default; }
.picker-result-unmapped:hover { background: #fff7d6; }
.picker-result-unmapped .picker-result-avatar { background: #d8d8d8; }
.picker-unmapped-warn {
  color: #b45309;
  font-weight: 600;
}
.picker-map-link {
  background: #fff;
  border: 1px solid #f5c344;
  color: #92400e;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}
.picker-map-link:hover { background: #fef3c7; }
.picker-result-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.picker-result-info {
  flex: 1;
  min-width: 0;
}
.picker-result-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.picker-result-meta {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: capitalize;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-empty,
.picker-empty-selected {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}
.picker-empty-selected {
  background: var(--body-bg);
  border-radius: var(--radius);
  margin-top: 8px;
}
.picker-added-tag {
  font-size: 10px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
}

.picker-selected {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.picker-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--body-bg);
  border-radius: var(--radius);
  font-size: 12px;
}
.picker-chip-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.picker-chip-info strong { font-size: 12px; }
.picker-chip-info small { font-size: 10px; color: var(--text-muted); }
.picker-chip-role {
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;
  text-transform: capitalize;
}
.picker-chip-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
}
.picker-chip-toggle input { margin: 0; }
.picker-chip-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.picker-chip-remove:hover { color: #f44336; }

/* ===== CRM Contacts panel ===== */
.contacts-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.contacts-toolbar-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}
.contacts-count {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.badge-org {
  display: inline-block;
  padding: 3px 10px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-unmapped {
  display: inline-block;
  padding: 3px 10px;
  background: #fffbeb;
  color: #b45309;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.crm-id {
  font-family: monospace;
  font-size: 11px;
  color: var(--text-muted);
  background: var(--body-bg);
  padding: 2px 6px;
  border-radius: 4px;
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ===== Ticket list — richer row layout ===== */
.ticket-cell {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 360px;
}
.ticket-cell .ticket-id {
  font-size: 11px;
  font-weight: 600;
}
.ticket-cell .ticket-subject {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}
.ticket-classification {
  display: inline-block;
  padding: 1px 8px;
  background: #f3f3f3;
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 600;
  border-radius: 10px;
  margin-top: 2px;
  width: fit-content;
}
.ticket-requester-cell {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-width: 180px;
}
.ticket-requester-cell strong {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ticket-requester-cell small {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* People stack — overlapping avatars */
.people-stack {
  display: flex;
  align-items: center;
}
.people-stack-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  border: 2px solid #fff;
  margin-left: -8px;
  flex-shrink: 0;
}
.people-stack-avatar:first-child {
  margin-left: 0;
}
.people-stack-more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--body-bg);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  border: 2px solid #fff;
  margin-left: -8px;
}

/* Agent profile badge */
.agent-profile-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== Conversation entry card styling ===== */
.convo-entry.convo-agent {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 8px 0;
  padding: 16px;
  border-left: 3px solid var(--primary);
}
.convo-entry.convo-requester {
  background: var(--body-bg);
  border: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
  border-radius: var(--radius);
  margin: 8px 0;
  padding: 16px;
  border-left: 3px solid #8B5CF6;
}
.convo-badge-agent {
  padding: 1px 8px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
}

/* Reply composer wrapper */
.reply-composer-wrap {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

/* Property sidebar section headers */
.ticket-properties h3.prop-section-header {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}
