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

:root {
  --sidebar-w: 256px;
  --sidebar-bg: #0f172a;
  --sidebar-border: rgba(255,255,255,.06);
  --sidebar-text: #94a3b8;
  --sidebar-hover: rgba(255,255,255,.05);
  --sidebar-active-bg: rgba(59,130,246,.15);
  --sidebar-active-text: #60a5fa;
  --sidebar-active-border: #3b82f6;

  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-disabled: #cbd5e1;

  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: #eff6ff;
  --accent-border: #bfdbfe;

  --success: #10b981;
  --success-light: #ecfdf5;
  --success-border: #a7f3d0;

  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --warning-border: #fde68a;

  --danger: #ef4444;
  --danger-light: #fef2f2;
  --danger-border: #fecaca;

  --purple: #8b5cf6;
  --purple-light: #f5f3ff;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;

  --shadow-xs: 0 1px 2px rgba(0,0,0,.05);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow: 0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.04);
  --shadow-md: 0 10px 15px rgba(0,0,0,.06), 0 4px 6px rgba(0,0,0,.04);
  --shadow-lg: 0 20px 25px rgba(0,0,0,.08), 0 8px 10px rgba(0,0,0,.04);

  --transition: .15s ease;
}

html { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ─── Layout ─────────────────────────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

#page-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  transition: margin-left var(--transition);
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-logo {
  padding: 22px 20px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.sidebar-logo-icon svg { color: white; }

.sidebar-logo-text { min-width: 0; }
.sidebar-logo-title {
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -.2px;
  white-space: nowrap;
}
.sidebar-logo-sub {
  color: var(--sidebar-text);
  font-size: 11px;
  margin-top: 1px;
  white-space: nowrap;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}

.nav-section-label {
  padding: 10px 20px 4px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #334155;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px 9px 16px;
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  border-left: 2px solid transparent;
  position: relative;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #e2e8f0;
}

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: var(--sidebar-active-border);
}

.nav-item svg { flex-shrink: 0; opacity: .8; }
.nav-item.active svg { opacity: 1; }
.nav-item-label { flex: 1; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
}

.sidebar-user:hover { background: var(--sidebar-hover); }

.user-avatar {
  width: 34px; height: 34px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img { width: 100%; height: 100%; object-fit: cover; }

.user-info { flex: 1; min-width: 0; }
.user-name {
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-meta { color: var(--sidebar-text); font-size: 11px; margin-top: 1px; }

.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--sidebar-text);
  padding: 5px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.btn-icon:hover { background: rgba(255,255,255,.08); color: var(--danger); }

/* ─── Hamburger ──────────────────────────────────────────────────────────────── */
.hamburger {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  z-index: 300;
  background: var(--sidebar-bg);
  border: 1px solid var(--sidebar-border);
  border-radius: var(--radius-sm);
  padding: 7px;
  cursor: pointer;
  color: #94a3b8;
  align-items: center;
  justify-content: center;
}

/* ─── Page wrapper ───────────────────────────────────────────────────────────── */
.page {
  padding: 28px 32px;
  max-width: 1440px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.3px;
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

.page-actions { display: flex; gap: 10px; align-items: center; flex-shrink: 0; }

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1;
}

.btn svg { flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(59,130,246,.3);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 8px rgba(59,130,246,.35);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}
.btn-danger:hover { background: #dc2626; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid transparent;
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); }

.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }

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

/* ─── Card ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface);
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title svg { color: var(--text-muted); }

.card-body { padding: 20px; }
.card-body-sm { padding: 14px 20px; }
.card-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

/* ─── Stat cards ─────────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 3px;
  height: 100%;
  background: var(--accent);
}

.stat-card.blue::before  { background: var(--accent); }
.stat-card.green::before { background: var(--success); }
.stat-card.amber::before { background: var(--warning); }
.stat-card.red::before   { background: var(--danger); }

.stat-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 14px;
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.stat-icon.blue  { background: var(--accent-light); color: var(--accent); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.amber { background: var(--warning-light); color: var(--warning); }
.stat-icon.red   { background: var(--danger-light); color: var(--danger); }

.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-size: 30px; font-weight: 800; color: var(--text-primary); line-height: 1.1; margin: 4px 0 2px; letter-spacing: -1px; }
.stat-sub { font-size: 12.5px; color: var(--text-muted); }

/* ─── Charts grid ────────────────────────────────────────────────────────────── */
.charts-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.charts-grid-main {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.chart-wrap { position: relative; height: 260px; }

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

table { width: 100%; border-collapse: collapse; }

thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

thead th:first-child { border-radius: var(--radius-sm) 0 0 0; }
thead th:last-child  { border-radius: 0 var(--radius-sm) 0 0; }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--transition);
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody td { padding: 13px 16px; vertical-align: middle; }

