/* ============================================================
   Healthcare Helpdesk — Global Stylesheet
   Design system: clean, accessible, clinical-grade.
   ============================================================ */

:root {
  --primary:        #003087;
  --primary-hover:  #00236b;
  --primary-light:  #e8f0fb;
  --accent:         #1a73e8;
  --success:        #1e7e34;
  --success-bg:     #d4edda;
  --warning:        #856404;
  --warning-bg:     #fff3cd;
  --danger:         #842029;
  --danger-bg:      #f8d7da;
  --info-bg:        #cff4fc;
  --gray-50:        #f8f9fa;
  --gray-100:       #f1f3f5;
  --gray-200:       #e9ecef;
  --gray-300:       #dee2e6;
  --gray-500:       #adb5bd;
  --gray-700:       #495057;
  --gray-800:       #343a40;
  --gray-900:       #212529;
  --border:         1px solid var(--gray-300);
  --radius:         6px;
  --radius-lg:      10px;
  --shadow:         0 1px 4px rgba(0,0,0,0.10);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.12);
  --font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif;
  --font-mono:      'Consolas', 'Courier New', monospace;
  --transition:     150ms ease;
}

/* ── Dark Mode ─────────────────────────────── */
/* Dark theme variables */
:root[data-theme="dark"] {
  --primary:        #4a9eff;
  --primary-hover:  #6cb3ff;
  --primary-light:  #1a2a3e;
  --accent:         #5b9df5;
  --success:        #2ecc71;
  --success-bg:     #1a3a2a;
  --warning:        #f0c040;
  --warning-bg:     #3a3520;
  --danger:         #e74c3c;
  --danger-bg:      #3a1a1a;
  --info-bg:        #1a2a3a;
  --gray-50:        #1e1e2e;
  --gray-100:       #252536;
  --gray-200:       #2e2e42;
  --gray-300:       #3e3e56;
  --gray-500:       #8888a0;
  --gray-700:       #c0c0d0;
  --gray-800:       #d8d8e8;
  --gray-900:       #e8e8f0;
  --border:         1px solid var(--gray-300);
  --shadow:         0 1px 4px rgba(0,0,0,0.30);
  --shadow-md:      0 4px 16px rgba(0,0,0,0.35);
  --surface:        #252536;
  --surface-raised: #2e2e42;
}

/* Dark theme element overrides */
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea,
:root[data-theme="dark"] input[type="text"],
:root[data-theme="dark"] input[type="email"],
:root[data-theme="dark"] input[type="password"],
:root[data-theme="dark"] input[type="search"],
:root[data-theme="dark"] input[type="number"],
:root[data-theme="dark"] input[type="time"] {
  background-color: var(--gray-200);
  color: var(--gray-900);
  border-color: var(--gray-300);
}

:root[data-theme="dark"] .card,
:root[data-theme="dark"] .modal-content,
:root[data-theme="dark"] .modal {
  background-color: var(--gray-100);
}

