/* Track Up — components. Built on the token layer.
   Premium, structured, data-forward. Spring micro-interactions throughout. */

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 7px 11px; color: var(--text); border: 1px solid transparent;
  border-radius: var(--radius-sm); font-size: var(--text-xs); font-weight: 550; line-height: 1;
  transition: background var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
  white-space: nowrap; user-select: none;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent); color: var(--text-inverse);
  box-shadow: var(--shadow-xs);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); box-shadow: var(--shadow-sm); }
.btn-primary:focus-visible { box-shadow: var(--shadow-focus); outline: none; }

.btn-secondary {
  background: var(--surface); color: var(--text); border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); border-color: var(--slate-400); }

.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover:not(:disabled) { background: var(--bg-subtle); color: var(--text); }

.btn-danger { background: var(--danger); color: white; box-shadow: var(--shadow-xs); }
.btn-danger:hover:not(:disabled) { background: #b91c1c; box-shadow: var(--shadow-sm); }
.btn-danger:disabled { opacity: 0.45; cursor: not-allowed; box-shadow: none; }

.btn-sm { min-height: 28px; padding: 5px 9px; font-size: 11px; }
.btn-xs { min-height: 24px; padding: 3px 7px; font-size: 10px; gap: 4px; }
.btn-lg { min-height: 40px; padding: 10px 16px; font-size: var(--text-sm); }
.btn-icon { padding: 7px; width: 32px; height: 32px; min-height: 32px; }
.btn-icon.btn-sm { width: 28px; height: 28px; min-height: 28px; padding: 6px; }
.btn-icon.btn-xs { width: 24px; height: 24px; min-height: 24px; padding: 4px; }

/* Comments */
.comment-item.is-pinned { background: var(--warning-soft); border-radius: var(--radius-sm); padding-left: var(--space-3); padding-right: var(--space-3); }
.comment-item.is-reply { padding: var(--space-2) 0; }
.comment-actions { opacity: 0; transition: opacity var(--dur) var(--ease); }
.comment-item:hover .comment-actions { opacity: 1; }
@media (max-width: 768px) { .comment-actions { opacity: 1; } }

/* Reactions */
.reactions-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 6px; }
.reaction { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--border); background: var(--bg); font-size: 12px; cursor: pointer; transition: all var(--dur-fast) var(--ease); }
.reaction:hover { border-color: var(--accent); transform: translateY(-1px); }
.reaction.is-mine { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.reaction-emoji { font-size: 13px; line-height: 1; }
.reaction-count { font-variant-numeric: tabular-nums; color: var(--text-muted); font-weight: 500; }
.reaction.is-mine .reaction-count { color: var(--accent-strong); }
.reaction-picker { position: relative; display: inline-block; }
.reaction-add { display: inline-flex; align-items: center; justify-content: center; padding: 2px 8px; border-radius: 99px; border: 1px dashed var(--border); color: var(--text-muted); cursor: pointer; list-style: none; }
.reaction-add::-webkit-details-marker { display: none; }
.reaction-add:hover { color: var(--accent); border-color: var(--accent); }
.reaction-picker-pop { position: absolute; top: 100%; left: 0; margin-top: 4px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; box-shadow: var(--shadow-md); display: flex; gap: 2px; z-index: 50; animation: kcFadeIn var(--dur) var(--ease-spring); }
.reaction-picker-pop button { font-size: 16px; padding: 4px 6px; border-radius: var(--radius-sm); border: none; background: transparent; cursor: pointer; transition: background var(--dur-fast) var(--ease); }
.reaction-picker-pop button:hover { background: var(--bg-inset); }

/* Notification bell + dropdown */
.notif-badge { position: absolute; top: -2px; right: -2px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 600; min-width: 16px; height: 16px; border-radius: 99px; display: grid; place-items: center; padding: 0 4px; border: 2px solid var(--bg); animation: kcFadeIn var(--dur) var(--ease-spring); }
.notif-dropdown { position: absolute; top: calc(100% + 8px); right: 0; width: 360px; max-width: calc(100vw - 32px); max-height: 480px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 100; overflow: hidden; display: flex; flex-direction: column; animation: kcFadeIn var(--dur) var(--ease-spring); }
.notif-dropdown.hidden { display: none; }
.notif-dropdown-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3); border-bottom: 1px solid var(--border); }
.profile-dropdown { position: absolute; top: calc(100% + 8px); right: 0; width: 240px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); z-index: 100; overflow: hidden; animation: kcFadeIn var(--dur) var(--ease-spring); }
.profile-btn { width: 30px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 50%; background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; overflow: hidden; transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard); }
.profile-btn:hover { border-color: var(--slate-400); box-shadow: var(--shadow-xs); }
.profile-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.profile-btn-initials { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 100%; color: #fff; font-size: 10px; font-weight: 600; }
.profile-dropdown.hidden { display: none; }
.profile-dropdown-header { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3); border-bottom: 1px solid var(--border); }
.profile-dropdown-name { font-size: 12px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-dropdown-role { font-size: 10px; color: var(--text-muted); }
.profile-dropdown-item { display: flex; align-items: center; gap: var(--space-2); padding: 8px var(--space-3); font-size: 12px; color: var(--text); text-decoration: none; background: none; border: none; cursor: pointer; width: 100%; text-align: left; transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard); }
.profile-dropdown-item:hover { background: var(--bg-inset); color: var(--text); }
.profile-dropdown-item i { color: var(--text-muted); flex-shrink: 0; }
.profile-dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }
.profile-dropdown-danger { color: var(--danger); }
.profile-dropdown-danger:hover { background: var(--danger-soft); color: var(--danger); }
.profile-dropdown-danger i { color: var(--danger); }

