/* ============================================================
   Call Me Helpdesk — Main Stylesheet
   ============================================================ */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --success: #22c55e;
  --success-bg: #dcfce7;
  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --info: #3b82f6;
  --info-bg: #dbeafe;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-w: 240px;
  --sidebar-bg: #1e1b4b;
  --sidebar-text: #c7d2fe;
  --sidebar-active: #6366f1;
  --topbar-h: 60px;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,.12);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.15);
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --gray-50: #111827; --gray-100: #1f2937; --gray-200: #374151;
    --gray-300: #4b5563; --gray-400: #6b7280; --gray-500: #9ca3af;
    --gray-600: #d1d5db; --gray-700: #e5e7eb; --gray-800: #f3f4f6;
    --gray-900: #f9fafb;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  color: var(--gray-800);
  background: var(--gray-50);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 4px; }

/* ============================================================
   Accessibility
   ============================================================ */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

/* ============================================================
   Container
   ============================================================ */
.container { max-width: 1120px; margin: 0 auto; padding: 0 1.5rem; }

/* ============================================================
   AUTH Layout
   ============================================================ */
.auth-body {
  min-height: 100vh;
  background: linear-gradient(135deg, #1e1b4b 0%, #4f46e5 50%, #818cf8 100%);
  display: flex; align-items: center; justify-content: center;
}
.auth-wrapper { width: 100%; max-width: 440px; padding: 2rem 1rem; }
.auth-brand {
  display: flex; align-items: center; gap: .75rem;
  color: #fff; font-size: 1.5rem; font-weight: 700;
  justify-content: center; margin-bottom: 2rem;
}
.auth-card {
  background: #fff; border-radius: var(--radius-lg);
  padding: 2.5rem; box-shadow: var(--shadow-lg);
}
.auth-title { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); margin-bottom: .5rem; text-align: center; }
.auth-subtitle { color: var(--gray-500); text-align: center; margin-bottom: 1.5rem; }
.auth-footer { text-align: center; color: rgba(255,255,255,.7); font-size: .85rem; margin-top: 1.5rem; }
.auth-links { text-align: center; margin-top: 1.25rem; font-size: .9rem; color: var(--gray-500); }

/* ============================================================
   APP Layout
   ============================================================ */
.app-body { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w); background: var(--sidebar-bg);
  display: flex; flex-direction: column; z-index: 100;
  overflow-y: auto; overflow-x: hidden;
  transition: transform .25s ease;
}
.sidebar-header {
  padding: 1.25rem 1.25rem .75rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand {
  display: flex; align-items: center; gap: .75rem;
  color: #fff; font-size: 1.1rem; font-weight: 700;
  text-decoration: none;
}
.sidebar-brand-name { white-space: nowrap; }
.sidebar-company {
  display: block; font-size: .75rem; color: var(--sidebar-text);
  margin-top: .35rem; opacity: .8;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sidebar-nav { padding: .75rem 0; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .625rem 1.25rem; color: var(--sidebar-text);
  font-size: .875rem; text-decoration: none;
  border-radius: 0; transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.nav-item.active { background: rgba(99,102,241,.25); color: #fff; border-left: 3px solid var(--sidebar-active); }
.nav-item.active:hover { background: rgba(99,102,241,.3); }
.nav-section-label {
  font-size: .7rem; font-weight: 600; letter-spacing: .08em;
  text-transform: uppercase; color: rgba(199,210,254,.4);
  padding: 1.25rem 1.25rem .35rem;
}

.app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex; flex-direction: column;
  min-height: 100vh;
}

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h); background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem; box-shadow: var(--shadow-sm);
}
.topbar-toggle { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: .5rem; }
.topbar-toggle span { display: block; width: 20px; height: 2px; background: var(--gray-600); border-radius: 2px; }
.topbar-search { flex: 1; max-width: 380px; }
.search-input {
  width: 100%; padding: .5rem 1rem;
  border: 1px solid var(--gray-200); border-radius: 9999px;
  font-size: .875rem; background: var(--gray-50);
  transition: border-color .15s, box-shadow .15s;
}
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.topbar-actions { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.btn-icon {
  position: relative; width: 38px; height: 38px;
  border-radius: 50%; background: none; border: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--gray-600); transition: background .15s;
}
.btn-icon:hover { background: var(--gray-100); }
.badge-dot {
  position: absolute; top: -2px; right: -2px;
  background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 700; min-width: 18px; height: 18px;
  border-radius: 9px; display: flex; align-items: center; justify-content: center;
  padding: 0 4px; border: 2px solid #fff;
}

/* User dropdown */
.topbar-user, .topbar-notif { position: relative; }
.user-btn {
  display: flex; align-items: center; gap: .5rem;
  background: none; border: none; cursor: pointer;
  padding: .375rem .75rem; border-radius: 9999px;
  font-size: .875rem; color: var(--gray-700);
  transition: background .15s;
}
.user-btn:hover { background: var(--gray-100); }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
}
.user-name { font-weight: 500; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-panel, .notif-panel {
  position: absolute; right: 0; top: calc(100% + .5rem);
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  min-width: 180px; z-index: 200; padding: .5rem 0;
}
.user-panel[hidden], .notif-panel[hidden] { display: none; }
.user-panel a, .notif-panel a { display: block; padding: .5rem 1rem; font-size: .875rem; color: var(--gray-700); transition: background .1s; }
.user-panel a:hover { background: var(--gray-50); text-decoration: none; }
.user-panel hr { border: none; border-top: 1px solid var(--gray-200); margin: .35rem 0; }

.notif-panel { min-width: 320px; }
.notif-header { display: flex; align-items: center; justify-content: space-between; padding: .75rem 1rem; border-bottom: 1px solid var(--gray-200); font-weight: 600; font-size: .9rem; }
.notif-list { max-height: 320px; overflow-y: auto; }
.notif-item { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-100); font-size: .85rem; }
.notif-item:last-child { border-bottom: none; }
.notif-loading { padding: 1.5rem; text-align: center; color: var(--gray-400); }