:root[data-theme="dark"] .navbar {
  background: linear-gradient(135deg, #1a1a3e 0%, #0a0a2e 100%);
}

:root[data-theme="dark"] .table-wrapper th,
:root[data-theme="dark"] thead th,
:root[data-theme="dark"] .search-results-table th,
:root[data-theme="dark"] .admin-table th {
  background-color: var(--gray-200);
}

/* Stat cards */
:root[data-theme="dark"] .stat-card {
  background: var(--gray-100);
}

/* Login page */
:root[data-theme="dark"] .login-page {
  background: linear-gradient(135deg, #0a0a2e 0%, #1a1a3e 100%);
}
:root[data-theme="dark"] .login-card {
  background: var(--gray-100);
}

/* Audit timeline */
:root[data-theme="dark"] .audit-item {
  background: var(--gray-100);
}
:root[data-theme="dark"] .audit-item::before {
  border-color: var(--gray-100);
}

/* Portal & service cards */
:root[data-theme="dark"] .portal-banner {
  background: var(--gray-100);
}
:root[data-theme="dark"] .portal-my-requests {
  background: var(--gray-100);
}
:root[data-theme="dark"] .portal-service-card {
  background: var(--gray-100);
}

/* Rich text editor */
:root[data-theme="dark"] .rte-wrapper {
  background: var(--gray-100);
}
:root[data-theme="dark"] .comment-composer {
  background: var(--gray-100);
}
:root[data-theme="dark"] .comment-visibility-btn {
  background: var(--gray-200);
}
:root[data-theme="dark"] .comment-attach-btn {
  background: var(--gray-200);
}

/* Comment bubbles */
:root[data-theme="dark"] .comment-own .comment-bubble {
  background: #1a2040;
  border-color: #2a3060;
}
:root[data-theme="dark"] .comment-internal {
  background: #2a2510;
  border-color: #5a4520;
}

/* Settings sidebar */
:root[data-theme="dark"] .settings-sidebar {
  background: var(--gray-100);
}

/* Search components */
:root[data-theme="dark"] .search-input {
  background: var(--gray-200);
  color: var(--gray-900);
  border-color: var(--gray-300);
}
:root[data-theme="dark"] .search-results {
  background: var(--gray-100);
  border-color: var(--gray-300);
}
:root[data-theme="dark"] .search-page-input {
  background: var(--gray-200);
  color: var(--gray-900);
}

/* User search dropdown */
:root[data-theme="dark"] .user-search-dropdown {
  background: var(--gray-100);
}
:root[data-theme="dark"] .user-selected-chip {
  background: #1a2040;
  border-color: #2a3060;
}

/* Modal (phase 2 duplicate selector) */
:root[data-theme="dark"] .modal-content {
  background: var(--gray-100);
}

/* Merge results */
:root[data-theme="dark"] .merge-results {
  background: var(--gray-100);
}

/* Pagination buttons */
:root[data-theme="dark"] .pagination button {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

/* Action icon buttons */
:root[data-theme="dark"] .btn-icon {
  background: var(--gray-200);
}

/* Logo preview in settings */
:root[data-theme="dark"] .logo-preview {
  background: var(--gray-200);
}

/* Department field highlight */
:root[data-theme="dark"] .department-field {
  background: var(--primary-light);
  border-color: var(--gray-300);
}

/* File drop zone */
:root[data-theme="dark"] .file-drop-zone:hover,
:root[data-theme="dark"] .file-drop-zone:focus {
  background: var(--primary-light);
}
:root[data-theme="dark"] .file-drop-zone.drag-over {
  background: var(--warning-bg);
}

/* File/attachment document placeholders */
:root[data-theme="dark"] .file-thumb-doc {
  background: var(--danger-bg);
  border-color: #5a2020;
}
:root[data-theme="dark"] .attachment-file-link {
  background: var(--danger-bg);
  border-color: #5a2020;
}

/* Idle logout modal */
:root[data-theme="dark"] .idle-modal {
  background: var(--gray-100);
}

/* Tech notes card header */
:root[data-theme="dark"] .card-tech-notes .card-header {
  background: #2a2510;
  border-bottom-color: #5a4520;
}

/* Comment visibility button states */
:root[data-theme="dark"] .comment-visibility-btn.private {
  background: #2a2510;
  border-color: #5a4520;
}
:root[data-theme="dark"] .comment-visibility-btn.public {
  background: #1a3020;
  border-color: #2a5040;
}

/* Badge overrides for dark - department badges */
:root[data-theme="dark"] .badge-dept-IT          { background: #1e3060; color: #7aa8f0; }
:root[data-theme="dark"] .badge-dept-Maintenance { background: #3a3010; color: #d0a050; }
:root[data-theme="dark"] .badge-dept-Epic        { background: #2a2050; color: #a090d0; }

/* Badge overrides for dark - priority badges */
:root[data-theme="dark"] .badge-priority-Low      { background: #1a3020; color: #60c080; }
:root[data-theme="dark"] .badge-priority-Medium   { background: #1e3060; color: #7aa8f0; }
:root[data-theme="dark"] .badge-priority-High     { background: #3a2810; color: #d0a060; }
:root[data-theme="dark"] .badge-priority-Critical { background: #3a1a1a; color: #f08080; }

/* Badge overrides for dark - status badges */
:root[data-theme="dark"] .badge-status-Open        { background: #1a2a3e; color: #60a0d0; }
:root[data-theme="dark"] .badge-status-In-Progress { background: #3a3010; color: #d0b040; }
:root[data-theme="dark"] .badge-status-Pending     { background: #2a2050; color: #b090e0; }
:root[data-theme="dark"] .badge-status-Resolved    { background: #1a3020; color: #60c080; }
:root[data-theme="dark"] .badge-status-Closed      { background: var(--gray-200); color: var(--gray-700); }

/* SLA badges */
:root[data-theme="dark"] .sla-badge.sla-ok       { background: #1a3020; border-color: #2a5040; color: #60c080; }
:root[data-theme="dark"] .sla-badge.sla-warning   { background: #3a3010; border-color: #5a4520; color: #d0b040; }
:root[data-theme="dark"] .sla-badge.sla-critical  { background: #3a1a1a; border-color: #5a2020; color: #f08080; }

/* HIPAA tag */
:root[data-theme="dark"] .hipaa-tag {
  background: #3a1a1a;
  border-color: #5a2020;
  color: #f08080;
}

/* Alert overrides */
:root[data-theme="dark"] .alert-info {
  color: #60c0e0;
  border-color: #2a4050;
}
:root[data-theme="dark"] .alert-error {
  border-color: #5a2020;
}
:root[data-theme="dark"] .alert-success {
  border-color: #2a5040;
}
:root[data-theme="dark"] .alert-warning {
  border-color: #5a4520;
}

/* Internal badge & private badge */
:root[data-theme="dark"] .badge-internal {
  background: #2a2510;
  color: #d0a050;
}
:root[data-theme="dark"] .comment-private-badge {
  background: #2a2510;
  border-color: #5a4520;
  color: #d0a050;
}
:root[data-theme="dark"] .tech-notes-badge {
  background: #2a2510;
  color: #d0a050;
}

/* Comment textarea internal */
:root[data-theme="dark"] .comment-textarea-internal {
  background: #2a2510;
  border-color: #5a4520;
}

/* Canned preview */
:root[data-theme="dark"] .canned-preview {
  background: var(--gray-200);
}

/* Table tbody hover */
:root[data-theme="dark"] tbody tr:hover {
  background: var(--gray-200);
}

/* Select dropdown arrow for dark mode */
:root[data-theme="dark"] select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23c0c0d0' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
}

/* Toast notifications dark mode */
:root[data-theme="dark"] .toast-container .toast {
  background: var(--gray-100);
  border-color: var(--gray-300);
}

/* Search result items */
:root[data-theme="dark"] .search-result-viewall {
  background: var(--gray-200);
}

/* Input focus ring toned down for dark */
:root[data-theme="dark"] input:focus,
:root[data-theme="dark"] select:focus,
:root[data-theme="dark"] textarea:focus {
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2);
}

/* Portal toggle active button */
:root[data-theme="dark"] .portal-toggle button.active {
  background: var(--gray-900);
  color: var(--gray-100);
}

/* KB article body code blocks */
:root[data-theme="dark"] .kb-article-body code,
:root[data-theme="dark"] .rte-content code {
  background: var(--gray-200);
}

/* Disabled select */
:root[data-theme="dark"] select:disabled {
  background: var(--gray-200);
  color: var(--gray-500);
}

/* ── Auto Dark Mode (prefers-color-scheme) ─── */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary:        #4a9eff;
    --primary-hover:  #6cb3ff;
    --primary-light:  #1a2a3e;
    --accent:         #5b9df5;
    --success:        #2ecc71;
    --success-bg:     #1a3a2a;
    --warning:        #f0c040;
    --warning-bg:     #3a3520;
    --danger:         #e74c3c;
    --danger-bg:      #3a1a1a;
    --info-bg:        #1a2a3a;
    --gray-50:        #1e1e2e;
    --gray-100:       #252536;
    --gray-200:       #2e2e42;
    --gray-300:       #3e3e56;
    --gray-500:       #8888a0;
    --gray-700:       #c0c0d0;
    --gray-800:       #d8d8e8;
    --gray-900:       #e8e8f0;
    --border:         1px solid var(--gray-300);
    --shadow:         0 1px 4px rgba(0,0,0,0.30);
    --shadow-md:      0 4px 16px rgba(0,0,0,0.35);
    --surface:        #252536;
    --surface-raised: #2e2e42;
  }

  :root:not([data-theme="light"]) input,
  :root:not([data-theme="light"]) select,
  :root:not([data-theme="light"]) textarea,
  :root:not([data-theme="light"]) input[type="text"],
  :root:not([data-theme="light"]) input[type="email"],
  :root:not([data-theme="light"]) input[type="password"],
  :root:not([data-theme="light"]) input[type="search"],
  :root:not([data-theme="light"]) input[type="number"],
  :root:not([data-theme="light"]) input[type="time"] {
    background-color: var(--gray-200);
    color: var(--gray-900);
    border-color: var(--gray-300);
  }

  :root:not([data-theme="light"]) .card,
  :root:not([data-theme="light"]) .modal-content,
  :root:not([data-theme="light"]) .modal {
    background-color: var(--gray-100);
  }

  :root:not([data-theme="light"]) .navbar {
    background: linear-gradient(135deg, #1a1a3e 0%, #0a0a2e 100%);
  }

  :root:not([data-theme="light"]) .table-wrapper th,
  :root:not([data-theme="light"]) thead th,
  :root:not([data-theme="light"]) .search-results-table th,
  :root:not([data-theme="light"]) .admin-table th {
    background-color: var(--gray-200);
  }

  :root:not([data-theme="light"]) .stat-card { background: var(--gray-100); }
  :root:not([data-theme="light"]) .login-page { background: linear-gradient(135deg, #0a0a2e 0%, #1a1a3e 100%); }
  :root:not([data-theme="light"]) .login-card { background: var(--gray-100); }
  :root:not([data-theme="light"]) .audit-item { background: var(--gray-100); }
  :root:not([data-theme="light"]) .audit-item::before { border-color: var(--gray-100); }
  :root:not([data-theme="light"]) .portal-banner { background: var(--gray-100); }
  :root:not([data-theme="light"]) .portal-my-requests { background: var(--gray-100); }
  :root:not([data-theme="light"]) .portal-service-card { background: var(--gray-100); }
  :root:not([data-theme="light"]) .rte-wrapper { background: var(--gray-100); }
  :root:not([data-theme="light"]) .comment-composer { background: var(--gray-100); }
  :root:not([data-theme="light"]) .comment-visibility-btn { background: var(--gray-200); }
  :root:not([data-theme="light"]) .comment-attach-btn { background: var(--gray-200); }
  :root:not([data-theme="light"]) .comment-own .comment-bubble { background: #1a2040; border-color: #2a3060; }
  :root:not([data-theme="light"]) .comment-internal { background: #2a2510; border-color: #5a4520; }
  :root:not([data-theme="light"]) .settings-sidebar { background: var(--gray-100); }
  :root:not([data-theme="light"]) .search-input { background: var(--gray-200); color: var(--gray-900); border-color: var(--gray-300); }
  :root:not([data-theme="light"]) .search-results { background: var(--gray-100); border-color: var(--gray-300); }
  :root:not([data-theme="light"]) .user-search-dropdown { background: var(--gray-100); }
  :root:not([data-theme="light"]) .user-selected-chip { background: #1a2040; border-color: #2a3060; }
  :root:not([data-theme="light"]) .pagination button { background: var(--gray-100); border-color: var(--gray-300); }
  :root:not([data-theme="light"]) .btn-icon { background: var(--gray-200); }
  :root:not([data-theme="light"]) .logo-preview { background: var(--gray-200); }
  :root:not([data-theme="light"]) .idle-modal { background: var(--gray-100); }
  :root:not([data-theme="light"]) .badge-dept-IT { background: #1e3060; color: #7aa8f0; }
  :root:not([data-theme="light"]) .badge-dept-Maintenance { background: #3a3010; color: #d0a050; }
  :root:not([data-theme="light"]) .badge-dept-Epic { background: #2a2050; color: #a090d0; }
  :root:not([data-theme="light"]) .badge-priority-Low { background: #1a3020; color: #60c080; }
  :root:not([data-theme="light"]) .badge-priority-Medium { background: #1e3060; color: #7aa8f0; }
  :root:not([data-theme="light"]) .badge-priority-High { background: #3a2810; color: #d0a060; }
  :root:not([data-theme="light"]) .badge-priority-Critical { background: #3a1a1a; color: #f08080; }
  :root:not([data-theme="light"]) .badge-status-Open { background: #1a2a3e; color: #60a0d0; }
  :root:not([data-theme="light"]) .badge-status-In-Progress { background: #3a3010; color: #d0b040; }
  :root:not([data-theme="light"]) .badge-status-Pending { background: #2a2050; color: #b090e0; }
  :root:not([data-theme="light"]) .badge-status-Resolved { background: #1a3020; color: #60c080; }
  :root:not([data-theme="light"]) .alert-info { color: #60c0e0; border-color: #2a4050; }
  :root:not([data-theme="light"]) .hipaa-tag { background: #3a1a1a; border-color: #5a2020; color: #f08080; }
  :root:not([data-theme="light"]) .badge-internal { background: #2a2510; color: #d0a050; }
  :root:not([data-theme="light"]) .comment-private-badge { background: #2a2510; border-color: #5a4520; color: #d0a050; }
  :root:not([data-theme="light"]) .canned-preview { background: var(--gray-200); }
  :root:not([data-theme="light"]) tbody tr:hover { background: var(--gray-200); }
  :root:not([data-theme="light"]) select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23c0c0d0' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); }
  :root:not([data-theme="light"]) .search-result-viewall { background: var(--gray-200); }
  :root:not([data-theme="light"]) input:focus,
  :root:not([data-theme="light"]) select:focus,
  :root:not([data-theme="light"]) textarea:focus { box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.2); }
  :root:not([data-theme="light"]) .portal-toggle button.active { background: var(--gray-900); color: var(--gray-100); }
  :root:not([data-theme="light"]) select:disabled { background: var(--gray-200); color: var(--gray-500); }
  :root:not([data-theme="light"]) .card-tech-notes .card-header { background: #2a2510; border-bottom-color: #5a4520; }
  :root:not([data-theme="light"]) .file-thumb-doc { background: var(--danger-bg); border-color: #5a2020; }
  :root:not([data-theme="light"]) .attachment-file-link { background: var(--danger-bg); border-color: #5a2020; }
  :root:not([data-theme="light"]) .department-field { background: var(--primary-light); border-color: var(--gray-300); }
  :root:not([data-theme="light"]) .merge-results { background: var(--gray-100); }
}

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

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

body {
  font-family: var(--font);
  color: var(--gray-900);
  background: var(--gray-100);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── Typography ──────────────────────────────── */
h1 { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
h2 { font-size: 1.35rem; font-weight: 600; color: var(--gray-800); }
h3 { font-size: 1.1rem;  font-weight: 600; color: var(--gray-800); }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

small { font-size: 0.8rem; color: var(--gray-700); }

/* ── Layout ──────────────────────────────────── */
.page-loader {
  display: flex; align-items: center; justify-content: center;
  height: 100vh; font-size: 1.1rem; color: var(--gray-700);
}

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 28px 24px;
}

/* ── Navbar ──────────────────────────────────── */
.navbar {
  background: var(--primary);
  color: #fff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  text-decoration: none;
}

.navbar-brand svg { width: 28px; height: 28px; }

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
}

.navbar-nav a,
.navbar-nav button {
  color: rgba(255,255,255,0.88);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: var(--font);
  padding: 6px 14px;
  border-radius: var(--radius);
  transition: background var(--transition), color var(--transition);
  text-decoration: none;
}

.navbar-nav a:hover,
.navbar-nav button:hover { background: rgba(255,255,255,0.15); color: #fff; }
.navbar-nav a.active { background: rgba(255,255,255,0.22); color: #fff; font-weight: 600; }

.navbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.85);
  font-size: 0.85rem;
}

.user-avatar {
  width: 34px; height: 34px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  color: #fff;
}

/* ── Cards ───────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  border: var(--border);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: var(--border);
}

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  font-size: 0.88rem;
  font-family: var(--font);
  font-weight: 500;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  transition: background var(--transition), opacity var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary   { background: var(--primary);  color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--primary-hover); }

.btn-secondary { background: var(--gray-200); color: var(--gray-800); border: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-300); }

.btn-danger    { background: var(--danger-bg); color: var(--danger); border: 1px solid #f1aeb5; }
.btn-danger:hover:not(:disabled)   { background: #f1aeb5; }

.btn-sm  { padding: 5px 12px; font-size: 0.82rem; }
.btn-lg  { padding: 11px 28px; font-size: 1rem; }

/* ── Forms ───────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 18px;
}

label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  font-size: 0.9rem;
  font-family: var(--font);
  color: var(--gray-900);
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,115,232,0.18);
}

textarea { resize: vertical; min-height: 110px; }

select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23495057' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

.field-note { font-size: 0.78rem; color: var(--gray-700); margin-top: 3px; }

/* Department-specific dynamic field highlight */
.department-field {
  background: var(--primary-light);
  border-radius: var(--radius);
  padding: 14px;
  border: 1px solid #b8d0f5;
}

/* ── Badges ──────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 0.76rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge-dept-IT          { background: #dbeafe; color: #1e40af; }
.badge-dept-Maintenance { background: #fef3c7; color: #92400e; }
.badge-dept-Epic        { background: #ede9fe; color: #5b21b6; }

.badge-priority-Low      { background: #d1fae5; color: #065f46; }
.badge-priority-Medium   { background: #dbeafe; color: #1e40af; }
.badge-priority-High     { background: #fed7aa; color: #92400e; }
.badge-priority-Critical { background: #fecaca; color: #991b1b; }

.badge-status-Open        { background: #e0f2fe; color: #0369a1; }
.badge-status-In-Progress { background: #fef9c3; color: #854d0e; }
.badge-status-Pending     { background: #f3e8ff; color: #6b21a8; }
.badge-status-Resolved    { background: #dcfce7; color: #166534; }
.badge-status-Closed      { background: var(--gray-200); color: var(--gray-700); }

/* ── Environment tag badges ── */
.badge-env-PROD { background: #dc3545; color: #fff; }
.badge-env-REL  { background: #0d6efd; color: #fff; }
.badge-env-SUP  { background: #198754; color: #fff; }
.badge-env-TST  { background: #fd7e14; color: #fff; }
.badge-env-N\/A { background: var(--gray-500); color: #fff; }

/* ── Tags ────────────────────────────────────── */
.field-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 3px;
  letter-spacing: 0.03em;
}

.hipaa-tag {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
}

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

.alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #f1aeb5; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #a3cfbb; }
.alert-info    { background: var(--info-bg);    color: #0c5460;        border: 1px solid #9eeaf9; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #ffda6a; }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--gray-50);
  font-weight: 600;
  text-align: left;
  padding: 10px 14px;
  border-bottom: 2px solid var(--gray-300);
  white-space: nowrap;
  color: var(--gray-700);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
thead th[style*="cursor: pointer"]:hover {
  background: var(--gray-100);
  color: var(--primary);
}

tbody tr { border-bottom: var(--border); transition: background var(--transition); }
tbody tr:hover { background: var(--gray-50); }
tbody td { padding: 11px 14px; vertical-align: middle; }

/* ── Ticket Grid ─────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  flex-wrap: wrap;
  gap: 12px;
}

.filters {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.filters select { width: auto; }

/* ── Ticket Detail ───────────────────────────── */
.ticket-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.meta-item { display: flex; flex-direction: column; gap: 3px; }
.meta-label { font-size: 0.75rem; text-transform: uppercase; color: var(--gray-500); font-weight: 600; letter-spacing: 0.05em; }
.meta-value { font-size: 0.92rem; color: var(--gray-900); font-weight: 500; }

.description-box {
  background: var(--gray-50);
  border: var(--border);
  border-radius: var(--radius);
  padding: 16px;
  white-space: pre-wrap;
  font-size: 0.9rem;
  line-height: 1.7;
  margin-bottom: 20px;
}

/* ── Audit Timeline ──────────────────────────── */
.audit-timeline { list-style: none; position: relative; padding-left: 24px; }
.audit-timeline::before {
  content: '';
  position: absolute;
  left: 7px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--gray-300);
}

.audit-item {
  position: relative;
  margin-bottom: 16px;
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.audit-item::before {
  content: '';
  position: absolute;
  left: -19px; top: 16px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 2px var(--primary);
}

.audit-action {
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary);
}

.audit-meta {
  font-size: 0.78rem;
  color: var(--gray-700);
  margin-top: 3px;
}

/* ── Stats Cards ─────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: #fff;
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  text-align: center;
}

.stat-number { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-label  { font-size: 0.8rem; color: var(--gray-700); margin-top: 4px; }

/* ── Login Page ──────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #003087 0%, #1a73e8 100%);
  padding: 24px;
}

.login-card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.login-logo {
  margin: 0 auto 24px;
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
}

.login-card h1 { margin-bottom: 4px; }
.login-subtitle { color: var(--gray-700); font-size: 0.9rem; margin-bottom: 32px; }

.sso-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 13px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: var(--font);
  background: #2f2f2f;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
}

.sso-btn:hover { background: #1a1a1a; }
.sso-btn svg { width: 20px; height: 20px; }

.login-footer {
  margin-top: 28px;
  font-size: 0.78rem;
  color: var(--gray-700);
  line-height: 1.7;
}

/* ── Portal / Service Catalog ────────────────── */
.portal-banner {
  background: #fff;
  border: var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 16px 24px;
  margin-bottom: 24px;
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--gray-800);
}

.portal-banner p { margin-bottom: 4px; }
.portal-banner p:last-child { margin-bottom: 0; }
.portal-banner h1,.portal-banner h2,.portal-banner h3 { margin: 8px 0 4px; font-size: 1rem; }
.portal-banner ul,.portal-banner ol { margin: 4px 0; padding-left: 20px; }
.portal-banner li { margin-bottom: 2px; }
.portal-banner hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.portal-banner blockquote { border-left: 3px solid var(--primary); margin: 6px 0; padding: 4px 12px; color: var(--gray-600); }

/* ── Rich Text Editor ─────────────────────────────────────── */
.rte-wrapper {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.rte-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
/* Bottom-toolbar variant: toolbar sits below the content area */
.rte-toolbar.rte-toolbar-bottom {
  border-bottom: none;
  border-top: 1px solid var(--border);
}
/* No outer border when used inside .comment-composer */
.comment-composer .rte-wrapper {
  border: none;
  border-radius: 0;
}
.rte-content {
  padding: 12px 14px;
  min-height: 120px;
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--gray-800);
}
.rte-wrapper.rte-tall .rte-content {
  min-height: 300px;
}
.rte-wrapper.rte-toolbar-bottom-wrapper .rte-content {
  min-height: 100px;
}
.rte-content:focus { outline: none; }
.rte-content p { margin: 0 0 6px; }
.rte-content p:last-child { margin-bottom: 0; }
.rte-content h2 { font-size: 1rem; font-weight: 700; margin: 8px 0 4px; }
.rte-content ul,.rte-content ol { margin: 4px 0; padding-left: 20px; }
.rte-content li { margin-bottom: 2px; }
.rte-content blockquote { border-left: 3px solid var(--primary); margin: 6px 0; padding: 4px 12px; color: var(--gray-600); }
.rte-content hr { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.rte-content strong { font-weight: 700; }
.rte-content em { font-style: italic; }
.rte-content u { text-decoration: underline; }
.rte-content s { text-decoration: line-through; }
.rte-content code { background: var(--gray-100); padding: 1px 4px; border-radius: 3px; font-family: monospace; font-size: 0.85em; }

/* ── Comment Composer (RTE + action bar) ────────────────────── */
.comment-composer {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
  transition: box-shadow 120ms;
}
.comment-composer:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 48, 135, 0.08);
}
.comment-composer-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.comment-composer-bar-sep { flex: 1; }

/* Private / Public visibility toggle */
.comment-visibility-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--gray-300);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
  color: var(--gray-700);
}
.comment-visibility-btn:hover { background: var(--gray-100); }
.comment-visibility-btn.private {
  color: #92400e;
  border-color: #fcd34d;
  background: #fffbeb;
}
.comment-visibility-btn.private:hover { background: #fef3c7; }
.comment-visibility-btn.public {
  color: #065f46;
  border-color: #6ee7b7;
  background: #f0fdf4;
}
.comment-visibility-btn.public:hover { background: #d1fae5; }

/* Response Templates / Variables link-style buttons */
.comment-bar-action {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  border: none;
  background: none;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  border-radius: var(--radius);
  transition: background var(--transition);
  white-space: nowrap;
}
.comment-bar-action:hover { background: var(--gray-100); }

/* Attach button */
.comment-attach-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  transition: background var(--transition);
}
.comment-attach-btn:hover { background: var(--gray-100); }

/* PRIVATE badge on internal comment threads */
.comment-private-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
  border-radius: 10px;
  padding: 1px 7px;
}

/* ── Knowledge Base article body (rendered HTML) ─────────── */
.kb-article-body {
  line-height: 1.8;
  font-size: 0.95rem;
  color: var(--gray-800);
}
.kb-article-body p { margin: 0 0 12px; }
.kb-article-body p:last-child { margin-bottom: 0; }
.kb-article-body h1 { font-size: 1.4rem; font-weight: 700; margin: 24px 0 10px; }
.kb-article-body h2 { font-size: 1.15rem; font-weight: 700; margin: 20px 0 8px; }
.kb-article-body h3 { font-size: 1rem; font-weight: 700; margin: 16px 0 6px; }
.kb-article-body ul, .kb-article-body ol { margin: 8px 0 12px; padding-left: 24px; }
.kb-article-body li { margin-bottom: 4px; }
.kb-article-body blockquote {
  border-left: 4px solid var(--primary);
  margin: 12px 0;
  padding: 8px 16px;
  background: var(--gray-50);
  color: var(--gray-700);
  border-radius: 0 var(--radius) var(--radius) 0;
}
.kb-article-body hr { border: none; border-top: 1px solid var(--border); margin: 20px 0; }
.kb-article-body strong { font-weight: 700; }
.kb-article-body em { font-style: italic; }
.kb-article-body code {
  background: var(--gray-100);
  padding: 2px 6px;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.87em;
}
.kb-article-body pre {
  background: var(--gray-100);
  padding: 12px 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: monospace;
  font-size: 0.87em;
  margin: 12px 0;
}

.portal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

.portal-grid-staff {
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 8px;
}

.portal-my-requests {
  grid-row: 1 / 3;
  background: #fff;
  border: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
}

.portal-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.portal-card-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--gray-900);
}

.portal-card-icon-sm {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Active / Closed toggle */
.portal-toggle {
  display: flex;
  background: var(--gray-100);
  border-radius: 20px;
  padding: 3px;
  margin-bottom: 16px;
  width: fit-content;
}

.portal-toggle button {
  background: transparent;
  border: none;
  padding: 6px 20px;
  font-size: 0.82rem;
  font-family: var(--font);
  font-weight: 500;
  color: var(--gray-700);
  border-radius: 18px;
  cursor: pointer;
  transition: all var(--transition);
}

.portal-toggle button.active {
  background: var(--gray-900);
  color: #fff;
  font-weight: 600;
}

.portal-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 0;
  gap: 10px;
  flex: 1;
}

.portal-empty-text {
  font-size: 0.9rem;
  color: var(--gray-500);
  text-align: center;
}

.portal-request-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0;
  flex: 1;
  overflow-y: auto;
  max-height: 340px;
}

.portal-request-list li {
  padding: 12px 0;
  border-bottom: var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.portal-request-list li:hover {
  background: var(--gray-50);
  margin: 0 -12px;
  padding: 12px;
  border-radius: var(--radius);
}

.portal-request-list li:last-child { border-bottom: none; }

.portal-request-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 6px;
}

.portal-request-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Service catalog cards */
.portal-service-card {
  background: #fff;
  border: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: var(--font);
  width: 100%;
}

.portal-service-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #e68a00;
  transform: translateY(-2px);
}

.portal-service-icon {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

.portal-service-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
}

.portal-service-desc {
  font-size: 0.8rem;
  color: var(--gray-700);
  line-height: 1.5;
}

/* ── Idle Logout Warning ─────────────────────── */
.idle-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(2px);
}
.idle-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 36px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  text-align: center;
  animation: fadeInScale 0.2s ease;
}
.idle-icon { margin-bottom: 16px; }
.idle-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0 0 12px;
}
.idle-body {
  color: var(--gray-700);
  font-size: 0.95rem;
  margin: 0 0 8px;
  line-height: 1.5;
}
.idle-body-sm { font-size: 0.82rem; color: var(--gray-500); margin-top: 4px; }
.idle-countdown {
  font-size: 3rem;
  font-weight: 800;
  color: var(--warning, #e07000);
  line-height: 1;
  margin: 16px 0;
  font-variant-numeric: tabular-nums;
}
.idle-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 24px;
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.94); }
  to   { opacity: 1; transform: scale(1); }
}

/* ── Modal ───────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  animation: fadeIn 0.15s ease;
}

.modal-content,
.modal {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 48px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: slideUp 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--gray-900);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: var(--gray-500);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: all var(--transition);
}

.modal-close:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
}

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

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── User Search (Submitted By) ──────────────── */

.user-search-wrap { position: relative; }

.user-search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 200;
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 280px;
  overflow-y: auto;
}

.user-search-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.user-search-item:hover { background: var(--gray-100); }

.user-search-name {
  display: block;
  font-weight: 500;
  font-size: 0.88rem;
  color: var(--gray-900);
}
.user-search-email {
  display: block;
  font-size: 0.76rem;
  color: var(--gray-700);
}

/* Selected user chip */
.user-selected-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  padding: 7px 10px;
}

.user-chip-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.user-chip-avatar-sm {
  width: 24px;
  height: 24px;
  min-width: 24px;
  font-size: 0.7rem;
}

.user-chip-name {
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--gray-900);
}
.user-chip-email {
  font-size: 0.78rem;
  color: var(--gray-700);
  margin-left: 2px;
}

.user-chip-clear {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-700);
  font-size: 0.75rem;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1;
}
.user-chip-clear:hover { background: #fee2e2; color: var(--danger); }

/* ── Comments ────────────────────────────────── */

.comment-post-box {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.comment-textarea {
  width: 100%;
  border: var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: var(--font-sans);
  resize: vertical;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.comment-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0,48,135,0.1);
}

.comment-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: var(--gray-300);
  color: var(--gray-900);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.comment-avatar-me {
  background: var(--primary);
  color: #fff;
}

.comment-thread {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-top: 4px;
}

.comment-item {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.comment-bubble {
  flex: 1;
  background: var(--gray-50);
  border: var(--border);
  border-radius: 0 var(--radius) var(--radius) var(--radius);
  padding: 10px 14px;
}
.comment-own .comment-bubble {
  background: #eef2ff;
  border-color: #c7d2fe;
  border-radius: var(--radius) 0 var(--radius) var(--radius);
}
.comment-internal {
  background: #fffbeb;
  border-color: #fbbf24;
  border-left-width: 3px;
}
.badge-internal {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 10px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* ── Tech Notes card ── */
.card-tech-notes {
  border-left: 4px solid #f59e0b;
}
.card-tech-notes .card-header {
  background: #fffbeb;
  border-bottom-color: #fde68a;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.tech-notes-icon {
  margin-right: 6px;
}
.tech-notes-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.comment-avatar-tech {
  background: #d97706;
  color: #fff;
}
.comment-textarea-internal {
  border-color: #fbbf24;
  background: #fffbeb;
}
.comment-textarea-internal:focus {
  border-color: #d97706;
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}
.btn-tech-note {
  background: #d97706;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s;
}
.btn-tech-note:hover:not(:disabled) {
  background: #b45309;
}
.btn-tech-note:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

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

.comment-author {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--gray-900);
}

.comment-role-tag {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--primary);
  color: #fff;
  padding: 1px 6px;
  border-radius: 4px;
}

.comment-time {
  font-size: 0.75rem;
  color: var(--gray-700);
  margin-left: auto;
}

.comment-body {
  font-size: 0.9rem;
  color: var(--gray-900);
  white-space: pre-wrap;
  line-height: 1.55;
}

/* ── File Attachments ────────────────────────── */

.file-drop-zone {
  border: 2px dashed var(--gray-400);
  border-radius: var(--radius);
  padding: 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: var(--gray-50);
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.file-drop-zone:hover, .file-drop-zone:focus {
  border-color: var(--primary);
  background: #f0f4ff;
  outline: none;
}
.file-drop-zone.drag-over { border-color: var(--accent); background: #fff7e6; }

.file-drop-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: var(--gray-700);
  font-size: 0.9rem;
  pointer-events: none;
}

.file-preview-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  width: 100%;
}

.file-preview-item {
  position: relative;
  width: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.file-thumb {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--gray-300);
}

.file-thumb-doc {
  width: 80px;
  height: 80px;
  border-radius: 6px;
  border: 1px solid #fca5a5;
  background: #fff5f5;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-preview-name {
  font-size: 0.72rem;
  color: var(--gray-900);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

.file-preview-size { font-size: 0.68rem; color: var(--gray-700); }

.file-remove-btn {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 0.65rem;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.file-remove-btn:hover { background: #b91c1c; }

.file-add-more {
  width: 80px;
  height: 80px;
  border: 2px dashed var(--gray-400);
  border-radius: 6px;
  background: none;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--gray-700);
  font-size: 0.75rem;
  gap: 2px;
  transition: border-color 0.15s, color 0.15s;
  align-self: flex-start;
}
.file-add-more:hover { border-color: var(--primary); color: var(--primary); }

/* Attachment panel on ticket detail page */
.attachment-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: var(--border);
}
.attachment-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.attachment-count {
  background: var(--gray-200);
  color: var(--gray-900);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 10px;
}
.attachment-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.attachment-thumb-link,
.attachment-file-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  width: 100px;
  transition: opacity 0.15s;
}
.attachment-thumb-link:hover,
.attachment-file-link:hover { opacity: 0.8; }

.attachment-thumb-img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--gray-300);
}
.attachment-file-link {
  width: 96px;
  height: 96px;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  background: #fff5f5;
  justify-content: center;
}
.attachment-name {
  font-size: 0.72rem;
  color: var(--gray-900);
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* ── Utility ─────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 20px; }
.mb-4 { margin-bottom: 20px; }
.text-muted { color: var(--gray-700); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 0.85rem; }
.font-mono { font-family: var(--font-mono); }
.w-100 { width: 100%; }
.d-none { display: none; }
.separator { border: none; border-top: var(--border); margin: 20px 0; }

/* ── Department Page ─────────────────────────── */
.dept-hero {
  background: linear-gradient(135deg, var(--primary) 0%, #004abf 100%);
  color: #fff;
  border-radius: var(--radius);
  padding: 32px 36px 28px;
  margin-bottom: 24px;
  position: relative;
}

.dept-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  margin-bottom: 14px;
  transition: color 0.15s;
}
.dept-back:hover { color: #fff; }

.dept-hero-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin: 0 0 6px;
  color: #fff;
  border: none;
  padding: 0;
}

.dept-hero-sub {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.97rem;
}

.dept-requests-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 10px;
}
.dept-requests-header h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gray-900);
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 960px) {
  .portal-grid {
    grid-template-columns: 1fr 1fr;
  }
  .portal-my-requests {
    grid-row: auto;
    grid-column: 1 / -1;
  }
  .portal-grid-staff {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .main-content  { padding: 16px; }
  .login-card    { padding: 32px 20px; }
  .page-header   { flex-direction: column; align-items: flex-start; }
  .filters       { width: 100%; }
  .filters select { flex: 1; }
  .portal-grid, .portal-grid-staff {
    grid-template-columns: 1fr;
  }
  .modal-content { max-height: 95vh; }
  .modal-body    { padding: 16px; }
  .portal-service-card { padding: 20px 16px; }
}

/* ── Settings Layout (Admin) ────────────────── */
.settings-layout {
  display: flex;
  gap: 0;
  min-height: calc(100vh - 58px - 56px);
  margin: -28px -24px;
}
.settings-sidebar {
  width: 260px;
  min-width: 260px;
  background: #fff;
  border-right: var(--border);
  padding: 24px 0;
  overflow-y: auto;
}
.settings-sidebar-title {
  padding: 0 20px 16px;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary);
  border-bottom: var(--border);
  margin: 0 0 12px;
}
.settings-nav-section { margin-bottom: 8px; }
.settings-nav-heading {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  font-weight: 600;
  padding: 12px 20px 6px;
  margin: 0;
}
.settings-sidebar ul { list-style: none; padding: 0; margin: 0; }
.settings-sidebar li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  font-size: 0.88rem;
  color: var(--gray-800);
  text-decoration: none;
  transition: all 0.15s ease;
  border-left: 3px solid transparent;
}
.settings-sidebar li a:hover {
  background: var(--gray-50);
  color: var(--primary);
}
.settings-sidebar li a.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
  border-left-color: var(--primary);
}
.settings-content {
  flex: 1;
  padding: 28px 32px;
  overflow-y: auto;
  background: var(--gray-100);
  min-height: calc(100vh - 58px);
}
.settings-content .page-header {
  margin-bottom: 20px;
}
.settings-content .page-header h1 {
  font-size: 1.3rem;
}
.settings-content .card {
  margin-bottom: 20px;
}

/* ── Toggle Switch ────────────────── */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}
.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--gray-300);
  border-radius: 24px;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  left: 2px;
  top: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch input:checked + .toggle-slider {
  background: var(--primary);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ── Permission Grid ────────────────── */
.perm-grid { width: 100%; border-collapse: collapse; }
.perm-grid th,
.perm-grid td { padding: 10px 14px; text-align: left; border-bottom: var(--border); }
.perm-grid th { font-size: 0.78rem; text-transform: uppercase; color: var(--gray-500); font-weight: 600; }
.perm-grid td:last-child { text-align: center; }
.perm-label { font-size: 0.9rem; color: var(--gray-800); }
.perm-desc { font-size: 0.78rem; color: var(--gray-500); margin-top: 2px; }

/* ── Settings form ────────────────── */
.settings-form { max-width: 640px; }
.settings-form .form-group { margin-bottom: 20px; }
.settings-form label { font-weight: 600; font-size: 0.88rem; color: var(--gray-800); }
.settings-form .form-hint { font-size: 0.78rem; color: var(--gray-500); margin-top: 4px; }
.logo-preview { margin: 12px 0; max-width: 300px; max-height: 120px; border: var(--border); border-radius: var(--radius); padding: 8px; background: #fff; }
.logo-preview img { max-width: 100%; max-height: 100px; object-fit: contain; }

/* ── Category tree ────────────────── */
.cat-row-child td:first-child { padding-left: 40px; }
.cat-row-child td:first-child::before {
  content: '└';
  color: var(--gray-500);
  margin-right: 8px;
}
.cat-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.cat-tag {
  display: inline-block;
  padding: 1px 8px;
  font-size: 0.72rem;
  border-radius: 10px;
  background: var(--gray-200);
  color: var(--gray-700);
}

/* ── SLA display ────────────────── */
.sla-hours { font-weight: 600; }
.sla-hours-warn { color: #ef6c00; }
.sla-hours-crit { color: #c62828; }

/* ── Canned response preview ────────────────── */
.canned-preview {
  padding: 12px;
  background: var(--gray-50);
  border: var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
}

/* ── Notification rule grid ────────────────── */
.notif-grid { width: 100%; border-collapse: collapse; }
.notif-grid th,
.notif-grid td { padding: 10px 14px; text-align: center; border-bottom: var(--border); }
.notif-grid th:first-child,
.notif-grid td:first-child { text-align: left; }
.notif-event { font-size: 0.88rem; font-weight: 500; }

/* ── Action buttons in tables ────────────────── */
.action-btns { display: flex; gap: 6px; justify-content: flex-end; }
.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  border: var(--border);
  background: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--gray-700);
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--gray-100); color: var(--primary); }
.btn-icon-danger:hover { background: var(--danger-bg); color: var(--danger); }

/* ============================================================
   PHASE 1: Search, SLA, Templates
   ============================================================ */

/* ── Search Bar (navbar) ────────────────────────────────── */
.search-container {
  position: relative;
  width: 280px;
  margin: 0 16px;
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.9rem;
  background: #fff;
  color: var(--gray-900);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 48, 135, 0.1);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--gray-300);
  border-top: none;
  border-radius: 0 0 var(--radius) var(--radius);
  max-height: 400px;
  overflow-y: auto;
  z-index: 500;
  box-shadow: var(--shadow-md);
}

.search-result-loading,
.search-result-empty {
  padding: 12px 14px;
  text-align: center;
  color: var(--gray-500);
  font-size: 0.9rem;
}

.search-result-item {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-200);
  cursor: pointer;
  transition: background var(--transition);
}

.search-result-item:hover {
  background: var(--gray-50);
}

.search-result-number {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-bottom: 2px;
}

.search-result-title {
  font-weight: 500;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.search-result-meta {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
}

.search-result-dept,
.search-result-priority {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 2px;
  background: var(--gray-100);
  color: var(--gray-700);
}

.search-result-viewall {
  display: block;
  width: 100%;
  padding: 10px 14px;
  text-align: center;
  border: none;
  background: var(--gray-50);
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background var(--transition);
}

.search-result-viewall:hover {
  background: var(--primary-light);
}

/* ── Search Page ────────────────────────────────────────── */
.search-page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

.search-page-input-bar {
  margin-bottom: 20px;
}

.search-page-input {
  width: 100%;
  max-width: 400px;
  padding: 12px 16px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 1rem;
}

.search-page-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 48, 135, 0.1);
}

.search-stats {
  padding: 12px 0;
  color: var(--gray-600);
  font-size: 0.95rem;
  margin-bottom: 16px;
}

.search-loading,
.search-empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}

.search-empty-state {
  background: var(--gray-50);
  border-radius: var(--radius);
}

.search-results-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

.search-results-table th {
  padding: 12px 14px;
  background: var(--gray-50);
  border-bottom: var(--border);
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-700);
}

.search-results-table td {
  padding: 12px 14px;
  border-bottom: var(--border);
}

.search-results-table tbody tr {
  cursor: pointer;
  transition: background var(--transition);
}

.search-results-table tbody tr:hover {
  background: var(--gray-50);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: var(--border);
}

.pagination button {
  padding: 8px 16px;
  border: var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--primary);
  cursor: pointer;
  font-weight: 600;
  transition: all var(--transition);
}

.pagination button:hover:not(:disabled) {
  background: var(--primary-light);
  border-color: var(--primary);
}

.pagination button:disabled {
  color: var(--gray-400);
  cursor: not-allowed;
}

/* ── SLA Badge ──────────────────────────────────────────── */
.sla-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--gray-100);
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
  white-space: nowrap;
}

.sla-badge.sla-ok {
  background: #dcfce7;
  border-color: #a3cfbb;
  color: #1e7e34;
}

.sla-badge.sla-warning {
  background: #fef3c3;
  border-color: #fcd34d;
  color: #92400e;
}

.sla-badge.sla-critical {
  background: #fee2e2;
  border-color: #f1aeb5;
  color: #842029;
}

.sla-badge-icon {
  font-size: 0.8rem;
}

.sla-badge-text {
  font-family: var(--font-mono);
}

.sla-badge-full {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sla-deadline {
  display: block;
  font-size: 0.75rem;
  color: var(--gray-600);
}

/* ── Ticket Templates Page ──────────────────────────────── */
.admin-page {
  max-width: 1000px;
  margin: 0 auto;
}

.admin-page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.admin-page-header h2 {
  margin: 0;
}

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

select:disabled {
  background: var(--gray-50, #f9fafb);
  color: var(--gray-400, #9ca3af);
  cursor: not-allowed;
}

.form-grid .full-width {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

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

.admin-table th {
  padding: 12px 14px;
  background: var(--gray-50);
  border-bottom: var(--border);
  text-align: left;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--gray-700);
}

.admin-table td {
  padding: 12px 14px;
  border-bottom: var(--border);
}

.admin-actions {
  display: flex;
  gap: 8px;
}

.portal-empty-text {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border: 1px solid var(--danger);
}

.btn-danger:hover {
  background: #72161a;
  border-color: #72161a;
}

/* ============================================================
   PHASE 2: Bulk Actions & Merging
   ============================================================ */

/* ── Bulk Action Bar ────────────────────────────────────── */
.bulk-action-bar {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--primary);
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-md);
  z-index: 100;
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.bulk-action-count {
  font-weight: 600;
  font-size: 0.95rem;
}

.bulk-action-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.bulk-action-buttons .btn {
  padding: 6px 14px;
  font-size: 0.85rem;
  white-space: nowrap;
}

.bulk-action-buttons .btn.btn-secondary {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

.bulk-action-buttons .btn.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.25);
}

/* ── Ticket row selection highlight ────────────────────── */
.row-selected {
  background-color: rgba(26, 115, 232, 0.08) !important;
}

/* ── Merge Modal ────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  padding: 20px;
  animation: modalFadeIn 0.2s ease;
}

.merge-modal {
  max-width: 600px;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-content h3 {
  margin: 0 0 12px 0;
  font-size: 1.1rem;
}

.modal-description {
  color: var(--gray-600);
  font-size: 0.9rem;
  margin-bottom: 16px;
}

.modal-content select,
.modal-content input {
  width: 100%;
  padding: 10px;
  border: var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.modal-content select:focus,
.modal-content input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 48, 135, 0.1);
}

.modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-buttons .btn {
  padding: 8px 16px;
}

/* ── Merge search and results ──────────────────────────── */
.merge-search-input {
  width: 100%;
  padding: 12px;
  border: var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  margin-bottom: 12px;
}

.merge-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 48, 135, 0.1);
}

.merge-loading,
.merge-no-results {
  text-align: center;
  padding: 16px;
  color: var(--gray-500);
  font-size: 0.9rem;
}

.merge-results {
  border: var(--border);
  border-radius: var(--radius);
  max-height: 300px;
  overflow-y: auto;
  margin-bottom: 12px;
}

.merge-result-item {
  padding: 12px;
  border-bottom: var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.merge-result-item:last-child {
  border-bottom: none;
}

.merge-result-item:hover {
  background: var(--gray-50);
}

.merge-result-item.selected {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
  padding-left: 9px;
}

.merge-result-number {
  font-size: 0.75rem;
  color: var(--gray-500);
  margin-bottom: 2px;
  font-family: var(--font-mono);
}

.merge-result-title {
  font-weight: 500;
  color: var(--gray-900);
  margin-bottom: 4px;
}

.merge-result-meta {
  display: flex;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--gray-600);
}

.merge-result-priority {
  font-weight: 600;
}

.merge-selected-info {
  background: var(--info-bg);
  border: 1px solid #b6e7fe;
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 12px;
  font-size: 0.9rem;
}

.merge-selected-info p {
  margin: 0;
  line-height: 1.5;
}

/* ── Merged ticket badge ───────────────────────────────── */
.badge-status-merged {
  background: #f3f4f6;
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

/* ── Settings responsive ────────────────── */
@media (max-width: 900px) {
  .settings-layout { flex-direction: column; }
  .settings-sidebar {
    width: 100%;
    min-width: 100%;
    border-right: none;
    border-bottom: var(--border);
    padding: 16px 0;
    overflow-y: visible;
  }
  .settings-content { padding: 20px 16px; }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .search-container {
    width: 200px;
  }

  .bulk-action-bar {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px;
  }

  .bulk-action-buttons {
    width: 100%;
  }

  .bulk-action-buttons .btn {
    flex: 1;
    min-width: 120px;
  }

  .modal-content {
    width: 95%;
    max-height: 90vh;
  }
}

@media (max-width: 640px) {
  .bulk-action-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .bulk-action-buttons {
    width: 100%;
    flex-direction: column;
  }

  .bulk-action-buttons .btn {
    width: 100%;
  }

  .modal-content {
    width: 100%;
    max-height: 100vh;
    border-radius: 0;
    max-width: 100%;
  }

  .merge-results {
    max-height: 200px;
  }
}

/* ============================================================
   TICKET DETAIL — Modern Header Bar + Tabs (Redesign 2026)
   ============================================================ */

/* ── Sticky header bar ── */
.ticket-detail-header {
  position: sticky;
  top: 58px;
  z-index: 90;
  background: #fff;
  border-bottom: var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 24px;
  flex-wrap: wrap;
  box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}

.ticket-header-back {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--gray-700);
  background: none;
  border: none;
  padding: 4px 8px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.ticket-header-back:hover { background: var(--gray-100); color: var(--gray-900); }

.ticket-header-number {
  font-family: var(--font-mono);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--gray-800);
  white-space: nowrap;
  padding: 4px 6px;
}

.ticket-header-sep {
  color: var(--gray-300);
  font-size: 1.1rem;
  padding: 0 2px;
  user-select: none;
}

/* Clickable header field (Status, Assignee) */
.ticket-header-field {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 1px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
  transition: background var(--transition);
  min-width: 80px;
}
.ticket-header-field:hover { background: var(--gray-100); }
.ticket-header-field.readonly { cursor: default; }
.ticket-header-field.readonly:hover { background: transparent; }
.ticket-header-field.locked { cursor: not-allowed; opacity: 0.7; }
.ticket-header-field.locked:hover { background: transparent; }

.ticket-header-field-label {
  font-size: 0.67rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  font-weight: 600;
}
.ticket-header-field-value {
  font-size: 0.84rem;
  color: var(--gray-800);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.ticket-field-chevron {
  font-size: 0.6rem;
  color: var(--gray-400);
  margin-left: 1px;
}

/* Generic header dropdown panel */
.ticket-header-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 190px;
  z-index: 400;
  overflow: hidden;
}
.ticket-header-dropdown-item {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 0.87rem;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition);
}
.ticket-header-dropdown-item:hover { background: var(--primary-light); }
.ticket-header-dropdown-item.selected {
  background: var(--primary-light);
  font-weight: 600;
  color: var(--primary);
}

/* Assignee dropdown extras */
.assignee-search-input {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-bottom: var(--border);
  font-size: 0.87rem;
  outline: none;
  box-sizing: border-box;
}
.assignee-dropdown { min-width: 230px; max-height: 280px; overflow-y: auto; }
.assignee-item-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.assignee-item-name { font-size: 0.87rem; font-weight: 500; }
.assignee-item-role { font-size: 0.72rem; color: var(--gray-500); }

/* Assignee display in header */
.assignee-header-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* Actions button + dropdown */
.ticket-actions-wrapper {
  position: relative;
  margin-left: auto;
}
.ticket-actions-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 230px;
  z-index: 400;
  overflow: hidden;
}
.ticket-action-item {
  padding: 10px 16px;
  cursor: pointer;
  font-size: 0.87rem;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background var(--transition);
  white-space: nowrap;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  color: var(--gray-800);
}
.ticket-action-item:hover { background: var(--primary-light); }
.ticket-action-item.danger { color: var(--danger); }
.ticket-action-item.danger:hover { background: var(--danger-bg); }
.ticket-action-item.disabled {
  color: var(--gray-500);
  cursor: not-allowed;
}
.ticket-action-item.disabled:hover { background: transparent; }
.ticket-actions-divider {
  height: 1px;
  background: var(--gray-200);
  margin: 4px 0;
}

/* ── Ticket body ── */
.ticket-detail-body { padding: 24px 0 0; }
.ticket-title {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--gray-900);
  margin: 0 0 6px;
  line-height: 1.35;
}
.ticket-created-by {
  font-size: 0.83rem;
  color: var(--gray-500);
  margin: 0 0 20px;
}
.ticket-inline-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ── Tab navigation ── */
.ticket-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--gray-200);
  margin: 20px 0 0;
}
.ticket-tab {
  padding: 10px 20px;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-500);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.ticket-tab:hover { color: var(--gray-800); }
.ticket-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-count {
  background: var(--gray-200);
  color: var(--gray-700);
  border-radius: 10px;
  padding: 1px 7px;
  font-size: 0.7rem;
  font-weight: 700;
}
.ticket-tab.active .tab-count {
  background: var(--primary-light);
  color: var(--primary);
}

.ticket-tab-content { padding: 20px 0; }

/* ── Details tab ── */
.ticket-details-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  border-top: var(--border);
}
.ticket-details-row {
  padding: 14px 20px 14px 0;
  border-bottom: var(--border);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.ticket-details-row.right-col {
  padding-left: 24px;
  padding-right: 0;
  border-left: var(--border);
}
.ticket-details-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gray-500);
  font-weight: 600;
}
.ticket-details-value {
  font-size: 0.9rem;
  color: var(--gray-800);
  font-weight: 400;
}

