/* ============================================================
   Collab Center — user app components (v1.4 "Enterprise Slate").
   Requires tokens.css. Class API is stable across versions;
   new-component classes are additive.
   ============================================================ */

/* ================= base ================= */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  touch-action: manipulation;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.25; margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0 0 var(--sp-3); }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { color: var(--accent-deep); text-decoration: underline; }
button { font: inherit; cursor: pointer; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
img, svg { max-width: 100%; vertical-align: middle; }
.icon { flex: none; }
hr, .divider { border: 0; border-top: 1px solid var(--line); margin: var(--sp-4) 0; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ================= app shell ================= */
.shell { display: flex; min-height: 100dvh; }

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--card);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 16px 14px;
  font-family: var(--font-display);
  font-weight: 700; font-size: 15px;
  color: var(--ink); letter-spacing: -.01em;
}
.brand .brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center;
  font-size: 15px; font-weight: 800;
  box-shadow: var(--shadow-xs);
}
.nav { padding: var(--sp-2); display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--ink-dim);
  font-weight: 500; font-size: var(--text-sm);
  border-left: 2px solid transparent;
  text-decoration: none;
  transition: background var(--dur) var(--ease-out), color var(--dur) var(--ease-out);
}
.nav a .icon { color: var(--ink-faint); transition: color var(--dur); }
.nav a:hover { background: var(--gray-50); color: var(--ink); }
.nav a:hover .icon { color: var(--ink-dim); }
.nav a.active {
  background: var(--gray-100);
  color: var(--ink);
  font-weight: 600;
  border-left-color: var(--accent);
}
.nav a.active .icon { color: var(--accent-deep); }
.nav .nav-section {
  margin: var(--sp-4) 10px var(--sp-1);
  font-size: 11px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-faint);
}
.sidebar-foot { border-top: 1px solid var(--line); padding: 10px; }
.user-chip { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--text-sm); padding: 4px 6px; }
.user-chip .user-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip a.icon-btn { margin-left: auto; }

.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--gray-100); color: var(--gray-600);
  border: 1px solid var(--line);
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; flex: none;
}
.avatar.avatar-sm { width: 22px; height: 22px; font-size: 10px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 0 var(--sp-6);
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: var(--z-sticky);
}
.topbar .page-title { font-size: var(--text-md); font-weight: 600; }
.topbar .spacer { flex: 1; }

.search-box { position: relative; width: min(360px, 34vw); }
.search-box .icon { position: absolute; left: 10px; top: 50%; translate: 0 -50%; color: var(--ink-faint); pointer-events: none; }
.search-box input {
  width: 100%; height: var(--control-h-sm); padding: 0 12px 0 32px;
  border: 1px solid var(--line); border-radius: var(--control-radius);
  background: var(--gray-50); font-size: var(--text-sm);
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur);
}
.search-box input:hover { border-color: var(--line-strong); }
.search-box input:focus { outline: none; background: var(--card); border-color: var(--accent); box-shadow: var(--ring); }
.search-box input::placeholder { color: var(--ink-faint); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  max-height: 60vh; overflow: auto; z-index: var(--z-dropdown);
  padding: 4px;
}
.search-results a {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 8px 10px; color: var(--ink); font-size: var(--text-sm);
  text-decoration: none; border-radius: var(--radius-sm);
}
.search-results a:hover, .search-results a.selected { background: var(--gray-100); }
.search-results .kind {
  margin-left: auto; font-size: 11px; color: var(--ink-faint);
  font-family: var(--font-mono); background: var(--gray-50);
  border: 1px solid var(--line); border-radius: 4px; padding: 1px 6px;
}
.search-results .no-results { padding: var(--sp-4); color: var(--ink-dim); font-size: var(--text-sm); }

.content { padding: var(--sp-6); flex: 1; min-width: 0; }
.content-narrow { max-width: 920px; }

