/* Agency CRM prototype — layout shell and components. Uses tokens.css only. */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; line-height: var(--line-height-tight); font-weight: var(--font-weight-semibold); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: var(--color-accent-soft-text); text-underline-offset: 2px; }
:root[data-theme="dark"] a { color: var(--color-accent-soft-text); }
button, input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; }
table { border-collapse: collapse; width: 100%; }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--color-focus-ring); border-radius: var(--radius-sm); }
input[type="time"]:focus, input[type="date"]:focus, input[type="datetime-local"]:focus,
input[type="time"]:focus-within, input[type="date"]:focus-within, input[type="datetime-local"]:focus-within { outline: none; box-shadow: var(--color-focus-ring); } /* inner date/time fields take focus; ring the whole control */

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--color-text-muted); }
.text-danger { color: var(--color-danger-text); font-weight: var(--font-weight-medium); }
.text-success { color: var(--color-success-text); }
.nowrap { white-space: nowrap; }
.small { font-size: var(--font-size-sm); }
.xs { font-size: var(--font-size-xs); }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute; left: var(--space-4); top: -100px; z-index: var(--z-toast);
  background: var(--color-accent); color: var(--color-accent-contrast);
  padding: var(--space-2) var(--space-4); border-radius: var(--radius-md);
  font-weight: var(--font-weight-semibold); text-decoration: none;
}
.skip-link:focus, .skip-link:focus-visible { top: var(--space-3); }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.app__main { min-width: 0; display: flex; flex-direction: column; }
.main { flex: 1; padding: var(--space-6); width: 100%; max-width: var(--content-max); margin: 0 auto; }
.main:focus { outline: none; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--color-sidebar-bg); color: var(--color-sidebar-text);
  display: flex; flex-direction: column; z-index: var(--z-sidebar);
  scrollbar-width: thin; scrollbar-color: var(--color-sidebar-border) transparent;
}
.sidebar__brand {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
}
.brand-mark {
  width: 32px; height: 32px; border-radius: var(--radius-md);
  background: var(--color-sidebar-active-bg); color: var(--color-sidebar-active-text);
  display: grid; place-items: center; font-weight: var(--font-weight-bold); font-size: var(--font-size-sm);
}
.brand-mark--logo { background: #fff; overflow: hidden; }
.brand-logo { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-name { font-weight: var(--font-weight-semibold); color: #fff; font-size: var(--font-size-md); overflow-wrap: anywhere; }
.brand-sub { font-size: var(--font-size-xs); color: var(--color-sidebar-muted); }
.icon-btn.sidebar__close { display: none; margin-left: auto; color: var(--color-sidebar-text); }

.nav { padding: 0 var(--space-3) var(--space-6); }
.nav-group + .nav-group { margin-top: var(--space-4); }
.nav-group__label {
  display: block; padding: var(--space-2) var(--space-3) var(--space-1);
  font-size: var(--font-size-2xs); font-weight: var(--font-weight-semibold);
  text-transform: uppercase; letter-spacing: var(--letter-spacing-caps); color: var(--color-sidebar-muted);
}
.nav-link {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3); border-radius: var(--radius-md);
  color: var(--color-sidebar-text); text-decoration: none; font-size: var(--font-size-base);
  transition: background var(--duration-fast) var(--ease-standard);
}
:root[data-theme="dark"] .nav-link, .nav-link { color: var(--color-sidebar-text); }
.nav-link svg { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.nav-link:hover { background: var(--color-sidebar-hover); }
.nav-link[aria-current="page"] {
  background: var(--color-sidebar-active-bg); color: var(--color-sidebar-active-text);
  font-weight: var(--font-weight-medium);
}
.nav-link[aria-current="page"] svg { opacity: 1; }
.nav-link:focus-visible { box-shadow: 0 0 0 2px var(--color-sidebar-bg), 0 0 0 4px var(--color-focus); }
.nav-link .nav-soon { margin-left: auto; font-size: var(--font-size-2xs); color: var(--color-sidebar-muted); }
.nav-link[aria-current="page"] .nav-soon { color: inherit; }
.sidebar__footer {
  margin-top: auto; padding: var(--space-4) var(--space-5); border-top: 1px solid var(--color-sidebar-border);
  font-size: var(--font-size-xs); color: var(--color-sidebar-muted);
}

.sidebar-backdrop { display: none; }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--topbar-height); padding: var(--space-2) var(--space-6);
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--color-border);
}
.icon-btn.topbar__menu { display: none; }
.topbar__title { font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: var(--space-2); }
.proto-badge {
  display: inline-flex; align-items: center; gap: var(--space-1);
  padding: 2px var(--space-2); border-radius: var(--radius-pill);
  background: var(--badge-warning-bg); color: var(--badge-warning-text);
  border: 1px dashed var(--badge-warning-dot);
  font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold); white-space: nowrap;
}

.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: var(--control-height); height: var(--control-height);
  border-radius: var(--radius-md); border: 1px solid transparent; background: transparent;
  color: var(--color-text); cursor: pointer; text-decoration: none;
}
.icon-btn:hover { background: var(--color-surface-hover); border-color: var(--color-border); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .counter {
  position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: var(--radius-pill); background: var(--color-accent); color: var(--color-accent-contrast);
  font-size: 10px; font-weight: var(--font-weight-bold); line-height: 17px; text-align: center;
}

/* ---------- Avatar ---------- */
.avatar {
  --av: 28px;
  width: var(--av); height: var(--av); border-radius: 50%; flex: none;
  display: inline-grid; place-items: center; font-size: 11px; font-weight: var(--font-weight-semibold);
  background: var(--badge-accent-bg); color: var(--badge-accent-text);
}
.avatar--sm { --av: 22px; font-size: 10px; }
.avatar--lg { --av: 36px; font-size: 13px; }
.avatar[data-tone="1"] { background: var(--badge-info-bg); color: var(--badge-info-text); }
.avatar[data-tone="2"] { background: var(--badge-success-bg); color: var(--badge-success-text); }
.avatar[data-tone="3"] { background: var(--badge-violet-bg); color: var(--badge-violet-text); }
.avatar[data-tone="4"] { background: var(--badge-warning-bg); color: var(--badge-warning-text); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--color-surface); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }
.person { display: inline-flex; align-items: center; gap: var(--space-2); white-space: nowrap; }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-5); }
.page-head__title { font-size: var(--font-size-2xl); letter-spacing: -0.01em; }
.page-head__sub { color: var(--color-text-muted); margin-top: var(--space-1); }
.page-head__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.breadcrumb { font-size: var(--font-size-sm); color: var(--color-text-muted); margin-bottom: var(--space-3); min-height: 1px; }
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-2); }
.breadcrumb li { display: inline-flex; align-items: center; gap: var(--space-2); }
.breadcrumb li + li::before { content: "/"; color: var(--color-border-strong); }
.breadcrumb a { color: var(--color-text-muted); }
.breadcrumb [aria-current="page"] { color: var(--color-text); font-weight: var(--font-weight-medium); }

