:root {
  --bg: #0d0d0d;
  --surface: #181818;
  --card: #1e1e1e;
  --card-hover: #242424;
  --border: #2a2a2a;
  --border-light: #333;
  --text: #e8e8e8;
  --text-muted: #909090;
  --text-dim: #b8b8b8;
  --accent: #e05a2b;
  --accent-hover: #c84a1e;
  --accent-light: rgba(224,90,43,.15);
  --accent-glow: rgba(224,90,43,.08);
  --sidebar-w: 220px;
  --topbar-h: 52px;
  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }
body { background: var(--bg); color: var(--text); font-family: 'Segoe UI', system-ui, sans-serif; font-size: 14px; margin: 0; }
a { color: inherit; text-decoration: none; }
input, textarea, select { color-scheme: dark; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #444; }

/* ── Layout ── */
#wrapper { display: flex; min-height: 100vh; }
#page-content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; display: flex; flex-direction: column; }

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  background: #111;
  border-right: 1px solid var(--border);
  position: fixed; top: 0; left: 0; bottom: 0;
  display: flex; flex-direction: column;
  z-index: 100;
}

.sidebar-brand {
  padding: 18px 20px 14px;
  font-size: 16px; font-weight: 800;
  color: var(--text); letter-spacing: -.3px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
}
.sidebar-brand .dot { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; flex-shrink: 0; }