/* ================= buttons ================= */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--control-h); padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--control-radius);
  font-weight: 600; font-size: var(--text-sm);
  background: var(--card); color: var(--gray-700);
  box-shadow: var(--shadow-xs);
  transition: background var(--dur) var(--ease-out), border-color var(--dur),
              box-shadow var(--dur), transform 80ms var(--ease-out);
  text-decoration: none; user-select: none; white-space: nowrap;
}
.btn:hover { background: var(--gray-50); border-color: var(--gray-400); color: var(--gray-800); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:focus-visible { box-shadow: var(--ring); }
.btn[disabled] { opacity: .5; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
}
.btn-primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: var(--on-accent); }
.btn-danger { background: var(--card); border-color: var(--danger); color: var(--danger); box-shadow: none; }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:focus-visible { box-shadow: var(--ring-danger); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-dim); }
.btn-ghost:hover { background: var(--gray-100); border-color: transparent; color: var(--ink); }
.btn-link { background: transparent; border-color: transparent; box-shadow: none; color: var(--accent-ink); padding: 0 4px; }
.btn-link:hover { background: transparent; text-decoration: underline; color: var(--accent-deep); }
.btn-sm { height: var(--control-h-sm); padding: 0 10px; font-size: var(--text-xs); border-radius: var(--radius-sm); }
.btn-lg { height: var(--control-h-lg); padding: 0 18px; font-size: var(--text-base); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--ink-dim);
  transition: background var(--dur) var(--ease-out), color var(--dur);
}
.icon-btn:hover { background: var(--gray-100); color: var(--ink); }

.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= forms ================= */
.field { margin-bottom: var(--sp-4); }
.field label, .form-label {
  display: block; margin-bottom: 6px;
  font-size: var(--text-sm); font-weight: 500; color: var(--gray-700);
}
.field label .req, .form-label .req { color: var(--danger); margin-left: 2px; }
.field .hint { font-size: var(--text-xs); color: var(--ink-faint); margin-top: 6px; line-height: 1.5; }
.field .error-text { font-size: var(--text-xs); color: var(--danger); margin-top: 6px; }

.input, textarea.input, select.input {
  width: 100%; height: var(--control-h); padding: 0 12px;
  border: 1px solid var(--line-strong); border-radius: var(--control-radius);
  background: var(--card); font-size: var(--text-base); color: var(--ink);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--dur), box-shadow var(--dur);
}
.input:hover { border-color: var(--gray-400); }
.input:focus { border-color: var(--accent); outline: none; box-shadow: var(--ring); }
.input::placeholder { color: var(--ink-faint); }
.input[disabled], .input[readonly] { background: var(--gray-50); color: var(--ink-dim); box-shadow: none; }
.input[readonly]:focus { border-color: var(--line-strong); box-shadow: none; }
.input.input-invalid { border-color: var(--danger); }
.input.input-invalid:focus { box-shadow: var(--ring-danger); }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }

select.input {
  appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667085' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}

/* input with leading/trailing icon */
.input-group { position: relative; }
.input-group > .icon {
  position: absolute; left: 11px; top: 50%; translate: 0 -50%;
  color: var(--ink-faint); pointer-events: none;
}
.input-group > .input { padding-left: 34px; }
.input-group .input-affix {
  position: absolute; right: 11px; top: 50%; translate: 0 -50%;
  font-size: var(--text-xs); color: var(--ink-faint); font-family: var(--font-mono);
}

/* form layout */
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--sp-4); }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 var(--sp-4); }
.form-section {
  display: grid; grid-template-columns: 260px minmax(0, 1fr);
  gap: var(--sp-6); padding: var(--sp-6) 0;
  border-top: 1px solid var(--line);
}
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section > .form-section-head h3 { font-size: var(--text-base); font-weight: 600; margin-bottom: 4px; }
.form-section > .form-section-head p { font-size: var(--text-sm); color: var(--ink-dim); margin: 0; }
.form-actions {
  display: flex; justify-content: flex-end; gap: var(--sp-2);
  padding-top: var(--sp-4); border-top: 1px solid var(--line); margin-top: var(--sp-4);
}