/* ---------- Card ---------- */
.card {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border);
}
.card__head--plain { border-bottom: 0; padding-bottom: 0; }
.card__title { font-size: var(--font-size-md); font-weight: var(--font-weight-semibold); }
.card__title .count { color: var(--color-text-muted); font-weight: var(--font-weight-regular); margin-left: var(--space-1); }
.card__body { padding: var(--space-4) var(--space-5); }
.card__body--flush { padding: 0; }
.card__foot { padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); font-size: var(--font-size-sm); color: var(--color-text-muted); }
.section-label {
  font-size: var(--font-size-2xs); font-weight: var(--font-weight-semibold); text-transform: uppercase;
  letter-spacing: var(--letter-spacing-caps); color: var(--color-text-muted); margin: var(--space-4) 0 var(--space-2);
}
.section-label:first-child { margin-top: 0; }

/* ---------- Grid helpers ---------- */
.grid { display: grid; gap: var(--space-4); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--dash { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }

/* ---------- Stat card ---------- */
.stat-card { padding: var(--space-4) var(--space-5); display: flex; flex-direction: column; gap: var(--space-2); }
.stat-card__label { font-size: var(--font-size-sm); color: var(--color-text-muted); font-weight: var(--font-weight-medium); display: flex; align-items: center; gap: var(--space-2); }
.stat-card__label svg { width: 16px; height: 16px; }
.stat-card__value { font-size: var(--font-size-xl); font-weight: var(--font-weight-semibold); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-card__lines { display: flex; flex-direction: column; gap: 2px; }
.stat-card__line { display: flex; justify-content: space-between; gap: var(--space-2); font-variant-numeric: tabular-nums; }
.stat-card__line strong { font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); }
.stat-card__line span { color: var(--color-text-muted); font-size: var(--font-size-xs); align-self: center; }
.stat-card__hint { font-size: var(--font-size-xs); color: var(--color-text-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-height); padding: 0 var(--space-4); border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-text);
  font-size: var(--font-size-base); font-weight: var(--font-weight-medium); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background var(--duration-fast) var(--ease-standard), border-color var(--duration-fast) var(--ease-standard);
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--color-surface-hover); }
.btn--primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-contrast); }
.btn--primary:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }
.btn--ghost { background: transparent; border-color: transparent; }
.btn--ghost:hover { background: var(--color-surface-hover); }
.btn--sm { height: var(--control-height-sm); padding: 0 var(--space-3); font-size: var(--font-size-sm); }
.btn--danger { color: var(--color-danger-text); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.link-btn { background: none; border: 0; padding: 0; color: var(--color-accent-soft-text); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }

/* ---------- Inputs ---------- */
.input, .select, .textarea {
  height: var(--control-height); padding: 0 var(--space-3); border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-text);
  font-size: var(--font-size-base); min-width: 0;
}
.textarea { height: auto; min-height: 80px; padding: var(--space-2) var(--space-3); resize: vertical; width: 100%; }
.select { padding-right: var(--space-8); appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.select--sm, .input--sm { height: var(--control-height-sm); font-size: var(--font-size-sm); }
.input::placeholder, .textarea::placeholder { color: var(--color-text-muted); opacity: 1; }
.input:hover, .select:hover { border-color: var(--color-text-muted); }
.field { display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.field__label { font-size: var(--font-size-xs); font-weight: var(--font-weight-medium); color: var(--color-text-muted); }
.search { position: relative; display: flex; align-items: center; }
.search svg { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--color-text-muted); pointer-events: none; }
.search .input { padding-left: 34px; width: 100%; }
.checkbox { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; font-size: var(--font-size-sm); }
.checkbox input { width: 24px; height: 24px; accent-color: var(--color-accent); margin: 0; }

/* ---------- Filter bar ---------- */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.filter-bar .search { flex: 1 1 220px; max-width: 320px; }
.filter-bar__spacer { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-bottom: var(--space-4); }
.chip {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: 30px; padding: 0 var(--space-3); border-radius: var(--radius-pill);
  border: 1px solid var(--color-border-strong); background: var(--color-surface); color: var(--color-text);
  font-size: var(--font-size-sm); cursor: pointer;
}
.chip .chip__count { font-size: var(--font-size-xs); color: var(--color-text-muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: var(--color-text); color: var(--color-bg); border-color: var(--color-text); }
.chip[aria-pressed="true"] .chip__count { color: inherit; opacity: 0.8; }

/* Contact chips (non-interactive) */
.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px var(--space-2);
  border-radius: var(--radius-sm); background: var(--color-bg-sunken); color: var(--color-text);
  font-size: var(--font-size-xs); white-space: nowrap; border: 1px solid var(--color-border);
}
.tags .tag { max-width: 180px; }
.tag__text { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tag svg { flex: none; width: 12px; height: 12px; color: var(--color-text-muted); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }

/* ---------- Badges ---------- */
.badge {
  --b-bg: var(--badge-neutral-bg); --b-text: var(--badge-neutral-text); --b-dot: var(--badge-neutral-dot);
  display: inline-flex; align-items: center; gap: 6px; padding: 2px var(--space-2) 2px 7px;
  border-radius: var(--radius-pill); background: var(--b-bg); color: var(--b-text);
  font-size: var(--font-size-xs); font-weight: var(--font-weight-medium); white-space: nowrap; line-height: 1.5;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--b-dot); flex: none; }
.badge--nodot { padding-left: var(--space-2); }
.badge--nodot::before { display: none; }
.badge--info { --b-bg: var(--badge-info-bg); --b-text: var(--badge-info-text); --b-dot: var(--badge-info-dot); }
.badge--success { --b-bg: var(--badge-success-bg); --b-text: var(--badge-success-text); --b-dot: var(--badge-success-dot); }
.badge--warning { --b-bg: var(--badge-warning-bg); --b-text: var(--badge-warning-text); --b-dot: var(--badge-warning-dot); }
.badge--danger { --b-bg: var(--badge-danger-bg); --b-text: var(--badge-danger-text); --b-dot: var(--badge-danger-dot); }
.badge--violet { --b-bg: var(--badge-violet-bg); --b-text: var(--badge-violet-text); --b-dot: var(--badge-violet-dot); }
.badge--accent { --b-bg: var(--badge-accent-bg); --b-text: var(--badge-accent-text); --b-dot: var(--badge-accent-dot); }

/* ---------- Tabs ---------- */
.tabs { position: relative; display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-border); margin-bottom: var(--space-4); overflow-x: auto; scrollbar-width: none; }
.tab {
  position: relative; padding: var(--space-2) var(--space-3) var(--space-3); border: 0; background: none; cursor: pointer;
  color: var(--color-text-muted); font-weight: var(--font-weight-medium); white-space: nowrap; font-size: var(--font-size-base);
}
.tab:hover { color: var(--color-text); }
.tab[aria-selected="true"] { color: var(--color-text); }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: var(--space-2); right: var(--space-2); bottom: -1px; height: 2px; border-radius: 2px; background: var(--color-accent); }
.tab .count { font-size: var(--font-size-xs); margin-left: 4px; color: var(--color-text-muted); }

