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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overflow: hidden;
}

button { cursor: pointer; border: none; background: none; font: inherit; }
input, textarea, select { font: inherit; }
a { color: inherit; text-decoration: none; }
textarea { resize: vertical; }

/* ── Calico Theme Variables ──────────────────────────────────────────────────── */
:root {
  --accent:        #E8823A;
  --accent-hover:  #F0933A;
  --accent-dim:    rgba(232,130,58,.15);
  --accent-border: rgba(232,130,58,.35);
  --danger:        #EF5350;
  --danger-hover:  #F06060;
  --danger-dim:    rgba(239,83,80,.15);
  --success:       #4CAF82;
  --warning:       #E8B43A;
  --radius:        8px;
  --radius-sm:     5px;
  --trans:         150ms ease;
}

[data-theme="dark"] {
  --bg:           #111113;
  --surface:      #1C1C1F;
  --surface-2:    #252528;
  --surface-3:    #2E2E32;
  --border:       #3A3A3E;
  --border-light: #302F34;
  --text:         #EDEDF0;
  --text-2:       #9F9FA5;
  --text-3:       #6B6B72;
  --shadow:       0 4px 24px rgba(0,0,0,.5);
  --shadow-sm:    0 2px 8px rgba(0,0,0,.4);
  --inset:        inset 0 1px 0 rgba(255,255,255,.04);
}

[data-theme="light"] {
  --bg:           #EDE6DB;
  --surface:      #FEFCF9;
  --surface-2:    #F5F0E8;
  --surface-3:    #EDE7DC;
  --border:       #D8D0C4;
  --border-light: #E5DDD0;
  --text:         #1A1810;
  --text-2:       #5A5248;
  --text-3:       #8A8070;
  --shadow:       0 4px 24px rgba(0,0,0,.12);
  --shadow-sm:    0 2px 8px rgba(0,0,0,.08);
  --inset:        inset 0 1px 0 rgba(255,255,255,.6);
}

body { background: var(--bg); color: var(--text); }

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border);
  transition: background var(--trans), border-color var(--trans);
}
.btn:hover { background: var(--surface-2); }
.btn-accent { background: var(--accent); color: #fff; border-color: transparent; }
.btn-accent:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger-dim); color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; border-radius: var(--radius-sm);
  color: var(--text-2); transition: background var(--trans), color var(--trans);
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

.form-row { display: flex; flex-direction: column; gap: 5px; }
.form-row label { font-size: 11px; font-weight: 600; color: var(--text-2); text-transform: uppercase; letter-spacing: .4px; }
.form-row-two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

input[type="text"], input[type="password"], input[type="date"],
textarea, select {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 7px 10px; outline: none; width: 100%;
  transition: border-color var(--trans);
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
select { appearance: none; cursor: pointer; }

.required { color: var(--accent); }

/* ── App Shell ───────────────────────────────────────────────────────────────── */
#app {
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────────── */
#header {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 62px; min-height: 62px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  z-index: 10;
}

.header-left { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.cat-logo { width: 34px; height: 40px; }
.app-title { font-size: 17px; font-weight: 700; color: var(--text); }

.header-center { flex: 1; }
.search-wrap {
  position: relative; max-width: 320px;
  display: flex; align-items: center;
}
.search-icon {
  position: absolute; left: 9px; width: 14px; height: 14px;
  color: var(--text-3); pointer-events: none;
}
#search-input {
  padding-left: 34px; height: 38px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  width: 100%;
}

.header-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* ── Filter Bar ──────────────────────────────────────────────────────────────── */
#filter-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}
#filter-bar select {
  width: auto; height: 34px; padding: 0 12px;
  font-size: 13px; border-radius: var(--radius-sm);
}

/* ── Main Content (row: sidebar + content-area) ──────────────────────────────── */
#main-content {
  flex: 1; overflow: hidden;
  display: flex; flex-direction: row;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────────── */
#sidebar {
  width: 44px; min-width: 44px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: width 250ms cubic-bezier(.4,0,.2,1), min-width 250ms cubic-bezier(.4,0,.2,1);
  flex-shrink: 0; z-index: 5;
}
#sidebar:hover { width: 220px; min-width: 220px; }

