:root {
  --bg: #0f1115;
  --bg-elev: #161922;
  --bg-card: #1c2030;
  --bg-tile: #1f2434;
  --bg-tile-hover: #252b3e;
  --border: #262b3b;
  --border-strong: #323849;
  --text: #e6e8ef;
  --text-dim: #9aa3b8;
  --text-faint: #6b7385;
  --accent: #5b8cff;
  --accent-2: #7c5cff;
  --green: #2bd4a4;
  --yellow: #f5c451;
  --red: #ff6b6b;
  --orange: #ff9b54;
  --purple: #b38bff;
  --blue: #5b8cff;
  --gray: #6b7385;
  --shadow: 0 8px 24px rgba(0,0,0,0.35);
  --shadow-sm: 0 2px 6px rgba(0,0,0,0.25);
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.hidden { display: none !important; }

/* ---------- LOGIN SCREEN ---------- */
.login-screen {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(91,140,255,0.15), transparent 50%),
    radial-gradient(circle at 80% 70%, rgba(124,92,255,0.15), transparent 50%),
    var(--bg);
  z-index: 50;
}
.login-card {
  width: min(420px, 92vw);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-card h2 { margin: 0 0 4px; font-size: 22px; }
.login-help { color: var(--text-faint); margin: 0 0 18px; font-size: 13px; }
.login-form { display: flex; flex-direction: column; gap: 8px; }
.login-form label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 1px; font-weight: 600; margin-top: 6px; }
.login-form .primary-btn { margin-top: 14px; padding: 11px; }
.login-error {
  margin-top: 8px;
  background: rgba(255,107,107,0.12);
  border: 1px solid rgba(255,107,107,0.35);
  color: var(--red);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 12px;
}
.login-footer {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-faint);
  text-align: center;
}
.login-footer code {
  background: var(--bg-tile);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text);
}

/* ---------- APP SHELL ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* Hide admin-only chrome for non-admins */
body.role-member .admin-only { display: none !important; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  padding: 18px 14px;
  gap: 18px;
  min-height: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px; }
.logo {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  font-weight: 800; font-size: 18px;
  color: white;
}
.brand-name { font-weight: 700; letter-spacing: 0.2px; }
.brand-sub { font-size: 11px; color: var(--text-faint); }

.nav { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 0; }
.nav-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--text-faint); padding: 6px;
}
.board-list { list-style: none; padding: 0; margin: 0; overflow-y: auto; flex: 1; }
.board-list li {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; color: var(--text-dim); font-weight: 500;
}
.board-list li:hover, .board-list li.active { background: var(--bg-card); color: var(--text); }
.board-list li .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }
.board-list li .board-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list li .board-del {
  opacity: 0; font-size: 14px; color: var(--text-faint);
  background: none; border: none; cursor: pointer;
}
.board-list li:hover .board-del { opacity: 1; }
.board-list li .board-del:hover { color: var(--red); }

.ghost-btn {
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text-dim);
  padding: 8px 10px; border-radius: 8px;
  cursor: pointer; font-size: 13px;
  font-family: inherit;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--text); }
.ghost-btn.small { padding: 6px 8px; font-size: 12px; }

.sidebar-footer { display: flex; flex-direction: column; gap: 10px; }
.current-user {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.current-user .owner-chip { width: 32px; height: 32px; font-size: 12px; cursor: default; border-color: var(--bg-card); }
.current-user .cu-info { display: flex; flex-direction: column; min-width: 0; }
.current-user .cu-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.current-user .cu-role { font-size: 10px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 1px; }
.current-user .cu-role.admin { color: var(--accent); }
.footer-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px 10px; gap: 16px;
  border-bottom: 1px solid var(--border);
}
.topbar-left h1 {
  margin: 0; font-size: 22px; font-weight: 700;
  outline: none; padding: 2px 4px; border-radius: 6px; display: inline;
}
.topbar-left h1:focus { background: var(--bg-card); }
.meta { color: var(--text-faint); font-size: 12px; margin-left: 8px; }

.topbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.topbar-right input[type="search"], .filter {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px; border-radius: 8px;
  font-size: 13px; outline: none;
  font-family: inherit;
}
.topbar-right input[type="search"] { width: 200px; }
.topbar-right input[type="search"]:focus, .filter:focus { border-color: var(--accent); }