/* ---------- Segmented control ---------- */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: var(--radius-md); background: var(--color-bg-sunken); border: 1px solid var(--color-border); }
.segmented button {
  height: 28px; padding: 0 var(--space-3); border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--color-text-muted); font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.segmented button svg { width: 14px; height: 14px; }
.segmented button[aria-pressed="true"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-sm); }

/* ---------- Table ---------- */
.table-wrap { position: relative; overflow-x: auto; border-radius: var(--radius-lg); }
.table-wrap:focus-visible { box-shadow: var(--color-focus-ring); }
.table th, .table td { padding: var(--space-3); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--color-border); }
.table thead th {
  font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-caps);
  color: var(--color-text-muted); font-weight: var(--font-weight-semibold); background: var(--color-surface-2); white-space: nowrap;
}
.table thead th:first-child { border-top-left-radius: var(--radius-lg); }
.table thead th:last-child { border-top-right-radius: var(--radius-lg); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--color-surface-hover); }
.table .cell-main { font-weight: var(--font-weight-semibold); color: var(--color-text); text-decoration: none; }
a.cell-main:hover { text-decoration: underline; }
.table .cell-sub { font-size: var(--font-size-xs); color: var(--color-text-muted); margin-top: 1px; }
.table .num, .table .right { text-align: right; }
.table--wrap-head thead th { white-space: normal; }
.table--compact th, .table--compact td { padding: var(--space-2) var(--space-3); }
.table--min-lg { min-width: 1040px; }
.table--min-md { min-width: 760px; }
.table .select--sm { min-width: 128px; }
.col-wide { min-width: 170px; }
.row-quick td { background: var(--color-surface-2); }
.quick-form { display: grid; grid-template-columns: 1.2fr 1.2fr 1fr 2fr auto; gap: var(--space-2); align-items: end; }

/* ---------- Lists ---------- */
.list-item { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--color-border); }
.list-item:last-child { border-bottom: 0; }
.list-item__main { flex: 1; min-width: 0; }
.list-item__title { font-weight: var(--font-weight-medium); }
button.list-item { width: 100%; text-align: left; background: none; border-left: 0; border-right: 0; border-top: 0; cursor: pointer; }
button.list-item:hover { background: var(--color-surface-hover); }
.list-item__meta { font-size: var(--font-size-xs); color: var(--color-text-muted); }
.group-title { padding: var(--space-3) var(--space-5) var(--space-1); font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-caps); font-weight: var(--font-weight-semibold); color: var(--color-text-muted); background: var(--color-surface-2); border-bottom: 1px solid var(--color-border); }

.progress { height: 6px; border-radius: var(--radius-pill); background: var(--color-bg-sunken); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--color-accent); border-radius: inherit; }

/* ---------- Dashboard ---------- */
.now-card { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-5); align-items: center; padding: var(--space-5); }
.now-card__timer { font-family: var(--font-mono); font-size: 2rem; font-weight: var(--font-weight-semibold); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.now-card__task { font-weight: var(--font-weight-semibold); font-size: var(--font-size-md); }
.pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--badge-danger-dot); display: inline-block; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.now-card__totals { display: flex; gap: var(--space-6); padding-left: var(--space-5); border-left: 1px solid var(--color-border); }
.kv__label { font-size: var(--font-size-xs); color: var(--color-text-muted); }
.kv__value { font-family: var(--font-mono); font-size: var(--font-size-lg); font-weight: var(--font-weight-semibold); }
.quick-add { display: flex; gap: var(--space-2); }
.quick-add { flex-wrap: wrap; align-items: flex-end; }
.quick-add .field:first-child { flex: 2 1 220px; }
.quick-add .field { flex: 1 1 180px; }
.quick-add .input, .quick-add .select { width: 100%; }
.rem-chip { text-decoration: none; }
.rem-chip .badge { padding-block: 0; }
.rem-summary .chips { margin-bottom: var(--space-3); }
.rem-item__link { font-weight: var(--font-weight-medium); }
.rem-item { padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 4px; }
.rem-item:last-child { border-bottom: 0; }
.rem-item__fact { font-size: var(--font-size-sm); }
.rem-item__next { font-size: var(--font-size-sm); color: var(--color-text-muted); }
.rem-item__next strong { color: var(--color-text); font-weight: var(--font-weight-medium); }
.rem-mark { width: 24px; height: 24px; border-radius: var(--radius-sm); background: var(--color-text); color: var(--color-bg); display: grid; place-items: center; font-weight: var(--font-weight-bold); font-size: var(--font-size-xs); }

/* ---------- Kanban ---------- */
.kanban { position: relative; display: grid; grid-template-columns: repeat(4, minmax(250px, 1fr)); gap: var(--space-4); overflow-x: auto; padding-bottom: var(--space-2); }
.kanban-col { background: var(--color-bg-sunken); border: 1px solid var(--color-border); border-radius: var(--radius-lg); padding: var(--space-3); min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.kanban-col__head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-1) var(--space-1) var(--space-2); }
.kanban-col__title { font-size: var(--font-size-sm); font-weight: var(--font-weight-semibold); display: flex; align-items: center; gap: var(--space-2); }
.kanban-col__count { font-size: var(--font-size-xs); color: var(--color-text-muted); background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-pill); padding: 0 var(--space-2); font-variant-numeric: tabular-nums; }
.kanban-col__empty { font-size: var(--font-size-sm); color: var(--color-text-muted); text-align: center; padding: var(--space-6) var(--space-2); border: 1px dashed var(--color-border-strong); border-radius: var(--radius-md); }
.task-card {
  display: flex; flex-direction: column; gap: var(--space-2); width: 100%; text-align: left; cursor: pointer;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md);
  padding: var(--space-3); box-shadow: var(--shadow-xs); color: var(--color-text);
  transition: border-color var(--duration-fast) var(--ease-standard), box-shadow var(--duration-fast) var(--ease-standard);
}
.task-card:hover { border-color: var(--color-border-strong); box-shadow: var(--shadow-sm); }
.task-card__title { font-weight: var(--font-weight-medium); line-height: 1.35; }
.task-card__meta { font-size: var(--font-size-xs); color: var(--color-text-muted); }
.task-card__foot { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); font-size: var(--font-size-xs); color: var(--color-text-muted); }
.task-card__foot .ico { display: inline-flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }
.task-card__foot svg { width: 13px; height: 13px; }
.blocker-mark { display: inline-flex; align-items: center; gap: 4px; color: var(--color-danger-text); font-weight: var(--font-weight-semibold); font-size: var(--font-size-xs); }
.blocker-mark svg { width: 13px; height: 13px; }
.task-card--done .task-card__title { text-decoration: line-through; color: var(--color-text-muted); }