/* ── Transfer mini-modal ── */
.transfer-modal { max-width: 400px; }

/* ── Responsive adjustments ── */
@media (max-width: 760px) {
  .ticket-detail-header { gap: 4px; padding: 8px 14px; }
  .ticket-header-field { min-width: unset; }
  .ticket-details-grid { grid-template-columns: 1fr; }
  .ticket-details-row.right-col { border-left: none; padding-left: 0; }
  .ticket-tabs { overflow-x: auto; }
}

/* ── Composer dropdowns (Response Templates / Variables) ─── */
.composer-dd-wrapper {
  position: relative;
}
.composer-dd {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  background: #fff;
  border: var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 220px;
  z-index: 500;
  overflow: hidden;
}
.composer-dd-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 14px;
  width: 100%;
  background: none;
  border: none;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.composer-dd-item:last-child { border-bottom: none; }
.composer-dd-item:hover { background: var(--primary-light); }
.composer-dd-item-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--gray-800);
}
.composer-dd-item:hover .composer-dd-item-label { color: var(--primary); }
.composer-dd-item-value {
  font-size: 0.72rem;
  color: var(--gray-500);
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 260px;
}

/* ── Comment attach chip list ─────────────────────────── */
.comment-attach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 6px 12px 0;
}
.comment-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.78rem;
  color: var(--gray-700);
}