.sidebar-inner {
  width: 220px;
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  flex: 1; padding: 10px 0;
}

.sidebar-section { display: flex; flex-direction: column; margin-bottom: 8px; }

.sidebar-section-hdr {
  display: flex; align-items: center; gap: 7px;
  padding: 5px 10px; white-space: nowrap;
  font-size: 10px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .5px;
}
.sidebar-section-icon { font-size: 14px; flex-shrink: 0; width: 24px; text-align: center; }
.sidebar-section-label { flex: 1; overflow: hidden; transition: opacity 150ms ease; }
.sidebar-cnt {
  background: var(--accent); color: #fff;
  border-radius: 10px; min-width: 16px; height: 16px;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px; flex-shrink: 0;
}

.sidebar-item {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px; cursor: pointer; white-space: nowrap;
  font-size: 11px; color: var(--text-2);
  transition: background var(--trans), color var(--trans);
  overflow: hidden;
}
.sidebar-item:hover { background: var(--surface-2); color: var(--text); }
.sidebar-item-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.sidebar-item-title {
  flex: 1; overflow: hidden; text-overflow: ellipsis;
  transition: opacity 150ms ease;
}
.sidebar-empty {
  padding: 4px 10px 4px 42px; font-size: 11px; color: var(--text-3);
  font-style: italic; white-space: nowrap;
  transition: opacity 150ms ease;
}

/* Pinned sidebar (when open tickets exist) — always expanded */
#sidebar.pinned { width: 220px; min-width: 220px; }

#sidebar-pin-btn {
  position: absolute; bottom: 8px; right: 6px;
  width: 28px; height: 28px;
  background: none; border: none; border-radius: 6px;
  color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--trans), background var(--trans), opacity 150ms ease;
  opacity: 0; pointer-events: none;
  flex-shrink: 0;
  z-index: 10;
}
#sidebar:hover #sidebar-pin-btn,
#sidebar.pinned #sidebar-pin-btn {
  opacity: 1; pointer-events: auto;
}
#sidebar-pin-btn:hover { background: var(--surface-2); color: var(--text); }
#sidebar-pin-btn.active { color: var(--accent); }
#sidebar { position: relative; }

/* Hide all text content when sidebar is collapsed and not pinned — only icons show */
#sidebar:not(:hover):not(.pinned) .sidebar-section-label,
#sidebar:not(:hover):not(.pinned) .sidebar-item-title,
#sidebar:not(:hover):not(.pinned) .sidebar-empty,
#sidebar:not(:hover):not(.pinned) .sidebar-cnt {
  opacity: 0;
  pointer-events: none;
}

/* Open Tickets sidebar items */
.open-ticket-item { justify-content: space-between; }
.open-ticket-item.active { background: var(--surface-2); color: var(--text); }
.open-ticket-close {
  background: none; border: none; color: var(--text-3);
  cursor: pointer; font-size: 16px; line-height: 1;
  padding: 0 0 0 4px; flex-shrink: 0;
  display: flex; align-items: center;
  transition: color var(--trans);
}
.open-ticket-close:hover { color: var(--danger); }

/* ── Content Area ────────────────────────────────────────────────────────────── */
#content-area {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
}

/* ── Kanban Board ────────────────────────────────────────────────────────────── */
#board {
  display: flex; flex-wrap: wrap; gap: 10px;
  padding: 14px 16px;
  align-items: flex-start; align-content: flex-start;
}

.board-column {
  display: flex; flex-direction: column;
  width: 220px; flex-shrink: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); height: 180px;
}