/* ---------- Drawer ---------- */
.overlay { position: fixed; inset: 0; background: var(--overlay-bg); z-index: var(--z-overlay); animation: fade-in var(--duration-base) var(--ease-standard); }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(var(--drawer-width), 100vw); z-index: var(--z-drawer);
  background: var(--color-surface); border-left: 1px solid var(--color-border); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slide-in var(--duration-slow) var(--ease-standard);
}
.drawer:focus { outline: none; }
.drawer__head { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-5); border-bottom: 1px solid var(--color-border); }
.drawer__title { font-size: var(--font-size-lg); flex: 1; }
.drawer__body { position: relative; flex: 1; overflow-y: auto; padding: var(--space-5); }
.drawer__foot { display: flex; gap: var(--space-2); justify-content: flex-end; padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); background: var(--color-surface-2); }
.meta-grid { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: var(--space-2) var(--space-4); font-size: var(--font-size-sm); margin-bottom: var(--space-5); }
.meta-grid dt { color: var(--color-text-muted); }
.meta-grid dd { margin: 0; min-width: 0; }
.callout { border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); font-size: var(--font-size-sm); border: 1px solid; }
.callout--danger { background: var(--badge-danger-bg); color: var(--badge-danger-text); border-color: color-mix(in srgb, var(--badge-danger-dot) 40%, transparent); }
.callout--info { background: var(--badge-info-bg); color: var(--badge-info-text); border-color: color-mix(in srgb, var(--badge-info-dot) 35%, transparent); }
.callout--warning { background: var(--badge-warning-bg); color: var(--badge-warning-text); border-color: color-mix(in srgb, var(--badge-warning-dot) 40%, transparent); }
.callout strong { font-weight: var(--font-weight-semibold); }
.checklist input { width: 16px; height: 16px; margin: 0; accent-color: var(--color-accent); }
.checklist li { display: flex; align-items: center; gap: var(--space-2); padding: 6px 0; }
.checklist li.is-done span { text-decoration: line-through; color: var(--color-text-muted); }
.subtask { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; border-bottom: 1px dashed var(--color-border); font-size: var(--font-size-sm); }
.subtask:last-child { border-bottom: 0; }
.subtask__title { flex: 1; min-width: 0; }
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Messages / comments / timeline ---------- */
.message { display: flex; gap: var(--space-3); padding: var(--space-3) 0; }
.message + .message { border-top: 1px solid var(--color-border); }
.message__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); }
.message__author { font-weight: var(--font-weight-semibold); }
.message__time { font-size: var(--font-size-xs); color: var(--color-text-muted); }
.message__body { margin-top: 2px; }
.message__reactions { display: flex; gap: 4px; margin-top: var(--space-2); }
.reaction { font-size: var(--font-size-xs); padding: 0 var(--space-2); border-radius: var(--radius-pill); border: 1px solid var(--color-border); background: var(--color-surface-2); }
.quote { border-left: 3px solid var(--color-border-strong); padding: 2px var(--space-3); margin: 4px 0; color: var(--color-text-muted); font-size: var(--font-size-sm); }
.composer { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-4); }
.timeline li { position: relative; padding: 0 0 var(--space-3) var(--space-5); font-size: var(--font-size-sm); }
.timeline li::before { content: ""; position: absolute; left: 4px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--color-border-strong); }
.timeline li::after { content: ""; position: absolute; left: 7px; top: 16px; bottom: 0; width: 1px; background: var(--color-border); }
.timeline li:last-child::after { display: none; }

/* ---------- Week (My time) ---------- */
.week-nav { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.week-nav__range { font-weight: var(--font-weight-semibold); min-width: 220px; text-align: center; }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--space-3); }
.day { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); display: flex; flex-direction: column; min-height: 260px; min-width: 0; }
.day--today { border-color: var(--color-accent); box-shadow: 0 0 0 1px var(--color-accent); }
.day--weekend { background: var(--color-surface-2); }
.day__head { padding: var(--space-3); border-bottom: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 2px; }
.day__name { font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-caps); color: var(--color-text-muted); font-weight: var(--font-weight-semibold); }
.day__date { font-weight: var(--font-weight-semibold); }
.day__entries { padding: var(--space-2); display: flex; flex-direction: column; gap: var(--space-2); flex: 1; }
.entry { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-2); background: var(--color-surface-2); display: flex; flex-direction: column; gap: 4px; }
.entry__title { font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); line-height: 1.3; overflow-wrap: anywhere; }
.entry__meta { display: flex; align-items: center; justify-content: space-between; gap: 4px; flex-wrap: wrap; font-size: var(--font-size-xs); color: var(--color-text-muted); }
.day__total { padding: var(--space-2) var(--space-3); border-top: 1px solid var(--color-border); display: flex; justify-content: space-between; font-size: var(--font-size-sm); }
.day__empty { color: var(--color-text-muted); font-size: var(--font-size-xs); text-align: center; padding: var(--space-4) 0; }

/* ---------- File list ---------- */
.file-icon { width: 34px; height: 34px; border-radius: var(--radius-md); background: var(--color-bg-sunken); display: grid; place-items: center; color: var(--color-text-muted); flex: none; font-size: 10px; font-weight: var(--font-weight-bold); text-transform: uppercase; }

/* ---------- Finance tab ---------- */
.finance-note { margin-bottom: var(--space-4); }

