/* ===== VARIABLES ===== */
:root {
  --bg: #0d1117;
  --bg-card: #161b22;
  --bg-sidebar: #010409;
  --bg-hover: #1f2937;
  --border: #30363d;
  --border-light: #21262d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #6e7681;
  --blue: #58a6ff;
  --blue-dark: #1f6feb;
  --green: #3fb950;
  --green-dark: #238636;
  --red: #f85149;
  --red-dark: #da3633;
  --yellow: #d29922;
  --purple: #a5d6ff;
  --sidebar-w: 260px;
  --radius: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}
a { color: var(--blue); text-decoration: none; cursor: pointer; }
button { cursor: pointer; font-family: inherit; font-size: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ===== UTILITIES ===== */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: .85rem; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-yellow { color: var(--yellow); }
.text-blue { color: var(--blue); }

/* ===== LOGIN ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0d1117 0%, #161b22 50%, #0d1117 100%);
}
.login-container { width: 100%; max-width: 920px; padding: 1rem; }
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem 2rem;
  box-shadow: var(--shadow);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo-img { width: 100%; max-width: 860px; height: auto; display: block; margin: 0 auto 1rem; border-radius: 16px; box-shadow: 0 10px 40px rgba(0,0,0,0.45), 0 3px 10px rgba(0,0,0,0.25); }
.login-logo h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); margin: .5rem 0 .2rem; }
.login-logo p { color: var(--text-muted); font-size: .9rem; }
.login-footer { text-align: center; color: var(--text-dim); font-size: .75rem; margin-top: 1.5rem; }

/* ===== FORMS ===== */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; color: var(--text-muted); font-size: .85rem; margin-bottom: .3rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: .6rem .9rem;
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
textarea { resize: vertical; min-height: 80px; }
.search-input { max-width: 200px; }
.select-input { max-width: 180px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  font-weight: 500;
  font-size: .875rem;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary { background: var(--blue-dark); color: #fff; border-color: var(--blue); }
.btn-primary:hover { background: var(--blue); }
.btn-secondary { background: var(--bg-card); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: var(--blue); color: var(--blue); }
.btn-danger { background: transparent; color: var(--red); border-color: var(--red-dark); }
.btn-danger:hover { background: var(--red-dark); color: #fff; }
.btn-success { background: var(--green-dark); color: #fff; }
.btn-success:hover { background: var(--green); }
.btn-sm { padding: .3rem .7rem; font-size: .8rem; }
.btn-full { width: 100%; justify-content: center; padding: .75rem; }
.btn-icon {
  background: none;
  border: none;
  color: rgba(255,255,255,0.45);
  font-size: 1rem;
  padding: .3rem .5rem;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.btn-icon:hover { color: #fff; background: rgba(255,255,255,0.1); }
.btn.copied { background: var(--green-dark) !important; border-color: var(--green) !important; color: #fff !important; }

/* ===== ALERTS ===== */
.alert { padding: .7rem 1rem; border-radius: var(--radius); font-size: .875rem; margin-top: .75rem; }
.alert-error { background: rgba(248,81,73,.1); border: 1px solid var(--red-dark); color: var(--red); }
.alert-success { background: rgba(63,185,80,.1); border: 1px solid var(--green-dark); color: var(--green); }

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

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: linear-gradient(160deg, #0f172a 0%, #1e3a5f 55%, #0a0f1e 100%);
  border-right: 1px solid rgba(255,255,255,0.07);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow: hidden;
}
/* Quadretti overlay */
.sidebar::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 30px 30px;
  pointer-events: none;
  z-index: 0;
}
.sidebar-header {
  position: relative; z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
  padding: .75rem .3rem .65rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  font-weight: 700;
  font-size: .9rem;
  color: #fff;
}
.sidebar-logo-img { width: 100%; height: auto; border-radius: 10px; display: block; box-shadow: 0 3px 12px rgba(0,0,0,0.5); }
.sidebar-brand { font-size: .95rem; font-weight: 700; line-height: 1.2; text-align: center; color: #fff; }
.sidebar-nav { position: relative; z-index: 1; flex: 1; padding: .5rem .5rem; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .6rem .9rem;
  color: rgba(255,255,255,0.6);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.05);
  box-shadow: 0 2px 6px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06);
  transition: all .15s;
  cursor: pointer;
}
.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,0.11);
  box-shadow: 0 4px 12px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.12);
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.13);
}
.nav-item.active {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  border-color: rgba(255,255,255,0.18);
  box-shadow: 0 4px 16px rgba(79,70,229,0.55), inset 0 1px 0 rgba(255,255,255,0.2);
}
.nav-icon { font-size: 1.05rem; flex-shrink: 0; }
.nav-label { font-size: .83rem; font-weight: 500; }
.sidebar-footer {
  position: relative; z-index: 1;
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .75rem 1rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.user-pill { display: flex; align-items: center; gap: .5rem; flex: 1; overflow: hidden; }
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(79,70,229,0.5);
}
.user-info { overflow: hidden; }
.user-name { font-size: .8rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: rgba(255,255,255,0.9); }
.user-role { font-size: .7rem; color: rgba(255,255,255,0.45); text-transform: capitalize; }

/* ===== MAIN ===== */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 1.5rem;
  max-width: calc(100vw - var(--sidebar-w));
  overflow-x: hidden;
  position: relative;
}
.main::before {
  content: '';
  position: fixed;
  top: 50%;
  left: calc(50% + calc(var(--sidebar-w) / 2));
  transform: translate(-50%, -50%);
  width: 720px;
  aspect-ratio: 680/280;
  background-image: url('/logo.svg');
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.07;
  pointer-events: none;
  z-index: 0;
}

/* ===== PAGE ===== */
.page { display: block; }
.page.hidden { display: none; }
.page-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .75rem;
  margin-bottom: 1.5rem;
}
.page-header h2 { font-size: 1.3rem; font-weight: 700; flex: 1; }
.page-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }

/* ===== STATS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  border-radius: 14px;
  padding: 1.4rem 1rem 1.2rem;
  text-align: center;
  transition: transform .18s, box-shadow .18s;
  border: 1px solid rgba(255,255,255,0.07);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 20px 20px;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 8px 28px rgba(0,0,0,0.4); }
.stat-card.blue  { background: linear-gradient(135deg, #1d3a6b 0%, #1e3a5f 100%); box-shadow: 0 4px 16px rgba(30,58,95,0.5); }
.stat-card.green { background: linear-gradient(135deg, #064e3b 0%, #065f46 100%); box-shadow: 0 4px 16px rgba(6,78,59,0.5); }
.stat-card.yellow{ background: linear-gradient(135deg, #78350f 0%, #92400e 100%); box-shadow: 0 4px 16px rgba(120,53,15,0.5); }
.stat-card.purple{ background: linear-gradient(135deg, #3b1e6b 0%, #4c1d95 100%); box-shadow: 0 4px 16px rgba(76,29,149,0.5); }
.stat-card.orange{ background: linear-gradient(135deg, #7c2d12 0%, #9a3412 100%); box-shadow: 0 4px 16px rgba(154,52,18,0.5); }
.stat-icon { font-size: 2rem; margin-bottom: .5rem; position: relative; z-index: 1; }
.stat-num { font-size: 2.2rem; font-weight: 800; line-height: 1; position: relative; z-index: 1; color: #fff; }
.stat-lbl { color: rgba(255,255,255,0.65); font-size: .78rem; margin-top: .35rem; position: relative; z-index: 1; font-weight: 500; }

/* ===== DASHBOARD QUICKLINKS GRID ===== */
.dash-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: .85rem;
  padding: 1rem;
}
.dash-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: 1.2rem .8rem 1rem;
  border-radius: 12px;
  background: linear-gradient(145deg, #1a2233, #1e2940);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 3px 10px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.06);
  cursor: pointer;
  text-decoration: none;
  transition: all .17s;
  text-align: center;
}
.dash-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
  border-color: rgba(88,166,255,0.3);
  background: linear-gradient(145deg, #1e2a40, #243250);
}
.dash-tile-icon { font-size: 2rem; line-height: 1; }
.dash-tile-name { font-size: .82rem; font-weight: 700; color: #e6edf3; letter-spacing: .01em; }
.dash-tile-desc { font-size: .72rem; color: rgba(255,255,255,0.45); line-height: 1.4; }

/* ===== CARD ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  padding: .9rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: .9rem;
}

/* ===== ROW-2 ===== */
.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

/* ===== SIMPLE LIST ===== */
.simple-list { padding: .5rem 0; }
.simple-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border-light);
  font-size: 1rem;
}
.simple-list-item:last-child { border-bottom: none; }
.simple-list-item .item-title { color: var(--text); font-size: 1.05rem; font-weight: 600; }
.simple-list-item .item-title a { font-size: 1.05rem !important; }
.simple-list-item .item-meta { color: var(--text); font-size: .9rem; }