/* ---- checkboxes & radios (custom, accessible) ---- */
input[type="checkbox"], input[type="radio"] {
  appearance: none; -webkit-appearance: none;
  width: 16px; height: 16px; margin: 0;
  border: 1px solid var(--line-strong); background: var(--card);
  cursor: pointer; flex: none; display: inline-block; vertical-align: middle;
  transition: background var(--dur), border-color var(--dur), box-shadow var(--dur);
}
input[type="checkbox"] { border-radius: 4px; }
input[type="radio"] { border-radius: 50%; }
input[type="checkbox"]:hover, input[type="radio"]:hover { border-color: var(--gray-400); }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible { outline: none; box-shadow: var(--ring); }
input[type="checkbox"]:checked {
  background-color: var(--accent); border-color: var(--accent);
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%232E2005' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}
input[type="radio"]:checked {
  border-color: var(--accent); border-width: 5px; background: var(--card);
}
input[type="checkbox"][disabled], input[type="radio"][disabled] {
  background-color: var(--gray-100); border-color: var(--line); cursor: not-allowed;
}
.checkbox-row, .radio-row {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--text-sm); color: var(--gray-700); cursor: pointer;
}
.checkbox-row .sub, .radio-row .sub { display: block; font-weight: 400; color: var(--ink-faint); font-size: var(--text-xs); }
.choice-card {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
  cursor: pointer; transition: border-color var(--dur), background var(--dur);
}
.choice-card:hover { border-color: var(--gray-400); }
.choice-card:has(input:checked) { border-color: var(--accent); background: var(--accent-wash); }
.choice-card input { margin-top: 2px; }
.choice-card .choice-title { font-weight: 600; font-size: var(--text-sm); }
.choice-card .choice-desc { font-size: var(--text-xs); color: var(--ink-dim); }

/* ---- switch ---- */
.switch { position: relative; display: inline-flex; align-items: center; cursor: pointer; }
.switch input {
  appearance: none; width: 36px; height: 20px; border-radius: 999px;
  background: var(--gray-300); border: 0; cursor: pointer;
  transition: background var(--dur) var(--ease-out);
}
.switch input:hover { background: var(--gray-400); }
.switch input:checked { background: var(--accent); }
.switch input:focus-visible { outline: none; box-shadow: var(--ring); }
.switch input::after {
  content: ''; position: absolute; left: 2px; top: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm);
  transition: translate var(--dur) var(--ease-out);
}
.switch input:checked::after { translate: 16px 0; }
.switch .switch-label { margin-left: 8px; font-size: var(--text-sm); }

/* ================= tabs & segmented ================= */
.tabs {
  display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--line);
  margin-bottom: var(--sp-5); overflow-x: auto;
}
.tabs .tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 12px; border: 0; background: transparent;
  font-size: var(--text-sm); font-weight: 500; color: var(--ink-dim);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  text-decoration: none; white-space: nowrap;
  transition: color var(--dur), border-color var(--dur), background var(--dur);
}
.tabs .tab:hover { color: var(--ink); background: var(--gray-50); text-decoration: none; }
.tabs .tab.active { color: var(--accent-ink); font-weight: 600; border-bottom-color: var(--accent); }
.tabs .tab .count {
  font-family: var(--font-mono); font-size: 11px;
  background: var(--gray-100); border-radius: 999px; padding: 0 7px;
}
.tab-panel[hidden] { display: none; }

/* segmented control (also used by the share picker .seg) */
.seg {
  display: inline-flex; padding: 2px; gap: 2px;
  background: var(--gray-100); border: 1px solid var(--line);
  border-radius: var(--control-radius);
}
.seg button {
  border: 0; background: transparent; padding: 4px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs); font-weight: 600; color: var(--ink-dim);
  transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--card); color: var(--ink); box-shadow: var(--shadow-xs); }