.column-header {
  display: flex; align-items: center; gap: 7px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.column-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.status-new      { background: #3B82F6; }
.status-working  { background: #36B37E; }
.status-on-hold  { background: #8B5CF6; }
.status-pending  { background: var(--warning); }
.status-complete { background: var(--text-3); }

.column-title { font-size: 12px; font-weight: 600; flex: 1; }
.column-badge { display: none; }

.column-count {
  flex: 1; display: flex; align-items: center; justify-content: center;
  font-size: 80px; font-weight: 700; color: var(--text-3);
  cursor: pointer; user-select: none;
  transition: color var(--trans);
}
.column-count:hover { color: var(--accent); }

.column-body {
  flex: 1; overflow-y: auto; padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 60px;
}
.column-empty { color: var(--text-3); font-size: 12px; text-align: center; padding: 16px 0; }

/* ── Ticket Card ─────────────────────────────────────────────────────────────── */
.ticket-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 11px;
  cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  transition: border-color var(--trans), box-shadow var(--trans);
}
.ticket-card:hover { border-color: var(--accent-border); box-shadow: var(--shadow-sm); }

.card-labels { display: flex; flex-wrap: wrap; gap: 4px; }
.card-title { font-size: 12px; font-weight: 500; line-height: 1.4; color: var(--text); }

.card-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 2px;
}
.card-priority {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--text-2);
}
.card-priority-dot {
  width: 7px; height: 7px; border-radius: 50%;
}
.priority-low      { background: var(--text-3); }
.priority-normal   { background: var(--text-2); }
.priority-high     { background: var(--warning); }
.priority-critical { background: var(--danger); }

.card-due {
  font-size: 11px; color: var(--text-3);
}
.card-due.overdue { color: var(--danger); font-weight: 600; }

.card-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.card-assignee { font-size: 11px; color: var(--text-2); }
.card-product  {
  font-size: 10px; font-weight: 600; padding: 1px 6px;
  background: var(--accent-dim); color: var(--accent);
  border-radius: 8px; border: 1px solid var(--accent-border);
}

/* ── Label Tags ──────────────────────────────────────────────────────────────── */
.label-tag {
  display: inline-flex; align-items: center;
  padding: 2px 7px; border-radius: 10px;
  font-size: 10px; font-weight: 600; text-transform: lowercase;
  border: 1px solid transparent;
}
.label-bug        { background: rgba(239,83,80,.15);  color: #EF5350; border-color: rgba(239,83,80,.3); }
.label-feature    { background: rgba(75,139,245,.15); color: #4B8BF5; border-color: rgba(75,139,245,.3); }
.label-enhancement{ background: rgba(76,175,130,.15); color: #4CAF82; border-color: rgba(76,175,130,.3); }
.label-question   { background: rgba(156,111,214,.15);color: #9C6FD6; border-color: rgba(156,111,214,.3); }
.label-urgent     { background: var(--accent-dim);    color: var(--accent); border-color: var(--accent-border); }
.label-custom     { background: var(--surface-3);     color: var(--text-2); border-color: var(--border); }

.label-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.label-option { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.label-option input[type="checkbox"] { display: none; }
.label-option input:checked + .label-tag { opacity: 1; box-shadow: 0 0 0 2px var(--accent); }
.label-option .label-tag { opacity: .5; transition: opacity var(--trans); }
.label-option:hover .label-tag { opacity: .8; }

/* ── Admin Panel ─────────────────────────────────────────────────────────────── */
#admin-panel {
  flex: 1; display: flex; flex-direction: column;
  padding: 16px; overflow: hidden; gap: 0;
}
.admin-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.admin-header h2 { font-size: 15px; font-weight: 700; }
#admin-table-wrap { flex: 1; overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); }
#admin-table { width: 100%; border-collapse: collapse; }
#admin-table th {
  background: var(--surface); color: var(--text-2);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
#admin-table td { padding: 9px 12px; border-bottom: 1px solid var(--border-light); font-size: 12px; }
#admin-table tbody tr { cursor: pointer; transition: background var(--trans); }
#admin-table tbody tr:hover { background: var(--surface-2); }
#admin-table tbody tr:last-child td { border-bottom: none; }

/* ── Detail Panel (inline in content area) ───────────────────────────────────── */
#detail-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg);
  overflow: hidden;
}
#detail-panel.open { display: flex; }

.detail-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.detail-header-actions { display: flex; gap: 8px; }

.detail-body {
  flex: 1; overflow-y: auto; padding: 28px 20px;
  display: flex; flex-direction: column;
}
.tab-content {
  max-width: 900px; width: 100%; margin: 0 auto;
  display: flex; flex-direction: column; gap: 16px;
  padding-bottom: 8px;
}
.section-divider {
  max-width: 900px; width: 100%; margin: 28px auto 4px;
  font-size: 11px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .6px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border);
}

.detail-title-input {
  font-size: 16px; font-weight: 600; color: var(--text);
  background: transparent; border: none; border-bottom: 2px solid var(--border);
  border-radius: 0; padding: 4px 0; width: 100%;
  transition: border-color var(--trans);
}
.detail-title-input:focus { border-bottom-color: var(--accent); outline: none; }

.detail-meta-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px;
}
.detail-field { display: flex; flex-direction: column; gap: 6px; }
.detail-field > label {
  font-size: 11px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .4px;
}
.detail-field input, .detail-field select, .detail-field textarea { font-size: 12px; }

.custom-label-row { display: flex; gap: 8px; margin-top: 6px; }
.custom-label-row input { flex: 1; height: 28px; }
.custom-label-row .btn { flex-shrink: 0; height: 28px; padding: 0 12px; }
#detail-custom-tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.custom-tag-remove {
  display: inline-flex; align-items: center; gap: 3px; cursor: pointer;
}
.custom-tag-remove svg { width: 10px; height: 10px; }

.detail-byline { font-size: 11px; color: var(--text-3); }

/* ── Comments ────────────────────────────────────────────────────────────────── */
.comments-section { display: flex; flex-direction: column; gap: 10px; }
#comments-list { display: flex; flex-direction: column; gap: 10px; }
.comment-bubble {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px;
}
.comment-meta {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.comment-author { font-size: 11px; font-weight: 600; color: var(--accent); }
.comment-date   { font-size: 10px; color: var(--text-3); }
.comment-body   { font-size: 12px; color: var(--text); white-space: pre-wrap; }
.comment-empty  { font-size: 12px; color: var(--text-3); text-align: center; padding: 8px 0; }
.comment-form   { display: flex; flex-direction: column; gap: 6px; }
#comment-submit { align-self: flex-end; }

/* ── New Ticket Screen (full-page) ───────────────────────────────────────────── */
#modal-backdrop {
  position: fixed; inset: 0; z-index: 400;
  background: var(--bg);
  display: flex; flex-direction: column;
}
#modal-box {
  flex: 1; display: flex; flex-direction: column; overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 20px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-body {
  flex: 1; overflow-y: auto; padding: 0;
}
#new-ticket-content {
  max-width: 900px; margin: 0 auto; padding: 28px 20px;
  display: flex; flex-direction: column; gap: 18px;
}
.new-ticket-title {
  font-size: 22px; font-weight: 700; color: var(--text);
  padding-bottom: 8px; border-bottom: 2px solid var(--border);
}