/* ===== RESEARCH HISTORY WIDGET ===== */
.research-tabs { display: flex; gap: .4rem; padding: .5rem 1rem .25rem; border-bottom: 1px solid var(--border-light); }
.rtab { background: none; border: 1px solid var(--border); color: var(--text-muted); border-radius: 6px; padding: .25rem .75rem; font-size: .85rem; cursor: pointer; transition: all .15s; }
.rtab:hover { border-color: var(--blue); color: var(--blue); }
.rtab.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.research-item { flex-direction: row; align-items: center; gap: .5rem; }
.research-item-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .1rem; }
.research-item-body .item-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-xs { font-size: .75rem; padding: .2rem .55rem; min-width: 60px; flex-shrink: 0; }
.research-reuse-btn { opacity: .7; }
.research-reuse-btn:hover { opacity: 1; }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
.table th {
  background: rgba(30,38,50,.6);
  padding: .65rem 1rem;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: .65rem 1rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.td-loading { text-align: center; padding: 2rem; color: var(--text-muted); }
.td-actions { display: flex; gap: .3rem; white-space: nowrap; }

/* ===== BADGES ===== */
.badge {
  display: inline-block;
  padding: .15rem .55rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-green { background: rgba(63,185,80,.15); color: var(--green); }
.badge-blue { background: rgba(88,166,255,.15); color: var(--blue); }
.badge-yellow { background: rgba(210,153,34,.15); color: var(--yellow); }
.badge-red { background: rgba(248,81,73,.15); color: var(--red); }
.badge-gray { background: rgba(139,148,158,.15); color: var(--text-muted); }
.badge-purple { background: rgba(188,140,255,.15); color: #bc8cff; }

/* ===== CARDS GRID (Tickets) ===== */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.ticket-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
}
.ticket-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
}
.ticket-question {
  font-weight: 600;
  font-size: .875rem;
  flex: 1;
}
.ticket-response {
  color: var(--text-muted);
  font-size: .8rem;
  line-height: 1.5;
  max-height: 80px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
.ticket-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: .75rem;
  color: var(--text-dim);
}
.ticket-actions { display: flex; gap: .4rem; }

/* ===== TICKET TABLE ===== */
.th-sort { cursor: pointer; user-select: none; }
.th-sort:hover { color: var(--text); }
.th-sort::after { content: ' ⇅'; opacity: .35; font-size: .7rem; }
.th-sort-asc::after { content: ' ↑'; opacity: 1; color: var(--blue); }
.th-sort-desc::after { content: ' ↓'; opacity: 1; color: var(--blue); }
.ticket-q-cell { font-weight: 600; font-size: .85rem; max-width: 260px; }
.ticket-r-cell { color: var(--text-muted); font-size: .8rem; max-width: 320px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ===== AI ASSISTANT ===== */
.ai-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.ai-chat {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.ai-welcome {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
}
.ai-bot-icon { font-size: 3rem; margin-bottom: 1rem; }
.ai-welcome h3 { color: var(--text); margin-bottom: .5rem; }
.ai-bubble {
  display: flex;
  gap: .75rem;
  max-width: 80%;
}
.ai-bubble.user { align-self: flex-end; flex-direction: row-reverse; }
.bubble-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.bubble-avatar.bot { background: rgba(88,166,255,.15); }
.bubble-avatar.usr { background: var(--blue-dark); color: #fff; font-size: .8rem; font-weight: 700; }
.bubble-content { flex: 1; }
.bubble-text {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem 1rem;
  font-size: .875rem;
  line-height: 1.6;
  white-space: pre-wrap;
}
.ai-bubble.user .bubble-text { background: rgba(31,111,235,.2); border-color: var(--blue-dark); }
.bubble-meta {
  font-size: .72rem;
  color: var(--text-dim);
  margin-top: .3rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.ai-bubble.user .bubble-meta { justify-content: flex-end; }
.token-counter { font-size: .7rem; color: var(--text-muted); opacity: .75; white-space: nowrap; cursor: default; }
.bubble-actions { display: flex; gap: .3rem; margin-top: .4rem; }
.ticket-suggestion-banner {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  margin-top: .6rem; padding: .5rem .75rem;
  background: rgba(99,102,241,.08); border: 1px solid rgba(99,102,241,.25);
  border-radius: 8px; font-size: .82rem;
}
.ticket-suggestion-icon { font-size: 1rem; flex-shrink: 0; }
.ticket-suggestion-text { flex: 1; color: var(--text-secondary); }
.ticket-suggestion-btn { flex-shrink: 0; }
.badge-xs { font-size: .65rem; padding: .1rem .35rem; }
.badge-gray { background: rgba(150,150,150,.15); color: var(--text-muted); }

/* Ticket templates block */
.tkt-templates-block {
  margin-top: .75rem;
  border: 1px solid rgba(99,102,241,.25);
  border-radius: 10px;
  overflow: hidden;
}
.tkt-templates-header {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem .75rem;
  background: rgba(99,102,241,.08);
  font-size: .82rem; color: var(--text-secondary);
  border-bottom: 1px solid rgba(99,102,241,.15);
}
.tkt-card {
  padding: .65rem .75rem;
  border-bottom: 1px solid rgba(99,102,241,.10);
}
.tkt-card:last-child { border-bottom: none; }
.tkt-card-header {
  display: flex; align-items: center; gap: .4rem; flex-wrap: wrap;
  margin-bottom: .4rem;
}
.tkt-card-subject {
  font-size: .82rem; font-weight: 600; color: var(--text-primary); flex: 1;
}
.tkt-card-preview {
  font-size: .78rem; color: var(--text-secondary);
  white-space: pre-wrap; line-height: 1.45;
  max-height: 160px; overflow-y: auto;
  background: rgba(0,0,0,.04); border-radius: 6px;
  padding: .5rem .6rem; margin-bottom: .5rem;
  font-family: inherit;
}
.tkt-card-actions { display: flex; gap: .4rem; flex-wrap: wrap; }
.ai-thinking { color: var(--text-muted); font-style: italic; font-size: .875rem; }

/* Robot thinking animation */
.ai-thinking-anim { display: flex; align-items: center; gap: .7rem; }
.ai-thinking-robot {
  font-size: 2rem;
  display: inline-block;
  animation: robot-bounce 0.6s ease-in-out infinite alternate;
  transform-origin: bottom center;
}
.ai-thinking-dots { display: flex; gap: .35rem; align-items: center; flex-direction: column; }
.ai-thinking-dots span {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary, #6366f1); display: inline-block;
  animation: dot-pulse 1.2s ease-in-out infinite;
}
.ai-thinking-dots span:nth-child(2) { animation-delay: .2s; }
.ai-thinking-dots span:nth-child(3) { animation-delay: .4s; }
.ai-thinking-label { font-size: .84rem; color: var(--text-muted); font-style: italic; }
@keyframes robot-bounce {
  from { transform: translateY(0) rotate(-5deg); }
  to   { transform: translateY(-7px) rotate(5deg); }
}
@keyframes dot-pulse {
  0%, 80%, 100% { transform: scale(0.5); opacity: .3; }
  40%           { transform: scale(1.3); opacity: 1; }
}

.ai-input-bar {
  display: flex;
  gap: .6rem;
  padding: .9rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.ai-text-input { flex: 1; background: var(--bg-card); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.25rem; overflow-y: auto; flex: 1; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  padding: .9rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ===== TOAST ===== */
#toasts {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}
.toast {
  padding: .75rem 1.1rem;
  border-radius: var(--radius);
  font-size: .875rem;
  color: #fff;
  box-shadow: var(--shadow);
  animation: slideIn .25s ease;
  max-width: 320px;
}
.toast-success { background: var(--green-dark); }
.toast-error { background: var(--red-dark); }
.toast-info { background: var(--blue-dark); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== STATUS BADGES ===== */
.stato-programmato { color: var(--blue); }
.stato-in_corso { color: var(--yellow); }
.stato-completato { color: var(--green); }
.stato-annullato { color: var(--red); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .row-2 { grid-template-columns: 1fr; }
  .sidebar { width: 60px; min-width: 60px; }
  .sidebar-brand, .nav-label, .user-info, .sidebar-footer .btn-icon { display: none; }
  .sidebar-header { justify-content: center; }
  .nav-item { justify-content: center; padding: .7rem; }
  .sidebar-footer { justify-content: center; }
  .main { margin-left: 60px; max-width: calc(100vw - 60px); }
}
@media (max-width: 600px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-actions { width: 100%; }
  .search-input, .select-input { max-width: 100%; width: 100%; }
}

/* ===== KNOWLEDGE BASE - TABS & CARDS ===== */
.kb-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-bottom: .75rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .6rem;
}
.kb-tab {
  padding: .4rem .9rem;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: .82rem;
  cursor: pointer;
  transition: all .15s;
}
.kb-tab:hover { border-color: var(--blue); color: var(--blue); }
.kb-tab.active { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.kb-tab-count { font-size: .72rem; opacity: .8; margin-left: .2rem; }

.kb-subfilters {
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: .6rem;
}
.kb-type-pills { display: flex; flex-wrap: wrap; gap: .3rem; flex: 1; }
.kb-pill {
  padding: .3rem .75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: transparent;
  color: var(--text-muted);
  font-size: .78rem;
  cursor: pointer;
  transition: all .15s;
}
.kb-pill:hover { border-color: var(--primary); color: var(--text); }
.kb-pill.active { background: var(--primary,#6366f1); border-color: var(--primary,#6366f1); color: #fff; font-weight: 600; }

/* Cards grid */
.kb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: .85rem;
}
.kb-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .9rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  transition: border-color .15s, box-shadow .15s;
}
.kb-card:hover { border-color: var(--blue); box-shadow: 0 2px 12px rgba(0,0,0,.18); }
.kb-card-draft { border-left: 3px solid var(--yellow); }

.kb-card-header { display: flex; flex-direction: column; gap: .35rem; }
.kb-card-title { font-weight: 700; font-size: .95rem; line-height: 1.3; }
.kb-card-title mark.kb-hl { background: rgba(88,166,255,.25); color: var(--blue); border-radius: 3px; padding: 0 2px; }
.kb-attach-icon { font-size: .8rem; }
.kb-card-badges { display: flex; flex-wrap: wrap; gap: .3rem; }

.kb-card-preview {
  font-size: .82rem;
  color: var(--text-muted);
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.kb-card-preview mark.kb-hl { background: rgba(88,166,255,.2); color: var(--blue); border-radius: 2px; padding: 0 1px; }

.kb-card-expand { margin-top: .2rem; }
.kb-card-full {
  white-space: pre-wrap;
  font-size: .82rem;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: .65rem .85rem;
  max-height: 320px;
  overflow-y: auto;
  line-height: 1.5;
}

.kb-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .1rem;
}
.kb-usage { font-size: .75rem; color: var(--text-dim); }
.kb-card-actions { display: flex; flex-wrap: wrap; gap: .3rem; }

.kb-empty, .kb-card-loading {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
  padding: 2.5rem;
  font-size: .9rem;
}

@media (max-width: 700px) {
  .kb-grid { grid-template-columns: 1fr; }
  .kb-tabs { gap: .25rem; }
}

/* ===== TURNI SD ===== */
.turni-tabs {
  display: flex;
  gap: .3rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .5rem;
}
.turni-tab {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: .45rem .9rem;
  border-radius: var(--radius);
  font-size: .85rem;
  cursor: pointer;
  transition: all .15s;
}
.turni-tab:hover { background: var(--bg-hover); color: var(--text); }
.turni-tab.active { background: var(--blue-dark); border-color: var(--blue); color: #fff; }
.turni-tab-content { display: block; }
.turni-tab-content.hidden { display: none; }

/* Week navigation */
.turni-week-nav {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

/* Turni grid */
.turni-grid-wrap { overflow-x: auto; }
.turni-grid {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
  min-width: 900px;
}
.turni-grid th {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: .5rem .6rem;
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}
.turni-grid th.th-nome { text-align: left; min-width: 150px; }
.turni-grid td {
  border: 1px solid var(--border-light);
  padding: .35rem .5rem;
  text-align: center;
  vertical-align: top;
  font-size: .78rem;
  cursor: default;
}
.turni-grid td.td-nome {
  text-align: left;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  background: var(--bg-card);
}
.turni-grid td .turno-orario { display: block; font-size: .75rem; font-weight: 600; }
.turni-grid td .turno-info { display: block; font-size: .7rem; color: var(--text-muted); }
.turni-grid td .turno-note { display: block; font-size: .68rem; color: var(--yellow); font-style: italic; }

/* Cell colors by tipo */
.turno-sd    { background: rgba(63,185,80,.12); }
.turno-we    { background: rgba(0,200,180,.12); }
.turno-la    { background: rgba(255,165,0,.15); }
.turno-ev    { background: rgba(165,105,255,.15); }
.turno-so    { background: rgba(80,150,255,.12); }
.turno-ferie { background: rgba(88,166,255,.18); }
.turno-riposo { background: rgba(100,100,100,.12); color: var(--text-dim); }
.turno-malattia { background: rgba(248,81,73,.18); }
.turno-permesso { background: rgba(210,153,34,.18); }
.turno-trasferta { background: rgba(200,120,220,.15); }
.turno-corso  { background: rgba(100,180,255,.12); }
.turno-sw    { background: rgba(0,220,180,.12); }
.turno-festivita { background: rgba(80,80,80,.2); }
.turno-chiusura { background: rgba(80,80,80,.3); }
.turno-vuoto { background: transparent; color: var(--text-dim); font-size: .7rem; }

.turno-sabato td { background: rgba(0,0,0,.1); opacity: .7; }

/* Summary row */
.turni-grid tr.summary-row td {
  background: var(--bg-card);
  font-size: .72rem;
  color: var(--text-muted);
  padding: .25rem .4rem;
}
.turni-grid tr.summary-row td .sede-badge {
  display: inline-block;
  background: var(--bg-hover);
  border-radius: 3px;
  padding: 1px 5px;
  margin: 1px;
  font-weight: 600;
  color: var(--text);
}

/* Admin edit cell */
.turni-grid td.editable:hover { outline: 1px solid var(--blue); cursor: pointer; }
.turni-grid td.td-nome-edit { cursor: pointer; }
.turni-grid td.td-nome-edit:hover { background: var(--bg-hover); outline: 1px solid var(--blue); }
.td-nome-hint { font-size: .7rem; color: var(--blue); opacity: 0; margin-left: .3rem; }
.turni-grid td.td-nome-edit:hover .td-nome-hint { opacity: 1; }

/* Add/bottom row of sede section */
.turni-sede-add-row {
  padding: .4rem .6rem;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  background: var(--bg-card);
}
.turni-sede-add-btn {
  width: 100%;
  text-align: left;
  color: var(--text-muted);
  font-size: .8rem;
  padding: .3rem .5rem;
  border-radius: 4px;
  transition: all .15s;
}
.turni-sede-add-btn:hover { background: var(--bg-hover); color: var(--blue); }

/* Risorse filter bar */
.risorse-filter-bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem; flex-wrap: wrap;
  margin-bottom: 1rem; padding: .6rem .8rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
}
.risorse-filter-btns { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Risorsa card stato */
.risorsa-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: .2rem; }
.risorsa-stato-badge {
  font-size: .68rem; font-weight: 700; padding: .1rem .45rem;
  border-radius: 20px; letter-spacing: .04em;
}
.stato-attivo { background: #16a34a22; color: #4ade80; border: 1px solid #4ade8055; }
.stato-oos { background: #b91c1c22; color: #f87171; border: 1px solid #f8717155; }
.turni-risorsa-card.risorsa-oos { opacity: .65; }
.turni-risorsa-card.risorsa-oos:hover { opacity: 1; }

/* Btn variants */
.btn-success { background: #16a34a; color: #fff; border-color: #16a34a; }
.btn-success:hover { background: #15803d; }
.btn-warning { background: #92400e; color: #fcd34d; border-color: #b45309; }
.btn-warning:hover { background: #78350f; }

/* Rileva inattivi modal */
.rileva-list { display: flex; flex-direction: column; gap: .3rem; max-height: 320px; overflow-y: auto; }
.rileva-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .45rem .6rem; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg-card);
}
.rileva-row:hover { background: var(--bg-hover); }
.rileva-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--blue); flex-shrink: 0; }

/* Out of Service badge */
.oos-badge {
  display: inline-block;
  font-size: .65rem;
  font-weight: 700;
  padding: .1rem .35rem;
  border-radius: 3px;
  background: #b91c1c22;
  color: #f87171;
  border: 1px solid #f8717144;
  vertical-align: middle;
  letter-spacing: .04em;
}
.td-nome-oos { opacity: .7; }
.td-nome-oos .oos-badge { margin-left: .3rem; }
.ruolo-badge {
  display: inline-block;
  font-size: .6rem;
  font-weight: 700;
  padding: .1rem .3rem;
  border-radius: 3px;
  vertical-align: middle;
  letter-spacing: .05em;
  margin-left: .3rem;
  border: 1px solid currentColor;
  opacity: .85;
}
.ruolo-badge-pm  { color: #e3b341; background: #e3b34118; }
.ruolo-badge-co  { color: #bc8cff; background: #bc8cff18; }
.ruolo-badge-tl  { color: #58a6ff; background: #58a6ff18; }
.temp-badge {
  display: inline-block;
  font-size: .6rem;
  font-weight: 700;
  padding: .1rem .3rem;
  border-radius: 3px;
  vertical-align: middle;
  letter-spacing: .05em;
  margin-left: .3rem;
  border: 1px solid #f0883e88;
  color: #f0883e;
  background: #f0883e18;
}
.turno-away {
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 4px,
    rgba(255,255,255,.04) 4px,
    rgba(255,255,255,.04) 8px
  );
  color: var(--text-dim);
  font-size: .72rem;
  text-align: center;
}
.oos-alert {
  background: #b91c1c18;
  border: 1px solid #f8717166;
  color: #fca5a5;
  border-radius: 6px;
  padding: .6rem .9rem;
  font-size: .85rem;
  margin-bottom: .9rem;
}

/* Reassign modal sections */
.reassign-section { margin-bottom: .5rem; }
.reassign-section-title { font-weight: 600; font-size: .9rem; margin-bottom: .2rem; }
.reassign-section-sub { font-size: .8rem; color: var(--text-muted); margin-bottom: .4rem; }
.reassign-divider { border: none; border-top: 1px solid var(--border); margin: .9rem 0; }

/* Reassign risorsa modal */
.reassign-risorse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .5rem;
  max-height: 340px;
  overflow-y: auto;
  padding-right: .25rem;
}
.reassign-risorsa-card {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
}
.reassign-risorsa-card:hover { border-color: var(--blue); background: var(--bg-hover); }
.reassign-risorsa-card.selected { border-color: var(--blue); background: var(--blue-dark); }
.reassign-risorsa-card.is-current { opacity: .5; }
.reassign-risorsa-card.selected.is-current { opacity: 1; }
.reassign-risorsa-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem; flex-shrink: 0;
}
.reassign-risorsa-nome { font-weight: 600; font-size: .9rem; }
.reassign-risorsa-sub { font-size: .75rem; color: var(--text-muted); }

/* Sabati table */
.sabato-attivo { color: var(--green); font-weight: 600; }
.sabato-chiuso { color: var(--text-dim); }

/* Risorse grid */
.turni-risorse-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}
.turni-sede-group { grid-column: 1/-1; }
.turni-sede-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--blue);
  padding: .5rem 0 .3rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: .5rem;
}
.turni-risorsa-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.turni-risorsa-nome { font-weight: 600; color: var(--text); }
.turni-risorsa-ruolo { font-size: .8rem; color: var(--text-muted); }
.turni-risorsa-servizio {
  display: inline-block;
  font-size: .7rem;
  padding: 1px 7px;
  border-radius: 3px;
  margin-bottom: .2rem;
}
.serv-SD  { background: rgba(63,185,80,.2); color: var(--green); }
.serv-WE  { background: rgba(0,200,180,.2); color: #0dceba; }
.serv-Net { background: rgba(88,166,255,.2); color: var(--blue); }
.serv-DV  { background: rgba(165,105,255,.2); color: #b19cff; }

/* Riferimenti grid */
.turni-riferimenti-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}
.turni-rif-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: .85rem 1rem;
}
.turni-rif-sede {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--blue);
  margin-bottom: .5rem;
}
.turni-rif-nome { font-weight: 600; font-size: .95rem; }
.turni-rif-ruolo { font-size: .8rem; color: var(--text-muted); margin-bottom: .4rem; }
.turni-rif-contacts { display: flex; flex-direction: column; gap: .2rem; margin-top: .3rem; }
.turni-rif-contact { display: flex; align-items: center; gap: .4rem; font-size: .82rem; }
.turni-rif-contact a { color: var(--blue); }


/* Lauree link */
.laurea-link { color: var(--blue); font-size: .78rem; }

/* Icona picker eventi config */
.cfg-icona-btn:hover { background: #f1f5f9 !important; border-color: #94a3b8 !important; }
.cfg-icona-sel { background: #dbeafe !important; border-color: #3b82f6 !important; }

/* Turni filter bar */
.turni-filter-bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  padding: .75rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
}
.turni-sede-filters {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  flex: 1;
}
.turni-sede-btn {
  padding: .35rem .75rem;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: .82rem;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.turni-sede-btn:hover { background: var(--border); color: var(--text); }
.turni-sede-btn.active {
  background: var(--blue-dark);
  border-color: var(--blue);
  color: #fff;
  font-weight: 600;
}
.turni-risorsa-filter {
  display: flex;
  align-items: center;
  gap: .5rem;
  white-space: nowrap;
}

/* Sede-separated week sections */
.turni-sede-section {
  margin-bottom: 1.5rem;
}
.turni-sede-section-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .5rem .9rem;
  border-radius: 6px 6px 0 0;
  font-weight: 700;
  font-size: .92rem;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #fff;
}
.turni-sede-section-header .sede-count {
  font-size: .78rem;
  font-weight: 400;
  opacity: .8;
  margin-left: auto;
}
.turni-sede-section .turni-grid-wrap {
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
}

/* Personal / single-resource view */
.turni-personal-view {
  margin-top: .5rem;
}
.turni-personal-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .6rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
}
.turni-personal-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.turni-personal-sede {
  font-size: .8rem;
  padding: .2rem .6rem;
  border-radius: 12px;
  color: #fff;
  font-weight: 600;
}
.turni-personal-days {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: .6rem;
}
.turni-day-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .6rem;
  min-height: 110px;
  display: flex;
  flex-direction: column;
  gap: .3rem;
  transition: border-color .15s;
}
.turni-day-card:hover { border-color: var(--blue); }
.turni-day-card.editable { cursor: pointer; }
.turni-day-label {
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: .05em;
}
.turni-day-date {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: .2rem;
}
.turni-day-tipo {
  font-size: .88rem;
  font-weight: 700;
  padding: .2rem .4rem;
  border-radius: 4px;
  text-align: center;
}
.turni-day-orario {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
}
.turni-day-sede {
  font-size: .75rem;
  color: var(--text-muted);
}
.turni-day-note {
  font-size: .72rem;
  color: var(--yellow);
  font-style: italic;
  margin-top: auto;
}
.turni-day-delta {
  font-size: .72rem;
  color: var(--text-muted);
}
.turni-day-edit-hint {
  font-size: .68rem;
  color: var(--blue);
  text-align: right;
  margin-top: auto;
  opacity: 0;
  transition: opacity .15s;
}
.turni-day-card:hover .turni-day-edit-hint { opacity: 1; }
.turni-day-sub { font-size: .75rem; color: var(--text-muted); }

/* Personal view header */
.turni-personal-header { flex-wrap: wrap; }
.turni-personal-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  flex-shrink: 0;
}
.turni-personal-nome { font-weight: 700; font-size: 1.05rem; }
.turni-personal-sub { font-size: .82rem; color: var(--text-muted); margin-top: .1rem; }
.turni-personal-week-label { margin-left: auto; font-size: .82rem; color: var(--text-muted); }

/* Sede section header sub-elements */
.turni-sede-section-header { background: var(--bg-hover); }
.turni-sede-section-title { font-weight: 700; font-size: .92rem; text-transform: uppercase; letter-spacing: .04em; }
.turni-sede-section-code { font-size: .72rem; }
.turni-sede-section-count { font-size: .78rem; color: var(--text-muted); margin-left: auto; }

/* Day card weekend dim */
.turni-day-card.is-weekend { opacity: .7; }
.turni-day-card.is-weekend:hover { opacity: 1; }

@media (max-width: 900px) {
  .turni-personal-days { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 600px) {
  .turni-personal-days { grid-template-columns: repeat(2, 1fr); }
  .turni-filter-bar { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 700px) {
  .turni-risorse-grid, .turni-riferimenti-grid { grid-template-columns: 1fr; }
}

/* ── Ticket Accordion ─────────────────────────────────────── */
.tk-group { margin-bottom: .6rem; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.tk-group-header {
  display: flex; align-items: center; gap: .6rem;
  padding: .6rem .9rem; cursor: pointer;
  background: var(--bg-card);
  user-select: none;
  transition: background .15s;
}
.tk-group-header:hover { background: var(--bg-hover); }
.tk-group-header.is-open { border-bottom: 1px solid var(--border); }
.tk-group-title { font-weight: 700; font-size: .95rem; flex: 1; }
.tk-group-counts { display: flex; gap: .35rem; }
.tk-group-arrow { font-size: .7rem; color: var(--text-muted); transition: transform .2s; }
.tk-group-header.is-open .tk-group-arrow { transform: rotate(90deg); }
.tk-group-body { display: none; }
.tk-group-body.is-open { display: block; }

.tk-card {
  display: flex; align-items: flex-start; gap: .7rem;
  padding: .55rem .9rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-main);
  transition: background .12s;
}
.tk-card:last-child { border-bottom: none; }
.tk-card:hover { background: var(--bg-hover); }
.tk-card-type { flex-shrink: 0; width: 1.5rem; text-align: center; font-size: .85rem; }
.tk-card-body { flex: 1; min-width: 0; }
.tk-card-q { font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-card-preview { font-size: .78rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: .1rem; }
.tk-card-actions { display: flex; gap: .3rem; flex-shrink: 0; }
.badge-type-self  { background: #d1fae5; color: #065f46; }
.badge-type-tech  { background: #dbeafe; color: #1e40af; }
.badge-type-l2    { background: #ede9fe; color: #5b21b6; }