.page-content { flex: 1; padding: 1.75rem 1.5rem; }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem; border-radius: var(--radius);
  font-size: .875rem; font-weight: 500; line-height: 1.5;
  border: 1px solid transparent; cursor: pointer;
  text-decoration: none; transition: background .15s, border-color .15s, box-shadow .15s;
  white-space: nowrap;
}
.btn:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-secondary { background: var(--gray-200); color: var(--gray-700); border-color: var(--gray-200); }
.btn-secondary:hover { background: var(--gray-300); text-decoration: none; }
.btn-success { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #16a34a; text-decoration: none; color: #fff; }
.btn-ghost { background: transparent; color: var(--gray-600); border-color: var(--gray-300); }
.btn-ghost:hover { background: var(--gray-100); text-decoration: none; }
.btn-outline-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-outline-danger:hover { background: var(--danger-bg); text-decoration: none; }
.btn-outline-primary { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary-light); text-decoration: none; }
.btn-outline-warning { background: transparent; color: var(--warning); border-color: var(--warning); }
.btn-outline-warning:hover { background: var(--warning-bg); text-decoration: none; }
.btn-sm { padding: .3rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* ============================================================
   Form Elements
   ============================================================ */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: .875rem; font-weight: 500; color: var(--gray-700); margin-bottom: .35rem; }