/* ================= badges & chips ================= */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 8px; border-radius: 999px;
  font-size: var(--text-xs); font-weight: 500; line-height: 1.7;
  background: var(--gray-50); color: var(--gray-600);
  border: 1px solid var(--line);
}
.badge-verdigris, .badge-accent { background: var(--accent-wash); color: var(--accent-ink); border-color: var(--accent-wash-strong); }
.badge-amber, .badge-warn { background: var(--warn-wash); color: var(--warn); border-color: #F5DFB8; }
.badge-claret, .badge-danger { background: var(--danger-wash); color: var(--danger); border-color: #F2CFD6; }
.badge-moss, .badge-ok { background: var(--ok-wash); color: var(--ok); border-color: #C9E7D4; }
.badge-info { background: var(--info-wash); color: var(--info); border-color: #CCDEF5; }
.badge .mono, .mono { font-family: var(--font-mono); }
.due-badge { font-family: var(--font-mono); font-size: 11px; }

.kbd {
  font-family: var(--font-mono); font-size: 11px; color: var(--gray-600);
  background: var(--gray-50); border: 1px solid var(--line-strong);
  border-bottom-width: 2px; border-radius: 5px; padding: 1px 5px;
}

/* ================= alerts ================= */
.alert {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--gray-50);
  font-size: var(--text-sm); margin-bottom: var(--sp-4);
}
.alert .icon { margin-top: 1px; }
.alert-info { background: var(--info-wash); border-color: #CCDEF5; color: #12437E; }
.alert-warn { background: var(--warn-wash); border-color: #F5DFB8; color: var(--warn); }
.alert-danger { background: var(--danger-wash); border-color: #F2CFD6; color: var(--danger); }
.alert-ok { background: var(--ok-wash); border-color: #C9E7D4; color: var(--ok); }

/* ================= panels & cards ================= */
.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.panel-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: var(--text-base); font-weight: 600; }
.panel-head .eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--ink-faint);
}
.panel-head .spacer { flex: 1; }
.panel-body { padding: var(--sp-5); }

/* the spine — colored left rail encoding priority/type */
.spine { border-left: 3px solid var(--spine-normal); }
.spine-low { border-left-color: var(--spine-low); }
.spine-normal { border-left-color: var(--spine-normal); }
.spine-high { border-left-color: var(--spine-high); }
.spine-urgent { border-left-color: var(--spine-urgent); }

/* ================= data table (app side) ================= */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
table.data th {
  text-align: left; padding: 8px 12px;
  font-size: 11px; letter-spacing: .06em; text-transform: uppercase;
  color: var(--gray-500); font-weight: 600;
  background: var(--gray-50); border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: var(--gray-25); }
table.data .actions { text-align: right; white-space: nowrap; }

/* ================= page head ================= */
.page-head {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-bottom: var(--sp-5); flex-wrap: wrap;
}
.page-head h1 { font-size: var(--text-xl); }
.page-head .spacer { flex: 1; }
.page-sub { color: var(--ink-dim); font-size: var(--text-sm); margin-top: 4px; }

/* ================= boards index ================= */
.board-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}
.board-tile {
  display: block; padding: var(--sp-4) var(--sp-5);
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs); color: var(--ink);
  transition: box-shadow var(--dur) var(--ease-out), border-color var(--dur);
  text-decoration: none;
}
.board-tile:hover { box-shadow: var(--shadow-md); border-color: var(--line-strong); text-decoration: none; color: var(--ink); }
.board-tile h3 { font-size: var(--text-base); margin-bottom: 6px; }
.board-tile .meta { font-size: var(--text-xs); color: var(--ink-dim); display: flex; gap: var(--sp-3); }

/* ================= kanban ================= */
.kanban {
  display: flex; gap: var(--sp-4); align-items: flex-start;
  overflow-x: auto; padding-bottom: var(--sp-6);
  min-height: 60vh;
}
.kanban-col {
  flex: 0 0 300px; max-width: 300px;
  background: var(--gray-100);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--sp-2);
  display: flex; flex-direction: column;
  max-height: calc(100dvh - var(--topbar-h) - 140px);
}
.kanban-col-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 6px 6px 8px 10px;
  font-weight: 600; font-size: var(--text-sm);
}
.kanban-col-head .count {
  font-family: var(--font-mono); font-size: 11px; font-weight: 500;
  color: var(--ink-dim); background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px; padding: 0 7px;
}
.kanban-col-head .spacer { flex: 1; }
.kanban-cards {
  display: flex; flex-direction: column; gap: var(--sp-2);
  overflow-y: auto; padding: 2px; min-height: 24px; flex: 1;
}
.task-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow-xs);
  cursor: pointer;
  transition: box-shadow var(--dur) var(--ease-out), border-color var(--dur);
}
.task-card:hover { box-shadow: var(--shadow-md); }
.task-card .task-title { font-weight: 500; font-size: var(--text-sm); line-height: 1.4; color: var(--gray-800); }
.task-card.task-done .task-title { text-decoration: line-through; color: var(--ink-faint); }
.task-card .task-meta {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-top: var(--sp-2); flex-wrap: wrap;
  font-size: var(--text-xs); color: var(--ink-dim);
}
.task-card .task-meta .spacer { flex: 1; }
.task-card .meta-item { display: inline-flex; align-items: center; gap: 3px; }
.task-card .due-over { color: var(--danger); font-weight: 600; }
.task-card .due-soon { color: var(--warn); font-weight: 600; }
.sortable-ghost { opacity: .4; }
.sortable-drag { rotate: 2deg; box-shadow: var(--shadow-lg); }
.quick-add { display: flex; gap: var(--sp-1); padding: 6px 2px 2px; }
.quick-add input {
  flex: 1; height: var(--control-h-sm);
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: transparent; padding: 0 10px; font-size: var(--text-sm);
  transition: border-color var(--dur), background var(--dur), box-shadow var(--dur);
}
.quick-add input:hover { border-color: var(--gray-400); }
.quick-add input:focus { background: var(--card); border-style: solid; border-color: var(--accent); outline: none; box-shadow: var(--ring); }
.add-col { flex: 0 0 260px; }
.add-col button {
  width: 100%; padding: var(--sp-3); border: 1px dashed var(--line-strong);
  border-radius: var(--radius-lg); background: transparent; color: var(--ink-dim);
  font-weight: 600; font-size: var(--text-sm);
  display: flex; align-items: center; gap: var(--sp-2); justify-content: center;
  transition: background var(--dur), color var(--dur);
}
.add-col button:hover { background: var(--gray-100); color: var(--ink); }