/* ---------- States ---------- */
.state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-3); padding: var(--space-12) var(--space-6); }
.state__icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--color-bg-sunken); color: var(--color-text-muted); }
.state__icon svg { width: 26px; height: 26px; }
.state--error .state__icon { background: var(--badge-danger-bg); color: var(--badge-danger-text); }
.state--forbidden .state__icon { background: var(--badge-warning-bg); color: var(--badge-warning-text); }
.state__title { font-size: var(--font-size-lg); }
.state__text { color: var(--color-text-muted); max-width: 460px; }
.state__code { font-family: var(--font-mono); font-size: var(--font-size-xs); color: var(--color-text-muted); }

.skeleton { position: relative; overflow: hidden; background: var(--skeleton-base); border-radius: var(--radius-sm); height: 12px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, var(--skeleton-shine), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { transform: translateX(100%); } }
.skeleton--title { height: 20px; width: 40%; }
.skeleton-row { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: var(--space-4); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--color-border); }
.skeleton-row:last-child { border-bottom: 0; }

/* ---------- Placeholder module ---------- */
.placeholder { max-width: 760px; }
.placeholder ul { list-style: disc; padding-left: var(--space-5); display: flex; flex-direction: column; gap: var(--space-1); }

/* ---------- Toast ---------- */
.toast-region { position: fixed; right: var(--space-5); bottom: var(--space-5); z-index: var(--z-toast); display: flex; flex-direction: column; gap: var(--space-2); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: var(--space-3);
  background: var(--color-text); color: var(--color-bg); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4); box-shadow: var(--shadow-lg); font-size: var(--font-size-sm); max-width: 380px;
  animation: toast-in var(--duration-base) var(--ease-standard);
}
.toast svg { width: 16px; height: 16px; flex: none; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  }

@media (max-width: 1080px) {
  .grid--dash { grid-template-columns: minmax(0, 1fr); }
  }

@media (max-width: 899.98px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: min(300px, 86vw); height: auto;
    transform: translateX(-100%); visibility: hidden;
    transition: transform var(--duration-slow) var(--ease-standard), visibility 0s linear var(--duration-slow);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.is-open { transform: none; visibility: visible; transition: transform var(--duration-slow) var(--ease-standard), visibility 0s; }
  .icon-btn.sidebar__close { display: inline-grid; }
  .sidebar__close:hover { background: var(--color-sidebar-hover); border-color: var(--color-sidebar-border); }
  .sidebar-backdrop.is-open { display: block; position: fixed; inset: 0; background: var(--overlay-bg); z-index: calc(var(--z-sidebar) - 1); }
  .topbar { padding: var(--space-2) var(--space-4); gap: var(--space-2); }
  .icon-btn.topbar__menu { display: inline-grid; }
  .topbar__title { font-size: var(--font-size-md); }
  .main { padding: var(--space-4); }
  .page-head__title { font-size: var(--font-size-xl); }
  .grid--2, .grid--3 { grid-template-columns: minmax(0, 1fr); }
  .now-card { grid-template-columns: minmax(0, 1fr); }
  .now-card__totals { border-left: 0; padding-left: 0; border-top: 1px solid var(--color-border); padding-top: var(--space-4); }
  .quick-form { grid-template-columns: 1fr 1fr; }
  .quick-form .field--wide, .quick-form .btn { grid-column: 1 / -1; }
  .week { grid-template-columns: minmax(0, 1fr); }
  .day { min-height: 0; }
  .kanban { grid-template-columns: repeat(4, minmax(260px, 82vw)); scroll-snap-type: x mandatory; }
  .kanban--5 { grid-template-columns: repeat(5, minmax(240px, 78vw)); }
  .kanban-col { scroll-snap-align: start; }
  .meta-grid { grid-template-columns: 120px minmax(0, 1fr); }
  .filter-bar .search { max-width: none; flex-basis: 100%; }
    .hide-mobile { display: none !important; }
  .toast-region { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); }

  /* Stacked-card tables */
  .table--stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table--stack, .table--stack tbody, .table--stack tr, .table--stack td { display: block; width: 100%; min-width: 0; }
  .table--stack tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-border); }
  .table--stack tbody tr:last-child { border-bottom: 0; }
  .table--stack td { border: 0; padding: 3px 0; display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: var(--space-2); align-items: center; text-align: left; }
  .table--stack td > .badge, .table--stack td > .select, .table--stack td > .person { justify-self: start; }
  .table--stack td::before { content: attr(data-label); font-size: var(--font-size-xs); color: var(--color-text-muted); }
  .table--stack td[data-label=""]::before, .table--stack td.td-primary::before { display: none; }
  .table--stack td.td-primary { grid-template-columns: minmax(0, 1fr); padding-bottom: var(--space-2); }
  .table--stack tbody tr:hover td { background: none; }
  .table--stack .num, .table--stack .right { text-align: left; }
}

@media (max-width: 560px) {
  .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .grid--4.grid--m2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .skeleton::after { display: none; }
  .pulse { animation: none; }
}

/* =====================================================================
   UI-01 shell additions: collapsible sidebar, topbar search, mini timer,
   account menu, popover, modal, forms, banners, demo marks.
   ===================================================================== */
.demo-mark {
  display: inline-block; padding: 0 6px; border-radius: var(--radius-pill); border: 1px dashed var(--badge-warning-dot);
  background: var(--badge-warning-bg); color: var(--badge-warning-text); font-size: var(--font-size-2xs);
  font-weight: var(--font-weight-semibold); text-transform: uppercase; letter-spacing: 0.04em; line-height: 1.6; vertical-align: middle;
}

/* Sidebar footer + collapse */
.sidebar__footer { display: flex; flex-direction: column; gap: var(--space-2); }
.sidebar__collapse {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 36px; padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-sidebar-border); border-radius: var(--radius-md); background: transparent;
  color: var(--color-sidebar-text); font-size: var(--font-size-sm); cursor: pointer;
}
.sidebar__collapse:hover { background: var(--color-sidebar-hover); }
.sidebar__collapse svg { width: 18px; height: 18px; flex: none; }
.sidebar__collapse:focus-visible { box-shadow: 0 0 0 2px var(--color-sidebar-bg), 0 0 0 4px var(--color-focus); }
.sidebar__note { margin: 0; }
.nav-lock { margin-left: auto; display: inline-flex; color: var(--color-sidebar-muted); }
.nav-lock svg { width: 14px; height: 14px; }
.nav-link[aria-current="page"] .nav-lock { color: inherit; }