/* ── Toasts ──────────────────────────────────────────────────────────────────── */
#toasts {
  position: fixed; bottom: 20px; right: 20px;
  display: flex; flex-direction: column; gap: 8px; z-index: 600;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 12px; box-shadow: var(--shadow);
  animation: toast-in 200ms ease;
  min-width: 220px; max-width: 320px;
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error   { border-color: var(--danger);  color: var(--danger); }
.toast.info    { border-color: var(--accent);  color: var(--accent); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── View Toggle ─────────────────────────────────────────────────────────────── */
.view-toggle { display: flex; gap: 4px; margin-left: auto; }
.view-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 14px; height: 34px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
  cursor: pointer; transition: all var(--trans);
}
.view-btn:hover { color: var(--text); background: var(--surface-3); }
.view-btn.active { color: var(--accent); background: var(--accent-dim); border-color: var(--accent-border); }

/* ── List View ───────────────────────────────────────────────────────────────── */
#list-view {
  flex: 1; display: flex; flex-direction: column;
  padding: 14px 16px; overflow: hidden;
}
#list-active-filter {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; margin-bottom: 10px;
  background: var(--accent-dim); border: 1px solid var(--accent-border); border-radius: var(--radius);
  font-size: 13px; color: var(--accent);
}
#list-active-filter button {
  background: none; border: 1px solid var(--accent-border); color: var(--accent);
  border-radius: 4px; padding: 2px 8px; cursor: pointer; font-size: 12px;
}
#list-active-filter button:hover { background: var(--accent-border); }
#list-table-wrap { flex: 1; overflow: auto; border-radius: var(--radius); border: 1px solid var(--border); }
#list-table { width: 100%; border-collapse: collapse; }
#list-table th {
  background: var(--surface); color: var(--text-2);
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  padding: 10px 12px; text-align: left;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
#list-table td { padding: 9px 12px; border-bottom: 1px solid var(--border-light); font-size: 12px; }
#list-table tbody tr { cursor: pointer; transition: background var(--trans); }
#list-table tbody tr:hover { background: var(--surface-2); }
#list-table tbody tr:last-child td { border-bottom: none; }
.list-status { display: inline-flex; align-items: center; gap: 5px; text-transform: capitalize; font-size: 12px; }
.list-status-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }

/* ── User Avatar Button ──────────────────────────────────────────────────────── */
.user-avatar-wrap { position: relative; }

.user-avatar-btn {
  position: relative; display: inline-flex;
  cursor: pointer; border: none; background: none; padding: 0;
}
.user-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  transition: opacity var(--trans);
}
.user-avatar-btn:hover .user-avatar { opacity: .85; }

.notif-badge {
  position: absolute; top: -5px; left: -5px;
  background: var(--danger); color: #fff;
  border-radius: 10px; min-width: 16px; height: 16px;
  font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px; pointer-events: none;
  border: 2px solid var(--bg);
}

/* ── User Dropdown ───────────────────────────────────────────────────────────── */
.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 224px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  z-index: 200; overflow: hidden;
}

.user-dropdown-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px;
}
.user-avatar-lg {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.user-full-name { font-size: 13px; font-weight: 600; color: var(--text); }
.user-username  { font-size: 11px; color: var(--text-3); }

.dropdown-divider { height: 1px; background: var(--border); }

.dropdown-item {
  display: flex; align-items: center; gap: 8px;
  width: 100%; padding: 9px 14px;
  font-size: 12px; color: var(--text);
  cursor: pointer; transition: background var(--trans);
  background: none; border: none; text-align: left;
}
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item-danger { color: var(--danger); }
.dropdown-item-danger:hover { background: var(--danger-dim); }
.dropdown-item-icon { font-size: 14px; }

.notif-badge-sm {
  margin-left: auto;
  background: var(--danger); color: #fff;
  border-radius: 10px; min-width: 18px; height: 18px;
  font-size: 10px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

.dropdown-section {
  padding: 10px 14px;
  display: flex; flex-direction: column; gap: 6px;
}
.dropdown-label {
  font-size: 10px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: .4px;
}

.theme-toggle-group { display: flex; gap: 4px; }
.theme-btn-opt {
  flex: 1; padding: 5px 8px; font-size: 11px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text-2);
  cursor: pointer; transition: all var(--trans);
}
.theme-btn-opt.active { background: var(--accent); color: #fff; border-color: transparent; }
.theme-btn-opt:hover:not(.active) { background: var(--surface-3); }

/* ── Detail Panel Tabs (removed — sections are now stacked) ─────────────────── */
.detail-tabs { display: none; }
.detail-tab  { display: none; }

/* ── Subscriptions Tab ───────────────────────────────────────────────────────── */
.sub-actions { margin-bottom: 14px; }
.sub-auto-note { font-size: 11px; color: var(--text-3); font-style: italic; }
.sub-list { display: flex; flex-direction: column; gap: 8px; }
.sub-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.sub-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.sub-name  { flex: 1; font-size: 12px; color: var(--text); }
.sub-badge {
  font-size: 10px; font-weight: 600; color: var(--text-3);
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 10px; padding: 1px 7px;
}

/* ── Notifications Panel ─────────────────────────────────────────────────────── */
#notif-panel {
  position: fixed; top: 0; right: -380px; width: 380px; height: 100vh;
  background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: right 280ms cubic-bezier(.4,0,.2,1);
  z-index: 350; box-shadow: var(--shadow);
}
#notif-panel.open { right: 0; }

#notif-backdrop {
  position: fixed; inset: 0; z-index: 349;
  background: rgba(0,0,0,.3); opacity: 0; pointer-events: none;
  transition: opacity 280ms ease;
}
#notif-backdrop.visible { opacity: 1; pointer-events: auto; }

