/* =================== PORTAL SHARED CSS =================== */
/* Used by both customer and staff static portals on Cloudflare Pages */

* { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
body { margin: 0; padding: 0; background: #f4f6f9; }

/* ---------- Login Page ---------- */
body.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0078D4 0%, #106EBE 50%, #005a9e 100%);
  position: relative; overflow-y: auto; padding: 16px 0;
}
body.login-page::before {
  content: ''; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: radial-gradient(circle at 30% 50%, rgba(0,200,255,0.06) 0%, transparent 50%),
              radial-gradient(circle at 70% 80%, rgba(255,255,255,0.04) 0%, transparent 50%);
  pointer-events: none; z-index: 0;
}
.login-wrapper { position: relative; z-index: 1; width: 420px; max-width: 100%; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo .logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 16px;
  background: linear-gradient(135deg, #0078D4 0%, #005a9e 100%);
  box-shadow: 0 8px 24px rgba(0,120,212,0.3); margin-bottom: 12px;
}
.login-logo .logo-icon i { font-size: 28px; color: #fff; }
.login-logo h1 { font-size: 22px; font-weight: 700; color: #fff; margin: 0; letter-spacing: -0.3px; }
.login-logo p { font-size: 13px; color: rgba(255,255,255,0.5); margin: 4px 0 0; font-weight: 400; }
.login-card {
  background: rgba(255,255,255,0.98); border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden;
  border: 1px solid rgba(255,255,255,0.1);
}
.login-card-body { padding: 36px 32px; }
.form-label { font-size: 13px; font-weight: 600; color: #495057; margin-bottom: 6px; }
.input-group { margin-bottom: 20px; }
.input-group-text {
  background: #f8f9fa; border: 1px solid #dee2e6; border-right: none;
  border-radius: 10px 0 0 10px; padding: 0 14px; color: #6c757d;
}
.form-control {
  border: 1px solid #dee2e6; border-left: none; border-radius: 0 10px 10px 0;
  padding: 12px 14px; font-size: 14px; height: 44px; transition: all 0.2s; background: #f8f9fa; width: 100%;
}
.form-control:focus { border-color: #0078D4; box-shadow: none; background: #fff; outline: none; }
.input-group:focus-within .input-group-text { border-color: #0078D4; background: #fff; }
.btn-login {
  background: linear-gradient(135deg, #0078D4 0%, #005a9e 100%);
  border: none; border-radius: 10px; padding: 12px; font-size: 15px;
  font-weight: 600; letter-spacing: 0.3px; height: 46px; width: 100%; color: #fff; cursor: pointer;
  box-shadow: 0 4px 12px rgba(0,120,212,0.25); transition: all 0.2s;
}
.btn-login:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(0,120,212,0.35); }
.btn-login:active { transform: translateY(0); }
.alert-login { border-radius: 10px; border: none; font-size: 13px; background: #fff5f5; color: #c92a2a; padding: 12px 14px; margin-bottom: 16px; display: none; }
.alert-login.show { display: block; }
.alert-login.alert-warning { background: #fff9e6; color: #8a6d1a; border: 1px solid #f0d98c; }
.login-footer { text-align: center; margin-top: 24px; font-size: 12px; color: rgba(255,255,255,0.4); font-weight: 400; }
.login-footer a { color: rgba(255,255,255,0.6); text-decoration: none; }
.divider { height: 1px; background: #f1f3f5; margin: 8px 0 20px; }
.back-link { text-align: center; margin-top: 16px; }
.back-link a { font-size: 13px; color: #0078D4; text-decoration: none; font-weight: 500; }
.btn-azure {
  background: #fff; color: #0078D4; border: 1px solid #0078D4; border-radius: 10px;
  padding: 12px; font-size: 14px; font-weight: 600; width: 100%; cursor: pointer; margin-top: 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: all 0.2s;
}
.btn-azure:hover { background: #f0f7ff; }

/* Staff login green theme */
body.login-page.staff-login { background: linear-gradient(135deg, #28a745 0%, #1e7e34 50%, #155724 100%); }
body.login-page.staff-login .login-logo .logo-icon { background: linear-gradient(135deg, #28a745 0%, #155724 100%); box-shadow: 0 8px 24px rgba(40,167,69,0.3); }
body.login-page.staff-login .btn-login { background: linear-gradient(135deg, #28a745 0%, #155724 100%); box-shadow: 0 4px 12px rgba(40,167,69,0.25); }
body.login-page.staff-login .form-control:focus { border-color: #28a745; }
body.login-page.staff-login .input-group:focus-within .input-group-text { border-color: #28a745; }
body.login-page.staff-login .back-link a { color: #28a745; }

@media (max-width: 480px) {
  .login-wrapper { width: 100%; padding: 0 16px; }
  .login-card-body { padding: 24px 18px; }
}

/* ---------- Portal Navbar ---------- */
.navbar-portal {
  background: linear-gradient(90deg, #0078D4, #005a9e); color: #fff;
  padding: 0 20px; height: 56px; display: flex; align-items: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15); position: sticky; top: 0; z-index: 1000;
}
.navbar-portal.staff { background: linear-gradient(90deg, #28a745, #155724); }
.navbar-portal .brand { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 8px; text-decoration: none; color: #fff; }
.navbar-portal .brand img { height: 28px; border-radius: 4px; }
.navbar-portal .nav-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.navbar-portal .nav-right .user-name { font-size: 14px; font-weight: 500; }
.navbar-portal .nav-right .auth-badge { font-size: 11px; background: rgba(255,255,255,0.2); padding: 2px 8px; border-radius: 10px; }
.navbar-portal .brand .version-badge { font-size: 11px; font-weight: 500; background: rgba(255,255,255,0.2); padding: 2px 8px; border-radius: 10px; margin-left: 4px; }
.login-footer #app-version { font-size: 12px; color: #6c757d; }
.navbar-portal .nav-right a, .navbar-portal .nav-right button {
  color: #fff; text-decoration: none; font-size: 14px; background: none; border: none; cursor: pointer;
  padding: 6px 12px; border-radius: 6px; transition: background 0.2s;
}
.navbar-portal .nav-right a:hover, .navbar-portal .nav-right button:hover { background: rgba(255,255,255,0.15); }

/* ---------- Content ---------- */
.content-wrapper { padding: 20px; max-width: 1400px; margin: 0 auto; }
.content-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.content-header h1 { font-size: 24px; font-weight: 700; color: #2c3e50; margin: 0; }
.content-header .btn-new {
  background: #0078D4; color: #fff; border: none; padding: 10px 20px; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 6px; transition: background 0.2s;
}
.content-header .btn-new:hover { background: #0069c0; }
.content-header .btn-new.staff { background: #28a745; }
.content-header .btn-new.staff:hover { background: #1e7e34; }

/* Scope toggle (My Tickets / My Company) */
.scope-toggle { display: inline-flex; border-radius: 10px; overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,0.08); }
.scope-toggle .scope-btn { background: #fff; color: #6b7280; border: 1px solid #e5e7eb; padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all 0.2s; display: flex; align-items: center; gap: 6px; }
.scope-toggle .scope-btn:hover { background: #f0fdf4; color: #00a884; }
.scope-toggle .scope-btn.active { background: #00a884; color: #fff; border-color: #00a884; }
body.dark-mode .scope-toggle .scope-btn { background: #1e293b; color: #94a3b8; border-color: #334155; }
body.dark-mode .scope-toggle .scope-btn:hover { background: #0f172a; color: #34d399; }
body.dark-mode .scope-toggle .scope-btn.active { background: #00a884; color: #fff; border-color: #00a884; }

/* ---------- Stat Cards ---------- */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex; align-items: center; gap: 16px; transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.stat-card .stat-icon {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff; flex-shrink: 0;
}
.stat-card .stat-info .stat-value { font-size: 28px; font-weight: 700; color: #2c3e50; line-height: 1; }
.stat-card .stat-info .stat-label { font-size: 12px; color: #6c757d; margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }
.stat-card.total .stat-icon { background: #0078D4; }
.stat-card.open .stat-icon { background: #ffc107; }
.stat-card.in-progress .stat-icon { background: #17a2b8; }
.stat-card.resolved .stat-icon { background: #28a745; }
.stat-card.closed .stat-icon { background: #6c757d; }
.stat-card.overdue .stat-icon { background: #dc3545; }

/* ---------- Filters ---------- */
.filter-row { display: flex; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; align-items: center; }
.filter-row input[type="text"], .filter-row select {
  padding: 10px 14px; border: 1px solid #dee2e6; border-radius: 8px; font-size: 14px; background: #fff; outline: none;
}
.filter-row input[type="text"] { flex: 1; min-width: 200px; }
.filter-row input[type="text"]:focus, .filter-row select:focus { border-color: #0078D4; }
.filter-row .badge-count { font-size: 13px; color: #6c757d; margin-left: auto; }

/* ---------- Ticket Cards ---------- */
.ticket-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); gap: 16px; }
.ticket-card {
  background: #fff; border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; border-left: 4px solid #0078D4;
}
.ticket-card:hover { transform: translateY(-2px); box-shadow: 0 4px 16px rgba(0,0,0,0.1); }
.ticket-card.priority-urgent { border-left-color: #dc3545; }
.ticket-card.priority-high { border-left-color: #fd7e14; }
.ticket-card.priority-normal { border-left-color: #0078D4; }
.ticket-card.priority-low { border-left-color: #28a745; }
.ticket-card .ticket-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 8px; }
.ticket-card .ticket-id { font-size: 12px; color: #6c757d; font-weight: 600; }
.ticket-card .ticket-subject { font-size: 16px; font-weight: 600; color: #2c3e50; margin: 4px 0 8px; }
.ticket-card .ticket-meta { display: flex; gap: 12px; font-size: 12px; color: #6c757d; flex-wrap: wrap; }
.ticket-card .ticket-meta .meta-item { display: flex; align-items: center; gap: 4px; }
.ticket-card .ticket-status { font-size: 11px; padding: 3px 10px; border-radius: 10px; font-weight: 600; }
.status-new { background: #e3f2fd; color: #0078D4; }
.status-in-progress { background: #e0f7fa; color: #17a2b8; }
.status-resolved { background: #e8f5e9; color: #28a745; }
.status-closed { background: #f5f5f5; color: #6c757d; }
.status-feedback { background: #fff3e0; color: #ff9800; }
.status-with-customer { background: #f3e5f5; color: #8e24aa; }

/* ---------- View Toggle (List/Kanban) ---------- */
.view-toggle { display: flex; gap: 0; margin-left: auto; border: 1px solid #dee2e6; border-radius: 8px; overflow: hidden; }
.view-btn {
  background: #fff; border: none; padding: 8px 12px; cursor: pointer; font-size: 14px; color: #6c757d;
  transition: all 0.2s; display: flex; align-items: center; gap: 4px;
}
.view-btn:hover { background: #f0f4f8; }
.view-btn.active { background: #0078D4; color: #fff; }
.view-btn.staff.active { background: #28a745; }

/* ---------- Kanban Board ---------- */
.kanban-board {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 16px;
  min-height: 400px; -webkit-overflow-scrolling: touch;
}
.kanban-column {
  flex: 0 0 280px; min-width: 280px; background: #f0f4f8; border-radius: 10px;
  display: flex; flex-direction: column; max-height: 70vh;
}
.kanban-column-header {
  padding: 12px 14px; font-size: 14px; font-weight: 700; color: #2c3e50;
  display: flex; align-items: center; gap: 8px; border-bottom: 2px solid #fff;
  border-radius: 10px 10px 0 0; background: #fff;
}
.kanban-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.dot-new { background: #0078D4; }
.dot-in-progress { background: #17a2b8; }
.dot-resolved { background: #28a745; }
.dot-closed { background: #6c757d; }
.dot-feedback { background: #ff9800; }
.dot-with-customer { background: #8e24aa; }
.kanban-count {
  margin-left: auto; background: #e9ecef; color: #495057; font-size: 12px;
  padding: 2px 8px; border-radius: 10px; font-weight: 600;
}
.kanban-cards {
  flex: 1; overflow-y: auto; padding: 10px; display: flex; flex-direction: column; gap: 8px;
  min-height: 80px; transition: background 0.2s;
}
.kanban-cards.drag-over { background: #d0e3f0; border: 2px dashed #0078D4; border-radius: 8px; }
.kanban-card {
  background: #fff; border-radius: 8px; padding: 10px 12px; cursor: grab;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1); border-left: 3px solid #0078D4;
  transition: box-shadow 0.2s, transform 0.15s;
}
.kanban-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); transform: translateY(-1px); }
.kanban-card.dragging { opacity: 0.5; cursor: grabbing; }
.kanban-card.priority-urgent { border-left-color: #dc3545; }
.kanban-card.priority-high { border-left-color: #fd7e14; }
.kanban-card.priority-normal { border-left-color: #0078D4; }
.kanban-card.priority-low { border-left-color: #28a745; }
.kanban-card .kanban-card-id { font-size: 11px; color: #6c757d; font-weight: 600; }
.kanban-card .kanban-card-subject { font-size: 13px; font-weight: 600; color: #2c3e50; margin: 4px 0 6px; line-height: 1.3; }
.kanban-card .kanban-card-meta { font-size: 11px; color: #6c757d; display: flex; flex-wrap: wrap; gap: 8px; }
.kanban-card .kanban-card-meta .meta-item { display: flex; align-items: center; gap: 3px; }
.kanban-card .kanban-progress { height: 4px; background: #e9ecef; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.kanban-card .kanban-progress-bar { height: 100%; border-radius: 2px; background: #0078D4; }
.kanban-card .kanban-progress-bar.high { background: #28a745; }
.kanban-empty { text-align: center; padding: 20px; color: #adb5bd; font-size: 12px; }

/* ---------- Table View (sortable) ---------- */
.table-view-wrap { background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); overflow: hidden; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.ticket-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 800px; }
.ticket-table thead { background: #f8f9fa; border-bottom: 2px solid #e9ecef; }
.ticket-table th {
  padding: 12px 14px; text-align: left; font-weight: 700; color: #495057; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.5px; white-space: nowrap; user-select: none;
}
.ticket-table th.sortable { cursor: pointer; transition: background 0.15s; }
.ticket-table th.sortable:hover { background: #e9ecef; }
.ticket-table th.sortable .sort-icon { font-size: 10px; color: #adb5bd; margin-left: 4px; }
.ticket-table th.sortable.sort-asc .sort-icon { color: #0078D4; }
.ticket-table th.sortable.sort-asc .sort-icon::before { content: "\f0de"; }
.ticket-table th.sortable.sort-desc .sort-icon { color: #0078D4; }
.ticket-table th.sortable.sort-desc .sort-icon::before { content: "\f0dd"; }
.ticket-table tbody tr { border-bottom: 1px solid #f0f0f0; cursor: pointer; transition: background 0.15s; }
.ticket-table tbody tr:hover { background: #f0f4f8; }
.ticket-table td { padding: 10px 14px; color: #2c3e50; vertical-align: middle; }
.ticket-table td.t-id { font-weight: 700; color: #6c757d; white-space: nowrap; }
.ticket-table td.t-subject { font-weight: 600; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-table td.t-status { white-space: nowrap; }
.ticket-table td.t-priority { white-space: nowrap; }
.ticket-table td.t-project, .ticket-table td.t-topic { white-space: nowrap; max-width: 140px; overflow: hidden; text-overflow: ellipsis; }
.ticket-table td.t-progress { white-space: nowrap; min-width: 90px; }
.ticket-table td.t-date { white-space: nowrap; color: #6c757d; font-size: 12px; }
.table-progress { display: flex; align-items: center; gap: 6px; }
.table-progress-bar { flex: 1; height: 6px; background: #e9ecef; border-radius: 3px; overflow: hidden; min-width: 50px; }
.table-progress-fill { height: 100%; border-radius: 3px; background: #0078D4; }
.table-progress-fill.high { background: #28a745; }
.table-progress-text { font-size: 11px; color: #6c757d; min-width: 32px; text-align: right; }
.priority-flag { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.priority-flag.urgent { background: #fee2e2; color: #dc2626; }
.priority-flag.high { background: #fed7aa; color: #ea580c; }
.priority-flag.normal { background: #fef3c7; color: #d97706; }
.priority-flag.low { background: #dbeafe; color: #2563eb; }
.priority-flag.immediate { background: #fecaca; color: #b91c1c; }
.priority-flag.default { background: #f3f4f6; color: #6b7280; }
.table-empty { text-align: center; padding: 40px 20px; color: #6c757d; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); display: none; align-items: flex-start; justify-content: center;
  z-index: 2000; padding: 20px; overflow-y: auto;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 16px; max-width: 800px; width: 100%; margin: 20px 0;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3); overflow: hidden;
}
.modal-header {
  padding: 20px 24px; border-bottom: 1px solid #eee; display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { font-size: 18px; font-weight: 700; margin: 0; color: #2c3e50; }
.modal-header .close-btn { background: none; border: none; font-size: 22px; color: #6c757d; cursor: pointer; padding: 4px 8px; }
.modal-header .close-btn:hover { color: #dc3545; }
.modal-body { padding: 24px; max-height: 70vh; overflow-y: auto; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #eee; display: flex; justify-content: flex-end; gap: 12px; }

/* ---------- Form ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: #495057; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 14px; border: 1px solid #dee2e6; border-radius: 8px; font-size: 14px; outline: none; transition: border 0.2s;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: #0078D4; }
.form-group textarea { min-height: 100px; resize: vertical; font-family: inherit; }
.form-group input[readonly] { background: #f0f0f0; color: #6c757d; cursor: not-allowed; }
/* Profile modal specific */
#profile-modal .modal-box { max-width: 520px; }
#profile-modal hr { border: none; border-top: 1px solid #eee; margin: 16px 0; }
#profile-modal .form-group input[type="password"] { font-family: inherit; }
.btn-primary {
  background: #0078D4; color: #fff; border: none; padding: 10px 24px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-primary:hover { background: #0069c0; }
.btn-primary.staff { background: #28a745; }
.btn-primary.staff:hover { background: #1e7e34; }
.btn-secondary { background: #e9ecef; color: #495057; border: none; padding: 10px 24px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-secondary:hover { background: #dee2e6; }
.btn-danger { background: #dc3545; color: #fff; border: none; padding: 8px 16px; border-radius: 8px; font-size: 13px; cursor: pointer; }

/* ---------- Ticket Detail ---------- */
.detail-section { margin-bottom: 20px; }
.detail-section h4 { font-size: 14px; font-weight: 700; color: #2c3e50; margin: 0 0 8px; text-transform: uppercase; letter-spacing: 0.5px; }

/* ---------- Survey ---------- */
.survey-section { background: #f0f7ff; border: 1px solid #bfdbfe; border-radius: 10px; padding: 16px; margin-bottom: 20px; }
.survey-title { font-size: 14px; font-weight: 700; color: #1e40af; margin-bottom: 4px; }
.survey-sub { font-size: 12px; color: #6b7280; margin-bottom: 12px; }
.survey-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.survey-row .survey-label { font-size: 13px; font-weight: 600; color: #374151; }
.survey-stars { display: inline-flex; gap: 2px; }
.survey-stars .star { font-size: 22px; color: #d1d5db; cursor: pointer; user-select: none; line-height: 1; }
.survey-stars .star.active { color: #fbbf24; }
.survey-stars .star:hover { color: #f59e0b; }
.survey-stars.readonly .star { cursor: default; }
.survey-comment { width: 100%; border: 1px solid #d1d5db; border-radius: 6px; padding: 8px; font-size: 13px; resize: vertical; min-height: 60px; box-sizing: border-box; }
.survey-result-card { background: #fff; border: 1px solid #e5e7eb; border-radius: 8px; padding: 12px; }
.survey-result-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; border-bottom: 1px solid #f3f4f6; }
.survey-result-row:last-child { border-bottom: none; }
.survey-result-row .lbl { font-size: 12px; color: #6b7280; }
.survey-result-row .val { font-weight: 700; color: #1e40af; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.detail-item .label { font-size: 12px; color: #6c757d; text-transform: uppercase; }
.detail-item .value { font-size: 14px; color: #2c3e50; font-weight: 500; }
.detail-description { background: #f8f9fa; border-radius: 8px; padding: 16px; font-size: 14px; line-height: 1.6; color: #2c3e50; }
.rich-content { line-height: 1.6; }
.rich-content img { max-width: 100%; border-radius: 8px; margin: 8px 0; }
.rich-content p { margin: 8px 0; }
.rich-content ul, .rich-content ol { margin: 8px 0; padding-left: 24px; }
.rich-content pre { background: #f1f3f5; padding: 12px; border-radius: 8px; overflow-x: auto; }
.rich-content blockquote { border-left: 3px solid #dee2e6; padding-left: 12px; color: #6c757d; margin: 8px 0; }
.rich-content table { border-collapse: collapse; width: 100%; }
.rich-content th, .rich-content td { border: 1px solid #dee2e6; padding: 8px; }
.rich-content a { color: #0078D4; }

/* ---------- Email rendering ---------- */
.email-description { font-size: 14px; line-height: 1.6; }
.email-header-card { background: #f8f9fa; border: 1px solid #e9ecef; border-radius: 8px; padding: 12px 16px; margin-bottom: 12px; }
.email-header-row { display: flex; gap: 8px; margin-bottom: 4px; font-size: 13px; }
.email-header-row:last-child { margin-bottom: 0; }
.email-header-label { min-width: 60px; font-weight: 600; color: #6c757d; }
.email-header-value { color: #2c3e50; word-break: break-word; flex: 1; }
.email-body { color: #2c3e50; white-space: pre-wrap; word-break: break-word; }
.rich-content.email-body { white-space: normal; }
.email-quote-nested { margin-top: 12px; padding-left: 14px; border-left: 3px solid #dee2e6; opacity: 0.92; }
.email-quote-nested .email-header-card { background: #f1f3f5; padding: 8px 12px; }
.email-quote-nested .email-header-label { font-size: 10px; }
.email-quote-nested .email-header-value { font-size: 12px; }
.email-quote-gt { margin-top: 10px; padding: 8px 12px; border-left: 3px solid #dee2e6; background: #f8f9fa; color: #6c757d; font-size: 13px; white-space: pre-wrap; word-break: break-word; border-radius: 0 4px 4px 0; }
.email-quote-collapsed { margin-top: 10px; }
.email-quote-summary { cursor: pointer; color: #0078D4; font-size: 12px; padding: 4px 0; user-select: none; }
.email-quote-summary:hover { text-decoration: underline; }

/* ---------- Dark mode email ---------- */
body.dark-mode .email-header-card { background: #1a1a2e; border-color: #333355; }
body.dark-mode .email-header-label { color: #9999bb; }
body.dark-mode .email-header-value { color: #ddddee; }
body.dark-mode .email-body { color: #ddddee; }
body.dark-mode .email-quote-nested { border-left-color: #444466; }
body.dark-mode .email-quote-nested .email-header-card { background: #141428; }
body.dark-mode .email-quote-gt { background: #141428; border-left-color: #444466; color: #9999bb; }

/* ---------- Notes ---------- */
.note-item { background: #f8f9fa; border-radius: 8px; padding: 12px 16px; margin-bottom: 12px; border-left: 3px solid #0078D4; }
.note-item .note-meta { font-size: 12px; color: #6c757d; margin-bottom: 4px; }
.note-item .note-body { font-size: 14px; color: #2c3e50; }
.note-item.staff-note { border-left-color: #28a745; }

/* ---------- Attachments ---------- */
.attachment-list { display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-chip {
  display: inline-flex; align-items: center; gap: 6px; background: #e9ecef; padding: 6px 12px;
  border-radius: 20px; font-size: 13px; color: #495057; text-decoration: none; transition: background 0.2s;
}
.attachment-chip:hover { background: #dee2e6; }
.attachment-chip i { color: #0078D4; }

/* ---------- Progress Slider ---------- */
.progress-slider { width: 100%; }
.progress-slider input[type="range"] { width: 100%; }
.progress-value { font-size: 14px; font-weight: 600; color: #0078D4; text-align: center; }

/* ---------- Toast ---------- */
.toast-msg {
  position: fixed; bottom: 24px; right: 24px; background: #2c3e50; color: #fff;
  padding: 14px 20px; border-radius: 10px; font-size: 14px; z-index: 3000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2); display: none; align-items: center; gap: 8px;
}
.toast-msg.show { display: flex; }
.toast-msg.success { background: #28a745; }
.toast-msg.error { background: #dc3545; }

/* ---------- Session Banner ---------- */
.session-banner {
  position: fixed; top: 56px; left: 0; right: 0; z-index: 1500;
  background: linear-gradient(90deg, #ff9800, #f57c00); color: #fff;
  padding: 10px 20px; display: none; align-items: center; justify-content: center; gap: 12px;
  font-size: 14px; box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.session-banner .countdown { font-weight: 700; font-size: 16px; }
.session-banner .btn-extend {
  background: #fff; color: #f57c00; border: none; padding: 4px 14px; border-radius: 6px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.session-banner .btn-extend:hover { background: #fff3e0; }
.session-banner .btn-logout {
  background: rgba(255,255,255,0.2); color: #fff; border: none; padding: 4px 14px; border-radius: 6px;
  font-size: 13px; cursor: pointer;
}

/* ---------- Session Status Badge (navbar) ---------- */
.session-status-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600; color: rgba(255,255,255,0.9);
  padding: 4px 10px; border-radius: 12px; background: rgba(255,255,255,0.15);
  margin-right: 4px;
}
.session-dot {
  width: 8px; height: 8px; border-radius: 50%; display: inline-block;
}
.session-dot.active { background: #4ade80; box-shadow: 0 0 6px #4ade80; animation: pulse-dot 2s infinite; }
.session-dot.expired { background: #f87171; }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---------- Session Expired Modal ---------- */
.session-modal-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.8); display: none; align-items: center; justify-content: center;
  z-index: 5000;  /* above all other modals */
}
.session-modal-overlay.show { display: flex; }
.session-modal-box {
  background: #fff; border-radius: 16px; padding: 40px; max-width: 460px; text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  border-top: 6px solid #dc3545;
  animation: modal-slide-in 0.3s ease-out;
}
@keyframes modal-slide-in { from { transform: translateY(-30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.session-modal-box .icon { font-size: 56px; color: #dc3545; margin-bottom: 16px; }
.session-modal-box h3 { font-size: 24px; font-weight: 700; color: #2c3e50; margin: 0 0 8px; }
.session-modal-box p { font-size: 15px; color: #6c757d; margin: 0 0 24px; line-height: 1.5; }
.session-modal-box .btn-login-again {
  background: #0078D4; color: #fff; border: none; padding: 12px 32px; border-radius: 10px;
  font-size: 15px; font-weight: 600; cursor: pointer;
}
.session-modal-box .btn-login-again:hover { background: #0069c0; }

/* ---------- Empty State ---------- */
.empty-state { text-align: center; padding: 60px 20px; color: #6c757d; }
.empty-state i { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 16px; }

/* ---------- Loading ---------- */
.loading-spinner { text-align: center; padding: 40px; color: #6c757d; }
.loading-spinner .spinner { display: inline-block; width: 32px; height: 32px; border: 3px solid #e9ecef; border-top-color: #0078D4; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
  .ticket-grid { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
  .navbar-portal .nav-right .user-name { display: none; }
  /* Navbar: allow wrapping and reduce gap on mobile */
  .navbar-portal { padding: 0 12px; height: auto; min-height: 56px; flex-wrap: wrap; gap: 4px; }
  .navbar-portal .brand { font-size: 16px; }
  .navbar-portal .nav-right { gap: 4px; flex-wrap: wrap; }
  .navbar-portal .nav-right a, .navbar-portal .nav-right button { padding: 6px 8px; font-size: 13px; }
  /* Content header wraps */
  .content-header h1 { font-size: 20px; }
  .content-header .btn-new { padding: 8px 14px; font-size: 13px; }
  /* Filter row stacks */
  .filter-row { flex-direction: column; align-items: stretch; gap: 8px; }
  .filter-row input[type="text"] { min-width: 0; width: 100%; }
  .filter-row select { width: 100%; }
  .filter-row .badge-count { margin-left: 0; text-align: center; }
  .view-toggle { margin-left: 0; align-self: stretch; }
  .view-btn { flex: 1; justify-content: center; }
  /* Kanban: columns scroll horizontally, cards narrower */
  .kanban-column { flex: 0 0 240px; min-width: 240px; }
  /* Modal full width on mobile */
  .modal-overlay { padding: 8px; }
  .modal-box { max-width: 100% !important; border-radius: 12px; }
  .modal-header { padding: 14px 16px; }
  .modal-header h3 { font-size: 16px; }
  .modal-body { padding: 16px; max-height: 80vh; }
  /* Session banner wraps */
  .session-banner { flex-wrap: wrap; gap: 4px; padding: 8px 12px; font-size: 12px; }
  .session-banner .countdown { font-size: 14px; }
  .session-banner .btn-extend, .session-banner .btn-logout { padding: 4px 10px; font-size: 12px; }
  /* Session modal full width */
  .session-modal-box { width: 96%; padding: 28px 20px; }
}
@media (max-width: 480px) {
  .stat-row { grid-template-columns: 1fr; }
  .content-wrapper { padding: 12px; }
  /* Navbar: hide button text, show only icons on very small screens */
  .navbar-portal .brand { font-size: 14px; }
  .navbar-portal .nav-right a, .navbar-portal .nav-right button { padding: 6px; font-size: 12px; }
  .content-header h1 { font-size: 18px; }
  .modal-body { padding: 12px; }
  /* Kanban: columns even narrower on phones */
  .kanban-column { flex: 0 0 200px; min-width: 200px; }
}

/* ── Topics Modal (v2.9.10) ─────────────────────── */
.topics-list { display: flex; flex-direction: column; gap: 10px; }
.topic-card {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px 14px;
  background: #f8fafc;
}
.topic-category { font-weight: 600; font-size: 15px; color: #2c3e50; margin-bottom: 4px; }
.topic-desc { font-size: 13px; color: #64748b; margin-bottom: 6px; line-height: 1.5; }
.topic-sla { display: flex; gap: 8px; flex-wrap: wrap; }
.sla-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 11px; padding: 3px 8px; border-radius: 4px;
  background: #e0f2fe; color: #0369a1;
}
.sla-badge:last-child { background: #dcfce7; color: #15803d; }

/* ── Error Modal (v2.9.11) ──────────────────────── */
.error-modal-box { max-width: 600px; }
.error-header { background: #dc2626; color: #fff; }
.error-header h3 { color: #fff; }
.error-header .close-btn { color: #fff; }
.error-detail {
  background: #fef2f2; border: 1px solid #fecaca;
  border-radius: 8px; padding: 14px; margin: 12px 0;
}
.error-detail .error-context {
  font-size: 13px; color: #7f1d1d; font-weight: 600; margin-bottom: 6px;
}
.error-detail .error-status {
  display: inline-block; font-size: 11px; padding: 2px 8px;
  border-radius: 4px; background: #fecaca; color: #991b1b; margin-bottom: 8px;
}
.error-detail .error-message {
  font-family: 'Courier New', monospace; font-size: 13px;
  color: #1f2937; white-space: pre-wrap; word-break: break-all;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 6px;
  padding: 10px; max-height: 300px; overflow-y: auto;
}
.error-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.btn-copy-error {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: 1px solid #d1d5db; border-radius: 6px;
  background: #f9fafb; color: #374151; cursor: pointer; font-size: 13px;
  transition: all 0.2s;
}
.btn-copy-error:hover { background: #f3f4f6; border-color: #9ca3af; }
.btn-copy-error.copied { background: #dcfce7; border-color: #86efac; color: #15803d; }

/* ── Quill WYSIWYG Editor ─────────────────────────── */
.ql-toolbar { border-radius: 6px 6px 0 0; border-color: #ddd; }
.ql-container { border-radius: 0 0 6px 6px; border-color: #ddd; min-height: 120px; font-size: 14px; }
.ql-editor { min-height: 120px; padding: 12px; line-height: 1.6; }
.ql-editor.ql-blank::before { color: #aaa; font-style: italic; }
.ql-snow .ql-picker-label { color: #555; }

/* ── SLA Badges & Detail (v2.9.11) ────────────────── */
.sla-row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.sla-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600;
  white-space: nowrap;
}
.sla-badge.sla-ok { background: #d4edda; color: #155724; }
.sla-badge.sla-warning { background: #fff3cd; color: #856404; }
.sla-badge.sla-breached { background: #f8d7da; color: #721c24; animation: sla-pulse 1.5s infinite; }
.sla-badge.sla-closed { background: #e2e3e5; color: #6c757d; }
@keyframes sla-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }
.sla-detail-row {
  padding: 12px; border-radius: 8px; margin-bottom: 10px;
  border-left: 4px solid #dee2e6; background: #f8f9fa;
}
.sla-detail-row.sla-ok { border-left-color: #28a745; }
.sla-detail-row.sla-warning { border-left-color: #ffc107; background: #fff8e1; }
.sla-detail-row.sla-breached { border-left-color: #dc3545; background: #fff5f5; }
.sla-detail-label { font-weight: 600; font-size: 14px; margin-bottom: 6px; color: #2c3e50; }
.sla-detail-info { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; margin-bottom: 8px; }
.sla-detail-target { color: #6c757d; }
.sla-detail-remaining { font-weight: 600; }
.sla-detail-row.sla-ok .sla-detail-remaining { color: #28a745; }
.sla-detail-row.sla-warning .sla-detail-remaining { color: #d39e00; }
.sla-detail-row.sla-breached .sla-detail-remaining { color: #dc3545; }
.sla-detail-status { font-weight: 600; text-transform: uppercase; font-size: 11px; padding: 2px 6px; border-radius: 3px; }
.sla-detail-row.sla-ok .sla-detail-status { background: #d4edda; color: #155724; }
.sla-detail-row.sla-warning .sla-detail-status { background: #fff3cd; color: #856404; }
.sla-detail-row.sla-breached .sla-detail-status { background: #f8d7da; color: #721c24; }
.sla-progress-bar { height: 6px; background: #e9ecef; border-radius: 3px; overflow: hidden; }
.sla-progress-fill { height: 100%; transition: width 0.3s ease; border-radius: 3px; }
.sla-fill-ok { background: #28a745; }
.sla-fill-warning { background: #ffc107; }
.sla-fill-breached { background: #dc3545; }

/* ── Image Lightbox + Attachment Thumbnails (v2.9.11) ─── */
.att-thumb-wrap {
  position: relative; display: inline-block;
  margin: 4px; border-radius: 8px; overflow: hidden;
  border: 1px solid #e5e7eb; transition: transform 0.2s, box-shadow 0.2s;
}
.att-thumb-wrap:hover { transform: scale(1.03); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.att-thumb {
  width: 100px; height: 100px; object-fit: cover; cursor: pointer;
  display: block; background: #f9fafb;
}
.att-thumb-dl {
  position: absolute; bottom: 4px; right: 4px;
  background: rgba(0,0,0,0.6); color: #fff;
  padding: 4px 6px; border-radius: 4px; font-size: 11px;
  opacity: 0; transition: opacity 0.2s; text-decoration: none;
}
.att-thumb-wrap:hover .att-thumb-dl { opacity: 1; }
.att-thumb-dl:hover { background: rgba(0,0,0,0.8); }

.lightbox-overlay {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.85); z-index: 10000;
  display: none; align-items: center; justify-content: center;
  cursor: pointer; padding: 20px;
}
.lightbox-overlay.show { display: flex; }
.lightbox-overlay img {
  max-width: 90%; max-height: 90%; object-fit: contain;
  border-radius: 8px; box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  cursor: default;
}
.lightbox-close {
  position: absolute; top: 16px; right: 24px;
  background: rgba(255,255,255,0.15); color: #fff;
  border: none; font-size: 32px; cursor: pointer;
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.lightbox-close:hover { background: rgba(255,255,255,0.3); }

/* ═══════════════════════════════════════════════════════════════
   v2.9.23 — Modern UI Refresh + Dark Mode
   ═══════════════════════════════════════════════════════════════ */

/* ── CSS Variables (theme tokens) ── */
:root {
  --p-bg: #f4f6f9;
  --p-surface: #ffffff;
  --p-surface-hover: #f8fafc;
  --p-border: #e5e7eb;
  --p-text: #1e293b;
  --p-text-muted: #64748b;
  --p-text-light: #94a3b8;
  --p-primary: #0078D4;
  --p-primary-dark: #005a9e;
  --p-shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --p-shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --p-shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --p-radius: 12px;
  --p-radius-sm: 8px;
  --p-transition: 0.2s ease;
}

/* ── Dark mode variables ── */
body.dark-mode {
  --p-bg: #0f172a;
  --p-surface: #1e293b;
  --p-surface-hover: #334155;
  --p-border: #334155;
  --p-text: #e2e8f0;
  --p-text-muted: #94a3b8;
  --p-text-light: #64748b;
  --p-shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --p-shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --p-shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

/* ── Base overrides ── */
body { background: var(--p-bg); color: var(--p-text); transition: background 0.3s, color 0.3s; }

/* ── Navbar improvements ── */
.navbar-portal {
  background: linear-gradient(90deg, var(--p-primary), var(--p-primary-dark));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(0,0,0,0.1);
}
.navbar-portal.staff { background: linear-gradient(90deg, #16a34a, #15803d); }
body.dark-mode .navbar-portal { background: linear-gradient(90deg, #1e293b, #0f172a); border-bottom-color: #334155; }
body.dark-mode .navbar-portal.staff { background: linear-gradient(90deg, #14532d, #052e16); }
.navbar-portal .brand { transition: opacity var(--p-transition); }
.navbar-portal .brand:hover { opacity: 0.85; }

/* ── Stat cards — modern flat design ── */
.stat-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius);
  padding: 18px 20px;
  box-shadow: var(--p-shadow-sm);
  transition: transform var(--p-transition), box-shadow var(--p-transition);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent, var(--p-primary));
}
.stat-card.total { --accent: #0078D4; }
.stat-card.open { --accent: #f59e0b; }
.stat-card.in-progress { --accent: #0891b2; }
.stat-card.resolved { --accent: #16a34a; }
.stat-card.closed { --accent: #6b7280; }
.stat-card.overdue { --accent: #dc2626; }
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--p-shadow-md); }
.stat-card .stat-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff; flex-shrink: 0;
  background: var(--accent, var(--p-primary));
}
.stat-card .stat-info .stat-value { font-size: 26px; font-weight: 800; color: var(--p-text); line-height: 1; }
.stat-card .stat-info .stat-label { font-size: 11px; color: var(--p-text-muted); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; font-weight: 600; }
body.dark-mode .stat-card { background: var(--p-surface); border-color: var(--p-border); }
body.dark-mode .stat-card .stat-info .stat-value { color: var(--p-text); }

/* ── Ticket cards — improved ── */
.ticket-card {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius);
  padding: 18px;
  box-shadow: var(--p-shadow-sm);
  cursor: pointer;
  transition: transform var(--p-transition), box-shadow var(--p-transition), border-color var(--p-transition);
  border-left: 4px solid var(--accent, var(--p-primary));
}
.ticket-card:hover { transform: translateY(-2px); box-shadow: var(--p-shadow-md); border-color: var(--p-primary); }
.ticket-card .ticket-subject { font-size: 15px; font-weight: 700; color: var(--p-text); margin: 4px 0 8px; line-height: 1.3; }
.ticket-card .ticket-id { font-size: 12px; color: var(--p-text-muted); font-weight: 600; }
.ticket-card .ticket-meta { color: var(--p-text-muted); }
body.dark-mode .ticket-card { background: var(--p-surface); border-color: var(--p-border); }
body.dark-mode .ticket-card .ticket-subject { color: var(--p-text); }

/* ── Filter row — modern inputs ── */
.filter-row input[type="text"], .filter-row select {
  padding: 10px 14px;
  border: 1px solid var(--p-border);
  border-radius: var(--p-radius-sm);
  font-size: 14px;
  background: var(--p-surface);
  color: var(--p-text);
  outline: none;
  transition: border-color var(--p-transition), box-shadow var(--p-transition);
}
.filter-row input[type="text"]:focus, .filter-row select:focus {
  border-color: var(--p-primary);
  box-shadow: 0 0 0 3px rgba(0,120,212,0.12);
}
body.dark-mode .filter-row input[type="text"], body.dark-mode .filter-row select {
  background: var(--p-surface); border-color: var(--p-border); color: var(--p-text);
}

/* ── View toggle — pill style ── */
.view-toggle { border-radius: 10px; overflow: hidden; border: 1px solid var(--p-border); }
.view-btn { background: var(--p-surface); color: var(--p-text-muted); border: none; padding: 8px 14px; cursor: pointer; transition: all var(--p-transition); }
.view-btn:hover { background: var(--p-surface-hover); }
.view-btn.active { background: var(--p-primary); color: #fff; }
.view-btn.staff.active { background: #16a34a; }
body.dark-mode .view-btn { background: var(--p-surface); color: var(--p-text-muted); }
body.dark-mode .view-btn:hover { background: var(--p-surface-hover); }

/* ── Table view — modern ── */
.table-view-wrap { background: var(--p-surface); border-radius: var(--p-radius); box-shadow: var(--p-shadow-sm); overflow: hidden; border: 1px solid var(--p-border); }
.ticket-table thead { background: var(--p-surface-hover); }
.ticket-table th { color: var(--p-text-muted); border-bottom: 2px solid var(--p-border); }
.ticket-table tbody tr { border-bottom: 1px solid var(--p-border); }
.ticket-table tbody tr:hover { background: var(--p-surface-hover); }
.ticket-table td { color: var(--p-text); }
.ticket-table td.t-id { color: var(--p-text-muted); }
.ticket-table td.t-date { color: var(--p-text-muted); }
body.dark-mode .table-view-wrap { background: var(--p-surface); border-color: var(--p-border); }
body.dark-mode .ticket-table thead { background: var(--p-surface-hover); }
body.dark-mode .ticket-table th { color: var(--p-text-muted); border-bottom-color: var(--p-border); }
body.dark-mode .ticket-table tbody tr { border-bottom-color: var(--p-border); }
body.dark-mode .ticket-table tbody tr:hover { background: var(--p-surface-hover); }
body.dark-mode .ticket-table td { color: var(--p-text); }

/* ── Kanban — modern ── */
.kanban-column { background: var(--p-surface-hover); border: 1px solid var(--p-border); }
.kanban-column-header { background: var(--p-surface); border-bottom: 2px solid var(--p-border); color: var(--p-text); }
.kanban-card { background: var(--p-surface); border: 1px solid var(--p-border); box-shadow: var(--p-shadow-sm); }
.kanban-card:hover { box-shadow: var(--p-shadow-md); }
.kanban-card .kanban-card-subject { color: var(--p-text); }
.kanban-card .kanban-card-meta { color: var(--p-text-muted); }
.kanban-cards.drag-over { background: rgba(0,120,212,0.1); border-color: var(--p-primary); }
body.dark-mode .kanban-column { background: var(--p-surface-hover); border-color: var(--p-border); }
body.dark-mode .kanban-column-header { background: var(--p-surface); border-bottom-color: var(--p-border); color: var(--p-text); }
body.dark-mode .kanban-card { background: var(--p-surface); border-color: var(--p-border); }
body.dark-mode .kanban-card .kanban-card-subject { color: var(--p-text); }

/* ── Modal — modern ── */
.modal-box {
  background: var(--p-surface);
  border-radius: 16px;
  box-shadow: var(--p-shadow-lg);
  border: 1px solid var(--p-border);
}
.modal-header { border-bottom: 1px solid var(--p-border); }
.modal-header h3 { color: var(--p-text); }
.modal-header .close-btn { color: var(--p-text-muted); }
.modal-body { color: var(--p-text); }
.modal-footer { border-top: 1px solid var(--p-border); }
body.dark-mode .modal-box { background: var(--p-surface); border-color: var(--p-border); }
body.dark-mode .modal-header { border-bottom-color: var(--p-border); }
body.dark-mode .modal-header h3 { color: var(--p-text); }
body.dark-mode .modal-body { color: var(--p-text); }
body.dark-mode .modal-footer { border-top-color: var(--p-border); }

/* ── Form inputs — modern ── */
.form-group input, .form-group select, .form-group textarea {
  background: var(--p-surface);
  border: 1px solid var(--p-border);
  color: var(--p-text);
  border-radius: var(--p-radius-sm);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--p-primary);
  box-shadow: 0 0 0 3px rgba(0,120,212,0.12);
}
.form-group label { color: var(--p-text-muted); }
body.dark-mode .form-group input, body.dark-mode .form-group select, body.dark-mode .form-group textarea {
  background: var(--p-surface); border-color: var(--p-border); color: var(--p-text);
}

/* ── Detail section — modern ── */
.detail-section h4 { color: var(--p-text); }
.detail-item .label { color: var(--p-text-muted); }
.detail-item .value { color: var(--p-text); }
.detail-description { background: var(--p-surface-hover); color: var(--p-text); border: 1px solid var(--p-border); }
body.dark-mode .detail-description { background: var(--p-surface-hover); color: var(--p-text); }

/* ── Notes — modern ── */
.note-item { background: var(--p-surface-hover); border: 1px solid var(--p-border); border-left: 3px solid var(--p-primary); }
.note-item .note-meta { color: var(--p-text-muted); }
.note-item .note-body { color: var(--p-text); }
body.dark-mode .note-item { background: var(--p-surface-hover); border-color: var(--p-border); }

/* ── Content header ── */
.content-header h1 { color: var(--p-text); }
body.dark-mode .content-header h1 { color: var(--p-text); }

/* ── Empty state ── */
.empty-state { color: var(--p-text-muted); }
body.dark-mode .empty-state { color: var(--p-text-muted); }

/* ── Loading spinner ── */
.loading-spinner { color: var(--p-text-muted); }
.loading-spinner .spinner { border-color: var(--p-border); border-top-color: var(--p-primary); }

/* ── Rich content ── */
.rich-content { color: var(--p-text); }
.rich-content a { color: var(--p-primary); }
body.dark-mode .rich-content { color: var(--p-text); }
body.dark-mode .rich-content pre { background: var(--p-surface-hover); }

/* ── Email rendering dark mode ── */
body.dark-mode .email-header-card { background: var(--p-surface-hover); border-color: var(--p-border); }
body.dark-mode .email-header-label { color: var(--p-text-muted); }
body.dark-mode .email-header-value { color: var(--p-text); }
body.dark-mode .email-body { color: var(--p-text); }

/* ── SLA detail dark mode ── */
body.dark-mode .sla-detail-row { background: var(--p-surface-hover); border-left-color: var(--p-border); }
body.dark-mode .sla-detail-label { color: var(--p-text); }
body.dark-mode .sla-detail-target { color: var(--p-text-muted); }

/* ── Session modal dark mode ── */
body.dark-mode .session-modal-box { background: var(--p-surface); box-shadow: var(--p-shadow-lg); }
body.dark-mode .session-modal-box h3 { color: var(--p-text); }
body.dark-mode .session-modal-box p { color: var(--p-text-muted); }

/* ── Topics modal dark mode ── */
body.dark-mode .topic-card { background: var(--p-surface-hover); border-color: var(--p-border); }
body.dark-mode .topic-category { color: var(--p-text); }
body.dark-mode .topic-desc { color: var(--p-text-muted); }

/* ── Error modal dark mode ── */
body.dark-mode .error-detail { background: var(--p-surface-hover); border-color: var(--p-border); }
body.dark-mode .error-detail .error-message { background: var(--p-surface); border-color: var(--p-border); color: var(--p-text); }

/* ── Quill editor dark mode ── */
body.dark-mode .ql-toolbar { border-color: var(--p-border); background: var(--p-surface); }
body.dark-mode .ql-container { border-color: var(--p-border); }
body.dark-mode .ql-editor { background: var(--p-surface); color: var(--p-text); }
body.dark-mode .ql-snow .ql-picker-label { color: var(--p-text-muted); }
body.dark-mode .ql-snow.ql-toolbar button:hover .ql-fill, body.dark-mode .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--p-text); }

/* ── Dark mode toggle button ── */
.dark-mode-toggle {
  background: rgba(255,255,255,0.15); border: none; color: #fff;
  padding: 6px 10px; border-radius: 8px; cursor: pointer;
  font-size: 14px; transition: background var(--p-transition);
}
.dark-mode-toggle:hover { background: rgba(255,255,255,0.25); }
body.dark-mode .dark-mode-toggle { background: rgba(255,255,255,0.1); }

/* ── Login page dark mode ── */
body.dark-mode.login-page { background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%); }
body.dark-mode.login-page .login-card { background: var(--p-surface); border-color: var(--p-border); }
body.dark-mode.login-page .form-label { color: var(--p-text-muted); }
body.dark-mode.login-page .form-control { background: var(--p-surface); border-color: var(--p-border); color: var(--p-text); }
body.dark-mode.login-page .input-group-text { background: var(--p-surface-hover); border-color: var(--p-border); color: var(--p-text-muted); }

/* ── Responsive improvements ── */
@media (max-width: 768px) {
  .stat-card { padding: 14px 16px; }
  .stat-card .stat-icon { width: 38px; height: 38px; font-size: 16px; }
  .stat-card .stat-info .stat-value { font-size: 22px; }
  .ticket-card { padding: 14px; }
  .modal-box { border-radius: 12px; }
}
@media (max-width: 480px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 12px 14px; }
  .stat-card .stat-info .stat-value { font-size: 20px; }
}