/* KingsChat user preview (invite modal) */
.kc-user-preview { margin-top: var(--space-2); min-height: 0; }
.kc-user-preview:empty { display: none; }
.kc-preview-card { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3); border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-subtle); animation: kcFadeIn var(--dur-fast) var(--ease-standard); }
.kc-preview-avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--slate-200); display: inline-flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 13px; font-weight: 600; overflow: hidden; }
.kc-preview-info { flex: 1; min-width: 0; }
.kc-preview-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kc-preview-username { font-size: 11px; color: var(--text-muted); }
.kc-preview-status { font-size: 10px; font-weight: 600; margin-top: 2px; }
.kc-preview-status.is-member { color: var(--success); }
.kc-preview-status.is-invited { color: var(--warning); }
.kc-preview-error { font-size: 11px; color: var(--danger); padding: 6px 0; display: flex; align-items: center; gap: 6px; }
.kc-preview-searching { font-size: 11px; color: var(--text-muted); padding: 6px 0; display: flex; align-items: center; gap: 6px; }
.notif-item { display: flex; align-items: flex-start; gap: var(--space-2); padding: 10px var(--space-3); border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); position: relative; transition: background var(--dur-fast) var(--ease); }
.notif-item:hover { background: var(--bg-inset); }
.notif-item.is-unread { background: var(--accent-soft); }
.notif-item.is-unread:hover { background: var(--accent-soft); filter: brightness(0.97); }
.notif-body { flex: 1; min-width: 0; }
.notif-text { font-size: var(--text-sm); line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.notif-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 4px; flex-shrink: 0; }
.notif-footer { display: block; text-align: center; padding: var(--space-3); font-size: var(--text-xs); color: var(--text-muted); text-decoration: none; border-top: 1px solid var(--border); }
.notif-footer:hover { background: var(--bg-inset); color: var(--text); }

/* Search palette */
.search-palette { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.5); backdrop-filter: blur(4px); z-index: 200; display: grid; place-items: start center; padding: 12vh var(--space-3) var(--space-3); animation: kcFadeIn var(--dur-fast) var(--ease); }
.search-palette.hidden { display: none; }
.search-palette-panel { width: 100%; max-width: 560px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); overflow: hidden; }
.search-palette-header { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3); border-bottom: 1px solid var(--border); }
.search-palette-header input { flex: 1; border: none; outline: none; font-size: var(--text-base); background: transparent; color: var(--text); font-family: var(--font-sans); }
.search-palette-results { max-height: 400px; overflow-y: auto; }
.search-result { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-3); border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); transition: background var(--dur-fast) var(--ease); }
.search-result:hover { background: var(--bg-inset); }
.search-result-icon { width: 28px; height: 28px; border-radius: var(--radius-sm); background: var(--bg-inset); display: grid; place-items: center; color: var(--text-muted); flex-shrink: 0; }
.search-result-body { flex: 1; min-width: 0; }
.search-result-title { font-size: var(--text-sm); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.search-palette-footer { display: flex; align-items: center; justify-content: space-between; padding: var(--space-2) var(--space-3); border-top: 1px solid var(--border); }

/* kbd */
kbd { display: inline-block; padding: 2px 6px; font-family: var(--font-mono); font-size: 11px; background: var(--bg-inset); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: 0 1px 0 var(--border); }

/* avatar-xs */
.avatar.avatar-xs { width: 24px; height: 24px; font-size: 10px; }

/* topbar-actions */
.topbar-actions { margin-left: auto; }

/* Bulk action bar */
.bulk-bar { display: flex; align-items: center; gap: var(--space-2); padding: 10px var(--space-3); background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); position: sticky; top: var(--space-2); z-index: 20; animation: kcFadeIn var(--dur) var(--ease-spring); }

/* Notification preferences (profile) */
.notif-group { border-bottom: 1px solid var(--border); }
.notif-group:last-of-type { border-bottom: none; }
.notif-group-header { display: flex; align-items: center; gap: var(--space-2); padding: 10px var(--space-5); background: var(--bg-subtle); font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.notif-group-items { padding: var(--space-2) var(--space-3); }
.notif-row { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-2); border-radius: var(--radius); cursor: pointer; transition: background var(--dur-fast) var(--ease); position: relative; }
.notif-row:hover { background: var(--bg-inset); }
.notif-row-icon { width: 32px; height: 32px; border-radius: var(--radius); background: var(--bg-inset); display: grid; place-items: center; color: var(--text-muted); flex-shrink: 0; }
.notif-row-body { flex: 1; min-width: 0; }
.notif-row-title { font-size: var(--text-sm); font-weight: 500; color: var(--text); }
.notif-row-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.4; }
.notif-toggle { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.notif-switch { width: 36px; height: 20px; border-radius: 99px; background: var(--bg-inset); border: 1px solid var(--border); position: relative; transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease); flex-shrink: 0; }
.notif-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-inverse); box-shadow: var(--shadow-sm); transition: transform var(--dur-fast) var(--ease-spring); }
.notif-toggle:checked + .notif-switch { background: var(--accent); border-color: var(--accent); }
.notif-toggle:checked + .notif-switch::after { transform: translateX(16px); }
.notif-toggle:focus-visible + .notif-switch { outline: 2px solid var(--accent); outline-offset: 2px; }
[data-theme="dark"] .notif-switch::after { background: var(--slate-100); }