/* ================= task modal internals ================= */
.task-modal-title {
  width: 100%; border: 0; background: transparent;
  font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600;
  padding: var(--sp-1) 0; color: var(--ink); letter-spacing: -.01em;
}
.task-modal-title:focus { outline: none; box-shadow: inset 0 -2px 0 var(--accent); }
.task-props {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3); margin: var(--sp-4) 0;
}
.task-props .field { margin: 0; }
.checklist { list-style: none; margin: var(--sp-2) 0; padding: 0; }
.checklist li { display: flex; align-items: center; gap: var(--sp-2); padding: 5px 0; }
.checklist li.done .cl-text { text-decoration: line-through; color: var(--ink-faint); }
.checklist .cl-text { flex: 1; font-size: var(--text-sm); }
.checklist .icon-btn { width: 26px; height: 26px; opacity: 0; }
.checklist li:hover .icon-btn { opacity: 1; }
.progress { height: 6px; background: var(--gray-100); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--ok); border-radius: 999px; transition: width var(--dur) var(--ease-out); }

/* ================= comments ================= */
.comments { margin-top: var(--sp-4); }
.comment { display: flex; gap: var(--sp-2); padding: var(--sp-2) 0; }
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: baseline; gap: var(--sp-2); }
.comment-head .who { font-weight: 600; font-size: var(--text-sm); }
.comment-head .when { font-size: 11px; color: var(--ink-faint); font-family: var(--font-mono); }
.comment-text { font-size: var(--text-sm); overflow-wrap: break-word; color: var(--gray-700); }
.comment-text p:last-child { margin-bottom: 0; }
.comment-form { display: flex; gap: var(--sp-2); margin-top: var(--sp-2); }

