@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;600;700&family=Inter:wght@400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface2: #1a1a24;
  --surface3: #22222f;
  --border: #252535;
  --border2: #303045;
  --text: #e0e0e0;
  --text-dim: #666680;
  --text-muted: #444460;
  --accent: #00ff88;
  --accent-dim: rgba(0,255,136,0.1);
  --accent-hover: #00dd66;
  --danger: #ff4455;
  --danger-dim: rgba(255,68,85,0.1);
  --warning: #ffaa00;
  --info: #4488ff;
  --critical: #ff2244;
  --high: #ff6644;
  --medium: #ffaa00;
  --low: #44cc88;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Courier New', monospace;
  --radius: 6px;
  --sidebar-w: 260px;
  --header-h: 48px;
  --transition: 150ms ease;
}

body { background: var(--bg); color: var(--text); font-family: var(--font); font-size: 13px; line-height: 1.5; min-height: 100vh; overflow: hidden; }

/* ── Scrollbars ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Typography ── */
.mono { font-family: var(--mono); }
.text-dim { color: var(--text-dim); }
.text-accent { color: var(--accent); }
.text-danger { color: var(--danger); }
.text-sm { font-size: 11px; }
.text-xs { font-size: 10px; }
.uppercase { text-transform: uppercase; letter-spacing: 0.08em; }
.font-bold { font-weight: 700; }

/* ── Layout ── */
.app-layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; transition: width var(--transition); overflow: hidden; }
.sidebar.collapsed { width: 48px; }
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.top-header { height: var(--header-h); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 16px; gap: 12px; flex-shrink: 0; background: var(--surface); }
.content-area { flex: 1; overflow-y: auto; padding: 20px; }

/* ── Sidebar ── */
.sidebar-header { padding: 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; min-height: 48px; }
.sidebar-logo { font-family: var(--mono); font-size: 14px; font-weight: 700; color: var(--accent); white-space: nowrap; overflow: hidden; }
.sidebar.collapsed .sidebar-logo { opacity: 0; }

.sidebar-nav { display: flex; gap: 4px; padding: 8px; }
.sidebar-nav button { background: none; border: none; color: var(--text-dim); cursor: pointer; padding: 5px; border-radius: 4px; font-size: 12px; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.sidebar-nav button:hover { background: var(--surface2); color: var(--text); }
.sidebar.collapsed .sidebar-nav { flex-direction: column; align-items: center; }

.sidebar-search { padding: 8px 12px; }
.search-input-wrap { display: flex; align-items: center; gap: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; }
.search-input-wrap:focus-within { border-color: var(--accent); }
.search-input-wrap input { background: none; border: none; outline: none; color: var(--text); font-size: 12px; width: 100%; }
.search-input-wrap .icon { color: var(--text-dim); font-size: 11px; flex-shrink: 0; }
.sidebar.collapsed .search-input-wrap { display: none; }

.sidebar-scroll { flex: 1; overflow-y: auto; padding: 4px 0; }
.sidebar-section { margin-bottom: 4px; }
.sidebar-section-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); padding: 8px 12px 4px; white-space: nowrap; overflow: hidden; }
.sidebar.collapsed .sidebar-section-title { display: none; }
.sidebar-item { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; font-size: 12px; color: var(--text-dim); border-radius: 0; border-left: 2px solid transparent; transition: all var(--transition); white-space: nowrap; overflow: hidden; position: relative; }
.sidebar-item:hover { background: var(--surface2); color: var(--text); }
.sidebar-item.active { background: var(--surface2); color: var(--accent); border-left-color: var(--accent); }
.sidebar-item .icon { flex-shrink: 0; font-size: 13px; width: 16px; text-align: center; }
.sidebar-item .label { overflow: hidden; text-overflow: ellipsis; flex: 1; }
.sidebar-item .count { font-size: 10px; background: var(--surface3); padding: 1px 5px; border-radius: 8px; color: var(--text-dim); margin-left: auto; flex-shrink: 0; }
.sidebar-item .count.active-count { background: var(--danger); color: white; }
.sidebar.collapsed .sidebar-item .label,
.sidebar.collapsed .sidebar-item .count { display: none; }
.sidebar.collapsed .sidebar-item { justify-content: center; padding: 8px; }