.sidebar-section { padding: 16px 12px 4px; font-size: 10px; font-weight: 700; color: #444; text-transform: uppercase; letter-spacing: 1px; }

.sidebar-nav { list-style: none; padding: 8px 8px 0; margin: 0; flex: 1; }
.sidebar-nav li a {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; border-radius: var(--radius-sm);
  color: var(--text-muted); font-size: 13px; font-weight: 500;
  transition: background .12s, color .12s;
}
.sidebar-nav li a:hover { background: var(--surface); color: var(--text-dim); }
.sidebar-nav li a.active { background: var(--accent-light); color: var(--accent); font-weight: 600; }
.sidebar-nav li a i { font-size: 15px; width: 18px; flex-shrink: 0; }

.sidebar-footer { padding: 14px; border-top: 1px solid var(--border); }
.avatar-sm {
  width: 30px; height: 30px; background: var(--accent); color: #fff;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h); background: #111;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}

/* ── Cards ── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.card-header {
  background: var(--surface); border-bottom: 1px solid var(--border);
  padding: 11px 16px; font-size: 13px; color: var(--text);
}

/* ── Buttons ── */
.btn { border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; transition: .12s; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #fff; }
.btn-outline-primary { color: var(--accent); border-color: var(--accent); background: transparent; }
.btn-outline-primary:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-outline-secondary { color: var(--text-muted); border-color: var(--border-light); background: transparent; }
.btn-outline-secondary:hover { background: var(--surface); color: var(--text); border-color: var(--border-light); }
.btn-secondary { background: var(--surface); border-color: var(--border); color: var(--text-muted); }
.btn-secondary:hover { background: var(--card-hover); color: var(--text); border-color: var(--border-light); }
.btn-ghost { background: transparent; border: none; padding: 4px 8px; border-radius: var(--radius-sm); color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-success { background: #16a34a; border-color: #16a34a; color: #fff; }
.btn-warning { background: #ca8a04; border-color: #ca8a04; color: #fff; }
.btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-sm { font-size: 12px; padding: 4px 10px; }

/* ── Forms ── */
.form-control, .form-select {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); font-size: 13px;
}
.form-control:focus, .form-select:focus {
  background: var(--surface); border-color: var(--accent);
  color: var(--text); box-shadow: 0 0 0 2px var(--accent-light); outline: none;
}
.form-control::placeholder { color: var(--text-muted); }
.form-label { color: var(--text-dim); font-size: 12px; font-weight: 600; }
.form-check-input { background-color: var(--surface); border-color: var(--border-light); }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.input-group-text { background: var(--surface); border-color: var(--border); color: var(--text-muted); }

/* ── Modal ── */
.modal-content { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.modal-header { border-bottom-color: var(--border); }
.modal-footer { border-top-color: var(--border); }
.modal-title { color: var(--text); font-size: 15px; font-weight: 700; }
.btn-close { filter: invert(1) brightness(.6); }
.btn-close:hover { filter: invert(1) brightness(1); }

/* ── Table ── */
.table { color: var(--text); }
.table > :not(caption) > * > * { padding: 10px 12px; border-color: var(--border); background: transparent; }
.table thead th { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; border-color: var(--border); }
.table-hover tbody tr:hover > * { background: var(--card-hover); }
.table-striped > tbody > tr:nth-of-type(odd) > * { background: rgba(255,255,255,.02); }

/* ── Badges ── */
.badge { font-size: 11px; font-weight: 600; border-radius: 4px; }
.status-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-new      { background: rgba(37,99,235,.2); color: #60a5fa; }
.badge-progress { background: rgba(22,163,74,.2); color: #4ade80; }
.badge-waiting  { background: rgba(202,138,4,.2); color: #fbbf24; }
.badge-closed   { background: rgba(8,145,178,.2); color: #22d3ee; }
.badge-rejected { background: rgba(220,38,38,.2); color: #f87171; }

/* ── Priority badges ── */
.priority-low    { background: rgba(100,116,139,.2); color: #94a3b8; }
.priority-medium { background: rgba(202,138,4,.2); color: #fbbf24; }
.priority-high   { background: rgba(234,88,12,.2); color: #fb923c; }
.priority-urgent { background: rgba(220,38,38,.2); color: #f87171; }

/* ── Task status badges ── */
.task-todo       { background: rgba(100,116,139,.2); color: #94a3b8; }
.task-inprogress { background: rgba(37,99,235,.2); color: #60a5fa; }
.task-review     { background: rgba(202,138,4,.2); color: #fbbf24; }
.task-done       { background: rgba(22,163,74,.2); color: #4ade80; }

/* ── Stat cards ── */
.stat-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; text-align: center;
}
.stat-value { font-size: 26px; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.stat-new      .stat-value { color: #60a5fa; }
.stat-progress .stat-value { color: #4ade80; }
.stat-waiting  .stat-value { color: #fbbf24; }
.stat-closed   .stat-value { color: #22d3ee; }
.stat-rejected .stat-value { color: #f87171; }
.stat-today    .stat-value { color: var(--accent); }

/* ── Kanban ── */
.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 16px; min-height: calc(100vh - 160px); }
.kanban-column { min-width: 260px; flex: 0 0 260px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; }
.kanban-col-header { padding: 12px 14px; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.kanban-cards { padding: 8px; flex: 1; overflow-y: auto; max-height: calc(100vh - 210px); }
.kanban-card { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 11px 12px; margin-bottom: 7px; cursor: pointer; transition: border-color .12s, box-shadow .12s; font-size: 13px; }
.kanban-card:hover { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-light); }
.kanban-card.dragging { opacity: .4; }
.kanban-cards.drag-over { background: var(--accent-glow); outline: 2px dashed var(--accent); border-radius: 8px; }

/* ── Timeline ── */
.timeline { position: relative; padding-left: 24px; }
.timeline::before { content:''; position:absolute; left:8px; top:0; bottom:0; width:2px; background: var(--border); }
.timeline-item { position: relative; margin-bottom: 14px; }
.timeline-dot { width:14px; height:14px; border-radius:50%; position:absolute; left:-20px; top:4px; border:2px solid var(--card); box-shadow:0 0 0 2px var(--border); }
.dot-created { background:#3b82f6; }
.dot-status  { background:var(--accent); }
.dot-comment { background:#6366f1; }
.timeline-content { background:var(--surface); border:1px solid var(--border); border-radius:8px; padding:9px 13px; }

/* ── Info labels ── */
.info-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: 2px; }
.info-value { font-size: 14px; color: var(--text); }

/* ── Task panel (slide-in) ── */
.task-panel-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 200;
  display: none; align-items: stretch; justify-content: flex-end;
}
.task-panel-overlay.open { display: flex; }
.task-panel {
  width: 560px; max-width: 95vw;
  background: var(--card); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; height: 100vh; overflow-y: auto;
}
.task-panel-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; position: sticky; top: 0;
  background: var(--card); z-index: 1;
}
.task-panel-body { padding: 20px; flex: 1; }
.task-panel-footer { padding: 16px 20px; border-top: 1px solid var(--border); }

/* ── Project cards ── */
.project-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.project-card:hover { border-color: var(--accent); box-shadow: 0 4px 20px rgba(224,90,43,.08); }
.project-color-bar { width: 4px; border-radius: 2px; flex-shrink: 0; align-self: stretch; min-height: 40px; }
.project-progress { height: 3px; background: var(--border); border-radius: 2px; margin-top: 10px; }
.project-progress-fill { height: 100%; border-radius: 2px; transition: width .3s; }

/* ── Files drop zone ── */
.files-drop-zone {
  position: absolute; inset: 0; background: var(--accent-glow);
  border: 2px dashed var(--accent); border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  z-index: 20; color: var(--accent); pointer-events: none;
}

/* ── Custom Fields table ── */
#customFieldsTable td { border-bottom: 1px solid var(--border); }
#customFieldsTable tr:last-child td { border-bottom: none; }
#customFieldsTable .form-control-sm,
#customFieldsTable .form-select-sm { font-size: 13px; }

/* ── Drag handle ── */
.drag-handle { cursor: grab; color: var(--text-muted); }

/* ── Misc ── */
.text-accent { color: var(--accent); }
.text-muted { color: var(--text-muted) !important; }
.bg-surface { background: var(--surface); }
.border-color { border-color: var(--border) !important; }
.font-monospace { font-family: 'Courier New', monospace; }
.divider { border-color: var(--border); }

/* ── Login ── */
.login-body { background: var(--bg); min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 40px 36px; width: 100%; max-width: 400px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.login-logo { width: 52px; height: 52px; background: var(--accent); border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 26px; color: #fff; margin: 0 auto 20px; }

/* ── Toast ── */
.toast { background: var(--card); border: 1px solid var(--border); color: var(--text); min-width: 240px; }
.toast-header { background: var(--surface); border-bottom-color: var(--border); color: var(--text); }

/* ── Pagination ── */
.pagination .page-link { background: var(--surface); border-color: var(--border); color: var(--text-muted); }
.pagination .page-link:hover { background: var(--card-hover); color: var(--text); }
.pagination .page-item.active .page-link { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── Dropdown ── */
.dropdown-menu { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.dropdown-item { color: var(--text-dim); font-size: 13px; }
.dropdown-item:hover { background: var(--surface); color: var(--text); }
.dropdown-divider { border-color: var(--border); }

/* ── Responsive ── */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); transition: transform .2s; }
  #sidebar.open { transform: translateX(0); }
  #page-content { margin-left: 0; }
  .task-panel { width: 100vw; }
}

/* ── Color presets ── */
.color-preset { width: 22px; height: 22px; border: 2px solid transparent; border-radius: 50%; cursor: pointer; transition: .12s; }
.color-preset:hover { border-color: var(--text); transform: scale(1.2); }

/* ── Light theme ── */
body.theme-light {
  --bg: #f1f5f9;
  --surface: #ffffff;
  --card: #ffffff;
  --card-hover: #f8fafc;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
  --text: #1e293b;
  --text-muted: #64748b;
  --text-dim: #475569;
  --accent-glow: rgba(224,90,43,.05);
}
body.theme-light input, body.theme-light textarea, body.theme-light select { color-scheme: light; }
body.theme-light .topbar { background: #ffffff; border-bottom-color: #e2e8f0; }
body.theme-light #sidebar { background: #1e293b; border-right-color: #334155; }
body.theme-light #sidebar .sidebar-brand { border-bottom-color: #334155; color: #f1f5f9; }
body.theme-light #sidebar .sidebar-section { color: #475569; }
body.theme-light #sidebar .sidebar-nav li a { color: #94a3b8; }
body.theme-light #sidebar .sidebar-nav li a:hover { background: rgba(255,255,255,.06); color: #cbd5e1; }
body.theme-light #sidebar .sidebar-nav li a.active { background: var(--accent-light); color: var(--accent); }
body.theme-light #sidebar .sidebar-footer { border-top-color: #334155; }
body.theme-light .table-hover tbody tr:hover > * { background: #f8fafc; }
body.theme-light .table-striped > tbody > tr:nth-of-type(odd) > * { background: rgba(0,0,0,.02); }
body.theme-light .timeline-content { background: #f8fafc; }
body.theme-light .kanban-column { background: #f8fafc; }
body.theme-light .kanban-card:hover { border-color: var(--accent); }
body.theme-light .task-panel { background: #ffffff; }
body.theme-light .task-panel-header { background: #ffffff; }
body.theme-light .project-card:hover { border-color: var(--accent); }
body.theme-light .btn-close { filter: none; }
body.theme-light .modal-backdrop { background: rgba(0,0,0,.4); }

/* ── Theme toggle ── */
.theme-toggle {
  background: var(--surface); border: 1px solid var(--border);
  padding: 6px 10px; border-radius: var(--radius-sm);
  color: var(--text); cursor: pointer; font-size: 16px; line-height: 1;
  transition: background .15s, border-color .15s, color .15s;
  display: flex; align-items: center;
}
.theme-toggle:hover { background: var(--card-hover); border-color: var(--accent); color: var(--accent); }

/* ── Integration cards ── */
.integration-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 24px; margin-bottom: 16px; }
.integration-card .int-header { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.integration-icon { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.int-status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }
.int-status.on  { background: rgba(22,163,74,.15); color: #4ade80; }
.int-status.off { background: rgba(100,116,139,.15); color: #94a3b8; }
.int-status .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
body.theme-light .int-status.on  { background: rgba(22,163,74,.12); color: #16a34a; }
body.theme-light .int-status.off { background: rgba(100,116,139,.12); color: #64748b; }