/* ---- Cards ---- */
.card {
  min-width: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.card-pad { padding: var(--space-4); }
.card-hover { transition: box-shadow var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard); }
.card-hover:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); transform: translateY(-1px); }

/* ---- Inputs ---- */
.input, .select, .textarea {
  width: 100%; min-height: 34px; padding: 8px 10px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: var(--text-xs); transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--shadow-focus);
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.textarea { min-height: 120px; resize: vertical; line-height: var(--leading-relaxed); }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }

.field { margin-bottom: var(--space-4); }
.field-label { display: block; margin-bottom: 6px; color: var(--text-muted); font-size: 11px; font-weight: 550; }
.field-error { color: var(--danger); font-size: 10px; margin-top: 5px; }
.field-help { color: var(--text-subtle); font-size: 10px; margin-top: 5px; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 6px; color: var(--text-muted); background: var(--bg-subtle);
  border-radius: var(--radius-sm); font-size: 9px; font-weight: 600; line-height: 1.2;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-dot::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---- Priority pills ---- */
.pri-low    { background: var(--slate-100); color: var(--slate-600); }
.pri-medium { background: var(--steel-50);  color: var(--steel-700); }
.pri-high   { background: var(--warning-soft); color: var(--warning); }
.pri-urgent { background: var(--danger-soft);  color: var(--danger); }

/* ---- Status pills ---- */
.st-todo       { background: var(--slate-100); color: var(--slate-600); }
.st-in_progress{ background: var(--steel-50);  color: var(--steel-700); }
.st-blocked    { background: var(--warning-soft); color: var(--warning); }
.st-done       { background: var(--success-soft); color: var(--success); }

/* Inline status select (task list) — looks like a badge but is interactive */
.status-inline-form { display: inline-block; margin: 0; }
.status-select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 3px 22px 3px 8px;
  font-size: 9px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 10px;
  transition: border-color var(--dur-fast) var(--ease-standard), opacity var(--dur-fast) var(--ease-standard);
}
.status-select:hover { border-color: currentColor; opacity: 0.88; }
.status-select:focus { outline: none; border-color: var(--accent); }
.status-select:disabled { opacity: 0.5; cursor: wait; }
.status-select option { background: var(--bg-elevated); color: var(--text); font-size: 11px; }

/* ---- Avatar ---- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-full);
  background: var(--slate-200); color: var(--slate-700);
  font-size: var(--text-xs); font-weight: 600; flex-shrink: 0;
  border: 1px solid var(--border);
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w); background: var(--bg-subtle); color: var(--text-muted); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
  z-index: 40; transition: transform var(--dur) var(--ease-out), width var(--dur) var(--ease-out);
}
/* Desktop collapsed state (icon-only rail) — scoped to desktop via media query */
@media (min-width: 769px) {
  .sidebar.collapsed { width: 60px; }
  .sidebar.collapsed .sidebar-brand { display: none; }
  .sidebar.collapsed .sidebar-section-label,
  .sidebar.collapsed .sidebar-link span,
  .sidebar.collapsed .sidebar-footer-meta { display: none; }
  .sidebar.collapsed .sidebar-link { justify-content: center; padding: 8px; }
  .sidebar.collapsed .sidebar-footer-row { justify-content: center; gap: 6px; }
  .sidebar.collapsed .sidebar-footer-avatar { display: inline-flex; }
}
.sidebar-brand { min-height: var(--topbar-h); padding: 0 var(--space-3); display: flex; align-items: center; gap: var(--space-2); border-bottom: 1px solid var(--border); }
.sidebar-brand-mark { width: 24px; height: 24px; border-radius: 5px; object-fit: contain; flex-shrink: 0; display: block; }
.sidebar-brand-name { font-family: var(--font-sans); font-size: var(--text-sm); color: var(--text); font-weight: 650; letter-spacing: -0.01em; white-space: nowrap; }
.sidebar-nav { flex: 1; padding: var(--space-3) var(--space-2); overflow-y: auto; overflow-x: hidden; }
.sidebar-section-label { font-size: 9px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); padding: var(--space-3) 10px 6px; font-weight: 600; white-space: nowrap; }
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius); color: var(--text-muted);
  font-size: 11px; font-weight: 500;
  transition: background var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard);
  margin-bottom: 2px; white-space: nowrap;
}
.sidebar-link:hover { background: var(--surface-hover); color: var(--text); }
.sidebar-link.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-xs); }
.sidebar-link.active .sidebar-link-icon { color: var(--text); }
.sidebar-link-icon { width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-footer { padding: var(--space-2); border-top: 1px solid var(--border); }
.sidebar-footer-row { display: flex; align-items: center; gap: 10px; padding: 6px 4px; }
.sidebar-footer-avatar { flex-shrink: 0; display: inline-flex; }
.sidebar-footer-meta { min-width: 0; flex: 1; }
.sidebar-footer-name { font-size: 11px; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer-role { font-size: 9px; color: var(--text-muted); }

/* Mobile backdrop */
.sidebar-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 35; opacity: 0; pointer-events: none; transition: opacity var(--dur) var(--ease-out); }
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h); background: var(--bg); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--space-2); padding: 0 var(--space-3);
  position: sticky; top: 0; z-index: 30; min-width: 0;
}
.topbar-title { font-size: var(--text-sm); font-weight: 650; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex-shrink: 1; }
.topbar .btn-icon { width: 30px; height: 30px; padding: 7px; }
.topbar-actions { flex-shrink: 0; }
.topbar-search { flex: 1; max-width: 420px; position: relative; }
.topbar-search .input { padding-left: 34px; background: var(--bg-subtle); border-color: transparent; }
.topbar-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-subtle); width: 16px; height: 16px; }