/* ================= notes ================= */
.notes-layout {
  display: grid; grid-template-columns: 224px 288px 1fr;
  gap: 0; min-height: calc(100dvh - var(--topbar-h));
  margin: calc(var(--sp-6) * -1);
}
.notes-folders {
  border-right: 1px solid var(--line); padding: var(--sp-4) var(--sp-2);
  background: var(--card);
}
.notes-folders .nav a { font-size: var(--text-sm); }
.notes-list { border-right: 1px solid var(--line); overflow-y: auto; background: var(--gray-50); }
.note-item {
  display: block; padding: 10px var(--sp-4);
  border-bottom: 1px solid var(--line);
  border-left: 2px solid transparent;
  color: var(--ink); text-decoration: none;
}
.note-item:hover { background: var(--gray-100); text-decoration: none; color: var(--ink); }
.note-item.active { background: var(--card); border-left-color: var(--accent); }
.note-item .note-title { font-weight: 600; font-size: var(--text-sm); }
.note-item .note-snip {
  font-size: var(--text-xs); color: var(--ink-dim);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.note-item .note-when { font-size: 11px; color: var(--ink-faint); font-family: var(--font-mono); }
.note-editor { display: flex; flex-direction: column; background: var(--card); min-width: 0; }
.note-editor-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-5); border-bottom: 1px solid var(--line);
}
.note-title-input {
  flex: 1; border: 0; background: transparent;
  font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600;
  letter-spacing: -.01em;
}
.note-title-input:focus { outline: none; }
.save-state { font-size: 11px; color: var(--ink-faint); font-family: var(--font-mono); min-width: 60px; text-align: right; }

.note-editor .ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--line); font-family: var(--font-body); }
.note-editor .ql-container.ql-snow { border: 0; font-family: var(--font-body); font-size: var(--text-base); flex: 1; }
.note-editor .ql-editor { padding: var(--sp-5); max-width: 780px; }

.rich-text h1, .rich-text h2, .rich-text h3 { margin: .6em 0 .3em; }
.rich-text ul, .rich-text ol { padding-left: 1.4em; margin: .4em 0; }
.rich-text blockquote { border-left: 3px solid var(--line-strong); margin: .5em 0; padding-left: var(--sp-3); color: var(--ink-dim); }
.rich-text pre { background: var(--gray-50); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: var(--sp-3); overflow-x: auto; font-family: var(--font-mono); font-size: var(--text-sm); }

/* ================= calendar ================= */
.calendar-wrap {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); padding: var(--sp-5);
  box-shadow: var(--shadow-xs);
}
.fc { font-family: var(--font-body); font-size: var(--text-sm); }
.fc .fc-toolbar-title { font-family: var(--font-display); font-size: var(--text-lg); font-weight: 600; letter-spacing: -.01em; }
.fc .fc-button {
  background: var(--card); border: 1px solid var(--line-strong); color: var(--gray-700);
  font-weight: 600; font-size: var(--text-xs); border-radius: var(--radius-sm);
  padding: 5px 10px; box-shadow: var(--shadow-xs);
}
.fc .fc-button:hover { background: var(--gray-50); border-color: var(--gray-400); }
.fc .fc-button-primary:not(:disabled).fc-button-active,
.fc .fc-button-primary:not(:disabled):active { background: var(--gray-100); border-color: var(--gray-400); color: var(--ink); }
.fc .fc-daygrid-day.fc-day-today { background: var(--accent-wash); }
.fc th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); }
.fc .fc-event { border-radius: var(--radius-sm); border: 0; padding: 1px 5px; font-size: var(--text-xs); cursor: pointer; }
.fc .fc-event.ev-mine { background: var(--accent-deep); color: #fff; }
.fc .fc-event.ev-shared { background: var(--gray-600); color: #fff; }
.fc a { color: inherit; }

/* ================= dashboard ================= */
.dash-grid {
  display: grid; gap: var(--sp-4);
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  align-items: start;
}
.stack { display: flex; flex-direction: column; gap: var(--sp-4); }
.list-rows { list-style: none; margin: 0; padding: 0; }
.list-rows li { border-bottom: 1px solid var(--line); }
.list-rows li:last-child { border-bottom: 0; }
.row-link {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 9px 8px;
  color: var(--ink); text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: var(--radius-sm);
}
.row-link:hover { background: var(--gray-50); text-decoration: none; color: var(--ink); }
.row-link .row-title { font-weight: 500; font-size: var(--text-sm); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-link .row-sub { font-size: var(--text-xs); color: var(--ink-dim); flex: none; }
.activity-item { display: flex; gap: var(--sp-2); padding: var(--sp-2) 0; font-size: var(--text-sm); border-bottom: 1px solid var(--line); }
.activity-item:last-child { border-bottom: 0; }
.activity-item .when { font-family: var(--font-mono); font-size: 11px; color: var(--ink-faint); flex: none; padding-top: 2px; }

/* ================= share picker ================= */
.share-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; }
.share-list li { display: flex; align-items: center; gap: var(--sp-2); padding: 9px 0; border-bottom: 1px solid var(--line); }
.share-list li:last-child { border-bottom: 0; }
.share-list .who { flex: 1; font-size: var(--text-sm); font-weight: 600; min-width: 0; }
.share-list .who small { display: block; font-weight: 400; color: var(--ink-dim); overflow: hidden; text-overflow: ellipsis; }

/* ================= dropdown menu ================= */
.menu {
  position: absolute; min-width: 190px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  padding: 4px; z-index: var(--z-dropdown);
}
.menu button, .menu a {
  display: flex; align-items: center; gap: var(--sp-2);
  width: 100%; padding: 8px 10px; border: 0; background: transparent;
  border-radius: var(--radius-sm); font-size: var(--text-sm);
  color: var(--gray-700); text-align: left; text-decoration: none;
}
.menu button:hover, .menu a:hover { background: var(--gray-100); color: var(--ink); }
.menu .danger { color: var(--danger); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

/* ================= modal ================= */
.modal-backdrop {
  position: fixed; inset: 0; z-index: var(--z-modal);
  background: rgba(16, 24, 40, .5);
  display: grid; place-items: center; padding: var(--sp-4);
  opacity: 0; transition: opacity var(--dur) var(--ease-out);
  overflow-y: auto;
}
.modal-backdrop.show { opacity: 1; }
.modal {
  background: var(--card); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: 100%; max-width: 680px; max-height: calc(100dvh - 48px);
  overflow-y: auto;
  scale: .97; transition: scale var(--dur) var(--ease-out);
}
.modal-backdrop.show .modal { scale: 1; }
.modal-sm, .modal.modal-sm { max-width: 440px; }
.modal-lg, .modal.modal-lg { max-width: 880px; }
.modal-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-5) var(--sp-6) 0;
}
.modal-head h2 { font-size: var(--text-md); flex: 1; }
.modal-body { padding: var(--sp-4) var(--sp-6); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-6) var(--sp-5);
  border-top: 1px solid var(--line); margin-top: var(--sp-2);
}
.modal-foot .left { margin-right: auto; }
body.modal-open { overflow: hidden; }
.confirm-text { font-size: var(--text-base); padding-top: var(--sp-2); }