@media (min-width: 900px) {
  :root[data-sidebar="collapsed"] .app { grid-template-columns: 72px minmax(0, 1fr); }
  :root[data-sidebar="collapsed"] .brand-text,
  :root[data-sidebar="collapsed"] .nav-link__label,
  :root[data-sidebar="collapsed"] .nav-lock,
  :root[data-sidebar="collapsed"] .sidebar__collapse-label,
  :root[data-sidebar="collapsed"] .sidebar__note {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  :root[data-sidebar="collapsed"] .nav-group__label { height: 1px; padding: 0; margin: var(--space-2) var(--space-3); background: var(--color-sidebar-border); overflow: hidden; color: transparent; }
  :root[data-sidebar="collapsed"] .nav { padding: 0 var(--space-2) var(--space-4); }
  :root[data-sidebar="collapsed"] .nav-link { justify-content: center; padding: var(--space-2); }
  :root[data-sidebar="collapsed"] .sidebar__brand { justify-content: center; padding: var(--space-4) var(--space-2); }
  :root[data-sidebar="collapsed"] .sidebar__footer { padding: var(--space-3) var(--space-2); }
  :root[data-sidebar="collapsed"] .sidebar__collapse { justify-content: center; padding: var(--space-2); }
  :root[data-sidebar="collapsed"] .sidebar__collapse svg { transform: scaleX(-1); }
}

/* Topbar: search trigger, mini timer, account */
.search-trigger {
  display: inline-flex; align-items: center; gap: var(--space-2); height: var(--control-height); min-width: 220px; padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong); border-radius: var(--radius-md); background: var(--color-surface);
  color: var(--color-text-muted); font-size: var(--font-size-sm); cursor: pointer;
}
.search-trigger svg { width: 16px; height: 16px; flex: none; }
.search-trigger__text { flex: 1; text-align: left; white-space: nowrap; }
.search-trigger__kbd { font-family: var(--font-mono); font-size: var(--font-size-2xs); border: 1px solid var(--color-border); border-radius: var(--radius-sm); padding: 0 4px; color: var(--color-text-muted); }
.search-results__list a { display: block; padding: var(--space-2) var(--space-2); border-radius: var(--radius-sm); color: var(--color-text); text-decoration: none; }
.search-results__list a:hover { background: var(--color-surface-hover); }
.search-results { margin-top: var(--space-3); max-height: 50vh; overflow-y: auto; }

.mini-timer {
  display: inline-flex; align-items: center; gap: var(--space-1); height: var(--control-height); padding: 0 2px 0 var(--space-3);
  border-radius: var(--radius-pill); border: 1px solid var(--color-border-strong); background: var(--color-surface);
  color: var(--color-text); text-decoration: none; font-size: var(--font-size-sm); white-space: nowrap;
}
.mini-timer svg { width: 16px; height: 16px; }
.mini-timer__link { display: inline-flex; align-items: center; gap: var(--space-2); color: inherit; text-decoration: none; height: 100%; }
.mini-timer__btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; border: 0; background: transparent; color: inherit; cursor: pointer; }
.mini-timer__btn:hover { background: color-mix(in srgb, currentColor 12%, transparent); }
.mini-timer__btn svg { width: 14px; height: 14px; }
.mini-timer.is-running { border-color: var(--badge-danger-dot); background: var(--badge-danger-bg); color: var(--badge-danger-text); }
.mini-timer__task { font-size: var(--font-size-xs); }

.account { position: relative; }
.account__btn {
  display: flex; align-items: center; gap: var(--space-2); min-height: var(--control-height); padding: 2px var(--space-2) 2px 2px;
  border: 1px solid transparent; border-radius: var(--radius-pill); background: transparent; color: var(--color-text); cursor: pointer; text-align: left;
}
.account__btn:hover { background: var(--color-surface-hover); border-color: var(--color-border); }
.account__btn > svg { width: 16px; height: 16px; color: var(--color-text-muted); }
.account__text { display: flex; flex-direction: column; line-height: 1.2; }
.account__name { font-weight: var(--font-weight-semibold); font-size: var(--font-size-sm); white-space: nowrap; }
.account__role { font-size: var(--font-size-xs); color: var(--color-text-muted); white-space: nowrap; }
.popover {
  position: absolute; z-index: var(--z-overlay); background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: var(--space-2);
}
.account__panel { right: 0; top: calc(100% + 6px); width: 300px; max-width: calc(100vw - 24px); }
.account__head { display: flex; flex-direction: column; padding: var(--space-2) var(--space-2) var(--space-3); border-bottom: 1px solid var(--color-border); }
.account__section { border: 0; margin: 0; padding: var(--space-3) var(--space-2); border-bottom: 1px solid var(--color-border); display: flex; flex-direction: column; gap: var(--space-1); min-width: 0; }
.account__section:last-child { border-bottom: 0; }
.account__section .select { width: 100%; }
.account__section legend { padding: 0; margin-bottom: var(--space-1); }
.radio { display: flex; align-items: center; gap: var(--space-2); min-height: 28px; font-size: var(--font-size-sm); cursor: pointer; }
.radio input { width: 16px; height: 16px; margin: 0; accent-color: var(--color-accent); }
.menu-item {
  display: flex; align-items: center; gap: var(--space-3); width: 100%; min-height: 36px; padding: var(--space-2);
  border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--color-text); text-decoration: none; font-size: var(--font-size-sm); cursor: pointer; text-align: left;
}
.menu-item:hover { background: var(--color-surface-hover); }
.menu-item svg { width: 16px; height: 16px; color: var(--color-text-muted); flex: none; }
.menu-item[aria-checked="true"], .menu-item.is-current { font-weight: var(--font-weight-semibold); }
.show-sm { display: none !important; }

/* Modal dialog */
.overlay--modal { display: block; }
.modal {
  position: fixed; z-index: var(--z-drawer); left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); display: flex; flex-direction: column;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  animation: fade-in var(--duration-base) var(--ease-standard);
}
.modal--md { width: min(640px, calc(100vw - 32px)); }
.modal--lg { width: min(780px, calc(100vw - 32px)); }
.modal:focus { outline: none; }
.modal__head { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-5) var(--space-5) var(--space-3); }
.modal__title { flex: 1; font-size: var(--font-size-lg); }
.modal__body { position: relative; overflow-y: auto; padding: 0 var(--space-5) var(--space-4); }
.modal__foot { display: flex; flex-wrap: wrap; gap: var(--space-2); justify-content: flex-end; padding: var(--space-3) var(--space-5); border-top: 1px solid var(--color-border); background: var(--color-surface-2); border-radius: 0 0 var(--radius-xl) var(--radius-xl); }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); }
.form-grid .field--wide { grid-column: 1 / -1; }
.form-grid .input, .form-grid .select { width: 100%; }
.field__hint { font-size: var(--font-size-xs); color: var(--color-text-muted); }
.field__error { font-size: var(--font-size-xs); color: var(--color-danger-text); font-weight: var(--font-weight-medium); }
.req { color: var(--color-danger-text); }
[aria-invalid="true"] { border-color: var(--color-danger-text) !important; box-shadow: 0 0 0 1px var(--color-danger-text); }
.form-errors:empty { display: none; }
.form-errors { margin-bottom: var(--space-3); padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--badge-danger-bg); color: var(--badge-danger-text); font-size: var(--font-size-sm); }
.form-errors ul { list-style: disc; padding-left: var(--space-5); margin-top: var(--space-1); }
.form-errors .link-btn { color: inherit; font-weight: var(--font-weight-semibold); }
.form-note { margin-bottom: var(--space-3); }