/* ---- Main layout ---- */
.app-shell { display: flex; min-height: 100vh; }
.app-main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.app-content { padding: var(--space-4); flex: 1; max-width: var(--content-max); width: 100%; margin: 0 auto; }
.app-content-narrow { max-width: 920px; }

/* ---- Page header ---- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); flex-wrap: wrap; }
.page-title { min-width: 0; margin: 0; color: var(--text); font-family: var(--font-display); font-size: var(--text-xl); font-style: normal; font-weight: 650; letter-spacing: -0.025em; line-height: 1.2; overflow-wrap: anywhere; }
.page-subtitle { margin-top: 4px; color: var(--text-muted); font-size: var(--text-xs); }

/* ---- Stat cards ---- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: var(--space-4); }
.stat-card { padding: var(--space-4); }
.stat-label { color: var(--text-muted); font-size: 10px; font-weight: 550; }
.stat-value { margin-top: 7px; color: var(--text); font-family: var(--font-display); font-size: 22px; font-weight: 650; line-height: 1; letter-spacing: -0.035em; }
.stat-delta { margin-top: 7px; color: var(--text-muted); font-size: 10px; }
.stat-icon { width: 30px; height: 30px; border-radius: var(--radius); display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); float: right; }
.stat-icon i, .stat-icon svg { width: 15px !important; height: 15px !important; }

/* ---- Timeline (vertical feed) ---- */
.timeline { position: relative; }
.timeline::before { content: ''; position: absolute; left: 11px; top: 0; bottom: 0; width: 1px; background: var(--border); }
.timeline-day { margin: var(--space-5) 0 var(--space-2); padding-left: 30px; color: var(--text-muted); font-size: 9px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.06em; }
.timeline-day:first-child { margin-top: 0; }
.timeline-item { position: relative; padding-left: 30px; margin-bottom: var(--space-2); }
.timeline-dot { position: absolute; left: 7px; top: 15px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); z-index: 1; transition: transform var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard); }
.timeline-item:hover .timeline-dot { transform: scale(1.15); border-color: var(--accent-hover); }
.timeline-card { padding: var(--space-3); cursor: pointer; transition: box-shadow var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard); }
.timeline-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.timeline-card.selected { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.timeline-meta { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; color: var(--text-muted); font-size: 10px; }
.timeline-title { margin: 0 0 3px; color: var(--text); font-size: var(--text-xs); font-weight: 600; }
.timeline-body { color: var(--text-muted); font-size: 11px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ---- Attachments preview ---- */
.attach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--space-2); margin-top: var(--space-3); }
.attach-thumb { aspect-ratio: 1; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); background: var(--bg-subtle); position: relative; }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--dur-slow) var(--ease-out); }
.attach-thumb:hover img { transform: scale(1.05); }
.attach-doc { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: var(--space-3); text-align: center; }
.attach-doc-icon { width: 32px; height: 32px; color: var(--text-muted); margin-bottom: 6px; }
.attach-doc-name { font-size: 11px; color: var(--text-muted); word-break: break-all; line-height: 1.3; }

/* ---- Kanban ---- */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(230px, 1fr)); gap: var(--space-3); align-items: start; }
.kanban-col { min-height: 200px; padding: var(--space-2); background: var(--bg-subtle); border: 1px solid var(--border); border-radius: var(--radius-lg); display: flex; flex-direction: column; }
.kanban-col-header { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 10px; color: var(--text-muted); font-size: 10px; font-weight: 600; flex-shrink: 0; }
.kanban-col-count { min-width: 20px; padding: 2px 6px; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 9px; text-align: center; }
.kanban-card { display: block; margin-bottom: var(--space-2); padding: 10px; color: inherit; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); cursor: grab; text-decoration: none; transition: box-shadow var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard); }
.kanban-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); transform: translateY(-1px); }
.kanban-card:active { transform: scale(0.99); cursor: grabbing; }
.kanban-card.dragging { opacity: 0.5; transform: rotate(2deg); cursor: grabbing; }
.kanban-card-title { font-size: var(--text-sm); font-weight: 500; color: var(--text); margin-bottom: 6px; line-height: var(--leading-snug); display: block; }
.kanban-card-meta { display: flex; align-items: center; gap: var(--space-2); font-size: 11px; color: var(--text-muted); flex-wrap: wrap; }
.kanban-card-meta .avatar { width: 20px; height: 20px; font-size: 9px; margin-left: auto; }
.kanban-drop-zone { min-height: 60px; border-radius: var(--radius); transition: background var(--dur-fast) var(--ease-standard), outline var(--dur-fast) var(--ease-standard); flex: 1; padding-bottom: var(--space-2); }
.kanban-drop-zone.drag-over { background: var(--accent-soft); outline: 2px dashed var(--accent-border); outline-offset: -2px; }
.kanban-empty { text-align: center; padding: var(--space-6) var(--space-2); color: var(--text-subtle); font-size: var(--text-xs); border: 1px dashed var(--border); border-radius: var(--radius); margin: var(--space-1); }
.kanban-empty i { display: block; margin: 0 auto var(--space-2); opacity: 0.5; }

