:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-muted: #f8fafc;
  --border: #e2e7ef;
  --border-strong: #ccd5e2;
  --text: #34425a;
  --text-strong: #1c2940;
  --muted: #68758a;
  --blue: #355bd8;
  --blue-dark: #294ab8;
  --green: #15805d;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--text-strong); line-height: 1.25; }
h1 { font-size: 23px; letter-spacing: -.035em; margin: 0 0 4px; font-weight: 700; }
h2 { font-size: 14px; margin: 0; font-weight: 600; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
button, input, select, textarea { font: inherit; color: inherit; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.overdue { color: var(--red); font-weight: 600; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.empty { color: var(--muted); text-align: center; padding: 20px 12px; margin: 0; }
.container { width: 100%; max-width: 1480px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .container { padding: 0 24px; } }

/* Header */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  position: relative;
  z-index: 20;
}
.topbar-inner { display: flex; align-items: center; gap: 24px; min-height: 58px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text-strong); font-size: 14px; letter-spacing: -.025em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.nav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
.nav a {
  display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 500; padding: 7px 9px;
  border-radius: 6px; white-space: nowrap;
}
.nav a:hover { color: var(--text-strong); background: var(--surface-muted); text-decoration: none; }
.nav a.active { color: var(--blue); background: #edf2ff; }
.nav-separator { width: 1px; height: 18px; background: var(--border); margin: 0 6px; }
.userbox { display: flex; align-items: center; gap: 10px; margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.user-name { display: inline-flex; align-items: center; gap: 7px; color: var(--text); font-weight: 600; max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.userbox form { margin: 0; }
.link-button { display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; color: var(--muted); cursor: pointer; padding: 0; }
.link-button:hover { color: var(--red); }
.nav-toggle {
  display: none; margin-left: auto; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 6px 9px; gap: 6px; align-items: center; cursor: pointer;
}
.mobile-nav { display: none; border-top: 1px solid var(--border); padding: 8px 16px 12px; }
.mobile-nav a, .mobile-nav button {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 9px 8px; border: 0; background: none;
  color: var(--text); border-radius: 8px; font-weight: 500;
}
.mobile-nav a:hover, .mobile-nav button:hover { background: var(--surface-muted); text-decoration: none; }
.mobile-nav form { margin: 0; }
@media (max-width: 1199px) {
  .nav { display: none; }
  .nav-toggle { display: inline-flex; }
  .userbox { display: none; }
  .mobile-nav:not([hidden]) { display: block; }
}

/* Page */
.page { padding-top: 22px; padding-bottom: 36px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-actions form { margin: 0; }
.eyebrow { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.subtitle { font-size: 12px; margin: 3px 0 0; color: var(--muted); }
.messages { margin-bottom: 16px; }
.message { border-radius: 10px; padding: 10px 14px; margin-bottom: 8px; border: 1px solid var(--border); background: var(--surface); }
.message.success { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.message.warning { border-color: #fde68a; background: #fffbeb; color: #92400e; }
.message.error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }

/* Cards and metrics */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 14px; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--border); background: var(--surface); }
.card-body { padding: 14px; }
.card-body > :first-child { margin-top: 0; }
.card-body > :last-child { margin-bottom: 0; }
.card-head h2 { display: inline-flex; align-items: center; gap: 8px; }
.card-head h2 .icon { color: var(--muted); }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.metric { display: flex; align-items: center; gap: 10px; min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 11px 14px; }
.metric.warning { border-color: #eedcc1; }
.metric-label { display: block; color: var(--text); font-weight: 600; font-size: 12px; }
.metric-value { margin-left: auto; font-size: 25px; font-weight: 650; letter-spacing: -.04em; line-height: 1; color: var(--text-strong); font-variant-numeric: tabular-nums; }
.metric-note { color: var(--muted); font-size: 11px; }


/* Buttons and badges */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 6px; padding: 6px 11px; min-height: 34px;
  font-size: 12px; font-weight: 500; cursor: pointer; background: var(--surface);
  color: var(--text); white-space: nowrap;
}
.button:hover { text-decoration: none; }
.button.primary { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 1px 2px #1c29401a, inset 0 1px 0 #ffffff20; }
.button.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.button.secondary { border-color: var(--border); color: var(--text); box-shadow: 0 1px 2px #1c294005; }
.button.secondary:hover { background: var(--surface-muted); }
.button.danger { color: var(--red); border-color: #fecaca; }
.button.danger:hover { background: #fef2f2; }
.button.small { min-height: 28px; padding: 4px 9px; font-size: 11px; }
.wide-button { width: 100%; margin-top: 10px; }
.badge { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 8px; font-size: 11px; font-weight: 600; }
.badge.soft { background: #eff6ff; color: #1e40af; }
.badge.success { background: #f0fdf4; color: #166534; }
.badge.warning { background: #fffbeb; color: #92400e; }
.badge.neutral { background: var(--surface-muted); color: var(--muted); border: 1px solid var(--border); }
.status-pill {
  display: inline-flex; align-items: center; gap: 5px; border: 1px solid currentColor;
  background: color-mix(in srgb, currentColor 7%, white);
  border-radius: 5px; padding: 2px 7px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }

/* Tables */
.table-scroll { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  background: var(--surface-muted); color: var(--muted); text-align: left;
  font-size: 11px; letter-spacing: .01em;
  font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 8px 10px; border-bottom: 1px solid #edf1f6; vertical-align: top; }
.table tbody tr:hover { background: #f6f8ff; }
.table tbody tr:last-child td { border-bottom: 0; }
.table.compact th, .table.compact td { padding: 7px 10px; }
.task-table { min-width: 1240px; table-layout: fixed; font-size: 12px; line-height: 1.4; font-variant-numeric: tabular-nums; }
.task-table th, .task-table td { padding: 7px 8px; }
.task-col-client, .task-col-employee { width: 12%; }
.task-col-text { width: 20%; }
.task-col-date, .task-col-section, .task-col-amount { width: 8%; }
.task-col-status, .task-col-result { width: 9%; }
.task-col-contacts { width: 14%; }
.task-table .task-cell { min-width: 0; max-width: none; }
.task-table .small { font-size: 11px; }
.task-table .status-pill { max-width: 100%; }
.task-table .status-pill-label, .task-table .num { overflow: hidden; text-overflow: ellipsis; }
.task-table .table-preview { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.task-cell { min-width: 220px; max-width: 320px; }
.count { background: var(--surface-muted); border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--muted); }

/* Filters and forms */
.filters-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}
.filter-field { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--muted); flex: 1 1 120px; min-width: 110px; }
.filter-search { flex: 1.8 1 190px; min-width: 180px; }
.filter-client { flex: 1.5 1 180px; min-width: 160px; }
.filter-field input, .filter-field select { min-width: 0; }
.client-combobox { display: block; position: relative; min-width: 0; }
.client-combobox > input[type="text"] { padding-right: 60px; text-overflow: ellipsis; }
.client-combobox-clear, .client-combobox-toggle { position: absolute; top: 50%; transform: translateY(-50%); display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 28px; padding: 0; border: 0; border-radius: 4px; background: transparent; color: var(--muted); cursor: pointer; }
.client-combobox-clear { right: 28px; font-size: 20px; }
.client-combobox-toggle { right: 3px; }
.client-combobox-toggle::after { content: ""; width: 6px; height: 6px; margin-top: -3px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
.client-combobox-clear:hover, .client-combobox-toggle:hover { background: var(--surface-muted); color: var(--text-strong); }
.client-combobox-list { margin: 0; inset: auto; position: fixed; z-index: 60; overflow-y: auto; overscroll-behavior: contain; padding: 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); box-shadow: 0 8px 24px rgb(28 41 64 / 12%); }
.client-combobox-option { padding: 8px 10px; border-radius: 5px; font-size: 13px; line-height: 1.45; overflow-wrap: anywhere; cursor: pointer; }
.client-combobox-option[aria-selected="true"] { color: var(--blue); font-weight: 600; }
.client-combobox-option:hover, .client-combobox-option.active { background: #edf2ff; color: var(--blue); }
.client-combobox-empty { padding: 12px 10px; color: var(--muted); font-size: 12px; }
.filter-actions { display: flex; gap: 6px; flex: 0 0 auto; margin-left: auto; }
.filter-card .card-body { padding: 12px; }
.filter-card > form { padding: 12px; }
.inline-filter { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.inline-filter .filter-field { min-width: 280px; flex: 1; }
@media (max-width: 640px) {
  .client-combobox > input[type="text"] { min-height: 42px; padding-right: 72px; font-size: 16px; }
  .client-combobox-clear, .client-combobox-toggle { width: 32px; height: 36px; }
  .client-combobox-clear { right: 35px; }
  .client-combobox-option { min-height: 44px; padding: 10px; font-size: 16px; }
  .filter-field { flex: 1 1 calc(50% - 10px); min-width: 0; }
  .filter-search { flex-basis: 100%; }
  .filter-client { flex-basis: 100%; min-width: 0; }
  .filter-actions { margin-left: 0; }
}
input[type="text"], input[type="search"], input[type="password"], input[type="date"],
input[type="number"], select, textarea {
  width: 100%; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 6px 9px; min-height: 34px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(53 91 216 / 12%); }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form-wide { grid-column: 1 / -1; }
.form-row { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.form-row > label, .form-field-heading > label { font-weight: 600; font-size: 12px; color: #374151; }
.form-check { flex-direction: row; align-items: center; gap: 8px; padding-top: 22px; }
.form-check input { width: auto; }
.form-check > label { font-weight: 500; font-size: 14px; }
.help { color: var(--muted); font-size: 11px; }
.help ul { margin: 4px 0; padding-left: 18px; }
.required { color: var(--red); }
.field-error { color: var(--red); font-size: 12px; }
.form-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; }
.form-error ul { margin: 0; padding-left: 18px; }
.form-actions { display: flex; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* Details */
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } }
.details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 18px; margin: 0; }
.details .wide { grid-column: 1 / -1; }
.details div { min-width: 0; }
.details dt { color: var(--muted); font-size: 11px; letter-spacing: .01em; margin-bottom: 2px; }
.details dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 520px) { .details { grid-template-columns: 1fr; } }

/* History */
.history-list { display: flex; flex-direction: column; gap: 12px; }
.history-item { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.history-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 9px 12px; background: var(--surface-muted); font-size: 12px; }
.history-item .table { font-size: 12px; }
.history-item .table td { padding: 6px 10px; }
.inline-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.inline-actions form { margin: 0; }

/* Pagination */
.pagination { display: flex; align-items: center; gap: 10px; justify-content: center; margin: 4px 0 22px; }
.page-info { color: var(--muted); font-size: 12px; }

/* Calendar */
.calendar-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.calendar-toolbar > .calendar-view-switch { justify-self: start; }
.calendar-toolbar > .link { justify-self: end; }
.calendar-period-nav { display: flex; align-items: center; justify-content: center; gap: 10px; }
.calendar-toolbar h2 { min-width: 160px; text-align: center; }
.calendar-view-switch { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-muted); }
.calendar-grid-week .calendar-cell { min-height: 360px; }
.calendar-grid-week .calendar-task { font-size: 12px; padding: 9px 6px; }
.calendar-no-tasks { color: var(--muted); font-size: 12px; margin-top: 12px; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(120px, 1fr)); min-width: 840px; }
.calendar-weekday { background: var(--surface-muted); color: var(--muted); font-size: 11px; letter-spacing: .01em; padding: 7px 10px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: left; }
.calendar-cell { min-height: 112px; padding: 6px; border-right: 1px solid #f1f5f9; border-bottom: 1px solid #f1f5f9; background: var(--surface); }
.calendar-cell.outside { background: #fafafa; color: #9ca3af; }
.calendar-cell.today { background: #f5f7ff; box-shadow: inset 0 0 0 1px #ccd7fa; }
.calendar-cell.today > .calendar-date > span:first-child { display: inline-flex; align-items: center; justify-content: center; min-width: 23px; height: 23px; padding: 0 4px; background: var(--blue); color: white; border-radius: 5px; font-weight: 600; }
.calendar-date { display: flex; align-items: center; justify-content: space-between; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
button.calendar-date { width: 100%; background: none; border: 0; padding: 2px 0; cursor: pointer; text-align: inherit; font: inherit; }
button.calendar-date:hover { color: var(--blue); }
button.calendar-date .count { transition: background .15s, border-color .15s; }
button.calendar-date:hover .count { background: #eff6ff; border-color: #bfdbfe; color: var(--blue); }
.calendar-task { display: flex; align-items: flex-start; gap: 6px; font-size: 11px; line-height: 1.35; color: var(--text); padding: 7px 6px; border: 1px solid var(--border); border-radius: 5px; margin-bottom: 5px; background: var(--surface); }
.calendar-task .status-dot { margin-top: 4px; flex-shrink: 0; }
.calendar-task-content { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.calendar-task-company { font-weight: 600; color: var(--text-strong); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-task-number { color: var(--muted); }
.calendar-task-number { font-weight: 400; font-size: 10px; }
.calendar-task-text { margin-top: 1px; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 1; overflow: hidden; }
.calendar-task-text-full { display: block; -webkit-line-clamp: unset; overflow: visible; white-space: normal; }
.calendar-task-compact { display: flex; align-items: center; gap: 5px; font-size: 11px; line-height: 1.35; color: var(--muted); padding: 3px 6px; border-radius: 5px; margin-bottom: 3px; }
.calendar-task-compact .status-dot { width: 6px; height: 6px; flex-shrink: 0; }
.calendar-task-compact-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.calendar-task-compact:hover { background: var(--surface-muted); color: var(--text); text-decoration: none; }
.calendar-extra-compact { margin-top: 2px; }
.task-tabs { display: flex; align-items: center; width: max-content; max-width: 100%; gap: 4px; margin: 0 auto 14px; padding: 4px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.task-tabs .button { min-height: 38px; padding: 8px 16px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--text); font-size: 13px; font-weight: 600; box-shadow: none; }
.task-tabs .button.primary { border-color: var(--blue); color: white; background: var(--blue); box-shadow: 0 1px 2px rgb(28 41 64 / 10%); }
.task-tabs .button:hover { color: var(--blue); background: #edf2ff; }
.task-tabs .button.primary:hover { border-color: var(--blue-dark); color: white; background: var(--blue-dark); }
.task-list-controls { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.task-list-controls > .source-toggles, .task-list-controls > .task-tabs { margin: 0; }
.task-contact + .task-contact { margin-top: 10px; }
.calendar-task:hover { background: var(--surface-muted); text-decoration: none; }
.plain-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.plain-list li { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; border-bottom: 1px solid #f1f5f9; padding-bottom: 8px; }

/* Day modal */
.day-modal {
  width: min(520px, calc(100vw - 32px));
  max-width: none;
  max-height: 82vh;
  max-height: 82dvh;
  margin: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.day-modal::backdrop { background: rgb(28 41 64 / 38%); backdrop-filter: blur(3px); }
.day-modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 2px; }
.day-modal-header h2 { font-size: 17px; }
.day-modal-close { background: none; border: 0; cursor: pointer; color: var(--muted); font-size: 22px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.day-modal-close:hover { color: var(--text-strong); background: var(--surface-muted); }
.day-modal-subtitle { margin: 0 0 12px; color: var(--muted); font-size: 12px; }
.day-modal-body { display: flex; flex-direction: column; gap: 6px; max-height: calc(82vh - 130px); max-height: calc(82dvh - 130px); overflow-y: auto; padding-right: 2px; }
.day-modal-body .calendar-task { margin-bottom: 0; }
html.day-modal-open { overflow: hidden; }

/* Task detail modal */
.task-detail-modal { width: min(720px, calc(100vw - 32px)); }
.task-detail-modal[open] { display: flex; flex-direction: column; overflow: hidden; }
.task-modal-content { display: flex; flex-direction: column; min-height: 0; }
.task-modal-content > form { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.task-modal-header, .task-modal-actions { flex-shrink: 0; }
.task-modal-content .task-modal-body { min-height: 0; padding-bottom: 14px; }
.task-modal-content .form-actions { flex-shrink: 0; margin-top: 0; padding-top: 14px; border-top: 1px solid var(--border); }
.task-modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.task-modal-title { font-size: 17px; margin: 0 0 2px; }
.task-modal-client { margin: 0; color: var(--muted); font-size: 13px; }
.task-modal-body { max-height: 56vh; max-height: 56dvh; overflow-y: auto; padding-right: 2px; }
.task-modal-actions { display: flex; gap: 8px; margin-top: 14px; justify-content: flex-end; }
html.task-modal-open { overflow: hidden; }

/* Task labels */
.task-labels { display: flex; flex-wrap: wrap; gap: 6px; }
.task-label {
  display: inline-flex; align-items: flex-start; gap: 6px;
  border: 1px solid var(--border); border-radius: 6px; padding: 4px 7px;
  font-size: 12px; line-height: 1.35; color: var(--text); background: var(--surface);
  max-width: 100%;
}
.task-label .status-dot { width: 7px; height: 7px; margin-top: 4px; flex-shrink: 0; }
.task-label-content { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.task-label-text { min-width: 0; overflow-wrap: anywhere; }
.task-label-date { color: var(--muted); font-size: 11px; white-space: nowrap; }
.task-label:hover { background: var(--surface-muted); text-decoration: none; }

/* Client task views */
.client-tasks-heading { display: flex; align-items: center; gap: 8px; min-width: 0; }
.client-task-toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.client-task-source-filters { flex-basis: 100%; min-width: 0; padding-top: 4px; }
.client-task-source-filters .source-toggles { margin: 0; }
.client-contact-filter { display: flex; align-items: flex-end; gap: 8px; margin: 0; flex: 0 1 320px; min-width: 0; max-width: 100%; }
.client-contact-filter .filter-field { min-width: 220px; }
.client-task-view { padding: 12px; }
.client-calendar-toolbar { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 12px; }
.client-calendar-toolbar h3 { margin: 0; font-size: 15px; min-width: 140px; text-align: center; }
.client-undated { margin-top: 16px; }
.client-undated h3 { margin: 0 0 8px; }
.client-calendar-grid { min-width: 0; width: 100%; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.client-calendar-grid .calendar-cell { min-height: 96px; }
.client-table { width: 100%; }
.client-table .task-cell { min-width: 0; max-width: none; }

/* Kanban */
.kanban { position: relative; display: flex; gap: 10px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; }
.kanban-column { background: #edf1f6; border: 1px solid var(--border); border-radius: 9px; min-width: 250px; width: 280px; flex: 1 1 280px; padding: 8px; }
.kanban-column.drop-target { outline: 2px dashed var(--blue); outline-offset: -2px; }
.kanban-head { display: flex; align-items: center; gap: 7px; padding: 2px 4px 10px; }
.kanban-head h2 { font-size: 13px; flex: 1; }
.kanban-cards { display: flex; flex-direction: column; gap: 8px; min-height: 60px; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: 7px; padding: 10px; cursor: grab; box-shadow: 0 1px 2px rgb(28 41 64 / 3%); }
.kanban-card:hover { border-color: #bdcbe0; }
.kanban-card.dragging { opacity: .5; }
.kanban-title { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; color: var(--text-strong); font-weight: 600; line-height: 1.45; margin-bottom: 7px; overflow-wrap: anywhere; }
.kanban-meta { display: flex; gap: 8px; justify-content: space-between; color: var(--muted); font-size: 11px; margin-bottom: 3px; }
.kanban-status-form { display: flex; gap: 6px; margin-top: 9px; padding-top: 8px; border-top: 1px solid #edf1f6; }
.kanban-status-form select { min-width: 0; min-height: 28px; font-size: 11px; padding: 4px 6px; }
.kanban-status-form .button { padding: 5px 8px; font-size: 11px; }

/* Auth and notices */
.auth-card { max-width: 420px; margin: 24px auto; }
.auth-card h1 { margin-bottom: 4px; }
.notice { border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); padding: 16px 18px; margin-bottom: 20px; }
.notice.important { border-color: #fde68a; background: #fffbeb; }
.notice.important strong { display: block; margin-bottom: 8px; color: #92400e; }
.token-value { display: block; margin-top: 6px; padding: 9px 11px; background: #111827; color: #f9fafb; border-radius: 8px; overflow-wrap: anywhere; }
.copy-group { margin: 6px 0 14px; }
.copy-field { display: flex; align-items: stretch; background: #111827; border-radius: 8px; }
.copy-field .token-value { flex: 1; min-width: 0; margin: 0; background: transparent; }
.copy-button { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 40px; min-height: 40px; padding: 0; border: 0; border-radius: 0 8px 8px 0; color: #cbd5e1; background: transparent; cursor: pointer; }
.copy-button:hover { background: #ffffff14; color: #fff; }
.copy-button:disabled { cursor: wait; }
.copy-button .icon { width: 18px; height: 18px; }
.copy-icon, .copy-done { display: flex; }
.copy-done, .copy-button.is-copied .copy-icon { display: none; }
.copy-button.is-copied .copy-done { display: flex; color: #86efac; }
.copy-status { display: block; margin-top: 6px; color: var(--green, #166534); }
.copy-status:empty { display: none; }
.copy-status.error { color: var(--red); }
.instructions { padding-left: 20px; color: var(--text); }
.instructions li { margin-bottom: 5px; }
.extension-tutorial { margin: 0 0 20px; }
.extension-tutorial-preview {
  display: block;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.extension-tutorial-preview img {
  display: block;
  width: 100%;
  height: auto;
}
.extension-tutorial-play {
  position: absolute;
  inset: auto 0 0;
  padding: 16px;
  color: #fff;
  background: rgba(17, 24, 39, .9);
  font-weight: 600;
  text-align: center;
}
.extension-tutorial-preview:hover .extension-tutorial-play { background: var(--blue-dark); }
.extension-tutorial-preview:focus-visible { outline: 3px solid var(--blue); outline-offset: 3px; }
.extension-tutorial figcaption { margin-top: 8px; }
.extension-tutorial-dialog {
  width: min(1280px, calc(100vw - 32px));
  max-width: none;
  max-height: 94vh;
  max-height: 94dvh;
  margin: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.extension-tutorial-dialog::backdrop { background: rgba(17, 24, 39, .8); }
.extension-tutorial-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.extension-tutorial-dialog video {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(94vh - 110px);
  max-height: calc(94dvh - 110px);
  background: #111827;
}
html.video-modal-open { overflow: hidden; }
.error-list { margin: 4px 0 10px; padding-left: 18px; color: #991b1b; font-size: 12px; }

/* Keep client calendars and tables flush with their card edges. */
.client-task-view:has(> .client-calendar-toolbar),
.client-task-view:has(> .table-scroll) { padding: 0; }
.client-calendar-toolbar { margin-bottom: 0; padding: 10px 14px; }
.client-undated { padding: 0 14px 14px; }


/* Shared icon rhythm and interaction states. */
.icon { display: inline-block; width: 16px; height: 16px; flex: 0 0 auto; vertical-align: middle; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 29px; height: 29px; border-radius: 8px; background: var(--blue); color: white; }
.brand-mark .icon { width: 20px; height: 20px; }
.user-avatar { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; flex-shrink: 0; border: 1px solid #dbe3f4; border-radius: 50%; color: var(--blue); background: #edf2ff; font-size: 11px; }
.metric-copy { min-width: 0; }
.metric-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; flex-shrink: 0; border-radius: 8px; background: #eef2ff; color: var(--blue); }
.metric.warning .metric-icon { background: #fff5e6; color: #a76b16; }
.metric.warning .metric-value { color: #9c651b; }
.metric.complete .metric-icon { background: #eaf6ef; color: var(--green); }
.input-with-icon { position: relative; display: flex; align-items: center; }
.input-with-icon > .icon { position: absolute; left: 10px; pointer-events: none; }
.input-with-icon > input { padding-left: 33px; }
.status-pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge.success::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; margin-right: 5px; }
.calendar-view-switch .button { border-color: transparent; background: transparent; color: var(--muted); box-shadow: none; }
.calendar-view-switch .button.primary { border-color: var(--border); color: var(--blue); background: white; box-shadow: 0 1px 3px rgb(28 41 64 / 5%); }
.calendar-view-switch .button:hover { color: var(--blue); background: var(--surface); }
.kanban-date { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.kanban-date .icon { width: 13px; height: 13px; }
.kanban-meta > :last-child { min-width: 0; overflow-wrap: anywhere; }
.table .task-cell > a { color: var(--text-strong); font-weight: 500; }
.task-table .task-cell > a { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
.table .task-cell > a:hover { color: var(--blue); }
.table th.num { text-align: right; }
.table td.nowrap > .small { max-width: 190px; white-space: normal; }
.details > div { border-bottom: 1px solid #edf1f6; padding-bottom: 9px; }
.details .task-contact { border: 0; padding: 0; }
.day-modal { box-shadow: 0 20px 70px rgb(28 41 64 / 20%); }
.task-modal-header { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.task-modal-actions { padding-top: 12px; border-top: 1px solid var(--border); }
.day-modal-close { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex-shrink: 0; background: var(--surface-muted); }
.auth-card .form-row + .form-row { margin-top: 12px; }
:where(a, button, input[type="checkbox"]):focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
input[type="checkbox"] { accent-color: var(--blue); }
@media (prefers-reduced-motion: no-preference) {
  .button, .nav a, .kanban-card, .task-label { transition: background-color .15s, border-color .15s, color .15s; }
}
@media (max-width: 1100px) {
  .calendar-toolbar { grid-template-columns: minmax(0, 1fr) auto; }
  .calendar-period-nav { grid-column: 1 / -1; grid-row: 2; }
  .calendar-toolbar > .link { grid-column: 2; grid-row: 1; }
}
@media (max-width: 900px) {
  .metric { padding: 10px; gap: 8px; }
  .metric-note { display: none; }
  .metric-value { font-size: 22px; }
}
@media (max-width: 520px) {
  .container { padding-left: 12px; padding-right: 12px; }
  .page { padding-top: 16px; }
  .page-head { align-items: flex-start; gap: 10px; margin-bottom: 14px; }
  .page-head h1 { font-size: 21px; overflow-wrap: anywhere; }
  .page-head > div:first-child { min-width: 0; }
  .page-actions { gap: 6px; }
  .task-tabs { gap: 2px; }
  .task-tabs .button { min-width: 0; padding: 8px 9px; font-size: 12px; }
  .metrics { gap: 6px; margin-bottom: 12px; }
  .metric { position: relative; flex-wrap: wrap; padding: 9px; gap: 7px; }
  .metric-icon { width: 24px; height: 24px; border-radius: 6px; }
  .metric-icon .icon { width: 14px; height: 14px; }
  .metric-copy { flex: 1; }
  .metric-label { font-size: 10px; }
  .metric-value { width: 100%; margin: 0; font-size: 22px; }
  .card-head { flex-wrap: wrap; gap: 5px; }
  .calendar-toolbar { gap: 8px; }
  .calendar-period-nav { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; width: 100%; }
  .calendar-toolbar h2 { min-width: 0; }
  .calendar-period-label { display: none; }
  .client-calendar-grid { min-width: 700px; }
  .inline-filter .filter-field { min-width: 0; flex-basis: 100%; }
  .client-contact-filter, .client-contact-filter .filter-field { width: 100%; min-width: 0; }
  .plain-list li { flex-wrap: wrap; gap: 3px; }
  .button { min-height: 36px; }
}
@media (max-width: 380px) {
  .metric-icon { display: none; }
}

/* Select dialogs: long names wrap, while the field stays compact. */
.select-picker { width: min(440px, calc(100vw - 24px)); max-width: none; max-height: 80vh; max-height: 80dvh; margin: auto; padding: 0; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); box-shadow: 0 20px 70px rgb(28 41 64 / 20%); }
.select-picker[open] { display: flex; flex-direction: column; }
.select-picker::backdrop { background: rgb(28 41 64 / 38%); backdrop-filter: blur(3px); }
.select-picker-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.select-picker-header h2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; font-size: 16px; min-width: 0; overflow-wrap: anywhere; }
.select-picker-close { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex-shrink: 0; padding: 0; border: 0; border-radius: 7px; background: var(--surface-muted); color: var(--muted); font-size: 24px; cursor: pointer; }
.select-picker-options { overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.select-picker-option { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; min-height: 50px; padding: 13px 16px; border: 0; border-bottom: 1px solid #edf1f6; background: var(--surface); text-align: left; font-size: 16px; line-height: 1.45; cursor: pointer; }
.select-picker-option > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.select-picker-option:last-child { border-bottom: 0; }
.select-picker-option[aria-checked="true"] { background: #edf2ff; color: var(--blue); font-weight: 600; }
.select-picker-option:disabled { color: var(--muted); opacity: .5; cursor: default; }
.select-picker-option:focus-visible { outline: 2px solid var(--blue); outline-offset: -3px; }
.select-picker-mark { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex-shrink: 0; color: transparent; font-size: 15px; }
.select-picker-option[aria-checked="true"] .select-picker-mark { color: var(--blue); }
.select-picker-option[role="checkbox"] .select-picker-mark { border: 1px solid var(--border-strong); border-radius: 4px; }
.select-picker-option[role="checkbox"][aria-checked="true"] .select-picker-mark { border-color: var(--blue); background: var(--blue); color: white; }
.select-picker-group { padding: 9px 16px; background: var(--surface-muted); color: var(--muted); font-size: 12px; font-weight: 600; }
.select-picker-footer { padding: 12px 16px; border-top: 1px solid var(--border); flex-shrink: 0; }
.select-picker-footer .button { width: 100%; min-height: 42px; font-size: 14px; }
.select-picker-error { padding: 10px 16px; margin: 0; color: var(--red); background: #fef2f2; font-size: 13px; }
html.select-picker-open { overflow: hidden; }
.select-trigger { display: none; align-items: center; justify-content: space-between; gap: 10px; width: 100%; min-width: 0; max-width: 100%; min-height: 34px; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 7px; background: var(--surface); color: var(--text); text-align: left; font-size: 13px; line-height: 1.4; cursor: pointer; }
.select-trigger-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.select-trigger::after { content: ""; width: 7px; height: 7px; flex-shrink: 0; margin: -4px 2px 0 0; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); }
.select-trigger:disabled { background: var(--surface-muted); color: var(--muted); cursor: default; }
.select-trigger[aria-expanded="true"] { border-color: var(--blue); box-shadow: 0 0 0 3px rgb(53 91 216 / 12%); }
select.has-mobile-picker[data-dialog-picker] { position: absolute; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; border: 0 !important; clip-path: inset(50%); overflow: hidden; opacity: 0; pointer-events: none; }
select[data-dialog-picker] + .select-trigger { display: flex; }
@media (max-width: 640px) {
  select { min-width: 0; max-width: 100%; min-height: 42px; font-size: 16px; }
  select.has-mobile-picker { position: absolute; width: 1px !important; height: 1px !important; min-height: 0 !important; padding: 0 !important; border: 0 !important; clip-path: inset(50%); overflow: hidden; opacity: 0; pointer-events: none; }
  .select-trigger { display: flex; min-height: 42px; font-size: 16px; }
  .client-contact-filter { flex-basis: 100%; }
}

/* Source switches and app-created tasks share a quiet violet accent. */
.source-toggles { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 18px; margin: 0 0 14px; }
.source-toggle { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 0; border-radius: 4px; color: var(--text); font-size: 12px; white-space: nowrap; }
.source-toggle:hover { text-decoration: none; }
.source-switch-track { position: relative; flex: 0 0 auto; width: 32px; height: 18px; border: 1px solid var(--border-strong); border-radius: 999px; background: var(--border-strong); }
.source-switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(28 41 64 / 18%); }
.source-toggle[aria-checked="true"] .source-switch-track { background: var(--blue); border-color: var(--blue); }
.source-toggle[aria-checked="true"] .source-switch-track::after { transform: translateX(14px); }
.source-toggle-local[aria-checked="true"] .source-switch-track { background: #8a63b6; border-color: #8a63b6; }
.source-toggle[aria-checked="false"] { color: var(--muted); }
@media (prefers-reduced-motion: no-preference) {
  .source-switch-track { transition: background-color .15s, border-color .15s; }
  .source-switch-track::after { transition: transform .15s; }
}
.task-origin { display: inline-block; width: fit-content; font-size: 10px; line-height: 1.5; font-weight: 600; color: #6d42a2; background: #efe5fa; border-radius: 4px; padding: 1px 5px; white-space: nowrap; }
.task-local, .table tr.task-local td { background: #faf6ff; }
.kanban-card.task-local, .calendar-task.task-local, .calendar-task-compact.task-local, .task-label.task-local { box-shadow: inset 3px 0 #b794d8; }
.calendar-task-compact.task-local { flex-wrap: wrap; }
.source-toggle:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
@media (max-width: 639px) {
  .source-toggles > .muted { width: 100%; }
  .source-toggle { min-height: 42px; }
}

.form-field-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 26px; }
.field-add { display: inline-flex; align-items: center; gap: 3px; padding: 3px 5px; border: 0; border-radius: 5px; background: transparent; color: var(--blue); cursor: pointer; font-size: 11px; white-space: nowrap; }
.field-add .icon { width: 13px; height: 13px; }
.field-add:hover { background: #edf2ff; }
.field-add:disabled { color: var(--muted); cursor: default; }
.field-add:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.contact-hint:empty { display: none; }
@media (max-width: 640px) { .field-add { min-height: 32px; padding: 5px; } }