/* ================= toasts ================= */
.toast-wrap {
  position: fixed; bottom: var(--sp-5); left: 50%; translate: -50% 0;
  display: flex; flex-direction: column; gap: var(--sp-2);
  z-index: var(--z-toast); pointer-events: none;
}
.toast {
  background: var(--gray-900); color: #fff;
  padding: 10px 16px; border-radius: var(--radius);
  font-size: var(--text-sm); font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; translate: 0 8px;
  transition: opacity var(--dur) var(--ease-out), translate var(--dur) var(--ease-out);
  max-width: min(90vw, 480px);
}
.toast.show { opacity: 1; translate: 0 0; }
.toast-error { background: var(--danger-deep); }
.toast-success { background: var(--gray-900); }

/* ================= empty states ================= */
.empty { text-align: center; padding: var(--sp-10) var(--sp-4); color: var(--ink-dim); }
.empty .icon { color: var(--gray-300); margin-bottom: var(--sp-3); }
.empty h3 { font-size: var(--text-md); color: var(--ink); margin-bottom: var(--sp-1); }
.empty p { font-size: var(--text-sm); max-width: 400px; margin: 0 auto var(--sp-4); }

/* ================= auth pages ================= */
.auth-wrap {
  min-height: 100dvh; display: grid; place-items: center;
  padding: var(--sp-4);
  background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 408px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  padding: var(--sp-8);
}
.auth-card .brand { padding: 0 0 var(--sp-5); font-size: var(--text-md); }
.auth-card h1 { font-size: var(--text-lg); margin-bottom: var(--sp-1); }
.auth-card .auth-sub { color: var(--ink-dim); font-size: var(--text-sm); margin-bottom: var(--sp-5); }
.auth-card .btn { width: 100%; height: var(--control-h-lg); }
.auth-links { margin-top: var(--sp-4); text-align: center; font-size: var(--text-sm); }
.form-error {
  background: var(--danger-wash); color: var(--danger);
  border: 1px solid #F2CFD6;
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: var(--text-sm); margin-bottom: var(--sp-4);
  display: none;
}
.form-error.show { display: block; }
.form-success {
  background: var(--ok-wash); color: var(--ok);
  border: 1px solid #C9E7D4;
  border-radius: var(--radius-sm); padding: 10px 12px;
  font-size: var(--text-sm); margin-bottom: var(--sp-4);
  display: none;
}
.form-success.show { display: block; }