.sidebar-footer { padding: 8px 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.user-avatar { width: 28px; height: 28px; background: var(--accent-dim); border: 1px solid var(--accent); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: var(--accent); flex-shrink: 0; }
.user-info { flex: 1; overflow: hidden; }
.user-name { font-size: 12px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-email { font-size: 10px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar.collapsed .user-info { display: none; }

/* ── Top Header ── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-dim); overflow: hidden; flex: 1; min-width: 0; }
.breadcrumb .crumb { color: var(--text-dim); cursor: pointer; transition: color var(--transition); }
.breadcrumb .crumb:hover { color: var(--text); }
.breadcrumb .crumb.current { color: var(--text); font-weight: 600; }
.breadcrumb .sep { color: var(--text-muted); font-size: 10px; }
.header-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; flex-shrink: 0; }

/* ── Buttons ── */
.btn { display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border: none; border-radius: var(--radius); font-size: 12px; font-weight: 600; cursor: pointer; transition: all var(--transition); white-space: nowrap; font-family: var(--font); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #000; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--border2); color: var(--text); }
.btn-danger { background: var(--danger-dim); color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: white; }
.btn-ghost { background: none; color: var(--text-dim); }
.btn-ghost:hover:not(:disabled) { background: var(--surface2); color: var(--text); }
.btn-sm { padding: 4px 8px; font-size: 11px; }
.btn-icon { padding: 6px; }
.btn-icon svg { width: 14px; height: 14px; }

/* ── Forms ── */
.form-input, .form-select, .form-textarea { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; color: var(--text); font-size: 13px; font-family: var(--font); outline: none; transition: border-color var(--transition); width: 100%; }
.form-input:focus, .form-select:focus, .form-textarea:focus { border-color: var(--accent); }
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 28px; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-dim); margin-bottom: 4px; }
.form-group { margin-bottom: 12px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 10px; color: var(--text-muted); margin-top: 3px; }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.card-header { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.card-title { font-size: 13px; font-weight: 600; flex: 1; }

/* ── Issue Cards ── */
.issue-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; }
.issue-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; transition: all var(--transition); cursor: pointer; position: relative; }
.issue-card:hover { border-color: var(--border2); transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
.issue-card.selected { border-color: var(--accent); background: var(--accent-dim); }
.issue-card.selected::before { content: '✓'; position: absolute; top: 6px; right: 8px; color: var(--accent); font-size: 11px; }
.issue-card.dragging { opacity: 0.5; }
.issue-card-header { padding: 10px 12px 6px; display: flex; align-items: flex-start; gap: 8px; }
.issue-num { font-family: var(--mono); font-size: 10px; background: var(--surface2); color: var(--text-dim); padding: 2px 6px; border-radius: 3px; flex-shrink: 0; font-weight: 600; }
.issue-title { font-size: 13px; font-weight: 600; flex: 1; line-height: 1.3; }
.issue-title-input { background: none; border: none; border-bottom: 1px solid var(--accent); color: var(--text); font-size: 13px; font-weight: 600; font-family: var(--font); outline: none; width: 100%; padding: 0; }
.priority-badge { font-size: 9px; padding: 2px 5px; border-radius: 3px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; flex-shrink: 0; }
.priority-badge.Critical { background: var(--critical); color: white; }
.priority-badge.High { background: var(--high); color: white; }
.priority-badge.Medium { background: var(--medium); color: #000; }
.priority-badge.Low { background: var(--low); color: #000; }
.issue-body { padding: 0 12px 10px; }
.issue-note { font-size: 12px; color: var(--text-dim); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.issue-note-input { background: var(--bg); border: 1px solid var(--border); border-radius: 3px; color: var(--text); font-size: 12px; font-family: var(--font); outline: none; width: 100%; padding: 4px 6px; resize: none; min-height: 50px; }
.issue-note-input:focus { border-color: var(--accent); }
.issue-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.tag { font-size: 10px; padding: 2px 6px; border-radius: 3px; font-family: var(--mono); }
.tag.selector { background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border); }
.tag.element { background: rgba(68,136,255,0.1); color: var(--info); }
.tag.testid { background: rgba(255,170,0,0.1); color: var(--warning); }
.tag.tailwind { background: rgba(0,255,136,0.1); color: var(--accent); }
.tag.category { background: var(--surface2); color: var(--text-dim); }
.issue-footer { padding: 6px 12px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.issue-actions { display: flex; gap: 4px; margin-left: auto; opacity: 0; transition: opacity var(--transition); }
.issue-card:hover .issue-actions { opacity: 1; }

/* ── Page Section ── */
.page-section { margin-bottom: 24px; }
.page-header { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; user-select: none; }
.page-header:hover .page-name { color: var(--accent); }
.page-toggle { font-size: 10px; color: var(--text-muted); transition: transform var(--transition); }
.page-toggle.expanded { transform: rotate(90deg); }
.page-name { font-size: 14px; font-weight: 600; flex: 1; }
.page-url { font-size: 11px; color: var(--text-muted); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 300px; }
.page-issue-count { font-size: 10px; background: var(--surface2); padding: 2px 6px; border-radius: 8px; color: var(--text-dim); }
.page-actions { display: flex; gap: 4px; opacity: 0; transition: opacity var(--transition); }
.page-header:hover .page-actions { opacity: 1; }
.page-body { padding-left: 20px; }

/* ── Batch Toolbar ── */
.batch-toolbar { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--surface2); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 16px; display: flex; align-items: center; gap: 12px; z-index: 100; box-shadow: 0 8px 32px rgba(0,0,0,0.5); }
.batch-toolbar .count { font-size: 12px; color: var(--accent); font-weight: 600; }
.batch-toolbar .sep { width: 1px; height: 20px; background: var(--border); }

/* ── Modal ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.7); z-index: 200; display: none; align-items: center; justify-content: center; }
.modal-overlay.active { display: flex; }
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; width: 560px; max-width: 90vw; max-height: 85vh; overflow-y: auto; }
.modal-lg { width: 760px; }
.modal-header { padding: 14px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 14px; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; padding: 0; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Toast ── */
.toast-container { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column-reverse; gap: 6px; z-index: 9999; }
.toast { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; font-size: 12px; display: flex; align-items: center; gap: 8px; animation: slideUp 0.2s ease; box-shadow: 0 4px 16px rgba(0,0,0,0.4); }
.toast.accent { border-color: var(--accent); color: var(--accent); }
.toast.danger { border-color: var(--danger); color: var(--danger); }
.toast.warning { border-color: var(--warning); color: var(--warning); }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Command Palette ── */
.cmd-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 300; display: none; align-items: flex-start; justify-content: center; padding-top: 15vh; }
.cmd-overlay.active { display: flex; }
.cmd-palette { background: var(--surface); border: 1px solid var(--border2); border-radius: 8px; width: 560px; max-width: 90vw; max-height: 60vh; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,0.6); }
.cmd-input-wrap { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.cmd-input { background: none; border: none; color: var(--text); font-size: 15px; font-family: var(--font); outline: none; flex: 1; }
.cmd-input::placeholder { color: var(--text-muted); }
.cmd-icon { color: var(--text-dim); font-size: 14px; }
.cmd-results { max-height: 400px; overflow-y: auto; padding: 4px 0; }
.cmd-group-title { font-size: 10px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-muted); padding: 6px 16px 2px; }
.cmd-item { display: flex; align-items: center; gap: 10px; padding: 8px 16px; cursor: pointer; font-size: 13px; transition: background var(--transition); }
.cmd-item:hover, .cmd-item.active { background: var(--surface2); }
.cmd-item .icon { font-size: 13px; color: var(--text-dim); width: 20px; text-align: center; }
.cmd-item .type-badge { font-size: 9px; text-transform: uppercase; letter-spacing: 0.05em; padding: 1px 5px; border-radius: 3px; margin-left: auto; }
.cmd-item .type-badge.project { background: var(--accent-dim); color: var(--accent); }
.cmd-item .type-badge.page { background: rgba(68,136,255,0.1); color: var(--info); }
.cmd-item .type-badge.issue { background: rgba(255,170,0,0.1); color: var(--warning); }
.cmd-empty { padding: 24px; text-align: center; color: var(--text-dim); font-size: 13px; }

/* ── Activity Feed ── */
.activity-panel { border-top: 1px solid var(--border); padding: 12px; max-height: 200px; overflow-y: auto; }
.activity-item { display: flex; gap: 8px; padding: 4px 0; font-size: 11px; color: var(--text-dim); }
.activity-user { color: var(--text); font-weight: 600; }
.activity-time { color: var(--text-muted); margin-left: auto; flex-shrink: 0; }

/* ── Stats Row ── */
.stats-row { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 16px; text-align: center; min-width: 70px; }
.stat-card .val { font-size: 22px; font-weight: 700; font-family: var(--mono); color: var(--accent); }
.stat-card .val.danger { color: var(--danger); }
.stat-card .lbl { font-size: 9px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-top: 2px; }

/* ── Empty State ── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-dim); }
.empty-icon { font-size: 36px; margin-bottom: 12px; opacity: 0.3; }
.empty-state h3 { font-size: 15px; color: var(--text-dim); margin-bottom: 6px; }
.empty-state p { font-size: 12px; color: var(--text-muted); }

/* ── Drag Handle ── */
.drag-handle { cursor: grab; color: var(--text-muted); font-size: 12px; padding: 2px; }
.drag-handle:active { cursor: grabbing; }

/* ── Status Select ── */
.status-select { background: var(--surface2); border: 1px solid var(--border); border-radius: 3px; color: var(--text-dim); font-size: 10px; padding: 2px 4px; cursor: pointer; }
.status-select:focus { outline: none; border-color: var(--accent); }

/* ── Inline edit ── */
[data-inline-edit] { cursor: text; border-bottom: 1px dashed var(--border2); padding: 0 2px; }
[data-inline-edit]:hover { border-bottom-color: var(--accent); }
[data-inline-edit]:focus { outline: none; border-bottom: 1px solid var(--accent); background: var(--bg); }

/* ── Login ── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg); overflow: auto; padding: 20px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 36px; width: 360px; max-width: 100%; }
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-text { font-family: var(--mono); font-size: 22px; font-weight: 700; color: var(--accent); letter-spacing: -0.5px; }
.login-logo .logo-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.login-form .form-group { margin-bottom: 14px; }
.login-form .btn { width: 100%; justify-content: center; padding: 10px; font-size: 13px; margin-top: 4px; }
.login-error { background: var(--danger-dim); border: 1px solid var(--danger); border-radius: 4px; padding: 8px 12px; font-size: 12px; color: var(--danger); margin-bottom: 12px; display: none; }
.login-error.show { display: block; }
.login-footer { text-align: center; margin-top: 16px; font-size: 10px; color: var(--text-muted); }

/* ── Keyboard Shortcuts Hint ── */
.kbd { background: var(--surface2); border: 1px solid var(--border2); border-radius: 3px; padding: 1px 5px; font-size: 10px; font-family: var(--mono); color: var(--text-dim); }

/* ── Project Header ── */
.project-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 20px; }
.project-title { font-size: 20px; font-weight: 700; font-family: var(--mono); }
.project-desc { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.project-badges { display: flex; gap: 6px; margin-top: 6px; }
.badge { font-size: 10px; padding: 2px 7px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.05em; }
.badge-private { background: var(--surface2); color: var(--text-dim); border: 1px solid var(--border); }
.badge-shared { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent); }

/* ── Member Pills ── */
.member-pills { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.member-pill { display: flex; align-items: center; gap: 4px; background: var(--surface2); border: 1px solid var(--border); border-radius: 20px; padding: 2px 8px; font-size: 11px; color: var(--text-dim); }
.member-pill .avatar { width: 16px; height: 16px; background: var(--accent-dim); border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: 700; color: var(--accent); }
.member-pill .remove { cursor: pointer; color: var(--text-muted); font-size: 10px; margin-left: 2px; }
.member-pill .remove:hover { color: var(--danger); }

/* ── Filter Bar ── */
.filter-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filter-chip { display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 3px 10px; font-size: 11px; color: var(--text-dim); cursor: pointer; transition: all var(--transition); }
.filter-chip:hover, .filter-chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.filter-chip .x { font-size: 10px; margin-left: 2px; }

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

/* ── Animations ── */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fadeIn 0.15s ease; }

/* ── Divider ── */
.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* ── Tooltip ── */
[data-tooltip] { position: relative; }
[data-tooltip]::after { content: attr(data-tooltip); position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%); background: var(--surface3); border: 1px solid var(--border); color: var(--text); font-size: 10px; padding: 3px 7px; border-radius: 3px; white-space: nowrap; pointer-events: none; opacity: 0; transition: opacity var(--transition); z-index: 50; }
[data-tooltip]:hover::after { opacity: 1; }
