.tk-wrap{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.tk-topbar{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  flex-wrap:wrap;
}

.tk-topbar h3{
  margin:0 0 4px;
}

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

.tk-btn{
  border:0 !important;
  border-radius:10px;
  padding:10px 14px;
  cursor:pointer;
  font-weight:600;
  background:#e5e7eb !important;
  color:#111827 !important;
}

.tk-btn-primary{
  background:#111827 !important;
  color:#fff !important;
}

.tk-btn-success{
  background:#dcfce7 !important;
  color:#166534 !important;
}

.tk-btn-danger{
  background:#fee2e2 !important;
  color:#991b1b !important;
}

.tk-btn-warning{
  background:#fef3c7 !important;
  color:#92400e !important;
}

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

.tk-filter{
  border:1px solid #e5e7eb !important;
  border-radius:999px;
  padding:8px 12px;
  background:#fff !important;
  color:#111827 !important;
  cursor:pointer;
}

.tk-filter.active{
  background:#111827 !important;
  color:#fff !important;
}

.tk-search{
  min-width:220px;
  flex:1;
  max-width:380px;
  border:1px solid #d1d5db;
  border-radius:10px;
  padding:9px 12px;
}

.tk-kpis{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  gap:12px;
}

.tk-kpi{
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:14px;
  padding:14px;
}

.tk-kpi span{
  display:block;
  color:#6b7280;
  font-size:12px;
}

.tk-kpi strong{
  display:block;
  margin-top:4px;
  font-size:20px;
}

.tk-table-wrap{
  overflow:auto;
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:14px;
}

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

.tk-table th,
.tk-table td{
  padding:12px;
  border-bottom:1px solid #f1f5f9;
  text-align:left;
  white-space:nowrap;
}

.tk-table th{
  font-size:12px;
  color:#64748b;
}

.tk-status,
.tk-priority{
  display:inline-flex;
  align-items:center;
  padding:5px 9px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
}

.tk-status-open{
  background:#dbeafe;
  color:#1d4ed8;
}

.tk-status-assigned{
  background:#ede9fe;
  color:#6d28d9;
}

.tk-status-pending{
  background:#fef3c7;
  color:#92400e;
}

.tk-status-resolved{
  background:#dcfce7;
  color:#166534;
}

.tk-status-closed,
.tk-status-cancelled{
  background:#f3f4f6;
  color:#475569;
}

.tk-priority-low{
  background:#f3f4f6;
  color:#475569;
}

.tk-priority-normal{
  background:#dbeafe;
  color:#1d4ed8;
}

.tk-priority-high{
  background:#ffedd5;
  color:#c2410c;
}

.tk-priority-urgent{
  background:#fee2e2;
  color:#991b1b;
}

.tk-empty{
  padding:32px;
  text-align:center;
  color:#6b7280;
}

.tk-modal-backdrop{
  position:fixed;
  inset:0;
  z-index:9999;
  background:rgba(15,23,42,.45);
  display:flex;
  justify-content:center;
  align-items:center;
  padding:20px;
}

.tk-modal{
  width:min(900px,100%);
  max-height:92vh;
  overflow:auto;
  background:#fff;
  border-radius:16px;
  padding:20px;
}

.tk-modal-head{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
  margin-bottom:18px;
}

.tk-form-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:14px;
}

.tk-form-grid label{
  display:flex;
  flex-direction:column;
  gap:6px;
  font-size:13px;
  font-weight:600;
}

.tk-form-grid input,
.tk-form-grid select,
.tk-form-grid textarea{
  width:100%;
  box-sizing:border-box;
  border:1px solid #d1d5db;
  border-radius:10px;
  padding:10px 12px;
  background:#fff;
  color:#111827;
}

.tk-full{
  grid-column:1/-1;
}

.tk-modal-actions{
  display:flex;
  justify-content:flex-end;
  gap:8px;
  flex-wrap:wrap;
  margin-top:18px;
}

.tk-section{
  margin-top:22px;
  padding-top:18px;
  border-top:1px solid #e5e7eb;
}

.tk-section h4{
  margin:0 0 12px;
}

.tk-note{
  border:1px solid #e5e7eb;
  background:#f9fafb;
  border-radius:12px;
  padding:12px;
  margin-bottom:10px;
}

.tk-note-meta{
  font-size:12px;
  color:#64748b;
  margin-bottom:6px;
}

.tk-history-item{
  border-left:3px solid #e5e7eb;
  padding:8px 12px;
  margin-bottom:8px;
}

.tk-history-meta{
  font-size:12px;
  color:#64748b;
}

.tk-error{
  margin-top:10px;
  padding:10px 12px;
  background:#fee2e2;
  color:#991b1b;
  border-radius:10px;
}

@media(max-width:800px){
  .tk-kpis{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

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

  .tk-full{
    grid-column:auto;
  }
}

#ticketBadge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:20px;
  height:20px;
  padding:0 6px;
  margin-left:8px;
  border-radius:999px;
  background:#dc2626 !important;
  color:#ffffff !important;
  font-size:11px;
  font-weight:700;
  line-height:1;
}

#ticketBadge.hidden{
  display:none !important;
}

#tickets input[type="file"],
#ticketModal input[type="file"]{
  width:100%;
  box-sizing:border-box;
  padding:10px;
  border:1px solid #d1d5db;
  border-radius:10px;
  background:#ffffff;
  color:#111827;
}

/* Ticket SLA / overdue */
.tk-overdue{
  display:inline-flex;
  align-items:center;
  padding:5px 9px;
  border-radius:999px;
  background:#fee2e2 !important;
  color:#991b1b !important;
  font-size:12px;
  font-weight:700;
}

.tk-overdue-alert{
  margin-top:8px;
  display:inline-block;
  padding:8px 10px;
  border-radius:10px;
  background:#fee2e2;
  color:#991b1b;
  font-size:13px;
  font-weight:700;
}

.tk-kpi-overdue strong{
  color:#b91c1c;
}

.tk-table tr:has(.tk-overdue){
  background:#fff7f7;
}

@media(min-width:1000px){
  .tk-kpis{
    grid-template-columns:repeat(5,minmax(0,1fr));
  }
}