.td-primary { font-weight: 500; color: var(--text-primary); }

/* ─── Badges ─────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

/* Priority */
.badge-critical { background: #fee2e2; color: #b91c1c; }
.badge-high     { background: #fef3c7; color: #b45309; }
.badge-medium   { background: var(--accent-light); color: #1d4ed8; }
.badge-low      { background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }

/* Status */
.badge-open        { background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--border); }
.badge-in_progress { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.badge-resolved    { background: var(--success-light); color: #047857; border: 1px solid var(--success-border); }
.badge-closed      { background: #1e293b; color: #94a3b8; }

/* ─── Filters bar ────────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px 20px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.filter-select,
.filter-input {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
}

.filter-select:focus,
.filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.filter-input { min-width: 200px; }
.filter-search { position: relative; }
.filter-search svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.filter-search input { padding-left: 32px; }
.filters-spacer { flex: 1; }

/* ─── Form ───────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: inherit;
  line-height: 1.5;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.form-control::placeholder { color: var(--text-disabled); }
textarea.form-control { resize: vertical; min-height: 110px; }
select.form-control { cursor: pointer; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ─── AI Preview ─────────────────────────────────────────────────────────────── */
.ai-preview-card {
  background: linear-gradient(135deg, #eff6ff 0%, #f5f3ff 100%);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-top: 8px;
}

.ai-preview-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #6366f1, #3b82f6);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.ai-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.ai-field {
  background: white;
  border: 1px solid #e0e7ff;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.ai-field-label { font-size: 11px; font-weight: 600; color: #6366f1; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
.ai-field-value { font-size: 14px; font-weight: 700; color: var(--text-primary); }

.confidence-bar {
  height: 5px;
  background: #e0e7ff;
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-top: 6px;
}

.confidence-fill {
  height: 100%;
  border-radius: var(--radius-full);
  transition: width .5s cubic-bezier(.4,0,.2,1);
}

.conf-high   { background: linear-gradient(90deg, #10b981, #34d399); }
.conf-medium { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.conf-low    { background: linear-gradient(90deg, #ef4444, #f87171); }

/* ─── Login ──────────────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
}

.login-left {
  flex: 1;
  display: none;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
  color: white;
}

.login-right {
  width: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(255,255,255,.03);
  backdrop-filter: blur(10px);
  border-left: 1px solid rgba(255,255,255,.06);
}

.login-box { width: 100%; max-width: 380px; }

.login-logo { margin-bottom: 36px; }

.login-logo-icon {
  width: 52px; height: 52px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(59,130,246,.35);
}

.login-logo h1 { color: #fff; font-size: 24px; font-weight: 800; letter-spacing: -.5px; }
.login-logo p  { color: #94a3b8; font-size: 13.5px; margin-top: 5px; }

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: #475569;
  font-size: 12px;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,.08);
}

.login-error {
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.3);
  color: #fca5a5;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-control-dark {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition), background var(--transition), box-shadow var(--transition);
}

.form-control-dark:focus {
  border-color: #3b82f6;
  background: rgba(255,255,255,.08);
  box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}

.form-control-dark::placeholder { color: #475569; }

.form-label-dark { display: block; font-size: 13px; font-weight: 600; color: #94a3b8; margin-bottom: 6px; }

/* ─── Ticket detail ──────────────────────────────────────────────────────────── */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

.ticket-description-box {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-secondary);
  white-space: pre-wrap;
  border: 1px solid var(--border);
}

.meta-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 20px;
}

.meta-item {}
.meta-label-sm { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 4px; }
.meta-value-sm { font-size: 13.5px; font-weight: 500; color: var(--text-primary); }

/* Prediction card */
.prediction-gradient {
  background: linear-gradient(135deg, #1e40af, #6d28d9);
  border-radius: var(--radius-lg);
  padding: 18px;
  color: white;
  margin-bottom: 16px;
}

.prediction-label { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; opacity: .7; margin-bottom: 3px; }
.prediction-value { font-size: 20px; font-weight: 800; letter-spacing: -.3px; margin-bottom: 10px; }
.prediction-meta  { font-size: 12px; opacity: .75; margin-bottom: 14px; }

/* Timeline */
.timeline { list-style: none; }
.timeline-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }

.timeline-dot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 3px;
}

.timeline-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.timeline-line {
  width: 1px;
  flex: 1;
  background: var(--border);
  margin-top: 4px;
}

.timeline-content { flex: 1; }
.timeline-text { font-size: 13px; color: var(--text-secondary); }
.timeline-text b { color: var(--text-primary); }
.timeline-time { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* Comments */
.comment-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.comment-item:last-child { border-bottom: none; }

.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.comment-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700;
  flex-shrink: 0;
}

.comment-author { font-size: 13px; font-weight: 600; }
.comment-time   { font-size: 11.5px; color: var(--text-muted); margin-left: auto; }
.comment-text   { font-size: 13.5px; color: var(--text-secondary); line-height: 1.6; }

/* ─── Pagination ─────────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.pagination-info { flex: 1; font-size: 13px; color: var(--text-muted); }

.page-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  font-family: inherit;
}

.page-btn:hover:not(:disabled) { background: var(--surface-2); border-color: var(--border-strong); }
.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

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

.alert svg { flex-shrink: 0; margin-top: 1px; }
.alert-info    { background: var(--accent-light); color: #1d4ed8; border: 1px solid var(--accent-border); }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid var(--success-border); }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid var(--warning-border); }
.alert-error   { background: var(--danger-light); color: #991b1b; border: 1px solid var(--danger-border); }

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg { margin-bottom: 16px; opacity: .4; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p  { font-size: 13.5px; }

/* ─── Skeleton ───────────────────────────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer { to { background-position: -200% 0; } }

/* ─── Mobile ticket cards ────────────────────────────────────────────────────── */
.ticket-mobile-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--transition), transform var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.ticket-mobile-card:active { transform: scale(.99); box-shadow: none; }

.tmc-top {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tmc-id {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'SF Mono', monospace;
}

.tmc-date {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-muted);
}

.tmc-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.tmc-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.tmc-assignee {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--text-muted);
  font-size: 12px;
}

/* ─── Visibility helpers ─────────────────────────────────────────────────────── */
.mobile-only  { display: none !important; }
.desktop-only { display: block !important; }

/* Filters collapsible on mobile */
.filters-collapsed {
  display: none !important;
}

/* ─── Divider ────────────────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ─── Spinner ────────────────────────────────────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .65s linear infinite;
  opacity: .7;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Utilities ──────────────────────────────────────────────────────────────── */
.hidden      { display: none !important; }
.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.items-center{ align-items: center; }
.gap-2       { gap: 8px; }
.gap-3       { gap: 12px; }
.mt-4        { margin-top: 16px; }
.mt-6        { margin-top: 24px; }
.mb-4        { margin-bottom: 16px; }
.mb-5        { margin-bottom: 20px; }
.text-muted  { color: var(--text-muted); }
.text-sm     { font-size: 12.5px; }
.text-xs     { font-size: 11.5px; }
.font-mono   { font-family: 'SF Mono', 'Fira Code', monospace; }
.font-semibold { font-weight: 600; }
.truncate    { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ─── Chat Page ──────────────────────────────────────────────────────────────── */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-height: 100vh;
  overflow: hidden;
  background: var(--bg);
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.chat-header-avatar {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(99,102,241,.3);
}

.chat-header-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.chat-header-sub {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.chat-online-dot {
  width: 7px; height: 7px;
  background: var(--success);
  border-radius: 50%;
  flex-shrink: 0;
  animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: .5; }
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-msg {
  display: flex;
  gap: 10px;
  max-width: 75%;
  animation: msg-in .2s ease;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chat-msg-ai   { align-self: flex-start; }
.chat-msg-user { align-self: flex-end; flex-direction: row-reverse; max-width: 65%; }

.chat-msg-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: 0 2px 6px rgba(99,102,241,.25);
}

.chat-msg-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.chat-msg-bubble {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.65;
  word-wrap: break-word;
}

.chat-msg-ai .chat-msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.chat-msg-user .chat-msg-bubble {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  color: white;
  border-top-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(59,130,246,.3);
}

.chat-msg-time {
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 4px;
}

/* Suggestion chips */
.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 12px;
}

.chat-suggestion-btn {
  background: var(--accent-light);
  border: 1px solid var(--accent-border);
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.chat-suggestion-btn:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
}

/* Typing animation */
.chat-typing {
  display: flex !important;
  gap: 5px;
  align-items: center;
  padding: 14px 18px !important;
}

.chat-typing span {
  width: 7px; height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing-bounce .9s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: .15s; }
.chat-typing span:nth-child(3) { animation-delay: .3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30%            { transform: translateY(-6px); opacity: 1; }
}

/* Code blocks in chat */
.chat-code {
  background: #1e293b;
  color: #e2e8f0;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  overflow-x: auto;
  margin: 6px 0;
  white-space: pre;
  display: block;
}

.chat-inline-code {
  background: #f1f5f9;
  color: #e11d48;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.chat-msg-user .chat-inline-code { background: rgba(255,255,255,.2); color: #fff; }

/* Input area */
.chat-input-area {
  padding: 12px 24px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.chat-input-wrap {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 8px 8px 8px 16px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.chat-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59,130,246,.1);
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  resize: none;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 22px;
  max-height: 140px;
  padding: 2px 0;
}

.chat-input::placeholder { color: var(--text-muted); }

.chat-send-btn {
  width: 38px; height: 38px;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition);
}
.chat-send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(59,130,246,.3);
}
.chat-send-btn:disabled { opacity: .5; cursor: not-allowed; }

.chat-input-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ─── Sidebar overlay (mobile) ───────────────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 150;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.visible { display: block; }

/* ─── Bottom navigation (mobile) ────────────────────────────────────────────── */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 62px;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--sidebar-border);
  z-index: 400;
  padding: 0 4px;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav-inner {
  display: flex;
  height: 62px;
  align-items: stretch;
}

.bottom-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--sidebar-text);
  font-size: 10.5px;
  font-weight: 500;
  padding: 6px 2px;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
}

.bottom-nav-item:hover,
.bottom-nav-item.active { color: var(--sidebar-active-text); }

.bottom-nav-item svg { transition: transform var(--transition); }
.bottom-nav-item.active svg { transform: scale(1.08); }

.bottom-nav-new {
  background: var(--accent);
  color: #fff !important;
  border-radius: var(--radius-sm);
  margin: 8px 4px;
  flex: 0 0 52px;
  width: 52px;
  padding: 0;
}
.bottom-nav-new:hover { background: var(--accent-hover); }

/* ─── Mobile ticket cards (dashboard critical list) ──────────────────────────── */
.mobile-cards { display: none; flex-direction: column; gap: 10px; padding: 0 0 4px; }

.mobile-ticket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-xs);
}

.mtc-top {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mtc-id {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'SF Mono', monospace;
  font-weight: 600;
}

.mtc-time {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-muted);
}

.mtc-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-decoration: none;
  line-height: 1.4;
}
.mtc-title:hover { color: var(--accent); }