.view-toggle {
  display: inline-flex; gap: 2px; padding: 3px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 8px;
}
.view-toggle button {
  background: transparent; border: none; color: var(--text-dim);
  padding: 5px 12px; border-radius: 6px; cursor: pointer; font-size: 12px;
  font-weight: 600; font-family: inherit;
}
.view-toggle button.active { background: var(--accent); color: white; }
.view-toggle button:not(.active):hover { color: var(--text); }

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; color: white;
  padding: 9px 14px; border-radius: 8px;
  font-weight: 600; cursor: pointer; font-size: 13px;
  box-shadow: 0 4px 12px rgba(91,140,255,0.25);
  font-family: inherit;
}
.primary-btn:hover { filter: brightness(1.1); }
.danger-btn {
  background: var(--red); color: white; border: none;
  padding: 9px 14px; border-radius: 8px; cursor: pointer;
  font-weight: 600; font-size: 13px; font-family: inherit;
}
.danger-btn:hover { filter: brightness(1.1); }

/* ---------- Stats ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr) 2fr;
  gap: 12px; padding: 16px 24px;
}
.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 4px;
}
.stat-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 1px; }
.stat-value { font-size: 22px; font-weight: 700; }
.stat-value.small { font-size: 13px; }
.progress-stat { gap: 8px; }
.progress-wrap {
  background: var(--bg-tile);
  height: 8px; border-radius: 99px; overflow: hidden;
  margin-top: 4px;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--accent));
  width: 0%; transition: width .3s ease;
}

/* ---------- Board area ---------- */
.board-area { padding: 8px 24px 24px; overflow: auto; flex: 1; }
.board-area.view-grid { display: flex; flex-direction: column; gap: 22px; }
.view-grid .group { display: flex; flex-direction: column; gap: 12px; }
.view-grid .tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

.board-area.view-kanban {
  display: flex; gap: 16px; overflow-x: auto; align-items: flex-start;
}
.view-kanban .group {
  flex: 0 0 320px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  display: flex; flex-direction: column; gap: 12px;
  max-height: 100%;
}
.view-kanban .tiles {
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; padding-right: 4px;
}

.empty-board {
  padding: 40px;
  text-align: center;
  color: var(--text-faint);
  font-size: 14px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  margin: 24px 0;
}

/* ---------- Group header ---------- */
.group-header {
  display: flex; align-items: center; gap: 10px; padding: 4px 4px;
}
.group-color { width: 4px; height: 22px; border-radius: 4px; background: var(--accent); }
.group-title {
  background: transparent; border: none; color: var(--text);
  font-weight: 700; font-size: 16px; outline: none;
  padding: 4px 6px; border-radius: 6px;
  flex: 1; min-width: 0;
  font-family: inherit;
}
.group-title:focus { background: var(--bg-tile); }
.group-title:disabled { color: var(--text); cursor: default; }
.group-count {
  color: var(--text-faint); font-size: 12px;
  padding: 3px 10px;
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-weight: 600;
}
.view-kanban .group-count { background: var(--bg-elev); }
.group-actions { display: flex; gap: 2px; }