.notif-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.notif-title { font-size: 14px; font-weight: 700; }

#notif-list { flex: 1; overflow-y: auto; }
.notif-empty { text-align: center; color: var(--text-3); font-size: 12px; padding: 32px 16px; }

.notif-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--trans); position: relative;
}
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: var(--accent-dim); }
.notif-item.unread:hover { filter: brightness(1.05); }

.notif-icon    { font-size: 18px; flex-shrink: 0; padding-top: 1px; }
.notif-content { flex: 1; min-width: 0; }
.notif-message { font-size: 12px; color: var(--text); line-height: 1.4; }
.notif-time    { font-size: 10px; color: var(--text-3); margin-top: 3px; }
.notif-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex-shrink: 0; margin-top: 4px;
}

/* ── Admin Tabs ──────────────────────────────────────────────────────────────── */
.admin-tabs {
  display: flex; border-bottom: 1px solid var(--border);
  margin-bottom: 14px; flex-shrink: 0;
}
.admin-tab {
  padding: 8px 16px; font-size: 12px; font-weight: 500; color: var(--text-2);
  background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: color var(--trans), border-color var(--trans);
  margin-bottom: -1px;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: var(--accent); border-bottom-color: var(--accent); }

#admin-tickets-tab { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#admin-queues-tab  { flex: 1; overflow-y: auto; }

/* ── Queue Management ────────────────────────────────────────────────────────── */
.queue-mgmt { display: flex; flex-direction: column; gap: 20px; }
.queue-create-form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.queue-create-form h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.queue-form-row { display: flex; gap: 8px; align-items: center; }
.queue-form-row input { flex: 1; height: 32px; }
.queue-form-row select { width: auto; height: 32px; }

.queue-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}
.queue-card-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;
}
.queue-card-title { font-size: 13px; font-weight: 600; }
.queue-app-badge {
  font-size: 10px; font-weight: 600; padding: 2px 8px;
  background: var(--accent-dim); color: var(--accent); border-radius: 10px;
}
.queue-members { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.queue-member-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 12px;
}
.queue-member-name { flex: 1; }
.queue-add-member-row { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.queue-add-member-row select { flex: 1; height: 30px; }

/* ── Queue Select Row (in detail panel) ─────────────────────────────────────── */
.queue-select-row { display: flex; gap: 8px; align-items: center; }
.queue-select-row select { flex: 1; height: 32px; }

/* ── Task Queue View ─────────────────────────────────────────────────────────── */
#task-queue-view {
  flex: 1; display: flex; flex-direction: column;
  padding: 16px; overflow: hidden;
}
#task-queue-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }

.task-item-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: flex-start; gap: 14px;
  border-color: var(--accent-border); background: var(--accent-dim);
}
.task-item-info { flex: 1; min-width: 0; }
.task-item-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.task-item-meta  { font-size: 11px; color: var(--text-3); }
.task-item-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: flex-start; }
.task-queue-empty { text-align: center; color: var(--text-3); font-size: 13px; padding: 40px 0; }

/* ── History Tab ─────────────────────────────────────────────────────────────── */
#history-list { display: flex; flex-direction: column; gap: 2px; }
.history-empty { font-size: 12px; color: var(--text-3); text-align: center; padding: 16px 0; }

.history-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 2px; border-bottom: 1px solid var(--border-light);
  font-size: 12px;
}
.history-item:last-child { border-bottom: none; }
.history-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  margin-top: 4px; background: var(--accent);
}
.history-dot.comment  { background: var(--text-3); }
.history-dot.created  { background: var(--success); }
.history-content { flex: 1; min-width: 0; line-height: 1.5; }
.history-actor   { font-weight: 600; color: var(--text); }
.history-change  { color: var(--text-2); }
.history-value   { color: var(--accent); font-weight: 500; }
.history-time    { font-size: 10px; color: var(--text-3); white-space: nowrap; margin-left: auto; padding-left: 8px; }