.form-control, .form-select {
  width: 100%; padding: .5rem .75rem;
  border: 1px solid var(--gray-300); border-radius: var(--radius);
  font-size: .875rem; color: var(--gray-800);
  background: #fff; transition: border-color .15s, box-shadow .15s;
  line-height: 1.5;
}
.form-control:focus, .form-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--danger); }
.form-textarea { min-height: 120px; resize: vertical; }
.form-error { display: block; color: var(--danger); font-size: .8rem; margin-top: .25rem; }
.form-hint { font-size: .78rem; color: var(--gray-400); }
.required-star { color: var(--danger); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-grid-2 { display: grid; grid-template-columns: 1fr 320px; gap: 1.5rem; }
.form-main {}
.form-sidebar { }
.form-fieldset { border: 1px solid var(--gray-200); border-radius: var(--radius); padding: 1rem; }
.form-fieldset legend { font-size: .85rem; font-weight: 600; padding: 0 .5rem; color: var(--gray-600); }
.form-row-split { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; font-size: .875rem; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .875rem; }
.input-with-action { position: relative; }
.input-with-action .form-control { padding-right: 2.5rem; }
.btn-toggle-password { position: absolute; right: .5rem; top: 50%; transform: translateY(-50%); background: none; border: none; cursor: pointer; color: var(--gray-400); padding: .25rem; }

/* ============================================================
   Cards
   ============================================================ */
.card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); overflow: hidden;
  margin-bottom: 1.5rem;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--gray-200);
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--gray-800); }
.card-body { padding: 1.25rem; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .6rem; border-radius: 9999px;
  font-size: .75rem; font-weight: 600; text-transform: capitalize;
}
.badge--open        { background: var(--info-bg);    color: #1d4ed8; }
.badge--in_progress { background: #ede9fe;            color: #7c3aed; }
.badge--pending     { background: var(--warning-bg); color: #92400e; }
.badge--on_hold     { background: var(--gray-200);   color: var(--gray-600); }
.badge--resolved    { background: var(--success-bg); color: #15803d; }
.badge--closed      { background: var(--gray-100);   color: var(--gray-500); }
.badge--cancelled   { background: var(--gray-200);   color: var(--gray-500); }
.badge--escalated   { background: var(--danger-bg);  color: #991b1b; }
.badge--note        { background: #fef9c3; color: #854d0e; font-size: .7rem; }
.badge--priority-urgent { background: var(--danger-bg); color: #991b1b; }
.badge--priority-high   { background: var(--warning-bg); color: #92400e; }
.badge--priority-medium { background: var(--info-bg); color: #1d4ed8; }
.badge--priority-low    { background: var(--gray-100); color: var(--gray-500); }

/* ============================================================
   SLA
   ============================================================ */
.sla-badge {
  display: inline-flex; align-items: center;
  padding: .2rem .6rem; border-radius: 9999px;
  font-size: .75rem; font-weight: 600;
}
.sla-badge--on_track  { background: var(--success-bg); color: #15803d; }
.sla-badge--at_risk   { background: var(--warning-bg); color: #92400e; }
.sla-badge--breached  { background: var(--danger-bg);  color: #991b1b; }
.sla-badge--paused    { background: var(--gray-100);   color: var(--gray-500); }
.sla-badge--resolved  { background: var(--success-bg); color: #15803d; }
.sla-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.sla-dot--on_track { background: var(--success); }
.sla-dot--at_risk   { background: var(--warning); }
.sla-dot--breached  { background: var(--danger); }
.sla-on_track { color: var(--success); }
.sla-at_risk  { color: var(--warning); }
.sla-breached { color: var(--danger); font-weight: 600; }

/* ============================================================
   Tables
   ============================================================ */
.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.data-table th { background: var(--gray-50); font-weight: 600; color: var(--gray-600); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.data-table th, .data-table td { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-200); text-align: left; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--gray-50); }
.data-table .row-danger { background: #fff5f5; }
.ticket-number { font-family: monospace; font-size: .8rem; color: var(--primary); font-weight: 600; }
.ticket-subject, .ticket-link { color: var(--gray-800); }
.ticket-subject:hover, .ticket-link:hover { color: var(--primary); text-decoration: none; }
.table-summary { font-size: .85rem; color: var(--gray-400); margin-top: .75rem; }

/* ============================================================
   Pagination
   ============================================================ */
.pagination { display: flex; align-items: center; gap: .35rem; margin-top: 1.25rem; }
.page-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius);
  border: 1px solid var(--gray-200); font-size: .85rem;
  color: var(--gray-700); transition: background .15s;
}
.page-link:hover { background: var(--gray-100); text-decoration: none; }
.page-link.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============================================================
   Stats / Dashboard
   ============================================================ */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: #fff; border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg); padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon { width: 44px; height: 44px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon--open     { background: var(--info-bg); color: #1d4ed8; }
.stat-icon--progress { background: #ede9fe; color: #7c3aed; }
.stat-icon--pending  { background: var(--warning-bg); color: #92400e; }
.stat-icon--overdue  { background: var(--danger-bg); color: #991b1b; }
.stat-icon--warn     { background: #fff7ed; color: #c2410c; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; color: var(--gray-900); }
.stat-label { font-size: .8rem; color: var(--gray-500); margin-top: .2rem; }
.stat-card--warning { border-color: var(--warning); }

.dashboard-charts { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; margin-bottom: 1.5rem; }
.chart-card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 1.25rem; }

.category-bars { list-style: none; }
.cat-bar-item { display: flex; align-items: center; gap: .75rem; padding: .4rem 0; font-size: .85rem; }
.cat-bar-name { width: 110px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--gray-600); }
.cat-bar-track { flex: 1; height: 8px; background: var(--gray-100); border-radius: 9px; overflow: hidden; }
.cat-bar-fill { height: 100%; background: var(--primary); border-radius: 9px; }
.cat-bar-count { width: 32px; text-align: right; font-weight: 600; color: var(--gray-700); }

/* ============================================================
   Filter bar
   ============================================================ */
.filter-bar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1.25rem; background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); padding: .75rem 1rem; }
.filter-search { max-width: 200px; }
.filter-select { max-width: 160px; }

/* ============================================================
   Page header
   ============================================================ */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 1.5rem; }
.page-title { font-size: 1.5rem; font-weight: 700; color: var(--gray-900); }
.page-subtitle { color: var(--gray-500); font-size: .95rem; margin-top: .2rem; }
.header-actions { display: flex; gap: .75rem; align-items: center; }
.link-sm { font-size: .8rem; color: var(--primary); }

/* ============================================================
   Ticket Show
   ============================================================ */
.ticket-layout { display: grid; grid-template-columns: 1fr 280px; gap: 1.5rem; align-items: start; }
.ticket-statusbar { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.thread { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); overflow: hidden; margin-bottom: 1rem; }
.thread-item { padding: 1.25rem; border-bottom: 1px solid var(--gray-200); }
.thread-item:last-child { border-bottom: none; }
.thread-item--note { background: #fefce8; }
.thread-item--private { background: #f0fdf4; }
.thread-header { display: flex; align-items: flex-start; gap: .75rem; margin-bottom: .75rem; }
.thread-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex-shrink: 0; }
.thread-meta { display: flex; flex-direction: column; gap: .1rem; font-size: .85rem; }
.thread-meta strong { font-size: .9rem; color: var(--gray-800); }
.thread-meta time { color: var(--gray-400); font-size: .8rem; }
.thread-content { font-size: .9rem; line-height: 1.7; color: var(--gray-700); }
.agent-tag { display: inline-block; background: var(--primary-light); color: var(--primary-dark); font-size: .65rem; font-weight: 700; padding: .1rem .4rem; border-radius: 4px; text-transform: uppercase; }
.reply-section { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 1.25rem; margin-bottom: 1rem; }
.reply-section h2 { font-size: 1rem; margin-bottom: 1rem; }
.reply-tabs { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--gray-200); padding-bottom: .5rem; }
.reply-tab { background: none; border: none; cursor: pointer; padding: .375rem .875rem; border-radius: var(--radius); font-size: .875rem; color: var(--gray-600); transition: background .15s; }
.reply-tab.active { background: var(--primary); color: #fff; }
.reply-actions { display: flex; gap: .75rem; margin-top: .75rem; }
.ticket-sidebar {}
.sidebar-section { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 1rem; margin-bottom: 1rem; }
.sidebar-section-title { font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); margin-bottom: .75rem; }
.sidebar-form .form-group { margin-bottom: .75rem; }
.details-list dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--gray-400); font-weight: 600; }
.details-list dd { font-size: .875rem; color: var(--gray-700); margin-bottom: .75rem; }
.action-btns { display: flex; flex-direction: column; gap: .5rem; }
.attachment-list { list-style: none; }
.attachment-list li { display: flex; justify-content: space-between; align-items: center; padding: .35rem 0; border-bottom: 1px solid var(--gray-100); font-size: .85rem; }
.attachment-link { display: flex; align-items: center; gap: .35rem; color: var(--primary); }
.attachment-size { font-size: .75rem; color: var(--gray-400); }

/* ============================================================
   Alerts
   ============================================================ */
.alert { padding: .875rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem; font-size: .875rem; }
.alert p { margin-bottom: .25rem; }
.alert p:last-child { margin-bottom: 0; }
.alert-success { background: var(--success-bg); color: #15803d; border: 1px solid #bbf7d0; }
.alert-danger  { background: var(--danger-bg);  color: #991b1b; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-bg); color: #92400e; border: 1px solid #fde68a; }
.alert-info    { background: var(--info-bg);    color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ============================================================
   Empty state
   ============================================================ */
.empty-state { text-align: center; color: var(--gray-400); padding: 1.5rem; }
.empty-state-full {
  text-align: center; padding: 4rem 2rem; color: var(--gray-400);
  background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg);
}
.empty-state-full svg { margin: 0 auto 1rem; display: block; opacity: .4; }
.empty-state-full p { font-size: 1rem; }

/* ============================================================
   PUBLIC layout
   ============================================================ */
.public-body { background: var(--gray-50); }
.public-header { background: #fff; border-bottom: 1px solid var(--gray-200); padding: 1rem 0; }
.public-header .container { display: flex; align-items: center; justify-content: space-between; }
.public-brand { display: flex; align-items: center; gap: .75rem; font-size: 1.1rem; font-weight: 700; color: var(--gray-900); }
.public-header nav { display: flex; gap: 1.5rem; }
.public-header nav a { font-size: .875rem; color: var(--gray-600); }
.public-header nav a:hover { color: var(--primary); text-decoration: none; }
.public-content { padding: 2.5rem 1.5rem; max-width: 720px; }
.public-footer { border-top: 1px solid var(--gray-200); padding: 1.5rem 0; text-align: center; color: var(--gray-400); font-size: .875rem; }
.public-hero { text-align: center; margin-bottom: 2rem; }
.public-hero h1 { font-size: 2rem; font-weight: 700; color: var(--gray-900); }
.public-hero p { color: var(--gray-500); margin-top: .5rem; }
.public-form-card { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 2rem; margin-bottom: 1.5rem; }
.public-links { text-align: center; font-size: .9rem; color: var(--gray-500); }
.public-links a { margin: 0 .5rem; }

/* Track page */
.track-header { background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius-lg); padding: 1.5rem; margin-bottom: 1.5rem; }
.track-subject { font-size: 1.1rem; font-weight: 600; color: var(--gray-800); margin: .5rem 0; }
.track-meta { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: .75rem; }
.track-company { font-size: .875rem; color: var(--gray-500); }
.track-assigned { background: var(--info-bg); color: #1d4ed8; padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; font-size: .875rem; }
.public-thread .thread-item--agent { background: var(--gray-50); }
.track-resolved-box { background: var(--success-bg); border: 1px solid #bbf7d0; border-radius: var(--radius-lg); padding: 1.5rem; text-align: center; margin-bottom: 1.5rem; }
.track-resolved-box svg { margin: 0 auto .75rem; display: block; }
.track-resolved-box p { color: #15803d; margin-bottom: .75rem; }
.track-footer-links { text-align: center; margin-top: 2rem; font-size: .875rem; color: var(--gray-400); }

/* Survey */
.survey-card { max-width: 560px; margin: 0 auto; }
.star-rating { display: flex; gap: .25rem; margin-top: .5rem; }
.star-label { cursor: pointer; }
.star-label input { position: absolute; opacity: 0; width: 0; height: 0; }
.star-label svg { color: var(--gray-300); transition: color .15s; }
.star-label:hover svg, .star-label:hover ~ .star-label svg { color: var(--warning); }
.star-label input:checked ~ .star-label svg { color: var(--gray-300); }
.star-rating:has(.star-label:nth-child(1) input:checked) .star-label:nth-child(1) svg { color: var(--warning); }
.star-rating:has(.star-label:nth-child(2) input:checked) .star-label:nth-child(n+1):nth-child(-n+2) svg { color: var(--warning); }
.star-rating:has(.star-label:nth-child(3) input:checked) .star-label:nth-child(n+1):nth-child(-n+3) svg { color: var(--warning); }
.star-rating:has(.star-label:nth-child(4) input:checked) .star-label:nth-child(n+1):nth-child(-n+4) svg { color: var(--warning); }
.star-rating:has(.star-label:nth-child(5) input:checked) .star-label svg { color: var(--warning); }
.nps-scale { display: flex; gap: .25rem; flex-wrap: wrap; margin: .5rem 0; }
.nps-label { cursor: pointer; }
.nps-label input { position: absolute; opacity: 0; width: 0; height: 0; }
.nps-num { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; border: 2px solid var(--gray-200); border-radius: var(--radius); font-size: .875rem; font-weight: 600; transition: border-color .15s, background .15s; }
.nps-label:hover .nps-num { border-color: var(--primary); background: var(--primary-light); }
.nps-label input:checked + .nps-num { background: var(--primary); color: #fff; border-color: var(--primary); }
.nps-labels { display: flex; justify-content: space-between; font-size: .75rem; color: var(--gray-400); margin-bottom: .5rem; }
.success-icon { text-align: center; margin-bottom: 1rem; }

/* ============================================================
   KB Suggestions
   ============================================================ */
.kb-suggestions {
  background: var(--info-bg); border: 1px solid #bfdbfe;
  border-radius: var(--radius); padding: .75rem 1rem;
  margin-bottom: 1rem; font-size: .875rem;
}
.kb-suggestions h3 { font-size: .875rem; font-weight: 600; margin-bottom: .5rem; color: #1d4ed8; }
.kb-suggestions ul { list-style: none; }
.kb-suggestions li { margin-bottom: .25rem; }
.kb-suggestions a { color: #1d4ed8; }

/* ============================================================
   Company selector (auth)
   ============================================================ */
.company-list { display: flex; flex-direction: column; gap: .5rem; }
.company-option { cursor: pointer; }
.company-option input { position: absolute; opacity: 0; width: 0; height: 0; }
.company-option-content {
  display: flex; align-items: center; gap: .875rem;
  padding: .875rem 1rem; border: 2px solid var(--gray-200);
  border-radius: var(--radius); transition: border-color .15s, background .15s;
}
.company-option input:checked + .company-option-content { border-color: var(--primary); background: var(--primary-light); }
.company-option:hover .company-option-content { border-color: var(--primary); }
.company-initials {
  width: 40px; height: 40px; border-radius: var(--radius);
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.company-logo-sm { width: 40px; height: 40px; border-radius: var(--radius); object-fit: contain; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1024px) {
  .dashboard-charts { grid-template-columns: 1fr; }
  .ticket-layout { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .topbar-toggle { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-search, .filter-select { max-width: 100%; }
  .form-row { grid-template-columns: 1fr; }
  .public-header .container { flex-direction: column; gap: 1rem; }
  .page-header { flex-direction: column; gap: .75rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .topbar-actions { gap: .5rem; }
  .user-name { display: none; }
  .auth-card { padding: 1.5rem; }
}

/* ============================================================
   Misc utilities
   ============================================================ */
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.text-center { text-align: center; }
.text-muted { color: var(--gray-400); }
.fw-bold { font-weight: 700; }

/* ============================================================
   Badge colour aliases (semantic helpers used across new views)
   ============================================================ */
.badge-success   { background: var(--success-bg);  color: #15803d; }
.badge-warning   { background: var(--warning-bg);  color: #92400e; }
.badge-danger    { background: var(--danger-bg);   color: #991b1b; }
.badge-info      { background: var(--info-bg);     color: #1d4ed8; }
.badge-secondary { background: var(--gray-100);    color: var(--gray-600); }
.badge-primary   { background: var(--primary-light); color: var(--primary-dark); }
.badge-purple    { background: #ede9fe;             color: #7c3aed; }
.badge-orange    { background: #fff7ed;             color: #c2410c; }

/* ============================================================
   Stat card aliases (alternate class names used in generated views)
   ============================================================ */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card-value { font-size: 1.75rem; font-weight: 700; line-height: 1; color: var(--gray-900); }
.stat-card-label { font-size: .8rem; color: var(--gray-500); margin-top: .2rem; }

/* ============================================================
   Table alias (.table maps to .data-table styles)
   ============================================================ */
.table { width: 100%; border-collapse: collapse; font-size: .875rem; }
.table th { background: var(--gray-50); font-weight: 600; color: var(--gray-600); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.table th, .table td { padding: .75rem 1rem; border-bottom: 1px solid var(--gray-200); text-align: left; }
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--gray-50); }
.table-sm th, .table-sm td { padding: .5rem .75rem; }
.table-responsive { overflow-x: auto; }

/* ============================================================
   Page actions alias
   ============================================================ */
.page-actions { display: flex; gap: .75rem; align-items: center; }

/* ============================================================
   CSS variable aliases for generated views
   ============================================================ */
:root {
  --bg-secondary:  var(--gray-50);
  --bg-auth:       #ffffff;
  --text-muted:    var(--gray-500);
  --border-color:  var(--gray-200);
}