/* ---- Tables ---- */
.table { width: 100%; font-size: 11px; }
.table th { padding: 9px var(--space-3); color: var(--text-muted); border-bottom: 1px solid var(--border); font-size: 9px; font-weight: 600; text-align: left; }
.table td { padding: 10px var(--space-3); color: var(--text); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:hover td { background: var(--surface-hover); }
.table tr:last-child td { border-bottom: none; }

/* ---- Toast ---- */
.toast-container { position: fixed; bottom: var(--space-5); right: var(--space-5); z-index: 100; display: flex; flex-direction: column; gap: var(--space-2); pointer-events: none; }
.toast {
  background: var(--slate-900); color: white; padding: 12px 16px; border-radius: var(--radius);
  box-shadow: var(--shadow-lg); font-size: var(--text-sm); display: flex; align-items: center; gap: var(--space-2);
  pointer-events: auto; min-width: 240px; max-width: 360px;
  animation: toast-in var(--dur) var(--ease-spring);
}
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.toast.leaving { animation: toast-out var(--dur) var(--ease-in-out) forwards; }
@keyframes toast-out {
  to { opacity: 0; transform: translateY(8px) scale(0.96); }
}

/* ---- Modal (native <dialog>) ---- */
.modal { width: calc(100% - var(--space-8)); max-width: 520px; max-height: 90vh; margin: auto; padding: 0; overflow-y: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); }
.modal[open] { animation: modal-in var(--dur) var(--ease-spring); }
.modal::backdrop { background: rgb(15 23 42 / 0.45); backdrop-filter: blur(3px); animation: fade-in var(--dur) var(--ease-out); }
.modal-header { padding: var(--space-4); display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--border); }
.modal-title { margin: 0; font-family: var(--font-display); font-size: var(--text-base); font-weight: 650; letter-spacing: -0.015em; }
.modal-body { padding: var(--space-4); }
.modal-footer { padding: var(--space-3) var(--space-4); display: flex; justify-content: flex-end; gap: var(--space-2); border-top: 1px solid var(--border); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes kcFadeIn { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* ---- Empty state ---- */
.empty { padding: var(--space-10) var(--space-5); color: var(--text-muted); text-align: center; }
.empty-icon { width: 36px; height: 36px; margin: 0 auto var(--space-3); color: var(--text-subtle); }
.empty-title { margin: 0 0 5px; color: var(--text); font-family: var(--font-display); font-size: var(--text-sm); font-weight: 650; }
.empty-body { max-width: 360px; margin: 0 auto; font-size: var(--text-xs); line-height: 1.55; }

/* ---- Loading ---- */
.spinner { width: 18px; height: 18px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.htmx-indicator { opacity: 0; transition: opacity var(--dur-fast) var(--ease-standard); }
.htmx-request .htmx-indicator, .htmx-indicator.htmx-request { opacity: 1; }
.btn .spinner { display: none; }
.btn.loading .spinner { display: inline-block; }
.btn.loading > *:not(.spinner) { opacity: 0.6; }

/* ---- Utility ---- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); } .gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); } .gap-6 { gap: var(--space-6); }
.flex-1 { flex: 1; } .flex-wrap { flex-wrap: wrap; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gap-4 { gap: var(--space-4); }
.text-xs { font-size: var(--text-xs); } .text-sm { font-size: var(--text-sm); } .text-base { font-size: var(--text-base); } .text-lg { font-size: var(--text-lg); } .text-xl { font-size: var(--text-xl); } .text-2xl { font-size: var(--text-2xl); }
.text-muted { color: var(--text-muted); } .text-subtle { color: var(--text-subtle); } .text-danger { color: var(--danger); } .text-success { color: var(--success); }
.font-medium { font-weight: 500; } .font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
.mt-1 { margin-top: var(--space-1); } .mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); } .mb-3 { margin-bottom: var(--space-3); } .mb-4 { margin-bottom: var(--space-4); } .mb-6 { margin-bottom: var(--space-6); }
.p-3 { padding: var(--space-3); } .p-4 { padding: var(--space-4); } .p-5 { padding: var(--space-5); } .p-6 { padding: var(--space-6); }
.w-full { width: 100%; }
.rounded { border-radius: var(--radius); } .rounded-lg { border-radius: var(--radius-lg); } .rounded-full { border-radius: var(--radius-full); }
.border { border: 1px solid var(--border); } .border-b { border-bottom: 1px solid var(--border); } .border-t { border-top: 1px solid var(--border); }
.bg-surface { background: var(--surface); } .bg-subtle { background: var(--bg-subtle); }
.relative { position: relative; } .absolute { position: absolute; } .fixed { position: fixed; }
.hidden { display: none; } .block { display: block; } .inline-block { display: inline-block; } .inline-flex { display: inline-flex; }
.desktop-hidden { display: none; } /* hidden on desktop; may be revealed on mobile via media query */
.cursor-pointer { cursor: pointer; }
.overflow-hidden { overflow: hidden; } .overflow-auto { overflow: auto; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lh-snug { line-height: var(--leading-snug); } .lh-relaxed { line-height: var(--leading-relaxed); }

/* ---- Reveal animation (scroll-triggered) ---- */
.reveal { opacity: 0; transform: translateY(8px); transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-spring); }
.reveal.in { opacity: 1; transform: none; }

.auth-shell { min-height: 100vh; background: var(--bg); }
.auth-card { padding: var(--space-6); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.auth-card-title { margin: 0; color: var(--text); font-family: var(--font-sans); font-size: var(--text-xl); font-style: normal; font-weight: 650; letter-spacing: -0.025em; }
.auth-card-sub { margin: 6px 0 0; color: var(--text-muted); font-size: var(--text-xs); line-height: 1.55; }
.tenant-pick { border-radius: var(--radius-sm) !important; }

.card > .card-pad h2, .card > .card-pad h3 { font-family: var(--font-sans) !important; font-size: var(--text-sm) !important; font-style: normal; font-weight: 650 !important; letter-spacing: -0.01em; }
.card h2[style*="font-display"], .card h3[style*="font-display"] { font-family: var(--font-sans) !important; font-size: var(--text-sm) !important; font-style: normal; font-weight: 650 !important; letter-spacing: -0.01em; }
.card > .card-pad p, .card p { line-height: 1.5; }
.reports-shell { grid-template-columns: 210px minmax(0, 1fr) 0 !important; margin: calc(-1 * var(--space-4)); height: calc(100vh - var(--topbar-h)) !important; }
.reports-shell.has-detail { grid-template-columns: 210px minmax(0, 1fr) minmax(0, 380px) !important; }
.reports-filters { padding: var(--space-3) !important; background: var(--bg-subtle) !important; }
.reports-filters h2 { font-family: var(--font-sans) !important; font-size: var(--text-sm) !important; }
.reports-filters .field { margin-bottom: var(--space-3); }
.reports-detail { background: var(--surface); }
.comment-item { border-color: var(--border) !important; }
.comment-actions .btn { min-height: 24px; }
.attach-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
.notif-dropdown { border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.notif-item { font-size: var(--text-xs); }
.search-palette-panel { border-radius: var(--radius-lg); }
.bulk-bar { border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.reports-filters-toggle { display: none; } /* hidden on desktop; revealed on mobile via media query */

.dashboard-shell { display: grid; gap: var(--space-4); font-family: var(--font-sans); }
.dashboard-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-4); min-width: 0; }
.dashboard-heading h1 { margin: 0; color: var(--text); font-family: var(--font-sans); font-size: var(--text-xl); font-style: normal; font-weight: 650; letter-spacing: -0.025em; line-height: 1.2; }
.dashboard-heading p { margin: 4px 0 0; color: var(--text-muted); font-size: var(--text-xs); }
.dashboard-heading-actions, .dashboard-table-actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }
.dashboard-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-4); }
.dashboard-metric { min-width: 0; padding: var(--space-4); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); transition: border-color var(--dur-fast) var(--ease-standard), box-shadow var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard); }
.dashboard-metric:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.dashboard-metric-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); color: var(--text-muted); font-size: 11px; font-weight: 500; }
.dashboard-metric-head span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-metric-head svg { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-subtle); }
.dashboard-metric > strong { display: block; margin-top: 7px; color: var(--text); font-family: var(--font-sans); font-size: 22px; font-weight: 650; letter-spacing: -0.035em; line-height: 1.1; }
.dashboard-metric small { display: flex; align-items: center; gap: 3px; margin-top: 7px; font-size: 10px; font-weight: 500; line-height: 1.2; }
.dashboard-metric small svg { width: 11px; height: 11px; }
.metric-neutral { color: var(--text-muted); }
.metric-positive { color: var(--success); }
.metric-negative { color: var(--danger); }
.dashboard-primary-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.9fr); gap: var(--space-4); align-items: stretch; }
.dashboard-panel { min-width: 0; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.dashboard-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); padding: var(--space-4); }
.dashboard-panel-head h2 { margin: 7px 0 0; color: var(--text); font-family: var(--font-sans); font-size: 24px; font-style: normal; font-weight: 650; letter-spacing: -0.035em; line-height: 1; }
.dashboard-panel-head h3 { margin: 0; color: var(--text); font-family: var(--font-sans); font-size: var(--text-sm); font-style: normal; font-weight: 650; line-height: 1.3; }
.dashboard-panel-head p { margin: 3px 0 0; color: var(--text-muted); font-size: 10px; }
.dashboard-panel-head-compact { align-items: center; border-bottom: 1px solid var(--border); }
.dashboard-eyebrow { color: var(--text-muted); font-size: 10px; font-weight: 500; }
.dashboard-small-action { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; padding: 6px 8px; color: var(--text-muted); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: 10px; font-weight: 500; transition: color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard), background var(--dur-fast) var(--ease-standard); white-space: nowrap; }
.dashboard-small-action:hover { color: var(--text); border-color: var(--border-strong); background: var(--surface-hover); }
.dashboard-small-action svg { width: 11px; height: 11px; }
.dashboard-chart { height: 250px; padding: 0 6px 2px 2px; }
.dashboard-status-list { padding: 0 var(--space-3); }
.dashboard-status-row { display: grid; grid-template-columns: 22px 34px minmax(0, 1fr) auto; align-items: center; gap: var(--space-2); min-height: 55px; padding: 8px 4px; border-bottom: 1px solid var(--border); transition: background var(--dur-fast) var(--ease-standard); }
.dashboard-status-row:last-child { border-bottom: 0; }
.dashboard-status-row:hover { background: var(--surface-hover); }
.dashboard-status-rank { color: var(--text-muted); font-size: 10px; font-weight: 600; }
.dashboard-status-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius); }
.dashboard-status-icon svg { width: 15px; height: 15px; }
.status-todo { color: var(--slate-600); background: var(--slate-100); }
.status-progress { color: var(--accent); background: var(--accent-soft); }
.status-hold { color: var(--warning); background: var(--warning-soft); }
.status-done { color: var(--success); background: var(--success-soft); }
.dashboard-status-copy { display: block; min-width: 0; }
.dashboard-status-copy strong, .dashboard-status-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-status-copy strong { color: var(--text); font-size: 11px; font-weight: 600; }
.dashboard-status-copy small { margin-top: 2px; color: var(--text-muted); font-size: 9px; }
.dashboard-status-count { color: var(--text); font-size: 11px; font-weight: 650; }
.dashboard-due-list { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.dashboard-due-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) 14px; align-items: center; gap: var(--space-2); min-width: 0; padding: var(--space-3); border-right: 1px solid var(--border); transition: background var(--dur-fast) var(--ease-standard); }
.dashboard-due-item:last-child { border-right: 0; }
.dashboard-due-item:hover { background: var(--surface-hover); }
.dashboard-due-item > svg { width: 13px; height: 13px; color: var(--text-subtle); }
.dashboard-due-date { display: grid; place-items: center; width: 34px; height: 38px; color: var(--accent); background: var(--accent-soft); border-radius: var(--radius); line-height: 1; }
.dashboard-due-date.is-overdue { color: var(--danger); background: var(--danger-soft); }
.dashboard-due-date strong { font-size: 13px; }
.dashboard-due-date small { margin-top: 2px; font-size: 8px; font-weight: 600; text-transform: uppercase; }
.dashboard-due-copy { min-width: 0; }
.dashboard-due-copy strong, .dashboard-due-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-due-copy strong { color: var(--text); font-size: 10px; font-weight: 600; }
.dashboard-due-copy small { margin-top: 3px; color: var(--text-muted); font-size: 9px; }
.dashboard-inline-empty { display: flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: 76px; padding: var(--space-4); color: var(--text-muted); font-size: var(--text-xs); }
.dashboard-inline-empty svg { width: 17px; height: 17px; color: var(--text-subtle); }
.dashboard-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.dashboard-table { min-width: 720px; width: 100%; font-size: 10px; }
.dashboard-table th { padding: 9px var(--space-3); color: var(--text-muted); background: var(--surface); border-bottom: 1px solid var(--border); font-size: 9px; font-weight: 600; text-align: left; }
.dashboard-table td { padding: 10px var(--space-3); color: var(--text); border-bottom: 1px solid var(--border); vertical-align: middle; }
.dashboard-table tbody tr:last-child td { border-bottom: 0; }
.dashboard-table tbody tr:hover td { background: var(--surface-hover); }
.dashboard-report-title { display: block; max-width: 300px; overflow: hidden; color: var(--text); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-report-title:hover { color: var(--accent); }
.dashboard-author { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dashboard-type-badge { display: inline-flex; padding: 3px 6px; color: var(--accent); background: var(--accent-soft); border-radius: var(--radius-sm); font-size: 9px; font-weight: 600; white-space: nowrap; }
.dashboard-date { color: var(--text-muted); white-space: nowrap; }
.dashboard-row-action { display: grid; place-items: center; width: 24px; height: 24px; margin-left: auto; color: var(--text-muted); border-radius: var(--radius-sm); }
.dashboard-row-action:hover { color: var(--text); background: var(--bg-subtle); }
.dashboard-row-action svg { width: 14px; height: 14px; }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .kanban { grid-template-columns: repeat(2, minmax(240px, 1fr)); }
  .dashboard-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-primary-grid { grid-template-columns: minmax(0, 1fr); }
  .dashboard-due-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-due-item:nth-child(2n) { border-right: 0; }
  .dashboard-due-item { border-bottom: 1px solid var(--border); }
  .dashboard-due-item:nth-last-child(-n+2) { border-bottom: 0; }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { transform: translateX(-100%); width: 248px; transition: transform var(--dur) var(--ease-out); }
  .sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; align-items: stretch; }
  .dashboard-heading { align-items: flex-start; }
  .dashboard-panel-head { gap: var(--space-2); }
  .dashboard-due-list { grid-template-columns: minmax(0, 1fr); }
  .dashboard-due-item, .dashboard-due-item:nth-child(2n), .dashboard-due-item:nth-last-child(-n+2) { border-right: 0; border-bottom: 1px solid var(--border); }
  .dashboard-due-item:last-child { border-bottom: 0; }
  .topbar-search { display: none; }
  #sidebar-collapse { display: none !important; } /* hide desktop collapse btn on mobile */
  #sidebar-toggle { display: inline-flex !important; } /* show hamburger on mobile */
  .topbar { padding: 0 var(--space-3); gap: var(--space-1); }
  .topbar-title { max-width: 40vw; }
  .topbar .badge.badge-info { display: none; } /* hide tenant badge on mobile */
  .topbar .btn span { display: none; } /* hide button text labels in topbar, keep icons */
  .topbar .btn i + span { display: none; }
  .notif-dropdown { right: -8px; }
  .search-palette { padding-top: 8vh; }
  .search-palette-results { max-height: 60vh; }
  /* Reports 3-column shell → stack vertically */
  .reports-shell { grid-template-columns: 1fr !important; height: auto !important; overflow: visible !important; }
  .reports-filters { border-right: none !important; border-bottom: 1px solid var(--border); max-height: none; }
  .reports-shell > section { padding: var(--space-3) !important; overflow: visible !important; }
  .reports-list { max-height: 60vh; }
  .reports-detail { display: none; } /* hide detail pane on mobile, use full page instead */
  /* Reports filters: collapsible on mobile — hidden by default, shown when .open */
  .reports-filters { display: none; }
  .reports-filters.open { display: block; }
  .reports-filters-toggle { display: inline-flex !important; }
  /* List rows with trailing action buttons: allow wrapping so buttons never get clipped */
  .flex.items-center.gap-3, .flex.items-start.gap-3 { flex-wrap: wrap; row-gap: var(--space-2); }
  /* Bulk action bar: wrap select + buttons on narrow screens */
  .bulk-bar { flex-wrap: wrap; row-gap: var(--space-2); }
  .bulk-bar .select { max-width: 100%; }
  /* Comment reply threads: tighten indent so content has room */
  .comment-replies { margin-left: 24px !important; padding-left: var(--space-2) !important; }
  /* Dashboard charts: stack instead of 3-col */
  .grid.grid-cols-3 > .card[style*="grid-column"] { grid-column: span 1 !important; }
  /* Tables: wrap in horizontal scroll */
  .table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
  .table thead, .table tbody, .table tr { display: table; width: auto; }
  /* Timeline: tighten on mobile */
  .timeline::before { left: 11px; }
  .timeline-day { padding-left: 32px; }
  .timeline-item { padding-left: 32px; }
  .timeline-dot { left: 5px; width: 12px; height: 12px; }
  .timeline-meta { flex-wrap: wrap; gap: 4px; }
  .timeline-meta .badge { margin-left: 0 !important; }
  /* Attach grid: smaller thumbs on mobile */
  .attach-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
  /* Cards: reduce padding */
  .card-pad { padding: var(--space-4); }
  /* Comments: action buttons wrap */
  .comment-actions { flex-wrap: wrap; gap: 4px; }
  .comment-item .flex.items-start.gap-3 { gap: var(--space-2); }
  /* Comments: hide action button text labels on mobile, keep icons */
  .comment-actions .btn-label { display: none; }
  /* Forms: make all inline flex forms wrap */
  form .flex.gap-2, form .flex.gap-3 { flex-wrap: wrap; }
  /* Pagination: wrap on mobile */
  .flex.items-center.justify-center.gap-2 { flex-wrap: wrap; }
  /* Modal: full width */
  .modal { max-width: calc(100vw - 32px); }
  /* Stat cards: smaller values */
  .stat-value { font-size: var(--text-2xl); }
  .stat-card { padding: var(--space-4); }
  /* Tasks: never kanban on mobile — always show list */
  .tasks-kanban-view { display: none !important; }
  .tasks-list-view { display: block !important; }
  /* Hide Board/List view toggle on mobile — list view only */
  .view-toggle { display: none !important; }
  /* Page header buttons: wrap; filter form gets its own full row so
     sibling buttons don't stretch to the form's (tall) height */
  .page-header .flex.gap-2 { flex-wrap: wrap; align-items: flex-start; }
  .page-header #task-filter-form { flex-basis: 100%; flex: 1 1 100%; }
  .page-header #filter-form { flex-basis: 100%; }
  /* Auth layout */
  .auth-shell { grid-template-columns: 1fr !important; }
  .auth-aside { display: none !important; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .app-content { padding: var(--space-3); }
  .dashboard-shell { gap: var(--space-3); }
  .dashboard-heading { display: grid; grid-template-columns: minmax(0, 1fr); }
  .dashboard-heading-actions { width: 100%; justify-content: flex-start; }
  .dashboard-metrics { gap: var(--space-2); }
  .dashboard-metric { padding: var(--space-3); }
  .dashboard-metric > strong { font-size: var(--text-xl); }
  .dashboard-panel-head { padding: var(--space-3); }
  .dashboard-table-actions .btn span { display: none; }
  .topbar-title { display: none; } /* hide title on very small screens to save space */
  .page-header { gap: var(--space-2); }
  .page-header .flex.gap-2, .page-header .flex.g-2 { flex-wrap: wrap; }
  .page-header form { width: 100%; flex-wrap: wrap; }
  .page-header form .input { width: 100%; min-width: 0; }
  .page-header form .select { min-width: 0; }
  .notif-dropdown { right: -12px; max-height: 70vh; width: calc(100vw - 24px); }
  .modal { max-width: calc(100vw - 24px); }
  .table { font-size: 11px; }
  .table th, .table td { padding: var(--space-2); }
  .btn-sm { padding: 5px 8px; }
  /* Hide non-essential table columns on mobile */
  .table .col-hide-mobile { display: none; }
  /* Attach grid: 2 columns on very small screens */
  .attach-grid { grid-template-columns: repeat(2, 1fr); }
  /* Stat icon: smaller */
  .stat-icon { width: 28px; height: 28px; }
  .stat-icon i { width: 14px !important; height: 14px !important; }
  /* Timeline: even tighter */
  .timeline-card { padding: var(--space-3); }
  /* Comments: avatar smaller */
  .comment-item .avatar { width: 28px; height: 28px; font-size: 11px; }
  /* Forms: reduce field margins */
  .field { margin-bottom: var(--space-3); }
  /* Search palette: full width */
  .search-palette-panel { max-width: calc(100vw - 24px); }
  /* Comment replies: minimal indent on very small screens */
  .comment-replies { margin-left: 16px !important; padding-left: var(--space-1) !important; }
  /* Cards: tighten padding */
  .card-pad { padding: var(--space-3); }
  /* Modal footer: stack buttons if needed */
  .modal-footer { flex-wrap: wrap; }
  .modal-footer .btn { flex: 1 1 auto; }
  /* Topbar: tighten gaps on very small screens */
  .topbar { padding: 0 var(--space-2); gap: 2px; }
  .topbar .btn-icon { width: 28px; height: 28px; }
  /* Page header action buttons: allow each to grow so labels aren't clipped */
  .page-header .flex.gap-2 .btn { flex: 1 1 auto; min-width: 0; }
  .page-header .flex.gap-2 .btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