/* ── Delete Confirm Modal ────────────────────────────────────────────────────── */
#delete-confirm-backdrop {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
}
#delete-confirm-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px 32px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  text-align: center;
}
.delete-confirm-title { font-size: 16px; font-weight: 700; color: var(--text); }
.delete-confirm-msg   { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.delete-confirm-actions { display: flex; gap: 10px; margin-top: 8px; }
.delete-confirm-actions .btn { min-width: 90px; justify-content: center; }

/* ── Manage Users Modal ──────────────────────────────────────────────────────── */
#manage-users-backdrop, #api-keys-backdrop {
  position: fixed; inset: 0; z-index: 450;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center;
}
#manage-users-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 900px; max-height: 85vh;
  display: flex; flex-direction: column;
}
#manage-users-body {
  overflow-y: auto; flex: 1;
}

.mu-table { width: 100%; border-collapse: collapse; }
.mu-table th {
  background: var(--surface-2); color: var(--text-2);
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  padding: 9px 14px; text-align: left;
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
.mu-table td { padding: 10px 14px; border-bottom: 1px solid var(--border-light); font-size: 12px; }
.mu-table tbody tr:last-child td { border-bottom: none; }
.mu-user-name { font-weight: 600; color: var(--text); }
.mu-user-role { font-size: 10px; color: var(--text-3); }

.mu-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.mu-tag-check { display: flex; align-items: center; gap: 4px; cursor: pointer; }
.mu-tag-check input[type="checkbox"] { accent-color: var(--accent); cursor: pointer; width: 13px; height: 13px; }
.mu-tag-check span { font-size: 11px; color: var(--text-2); }
.mu-save-btn { padding: 3px 10px; font-size: 11px; }

/* ── API Keys Modal ──────────────────────────────────────────────────────────── */
#api-keys-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: 100%; max-width: 580px; max-height: 85vh;
  display: flex; flex-direction: column;
}
.api-keys-hint {
  font-size: 11px; color: var(--text-3); line-height: 1.6;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
}
.api-keys-hint code {
  background: var(--surface-3); border-radius: 3px;
  padding: 1px 5px; font-family: monospace; font-size: 11px; color: var(--accent);
}

.api-key-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border-light);
  font-size: 12px;
}
.api-key-row:last-child { border-bottom: none; }
.api-key-app { font-weight: 600; color: var(--text); min-width: 90px; }
.api-key-label { color: var(--text-3); flex: 1; }
.api-key-value {
  font-family: monospace; font-size: 11px; color: var(--text-2);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 3px 8px;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}
.api-key-value:hover { border-color: var(--accent); color: var(--accent); }
.api-keys-empty { text-align: center; color: var(--text-3); font-size: 12px; padding: 24px 0; }

/* ── Saved Views Bar ───────────────────────────────────────────────────────── */
#saved-views-bar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 6px 16px; background: var(--surface-1); border-bottom: 1px solid var(--border);
}
#saved-views-chips { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.saved-view-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px 3px 12px;
  font-size: 12px; color: var(--text); cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.saved-view-chip:hover { border-color: var(--accent); background: var(--surface-3); }
.saved-view-chip-del {
  background: none; border: none; cursor: pointer;
  color: var(--text-3); font-size: 14px; line-height: 1;
  padding: 0 2px; border-radius: 50%;
}
.saved-view-chip-del:hover { color: var(--danger); }
.save-view-btn { font-size: 12px; padding: 4px 10px; white-space: nowrap; }

/* Save View Modal */
#save-view-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.55);
  z-index: 1100; display: flex; align-items: center; justify-content: center;
}
#save-view-box {
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
#save-view-box h3 { margin: 0 0 6px; font-size: 15px; }
#save-view-box p  { margin: 0 0 14px; font-size: 12px; color: var(--text-2); }
#save-view-name {
  width: 100%; box-sizing: border-box;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  padding: 8px 10px; font-size: 13px; margin-bottom: 14px;
}
#save-view-name:focus { outline: none; border-color: var(--accent); }
.save-view-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Attachments ───────────────────────────────────────────────────────────── */
.attachment-upload-area {
  border: 2px dashed var(--border); border-radius: var(--radius);
  padding: 20px; text-align: center; transition: border-color 0.2s, background 0.2s;
  margin-top: 10px; cursor: pointer;
}
.attachment-upload-area.drag-over {
  border-color: var(--accent); background: var(--accent-dim, rgba(232,130,58,0.08));
}
.attachment-drop-inner {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--text-2); font-size: 13px;
}
.attachment-drop-inner svg { width: 28px; height: 28px; opacity: 0.5; }
.attachment-browse-btn {
  background: none; border: none; color: var(--accent);
  cursor: pointer; font-size: 13px; padding: 0; text-decoration: underline;
}
.attachment-hint { font-size: 11px; color: var(--text-3); }