/* ── Print / PDF export ──────────────────────────────── */
@media print {
  /* Hide interactive chrome */
  nav,
  .navbar,
  .ticket-detail-header,
  .ticket-tabs,
  .comment-composer,
  .modal-overlay,
  .ticket-actions-wrapper,
  .btn:not(.btn-link) { display: none !important; }

  /* Clean card */
  body  { background: #fff !important; }
  .card {
    box-shadow: none !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  /* Show active tab content */
  .ticket-tab-content { display: block !important; padding: 12px 0 !important; }

  /* Comments */
  .comment-bubble  { box-shadow: none !important; page-break-inside: avoid; }
  .comment-thread  { page-break-inside: avoid; }

  /* Page title */
  .ticket-title    { font-size: 1.3rem !important; }
  .ticket-created-by { margin-bottom: 12px !important; }

  /* Force colours to print */
  * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; }
}

/* ── Toast Notifications ───────────────── */
.toast-container {
  position: fixed;
  top: 70px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  animation: toast-in 300ms ease;
  background: var(--gray-900);
  color: var(--gray-50);
}

.toast-info    { border-left: 4px solid var(--accent); }
.toast-success { border-left: 4px solid var(--success); }
.toast-warning { border-left: 4px solid var(--warning); }
.toast-error   { border-left: 4px solid var(--danger); }

.toast-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0.6;
  padding: 0 4px;
}
.toast-close:hover { opacity: 1; }

@keyframes toast-in {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ── KB Suggested Articles (ticket form) ── */
.kb-suggestions {
  background: var(--info-bg);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-top: 8px;
}

.kb-suggestions h4 {
  font-size: 0.85rem;
  margin-bottom: 8px;
  color: var(--accent);
}

.kb-suggestions ul {
  list-style: none;
  padding: 0;
}

.kb-suggestions li {
  padding: 4px 0;
}

.kb-suggestions a {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.85rem;
}

.kb-suggestions a:hover {
  text-decoration: underline;
}

/* ── Linked KB Articles (ticket detail) ── */
.kb-linked-articles {
  margin-top: 16px;
  padding: 12px;
  background: var(--gray-50);
  border-radius: var(--radius);
  border: var(--border);
}

.kb-linked-articles h4 {
  font-size: 0.9rem;
  margin-bottom: 8px;
  color: var(--gray-800);
}

.kb-link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--gray-200);
}

.kb-link-item:last-child {
  border-bottom: none;
}