/* Banners */
.banner { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) var(--space-4); margin-bottom: var(--space-3); border-radius: var(--radius-md); border: 1px solid; font-size: var(--font-size-sm); }
.banner > svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.banner__body { flex: 1; min-width: 0; }
.banner .link-btn { color: inherit; font-weight: var(--font-weight-semibold); }
.banner--demo { background: var(--badge-warning-bg); color: var(--badge-warning-text); border-color: color-mix(in srgb, var(--badge-warning-dot) 45%, transparent); border-style: dashed; }
.banner--info { background: var(--badge-info-bg); color: var(--badge-info-text); border-color: color-mix(in srgb, var(--badge-info-dot) 35%, transparent); }
.banner--warning { background: var(--badge-danger-bg); color: var(--badge-danger-text); border-color: color-mix(in srgb, var(--badge-danger-dot) 40%, transparent); }

.now-card__task.link-btn { color: var(--color-text); text-decoration: none; text-align: left; font-size: var(--font-size-md); font-weight: var(--font-weight-semibold); }
.now-card__task.link-btn:hover { text-decoration: underline; }
.crumbs-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.crumbs-row .breadcrumb { margin-bottom: var(--space-3); }
.proto-badge--inline { display: none; margin-bottom: var(--space-3); }

/* UI-03: pager, pipeline, conversion box, fieldsets */
.pager-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2); }
.pager { display: flex; flex-wrap: wrap; gap: 4px; }
.pager .btn { min-width: 32px; padding: 0 var(--space-2); }
.pager .btn.is-current { background: var(--color-text); color: var(--color-bg); border-color: var(--color-text); }
.kanban--5 { grid-template-columns: repeat(5, minmax(220px, 1fr)); }
.pipeline-sums { margin: 0 var(--space-1) var(--space-1); }
.task-card a.task-card__title { color: var(--color-text); text-decoration: none; }
.task-card a.task-card__title:hover { text-decoration: underline; }
.convert-box { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px dashed var(--color-border-strong); }
.convert-box p { flex: 1 1 260px; }
.fieldset { border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: var(--space-3) var(--space-4); margin: var(--space-4) 0 0; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--space-2); margin: var(--space-2) 0; }

.progress-cell { display: flex; align-items: center; gap: var(--space-2); min-width: 120px; }
.progress-cell .progress { flex: 1; }
.next-step { border-left: 3px solid var(--color-accent); }

/* UI-05: task cards with move menu, drag, drawer editing */
.task-card { position: relative; cursor: default; }
.task-card__open { background: none; border: 0; padding: 0; text-align: left; font: inherit; font-weight: var(--font-weight-medium); line-height: 1.35; color: var(--color-text); cursor: pointer; }
.task-card__open:hover { text-decoration: underline; }
.task-card--done .task-card__open { text-decoration: line-through; color: var(--color-text-muted); }
.task-card__move { position: relative; display: flex; justify-content: flex-end; margin-top: calc(-1 * var(--space-1)); }
.task-card__move .btn { height: 26px; font-size: var(--font-size-xs); color: var(--color-text-muted); }
.move-menu { right: 0; top: calc(100% + 4px); width: 220px; }
.move-menu__label { padding: var(--space-1) var(--space-2); }
.task-card.is-dragging { opacity: 0.5; }
.kanban-col.is-drop { outline: 2px dashed var(--color-accent); outline-offset: -2px; }
.task-link { text-align: left; text-decoration: none; color: var(--color-text); }
.drawer-controls { margin-bottom: var(--space-2); }
.inline-add { flex-wrap: wrap; }
.inline-add .input { flex: 1 1 200px; }
.inline-add .field__error { flex-basis: 100%; }
.checklist li { gap: var(--space-2); }
.checklist li label { flex: 1; }
.checklist__edit { flex-wrap: wrap; }
.checklist__edit .input { flex: 1 1 220px; }
.icon-btn--sm { width: 28px; height: 28px; }
.icon-btn--sm svg { width: 14px; height: 14px; }
.quick-task { margin-bottom: var(--space-4); }
.subtasks .subtask { list-style: none; }