.attachment-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border-light);
}
.attachment-item:last-child { border-bottom: none; }
.attachment-thumb {
  width: 48px; height: 48px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.attachment-icon {
  width: 48px; height: 48px; display: flex; align-items: center; justify-content: center;
  font-size: 24px; background: var(--surface-2); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.attachment-info { flex: 1; min-width: 0; }
.attachment-name {
  color: var(--accent); font-size: 13px; font-weight: 500;
  text-decoration: none; display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.attachment-name:hover { text-decoration: underline; }
.attachment-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.attachment-preview-link { display: flex; flex-shrink: 0; }

/* Pending attachments in new ticket modal */
#new-ticket-attachments-preview { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.pending-attachment-item {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-2); padding: 2px 0;
}
.pending-attachment-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pending-attachment-size { color: var(--text-3); flex-shrink: 0; }
.pending-attachment-remove {
  background: none; border: none; color: var(--text-3);
  cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px;
  transition: color var(--trans); flex-shrink: 0;
}
.pending-attachment-remove:hover { color: var(--danger); }

/* ── @Mention ──────────────────────────────────────────────────────────────── */
.mention-highlight {
  color: var(--accent); font-weight: 600; background: rgba(232,130,58,0.12);
  border-radius: 3px; padding: 0 2px;
}
.mention-dropdown {
  position: fixed; z-index: 2000; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0,0,0,0.35); min-width: 220px; max-width: 300px;
  overflow: hidden;
}
.mention-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; cursor: pointer; font-size: 13px;
  transition: background 0.1s;
}
.mention-item:hover { background: var(--surface-3); }
.mention-avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; flex-shrink: 0;
}
.mention-name { font-weight: 500; color: var(--text); }
.mention-handle { font-size: 11px; color: var(--text-3); margin-left: auto; }

/* ── Reports ───────────────────────────────────────────────────────────────── */
#reports-view { padding: 0 16px 24px; }
.report-cards {
  display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 24px;
}
.report-card {
  flex: 1; min-width: 120px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 20px; text-align: center;
}
.report-card-warn { border-color: var(--danger); }
.report-card-value {
  font-size: 32px; font-weight: 700; color: var(--text); line-height: 1;
}
.report-card-warn .report-card-value { color: var(--danger); }
.report-card-label { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.reports-charts {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.report-chart-card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.report-chart-card:first-child { grid-column: 1 / -1; }
.report-chart-card h3 { margin: 0 0 12px; font-size: 13px; color: var(--text-2); font-weight: 600; }
@media (max-width: 700px) {
  .reports-charts { grid-template-columns: 1fr; }
  .report-chart-card:first-child { grid-column: 1; }
}

/* ── CSP utility classes ─────────────────────────────────────────────────── */
.muted { color: var(--text-3); }
.notif-header-actions { display: flex; gap: 8px; align-items: center; }
.tbl-empty { text-align: center; color: var(--text-3); padding: 24px; }
.comment-preview { color: var(--text-2); }
.label-tag--cap { text-transform: capitalize; }
.queue-empty { color: var(--text-3); font-size: 12px; padding: 16px 0; }
.queue-no-members { color: var(--text-3); font-size: 12px; }
.btn-xs { padding: 2px 8px !important; font-size: 11px !important; }
.btn-xs--ml { margin-left: auto; }
.btn-add-mem { padding: 0 12px !important; height: 30px !important; font-size: 12px !important; }
.text-center { text-align: center; }
.perm-checkbox { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }
.state-center { padding: 24px; text-align: center; color: var(--text-3); }
.state-error { padding: 24px; color: var(--danger); }
.state-muted-sm { color: var(--text-3); padding: 16px; }
.state-danger-sm { color: var(--danger); padding: 16px; }