/* ---------- Tile ---------- */
.tile {
  background: var(--bg-tile);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; flex-direction: column; gap: 10px;
  cursor: grab;
  transition: transform .12s ease, border-color .12s ease, background .12s ease, box-shadow .12s ease;
  position: relative;
  overflow: hidden;
}
.tile:hover {
  background: var(--bg-tile-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.tile.locked { cursor: default; opacity: 0.85; }
.tile.locked:hover { transform: none; }
.tile.dragging { opacity: 0.4; cursor: grabbing; }
.tile.drag-over { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(91,140,255,0.25); }

.tile::before {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--gray); opacity: 0.85;
}
.tile[data-status="Done"]::before { background: var(--green); }
.tile[data-status="Stuck"]::before, .tile[data-status="Blocked"]::before { background: var(--red); }
.tile[data-status="Working on it"]::before { background: var(--orange); }
.tile[data-status="Review"]::before { background: var(--purple); }
.tile[data-status="Not started"]::before { background: var(--gray); }
.tile[data-status="Lead"]::before { background: var(--yellow); }
.tile[data-status="Negotiation"]::before { background: #2bb1d4; }
.tile[data-status="Proposal Sent"]::before { background: var(--accent-2); }
.tile[data-status="Awaiting Signature"]::before { background: #e879c0; }

.tile-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tile-title {
  background: transparent; border: none; color: var(--text);
  font-weight: 600; font-size: 14.5px; outline: none;
  padding: 2px 0; flex: 1; min-width: 0;
  font-family: inherit; line-height: 1.35;
}
.tile-title:focus { color: var(--accent); }
.tile-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s ease; flex-shrink: 0; }
.tile:hover .tile-actions { opacity: 1; }

.tile-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.tile-pill {
  padding: 4px 9px;
  font-size: 11px; font-weight: 600;
  border-radius: 6px; color: white;
  cursor: pointer; border: none;
  letter-spacing: 0.2px;
  font-family: inherit;
}
.tile-pill.locked { cursor: default; opacity: 0.9; }

.tile-pill[data-key="status"][data-value="Not started"] { background: #4a5168; }
.tile-pill[data-key="status"][data-value="Working on it"] { background: var(--orange); }
.tile-pill[data-key="status"][data-value="Stuck"] { background: var(--red); }
.tile-pill[data-key="status"][data-value="Done"] { background: var(--green); }
.tile-pill[data-key="status"][data-value="Review"] { background: var(--purple); }
.tile-pill[data-key="status"][data-value="Blocked"] { background: #b3413e; }
.tile-pill[data-key="status"][data-value="Lead"] { background: var(--yellow); color: #2a2200; }
.tile-pill[data-key="status"][data-value="Negotiation"] { background: #2bb1d4; }
.tile-pill[data-key="status"][data-value="Proposal Sent"] { background: var(--accent-2); }
.tile-pill[data-key="status"][data-value="Awaiting Signature"] { background: #e879c0; }

.tile-pill[data-key="priority"][data-value="Low"] { background: #4a5168; }
.tile-pill[data-key="priority"][data-value="Medium"] { background: var(--blue); }
.tile-pill[data-key="priority"][data-value="High"] { background: var(--orange); }
.tile-pill[data-key="priority"][data-value="Critical"] { background: var(--red); }

.tile-pill[data-key="type"][data-value="Software"] { background: var(--accent); }
.tile-pill[data-key="type"][data-value="Contract"] { background: var(--purple); }
.tile-pill[data-key="type"][data-value="Support"] { background: var(--gray); }
.tile-pill[data-key="type"][data-value="Discovery"] { background: #2bb1d4; }

.tile-client {
  font-size: 12px; color: var(--text-dim);
  display: flex; align-items: center; gap: 6px;
}
.tile-client::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-faint);
}

.tile-bottom {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: 10px; margin-top: auto;
  border-top: 1px solid var(--border);
  gap: 8px;
}
.tile-bottom-left { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.tile-bottom-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

.tile-due {
  font-size: 12px; color: var(--text-dim);
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 6px;
  background: rgba(255,255,255,0.04);
  white-space: nowrap; cursor: pointer;
}
.tile-due.due-soon { color: var(--orange); background: rgba(255,155,84,0.12); }
.tile-due.due-overdue { color: var(--red); background: rgba(255,107,107,0.15); font-weight: 600; }
.tile-hours {
  font-size: 11px; color: var(--text-faint);
  font-weight: 600; cursor: pointer;
}
.tile-proof {
  font-size: 11px; font-weight: 600;
  color: var(--accent);
  background: rgba(91,140,255,0.12);
  padding: 3px 8px; border-radius: 6px;
  cursor: pointer; white-space: nowrap;
}
.tile-proof:hover { background: rgba(91,140,255,0.22); }

.owner-chip {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-grid; place-items: center;
  color: white; font-weight: 700; font-size: 11px;
  cursor: pointer;
  border: 2px solid var(--bg-tile);
  flex-shrink: 0;
}
.owner-empty {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1.5px dashed var(--border-strong);
  display: inline-grid; place-items: center;
  color: var(--text-faint); cursor: pointer;
  font-size: 13px; background: transparent;
  flex-shrink: 0;
}

.add-tile {
  background: transparent;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-faint);
  cursor: pointer;
  font-size: 13px; font-weight: 500;
  min-height: 100px;
  transition: all .15s ease;
  font-family: inherit;
}
.add-tile:hover { border-color: var(--accent); color: var(--accent); background: rgba(91,140,255,0.04); }
.view-kanban .add-tile { min-height: 50px; }

.icon-btn {
  background: transparent; border: none; cursor: pointer;
  color: var(--text-faint); font-size: 14px;
  padding: 5px 7px; border-radius: 6px;
  font-family: inherit;
}
.icon-btn:hover { background: var(--bg-elev); color: var(--text); }
.icon-btn.delete-btn:hover { color: var(--red); }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.55);
  display: grid; place-items: center;
  z-index: 100;
}
.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  width: min(680px, 92vw);
  max-height: 85vh;
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px; overflow: auto; }
.modal-body label {
  display: block; font-size: 11px; color: var(--text-faint);
  margin-bottom: 6px; text-transform: uppercase; letter-spacing: 1px; font-weight: 600;
}
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.modal-field { display: flex; flex-direction: column; }
.modal-input, .modal-select {
  width: 100%;
  background: var(--bg-tile);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit; font-size: 13px;
  outline: none;
}
.modal-input:focus, .modal-select:focus { border-color: var(--accent); }
.modal-body textarea {
  width: 100%; min-height: 140px;
  background: var(--bg-tile);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px;
  font-family: inherit; font-size: 13px;
  outline: none; resize: vertical;
}
.modal-body textarea:focus { border-color: var(--accent); }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }

/* Floating select menu */
.floating-menu {
  position: fixed;
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 4px; z-index: 200;
  box-shadow: var(--shadow);
  min-width: 160px;
  max-height: 300px; overflow-y: auto;
}
.floating-menu .tile-pill,
.floating-menu .menu-item {
  display: block; width: 100%;
  margin: 3px 0; text-align: left;
  padding: 6px 10px; font-size: 12px;
  background: transparent; color: var(--text); border: none;
  border-radius: 6px; cursor: pointer;
  font-family: inherit;
}
.floating-menu .menu-item:hover { background: var(--bg-card); }
.floating-menu .menu-item .mi-rate { color: var(--text-faint); font-size: 10px; margin-left: 6px; }
.floating-menu .tile-pill { text-align: center; }

/* Color picker */
.color-dots { display: flex; gap: 6px; }
.color-dot {
  width: 18px; height: 18px; border-radius: 50%;
  cursor: pointer; border: 2px solid transparent;
}
.color-dot.selected { border-color: white; }

/* ---------- Proof of work ---------- */
.proof-section {
  border: 1px solid var(--border);
  background: var(--bg-tile);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 14px;
}
.proof-section.proof-required-on {
  border-color: var(--orange);
  background: rgba(255,155,84,0.06);
}
.proof-header { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.proof-required {
  font-size: 10px; color: var(--orange);
  background: rgba(255,155,84,0.15);
  padding: 2px 6px; border-radius: 4px;
  margin-left: 6px; letter-spacing: 0.4px;
}
.proof-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
}
.proof-empty { color: var(--text-faint); font-size: 12px; font-style: italic; padding: 4px 0; }
.proof-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.proof-card img {
  width: 100%; height: 90px;
  object-fit: cover; border-radius: 6px; background: #000;
}
.proof-file-icon {
  height: 90px; display: grid; place-items: center;
  font-size: 36px; background: var(--bg-elev); border-radius: 6px;
}
.proof-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.proof-name {
  font-size: 12px; color: var(--text);
  text-decoration: none; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.proof-name:hover { color: var(--accent); text-decoration: underline; }
.proof-meta { font-size: 10px; color: var(--text-faint); }
.proof-del {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.5) !important;
  font-size: 11px !important; padding: 3px 5px !important;
}
.proof-warning {
  margin-top: 10px; padding: 8px 10px;
  background: rgba(255,107,107,0.12);
  border: 1px solid rgba(255,107,107,0.35);
  border-radius: 6px; font-size: 12px; color: var(--red);
}

/* ---------- Users panel ---------- */
.users-table { width: 100%; border-collapse: collapse; }
.users-table th, .users-table td {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.users-table th { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.users-table td.actions { text-align: right; }
.users-table input, .users-table select {
  background: var(--bg-tile);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 8px; border-radius: 6px;
  font-size: 12px; outline: none; font-family: inherit;
  width: 100%;
}
.users-table input:focus, .users-table select:focus { border-color: var(--accent); }
.role-badge {
  display: inline-block;
  padding: 2px 8px; font-size: 10px; font-weight: 700;
  border-radius: 4px; letter-spacing: 0.5px; text-transform: uppercase;
}
.role-badge.admin { background: var(--accent); color: white; }
.role-badge.member { background: var(--bg-tile); color: var(--text-dim); }

/* Scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #444b63; }

@media (max-width: 1100px) {
  .topbar-right input[type="search"] { width: 160px; }
  .stats { grid-template-columns: repeat(2, 1fr) 2fr; }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .modal-row { grid-template-columns: 1fr; }
}

/* ---------- Notifications ---------- */
.notif-wrap { position: relative; }
.notif-btn { position: relative; padding: 6px 10px; }
.notif-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--red); color: white;
  font-size: 10px; font-weight: 700;
  padding: 2px 5px; border-radius: 10px; min-width: 16px; text-align: center;
  border: 1px solid var(--bg);
}
.notif-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 340px; max-height: 420px; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 32px rgba(0,0,0,.4);
  z-index: 200; padding: 8px;
}
.notif-panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px;
}
.notif-panel-header h3 { margin: 0; font-size: 13px; }
.notif-mark-all {
  background: none; border: none; color: var(--accent);
  font-size: 11px; cursor: pointer; padding: 2px 6px;
}
.notif-mark-all:hover { text-decoration: underline; }
.notif-item {
  display: flex; gap: 10px; padding: 10px 8px;
  border-radius: 6px; cursor: pointer;
  border-left: 3px solid transparent;
}
.notif-item:hover { background: rgba(255,255,255,.04); }
.notif-item.unread { border-left-color: var(--accent); background: rgba(91,140,255,.06); }
.notif-icon { font-size: 16px; }
.notif-body { flex: 1; min-width: 0; }
.notif-text { font-size: 12px; color: var(--text); line-height: 1.4; }
.notif-time { font-size: 10px; color: var(--text-faint); margin-top: 3px; }
.notif-empty { padding: 24px 8px; text-align: center; color: var(--text-faint); font-size: 12px; }

/* ---------- Comments / Activity ---------- */
.comments-section {
  margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border);
}
.comments-section h3 { margin: 0 0 10px; font-size: 13px; }
.comment-list { display: flex; flex-direction: column; gap: 10px; max-height: 260px; overflow-y: auto; padding-right: 4px; }
.comment {
  display: flex; gap: 10px; padding: 8px;
  background: var(--bg-tile); border-radius: 8px;
}
.comment .owner-chip { flex-shrink: 0; }
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.comment-author { font-size: 12px; font-weight: 600; }
.comment-time { font-size: 10px; color: var(--text-faint); }
.comment-text { font-size: 12px; color: var(--text-dim); line-height: 1.5; white-space: pre-wrap; word-wrap: break-word; }
.comment-system { background: transparent; border-left: 2px solid var(--border); border-radius: 0; padding-left: 10px; }
.comment-system .comment-text { color: var(--text-faint); font-style: italic; font-size: 11px; }
.comment-empty { color: var(--text-faint); font-size: 12px; font-style: italic; padding: 4px 0; }
.comment-form { display: flex; gap: 8px; margin-top: 10px; }
.comment-form textarea {
  flex: 1; min-height: 36px; max-height: 120px; resize: vertical;
  padding: 8px 10px; background: var(--bg-tile); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px; font-family: inherit; font-size: 12px;
}
.comment-form textarea:focus { border-color: var(--accent); outline: none; }
.comment-form button { align-self: flex-end; }

/* ---------- Members panel ---------- */
.members-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 320px; overflow-y: auto;
}
.member-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; background: var(--bg-tile); border-radius: 8px;
}
.member-row .member-info { flex: 1; min-width: 0; }
.member-row .member-name { font-size: 13px; font-weight: 600; }
.member-row .member-meta { font-size: 11px; color: var(--text-faint); }
.member-role-select {
  padding: 4px 8px; background: var(--bg); color: var(--text);
  border: 1px solid var(--border); border-radius: 4px; font-size: 11px;
}
.invite-form {
  display: flex; gap: 8px; margin-top: 14px;
  padding-top: 14px; border-top: 1px solid var(--border);
}
.invite-form input { flex: 1; }