/* UI-06: calendar, time entries */
.entry__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-1); }
.demo-note { margin-top: var(--space-2); }
.cal-grid { table-layout: fixed; }
.cal-grid th { padding: var(--space-2); font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-caps); color: var(--color-text-muted); background: var(--color-surface-2); border-bottom: 1px solid var(--color-border); }
.cal-grid th abbr { text-decoration: none; }
.cal-grid td { vertical-align: top; height: 112px; border: 1px solid var(--color-border); padding: 0; }
.cal-grid tr > td:first-child { border-left: 0; }
.cal-grid tr > td:last-child { border-right: 0; }
.cal-grid tbody tr:last-child td { border-bottom: 0; }
.cal-grid td.is-outside { background: var(--color-surface-2); }
.cal-grid td.is-outside .cal-day__num { color: var(--color-text-muted); }
.cal-grid td.is-today { box-shadow: inset 0 0 0 2px var(--color-accent); }
.cal-day { padding: var(--space-1) var(--space-2); display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-day__num { font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold); }
.cal-events { display: flex; flex-direction: column; gap: 4px; }
.cal-event { display: flex; flex-direction: column; padding: 2px 6px; border-radius: var(--radius-sm); text-decoration: none; border-left: 3px solid var(--badge-info-dot); background: var(--badge-info-bg); color: var(--badge-info-text); min-width: 0; }
.cal-event--project { border-left-color: var(--badge-violet-dot); background: var(--badge-violet-bg); color: var(--badge-violet-text); }
.cal-event.is-overdue { border-left-color: var(--badge-danger-dot); background: var(--badge-danger-bg); color: var(--badge-danger-text); }
.cal-event__title { font-size: var(--font-size-xs); font-weight: var(--font-weight-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-event__sub { font-size: var(--font-size-2xs); opacity: 0.9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal-agenda { display: none; }
.cal-agenda .list-item { align-items: flex-start; }
.cal-agenda .cal-event__title, .cal-agenda .cal-event__sub { white-space: normal; }

/* UI-08: long-text resilience (checked with ?text=long) */
h1, h2, h3, a, p, dd, .rem-item__link, .list-item__title, .cell-main, .cell-sub, .task-card__open, .task-card__title,
.task-card__meta, .entry__title, .message__body, .cal-event__title, .tag__text, .link-btn, .list-item__meta, .muted, .breadcrumb li, .state__text { overflow-wrap: anywhere; }
.crumbs-row .breadcrumb { min-width: 0; }
.badge, .mini-timer { flex-shrink: 0; }
.select { max-width: 100%; text-overflow: ellipsis; }
.filter-bar .select, .row .select, .quick-add .select { max-width: min(100%, 340px); }
.spread > *, .filter-bar > * { min-width: 0; max-width: 100%; }
.kanban-more { align-self: center; }
.day-picker { flex-wrap: wrap; gap: var(--space-1); }
.day-picker .btn.is-current { background: var(--color-text); color: var(--color-bg); border-color: var(--color-text); }

/* UI-07: module pages */
.module-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); margin-bottom: var(--space-4); }
.module-head__body { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.module-head__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: flex-start; }
.proto-tag { display: inline-flex; align-items: center; padding: 3px var(--space-3); border-radius: var(--radius-sm); background: var(--badge-warning-bg); color: var(--badge-warning-text); border: 2px dashed var(--badge-warning-dot); font-size: var(--font-size-xs); font-weight: var(--font-weight-bold); text-transform: uppercase; letter-spacing: 0.05em; }
.blocked-tag { display: inline-flex; padding: 2px var(--space-2); border-radius: var(--radius-sm); background: var(--badge-danger-bg); color: var(--badge-danger-text); font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold); font-family: var(--font-mono); }
.blocked-action { display: inline-flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.blocked-action .xs { max-width: 280px; }
.matrix th, .matrix td { text-align: center; white-space: nowrap; }
.matrix th:first-child, .matrix td:first-child { text-align: left; white-space: normal; min-width: 220px; position: sticky; left: 0; background: var(--color-surface); z-index: 1; }
.matrix thead th:first-child { background: var(--color-surface-2); }
.matrix .matrix__group td { background: var(--color-surface-2); font-size: var(--font-size-2xs); text-transform: uppercase; letter-spacing: var(--letter-spacing-caps); color: var(--color-text-muted); font-weight: var(--font-weight-semibold); text-align: left; }
.matrix .yes { color: var(--color-success-text); font-weight: var(--font-weight-bold); }
.matrix .no { color: var(--color-text-muted); }
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--color-text-muted); font-size: 12px; font-family: var(--font-sans); }
.chart .chart__value { fill: var(--color-text); font-weight: 600; }
.chart .chart__bar { fill: var(--chart-1); }
.chart .chart__bar--alt { fill: var(--chart-2); }
.chart .chart__grid { stroke: var(--color-border); stroke-dasharray: 2 3; }
.chart .chart__hit { fill: transparent; }
.chart .chart__hit:hover + .chart__bar, .chart g:hover .chart__bar { opacity: .85; }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-3); font-size: var(--font-size-sm); color: var(--color-text-muted); margin-bottom: var(--space-2); }
.legend__swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.chart-tip { position: absolute; pointer-events: none; background: var(--color-surface); border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm); padding: 4px 8px; font-size: var(--font-size-xs); box-shadow: var(--shadow-md, 0 2px 8px rgba(0,0,0,.15)); white-space: nowrap; z-index: 5; }
.chart-box { position: relative; }
.chart .chart__axis { stroke: var(--color-border-strong); }
.hbar { display: grid; grid-template-columns: 140px minmax(0, 1fr) 48px; gap: var(--space-2); align-items: center; font-size: var(--font-size-sm); }
.hbar__track { height: 10px; border-radius: var(--radius-pill); background: var(--color-bg-sunken); overflow: hidden; }
.hbar__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-table summary { cursor: pointer; color: var(--color-text-muted); margin-top: var(--space-2); }
.hbar__fill { display: block; height: 100%; background: var(--color-accent); border-radius: inherit; }
.chat { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.chat__channels .list-item[aria-current="page"] { background: var(--color-accent-soft); }
.chat__channels a.list-item { text-decoration: none; color: var(--color-text); }
.chat__channels .list-item__title, .chat__channels .list-item__meta { display: block; }
.chat__pane { display: flex; flex-direction: column; min-height: 420px; }
.chat__messages { flex: 1; padding: var(--space-2) var(--space-5); }
.message--mention { background: var(--badge-accent-bg); border-radius: var(--radius-md); padding-inline: var(--space-2); }
.unread { min-width: 20px; padding: 0 6px; border-radius: var(--radius-pill); background: var(--color-accent); color: var(--color-accent-contrast); font-size: var(--font-size-2xs); font-weight: var(--font-weight-bold); text-align: center; }
.notif-panel { right: 0; top: calc(100% + 6px); width: 340px; max-width: calc(100vw - 24px); }
.notif-wrap { position: relative; }
@media (max-width: 899.98px) {
  .chat { grid-template-columns: minmax(0, 1fr); }
  .hbar { grid-template-columns: 96px minmax(0, 1fr) 40px; }
}

/* Touch targets on coarse pointers */
@media (pointer: coarse) {
  .btn--sm, .chip, .segmented button, .select--sm, .input--sm { min-height: 40px; }
}

@media (max-width: 1200px) {
  .account__text { display: none; }
  .search-trigger { min-width: 0; }
  .search-trigger__kbd { display: none; }
}
@media (max-width: 1080px) {
  .search-trigger__text { display: none; }
  .search-trigger { width: var(--control-height); padding: 0; justify-content: center; }
  .hide-md { display: none; }
}
@media (max-width: 899.98px) {
  .sidebar__collapse { display: none; }
  .cal-month { display: none; }
  .cal-agenda { display: block; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .modal { top: auto; bottom: 0; left: 0; transform: none; width: 100vw; max-height: 92vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
  .modal__foot { border-radius: 0; }
}
@media (max-width: 560px) {
  .topbar .proto-badge { display: none; }
  .proto-badge--inline { display: inline-flex; }
  .account__btn > svg { display: none; }
  .hide-sm { display: none !important; }
  .show-sm { display: flex !important; }
  .mini-timer { padding: 0 2px 0 var(--space-2); }
  .topbar__actions { gap: var(--space-1); }
}

/* Server build: real-data companies hide the prototype badge */
.proto-badge[hidden] { display: none !important; }