/* ================= utilities ================= */
.flex { display: flex; align-items: center; gap: var(--sp-2); }
.muted { color: var(--ink-dim); }
.small { font-size: var(--text-sm); }
.tiny { font-size: var(--text-xs); }
.mt-2 { margin-top: var(--sp-2); } .mt-4 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-4 { margin-bottom: var(--sp-4); }
.hidden { display: none !important; }

/* ================= consistency & overflow guards ================= */
/* Special input types keep the shared control look without clipping. */
input[type="file"].input { height: auto; padding: 7px 12px; cursor: pointer; }
input[type="file"].input::file-selector-button {
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--gray-50); color: var(--gray-700);
  font: inherit; font-size: var(--text-xs); font-weight: 600;
  padding: 3px 10px; margin-right: 10px; cursor: pointer;
}
input[type="date"].input, input[type="time"].input,
input[type="datetime-local"].input { padding-right: 8px; }

/* Trailing-margin trims: last element inside a container never adds padding. */
.modal-body .field:last-child,
.panel-body .field:last-child { margin-bottom: 0; }
.panel-body > p:last-child,
.modal-body > p:last-child { margin-bottom: 0; }
.alert:last-child { margin-bottom: 0; }
.panel-body > .list-rows:only-child { margin: calc(var(--sp-2) * -1) 0; }

/* Dropdowns inside modals: keep them scrollable, never taller than the modal. */
.modal .search-results { max-height: 220px; }

/* Long content never blows out flex rows. */
.kanban-col-head .col-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-results a span:not(.kind) {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-chip .user-name { min-width: 0; }
.row-link .row-sub {
  max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.row-link .row-sub.due-badge { max-width: none; }
.board-tile .meta { flex-wrap: wrap; }
.board-tile .meta > span {
  min-width: 0; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.task-card .meta-item {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.share-list .who, .share-list .who small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comment-text, .rich-text { overflow-wrap: anywhere; }
.page-head h1 { min-width: 0; overflow-wrap: anywhere; }
table.data td { overflow-wrap: anywhere; }
table.data td.actions, table.data td.mono { overflow-wrap: normal; }

/* Grids never force horizontal scroll on the page. */
.dash-grid > *, .form-row > *, .form-row-3 > *, .task-props > * { min-width: 0; }
.content { overflow-x: clip; }
.kanban { overflow-x: auto; }

/* ================= mobile ================= */
.menu-toggle { display: none; }
@media (max-width: 900px) {
  .notes-layout { grid-template-columns: 1fr; margin: calc(var(--sp-4) * -1); }
  .notes-folders { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: var(--sp-2); }
  .notes-folders .nav { flex-direction: row; }
  .notes-list { max-height: 40vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .dash-grid { grid-template-columns: 1fr; }
  .form-section { grid-template-columns: 1fr; gap: var(--sp-3); }
}
@media (max-width: 768px) {
  .menu-toggle { display: inline-flex; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: calc(var(--z-modal) + 1);
    translate: -100% 0; transition: translate var(--dur) var(--ease-out);
    box-shadow: var(--shadow-xl); height: 100dvh;
  }
  body.sidebar-open .sidebar { translate: 0 0; }
  .sidebar-scrim {
    position: fixed; inset: 0; background: rgba(16, 24, 40, .5);
    z-index: var(--z-modal); display: none;
  }
  body.sidebar-open .sidebar-scrim { display: block; }
  .search-box { width: 100%; }
  .topbar { padding: 0 var(--sp-3); gap: var(--sp-2); }
  .content { padding: var(--sp-4) var(--sp-3); }
  .kanban-col { flex-basis: 84vw; max-width: 84vw; }
  .task-props { grid-template-columns: 1fr 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