.mtc-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mtc-assignee {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (min-width: 900px) {
  .login-left { display: flex; }
  .login-right { width: 440px; }
}

@media (max-width: 1200px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* Hamburger hidden — bottom nav takes over */
  .hamburger { display: none; }

  /* Sidebar slides in from left when .open */
  .sidebar { transform: translateX(-100%); transition: transform .25s cubic-bezier(.4,0,.2,1); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }

  #page-content { margin-left: 0; }

  /* Extra bottom padding so content isn't hidden behind bottom nav */
  .page { padding: 16px; padding-top: 20px; padding-bottom: 80px; }

  .stats-grid { grid-template-columns: 1fr 1fr; }
  .charts-grid-main { grid-template-columns: 1fr; }
  .charts-grid-2 { grid-template-columns: 1fr; }
  .detail-layout { grid-template-columns: 1fr; }
  .form-grid-2 { grid-template-columns: 1fr; }
  .login-right { width: 100%; border: none; }

  /* Bottom nav visible */
  .bottom-nav { display: block; }
  .mobile-cards { display: flex; }
  .desktop-table { display: none; }

  /* Show/hide helpers */
  .mobile-only  { display: block !important; }
  .desktop-only { display: none !important; }

  /* flex mobile-only items (badges, actions row) */
  .mobile-only.flex-row { display: flex !important; }

  /* Compact page header */
  .page-header { margin-bottom: 18px; }
  .page-title { font-size: 18px; }

  /* Stat card text */
  .stat-value { font-size: 26px; }

  /* Filters wrap on mobile */
  .filters-bar {
    flex-direction: column;
    gap: 10px;
    align-items: stretch;
  }
  .filter-select { width: 100%; }
  .filter-input  { min-width: 0; width: 100%; }
  .filters-spacer { display: none; }

  /* Ticket create two-col → single col */
  .create-layout { grid-template-columns: 1fr !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .stat-value { font-size: 22px; }
  .page { padding: 12px; padding-bottom: 80px; }
}

/* Chat mobile */
@media (max-width: 768px) {
  .chat-page { height: calc(100vh - 62px); }
  .chat-messages { padding: 14px 14px; gap: 12px; }
  .chat-msg { max-width: 88%; }
  .chat-msg-user { max-width: 80%; }
  .chat-header { padding: 12px 16px; }
  .chat-input-area { padding: 10px 14px 14px; }
  .chat-suggestions { gap: 6px; }
  .chat-suggestion-btn { font-size: 12px; padding: 5px 11px; }
}
