/* ============================================================
   BCR Helpdesk — design system
   Brand: Buffalo Computer Repair · primary blue #269fde
   ============================================================ */

:root {
  --primary: #269fde;
  --primary-dark: #1b80bf;
  --primary-darker: #156aa0;
  --primary-soft: #e8f4fc;
  --primary-soft-2: #d6ecf9;

  --ink: #1a2b3c;
  --ink-soft: #43556a;
  --muted: #748094;
  --border: #e3e8ef;
  --border-strong: #cbd5e1;
  --bg: #f4f7fb;
  --surface: #ffffff;

  --success: #00a86b;
  --success-soft: #e6f6ee;
  --warning: #e67e22;
  --warning-soft: #fff3e6;
  --danger: #e63946;
  --danger-soft: #fdecec;
  --violet: #7c5cff;
  --violet-soft: #f1edff;

  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(16, 42, 67, .06);
  --shadow: 0 4px 16px rgba(16, 42, 67, .08);
  --shadow-lg: 0 12px 32px rgba(16, 42, 67, .16);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", "Cascadia Code", Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-width: 0;
  overflow-x: clip;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: var(--mono); }

/* ---------- Layout ---------- */
.shell { min-height: 100vh; min-width: 0; width: 100%; }

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 600px at 20% -10%, var(--primary-soft) 0%, transparent 55%),
              radial-gradient(1000px 500px at 110% 110%, #e6f0fb 0%, transparent 50%),
              var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 32px 30px;
}

.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-logo img { height: 40px; width: auto; }
.auth-logo .wordmark { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.auth-logo .wordmark small { display: block; color: var(--muted); font-weight: 500; font-size: .8rem; }

/* App shell (admin/portal) */
.appbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  height: 60px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.appbar .brand { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.appbar .brand img { height: 30px; }
.appbar .spacer { flex: 1; }
.appbar .user-chip { display: flex; align-items: center; gap: 10px; }
.mobile-menu-btn { display: none; border: 0; padding: 7px 9px; border-radius: 8px; color: var(--ink); background: transparent; font-size: 1.25rem; cursor: pointer; }
.sidebar-backdrop { display: none; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-darker);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .85rem;
  flex: none;
}

.layout { display: flex; min-height: calc(100vh - 60px); min-width: 0; width: 100%; }

.sidebar {
  width: 220px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 10px;
  flex: none;
}
.sidebar .nav-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  font: inherit;
  font-weight: 550;
  text-align: left;
  margin-bottom: 2px;
}
.sidebar .nav-item:hover { background: var(--bg); }
.sidebar .nav-item:focus-visible { outline: 3px solid rgba(38, 159, 222, .35); outline-offset: 1px; }
.sidebar .nav-item.active { background: var(--primary-soft); color: var(--primary-darker); }
.sidebar .nav-item .badge-count {
  margin-left: auto; background: var(--primary); color: #fff;
  border-radius: 999px; font-size: .72rem; padding: 1px 7px; font-weight: 700;
}

.main { flex: 1; padding: 24px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600; font-size: .9rem; font-family: inherit;
  cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }

.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover:not(:disabled) { background: #0e1b28; }

.btn-ghost { background: transparent; color: var(--ink-soft); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--bg); }

.btn-soft { background: var(--primary-soft); color: var(--primary-darker); }
.btn-soft:hover:not(:disabled) { background: var(--primary-soft-2); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c92a37; }

.btn-danger-soft { background: var(--danger-soft); color: var(--danger); }
.btn-danger-soft:hover:not(:disabled) { background: #f9d6d9; }

.btn-sm { padding: 5px 11px; font-size: .82rem; }
.btn-block { width: 100%; justify-content: center; }

/* ---------- Forms ---------- */
.field { margin-bottom: 15px; }
.field label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: 5px; color: var(--ink-soft); }
.field .hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: .95rem;
  color: var(--ink);
  background: var(--surface);
  transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.textarea { min-height: 96px; resize: vertical; }
.input[readonly], .textarea[readonly] { background: var(--bg); color: var(--ink-soft); }

/* Read-only-by-default: value display + Edit toggle */
.ro-field { display: flex; align-items: center; gap: 10px; }
.ro-value { flex: 1; padding: 8px 12px; background: var(--bg); border-radius: var(--radius-sm); border: 1px dashed transparent; min-height: 38px; }
.ro-value.empty { color: var(--muted); font-style: italic; }

/* ---------- Cards / tables ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px;
  margin-bottom: 16px;
}
.dashboard-stat-card {
  appearance: none;
  width: 100%;
  min-height: 76px;
  margin: 0;
  padding: 12px 13px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.dashboard-stat-card:hover { transform: translateY(-2px); border-color: var(--primary-soft-2); box-shadow: 0 8px 20px rgba(20, 74, 110, .12); background: #fbfdff; }
.dashboard-stat-card:focus-visible { outline: 3px solid rgba(43, 143, 190, .3); outline-offset: 2px; border-color: var(--primary); }
.dashboard-stat-card:active { transform: translateY(0); }
.dashboard-stat-icon { font-size: 1.45rem; line-height: 1; }
.dashboard-stat-value { display: block; font-size: 1.25rem; line-height: 1.1; overflow-wrap: anywhere; }
.dashboard-stat-label { display: block; margin-top: 3px; color: var(--muted); font-size: .78rem; line-height: 1.2; }
.dashboard-stat-arrow { color: var(--primary); font-size: 1.35rem; opacity: .55; transition: transform .15s ease, opacity .15s ease; }
.dashboard-stat-card:hover .dashboard-stat-arrow, .dashboard-stat-card:focus-visible .dashboard-stat-arrow { opacity: 1; transform: translateX(2px); }
.customer-response-indicator { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid #f2b8b5; border-radius: 999px; background: #fff0ef; color: #b42318; font-size: .74rem; font-weight: 750; white-space: nowrap; }
.customer-response-indicator > span { color: #e03737; font-size: .7rem; }
.queue-preset { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 8px 6px 11px; border: 1px solid var(--primary-soft-2); border-radius: 999px; background: var(--primary-soft); color: var(--primary-darker); font-size: .8rem; font-weight: 700; }
.queue-preset button { appearance: none; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(43,143,190,.14); color: inherit; font: inherit; cursor: pointer; }
.queue-preset button:hover, .queue-preset button:focus-visible { background: rgba(43,143,190,.24); outline: 2px solid rgba(43,143,190,.24); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
.table tr.clickable { cursor: pointer; }
.table tbody tr:hover { background: #f8fafc; }
.portal-ticket-table { min-width: 960px; }
.portal-ticket-table th { white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 700; letter-spacing: .01em;
  text-transform: capitalize;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-blue { background: var(--primary-soft); color: var(--primary-darker); }
.badge-amber { background: var(--warning-soft); color: #b45f06; }
.badge-green { background: var(--success-soft); color: #007a4d; }
.badge-gray { background: #eef1f5; color: #5a6b7e; }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }

/* ---------- Thread / messages ---------- */
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 78%; padding: 11px 14px; border-radius: 12px; font-size: .94rem; }
.msg .meta { font-size: .74rem; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.msg-in { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 3px; }
.msg-out { align-self: flex-end; background: var(--primary-soft); border: 1px solid var(--primary-soft-2); border-top-right-radius: 3px; }
.msg-system { align-self: center; background: #f0f2f5; color: var(--muted); font-size: .8rem; border-radius: 999px; padding: 5px 14px; }
.conversation-card { width: 100%; max-width: 900px; margin-left: auto; margin-right: auto; padding: 16px 18px; }
.conversation-card .thread { gap: 10px; padding: 2px 8px 4px 0; max-height: min(58vh, 560px); overflow-y: auto; overflow-x: hidden; scrollbar-gutter: stable; overscroll-behavior: contain; scrollbar-color: var(--border-strong) transparent; }
.conversation-card .msg { max-width: 74%; padding: 9px 12px; line-height: 1.42; }
.conversation-card .msg .meta { margin-bottom: 3px; }
.conversation-card .divider { margin: 14px 0; }
.conversation-card .field { margin-bottom: 11px; }
.conversation-card .textarea { min-height: 78px; }
.conversation-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.conversation-heading h3 { margin: 0; }
.live-conversation-status { display: inline-flex; align-items: center; gap: 6px; color: #16794a; background: #eaf8f1; border: 1px solid #bee8d1; border-radius: 999px; padding: 4px 9px; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.live-conversation-status > span { width: 7px; height: 7px; border-radius: 50%; background: #1ea86a; box-shadow: 0 0 0 3px rgba(30,168,106,.13); }
.live-conversation-status.has-new { color: #8a3b08; background: #fff4e8; border-color: #ffd4ae; }
.live-conversation-status.has-new > span { background: #f28b28; box-shadow: 0 0 0 3px rgba(242,139,40,.14); }
.live-conversation-status.offline { color: var(--muted); background: #f4f5f7; border-color: var(--border); }
.live-conversation-status.offline > span { background: #9aa2ae; box-shadow: none; }
.message-channel { display: inline-flex; align-items: center; border-radius: 999px; padding: 2px 6px; font-size: .66rem; line-height: 1.2; font-weight: 800; background: #edf1f6; color: #4d5a6b; border: 1px solid #dce2e9; }
.message-channel.channel-sms { color: #0d6375; background: #e4f7fb; border-color: #b9e7f0; }
.message-channel.channel-email { color: #294fa3; background: #eaf0ff; border-color: #cdd9fb; }
.message-channel.channel-whatsapp { color: #087c45; background: #e5f8ee; border-color: #b9e8d0; }
.message-channel.channel-chat { color: #6b3ca1; background: #f2eafd; border-color: #decbf5; }
.message-channel.channel-phone { color: #8b4b08; background: #fff1dd; border-color: #f0d3aa; }
.message-company { color: var(--primary-darker); background: var(--primary-soft); border: 1px solid var(--primary-soft-2); border-radius: 999px; padding: 2px 7px; font-size: .66rem; font-weight: 700; }
.note {
  background: #fff9e6; border: 1px solid #f4e6b8; border-left: 4px solid #e6b800;
  padding: 10px 13px; border-radius: 8px; font-size: .9rem;
}
.note .meta { color: #8a6d00; font-size: .74rem; font-weight: 600; margin-bottom: 3px; }
.note.customer-visible-note { background: #eef8ff; border-color: #b9ddf5; color: var(--text); white-space: pre-wrap; overflow-wrap: anywhere; }
.note.customer-visible-note .meta { color: #216b96; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  padding: 9px 16px; cursor: pointer; font-weight: 600; font-size: .9rem;
  color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--primary-darker); border-bottom-color: var(--primary); }

/* ---------- Filter bar ---------- */
.filterbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filterbar .select { width: auto; min-width: 140px; }
.filterbar .spacer { flex: 1; }

/* ---------- Ticket/task intake guidance ---------- */
.ticket-kind-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid #cfe8f5;
  border-radius: 10px;
  background: #f1faff;
}
.ticket-kind-hint strong, .ticket-kind-hint span { display: block; }
.ticket-kind-hint strong { color: #145d84; font-size: .82rem; }
.ticket-kind-hint span { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.field-error { margin-top: 5px; color: var(--danger); font-size: .72rem; font-weight: 650; }
.input-invalid { border-color: var(--danger) !important; box-shadow: 0 0 0 3px rgba(203, 62, 62, .11) !important; }

/* ---------- Unified calendar ---------- */
.calendar-page-head { align-items: flex-end; }
.calendar-view-switch { display: inline-flex; padding: 3px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.calendar-nav-controls, .calendar-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.calendar-nav-controls strong { min-width: 145px; margin-left: 5px; font-size: 1rem; }
.calendar-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #fff;
  font-size: .76rem;
  font-weight: 650;
  cursor: pointer;
}
.calendar-filter.ticket { color: #17699b; }
.calendar-filter.project { color: #7654b5; }
.calendar-filter.task { color: #16825d; }
.calendar-jump { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .75rem; }
.calendar-jump .input { width: 145px; padding: 6px 8px; }
.calendar-loading { display: flex; justify-content: center; gap: 9px; padding: 70px 20px; color: var(--muted); }
.calendar-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  align-items: start;
  gap: 12px;
}
.calendar-month-panel, .calendar-agenda {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays { border-bottom: 1px solid var(--border); background: #f7f9fb; }
.calendar-weekdays div { padding: 9px 8px; color: var(--muted); font-size: .72rem; font-weight: 750; text-align: center; text-transform: uppercase; letter-spacing: .04em; }
.calendar-day {
  position: relative;
  min-height: 118px;
  padding: 7px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  transition: background .12s ease, box-shadow .12s ease;
}
.calendar-day:nth-child(7n) { border-right: none; }
.calendar-day:nth-last-child(-n+7) { border-bottom: none; }
.calendar-day:hover, .calendar-day:focus { z-index: 1; outline: none; background: #f8fbfd; box-shadow: inset 0 0 0 2px rgba(31, 157, 217, .18); }
.calendar-day.outside { background: #fafbfc; }
.calendar-day.outside .calendar-day-number { color: #aab5c0; }
.calendar-day.selected { background: #f5fbff; box-shadow: inset 0 0 0 2px rgba(31, 157, 217, .3); }
.calendar-day-number { display: flex; align-items: center; gap: 5px; margin-bottom: 5px; color: var(--ink); font-size: .78rem; font-weight: 750; }
.calendar-day-number span { padding: 2px 5px; border-radius: 999px; color: #fff; background: var(--primary); font-size: .58rem; text-transform: uppercase; }
.calendar-day-events { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.calendar-event {
  display: block;
  width: 100%;
  overflow: hidden;
  padding: 4px 6px;
  border: 0;
  border-left: 3px solid currentColor;
  border-radius: 5px;
  color: #17699b;
  background: #eaf7ff;
  font: inherit;
  font-size: .65rem;
  line-height: 1.2;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}
.calendar-event span { margin-right: 4px; font-weight: 750; }
.calendar-event.project { color: #7654b5; background: #f2edfb; }
.calendar-event.task { color: #16825d; background: #eaf8f2; }
.calendar-event.reminder { color: #bd6508; background: #fff3e3; }
.calendar-event.labor { color: #087b83; background: #e7f8f8; }
.calendar-event.worklog { color: #8b6a00; background: #fff8d9; }
.calendar-more { padding: 2px 4px; border: 0; color: var(--primary-darker); background: transparent; font-size: .65rem; font-weight: 750; text-align: left; cursor: pointer; }
.calendar-agenda { position: sticky; top: 12px; max-height: calc(100vh - 180px); overflow: auto; }
.calendar-agenda-head { position: sticky; top: 0; z-index: 2; padding: 14px 15px; border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, .96); backdrop-filter: blur(8px); }
.calendar-agenda-head strong, .calendar-agenda-head span { display: block; }
.calendar-agenda-head strong { font-size: .86rem; }
.calendar-agenda-head span { margin-top: 3px; color: var(--muted); font-size: .7rem; }
.calendar-agenda-list { padding: 7px; }
.calendar-agenda-item {
  display: grid;
  grid-template-columns: 55px 9px minmax(0, 1fr) 12px;
  align-items: start;
  gap: 7px;
  width: 100%;
  padding: 10px 7px;
  border: 0;
  border-bottom: 1px solid #edf0f3;
  color: inherit;
  background: transparent;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.calendar-agenda-item:hover { background: #f7fafc; }
.calendar-agenda-time { color: var(--muted); font-size: .65rem; text-align: right; }
.calendar-agenda-dot { width: 8px; height: 8px; margin-top: 3px; border-radius: 50%; background: #299eda; }
.calendar-agenda-item.project .calendar-agenda-dot { background: #8765c5; }
.calendar-agenda-item.task .calendar-agenda-dot { background: #26a675; }
.calendar-agenda-item.reminder .calendar-agenda-dot { background: #dd861e; }
.calendar-agenda-item.labor .calendar-agenda-dot { background: #1598a0; }
.calendar-agenda-item.worklog .calendar-agenda-dot { background: #bd970d; }
.calendar-agenda-copy { min-width: 0; }
.calendar-agenda-copy strong, .calendar-agenda-copy small { display: block; }
.calendar-agenda-copy strong { overflow: hidden; font-size: .75rem; line-height: 1.3; text-overflow: ellipsis; }
.calendar-agenda-copy small { margin-top: 3px; color: var(--muted); font-size: .65rem; line-height: 1.35; }
.calendar-agenda-open { color: var(--muted); font-size: 1.1rem; }
.calendar-shell.agenda-only { grid-template-columns: 1fr; }
.calendar-shell.agenda-only .calendar-month-panel { display: none; }
.calendar-shell.agenda-only .calendar-agenda { position: static; max-height: none; }
.calendar-shell.agenda-only .calendar-agenda-item { grid-template-columns: 90px 9px minmax(0, 1fr) 12px; }

/* ---------- New task modal ---------- */
.modal.task-create-modal {
  max-width: 700px;
  padding: 0;
  border: 1px solid rgba(120, 142, 164, .24);
  box-shadow: 0 24px 70px rgba(24, 44, 65, .24), 0 3px 10px rgba(24, 44, 65, .08);
}
.task-create-modal .modal-head {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 22px 26px 18px;
  margin: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, .98);
  backdrop-filter: blur(8px);
}
.task-create-modal .modal-head h2 { font-size: 1.28rem; letter-spacing: -.02em; }
.task-create-modal #m-form { padding: 20px 26px 24px; }
.task-create-intro {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 1px solid #cfe8f7;
  border-radius: 12px;
  background: linear-gradient(135deg, #f1faff 0%, #f8fcff 100%);
}
.task-create-icon {
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  height: 34px;
  border-radius: 10px;
  color: #fff;
  background: var(--primary);
  box-shadow: 0 5px 12px rgba(31, 157, 217, .24);
  font-weight: 800;
}
.task-create-intro strong, .task-create-intro span { display: block; }
.task-create-intro strong { color: var(--ink); font-size: .9rem; }
.task-create-intro span { color: var(--muted); font-size: .79rem; margin-top: 2px; }
.task-form-section {
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
}
.task-section-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.task-section-heading > span {
  display: grid;
  place-items: center;
  flex: 0 0 25px;
  height: 25px;
  border-radius: 50%;
  color: var(--primary-darker);
  background: var(--primary-soft);
  font-size: .75rem;
  font-weight: 800;
}
.task-section-heading strong, .task-section-heading small { display: block; }
.task-section-heading strong { font-size: .9rem; }
.task-section-heading small { color: var(--muted); font-size: .74rem; margin-top: 1px; }
.project-picker-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; }
.project-picker-row .btn { white-space: nowrap; }
.inline-project-panel {
  margin-top: 12px;
  padding: 14px;
  border: 1px dashed #9fcde8;
  border-radius: 10px;
  background: #f7fcff;
}
.inline-project-copy { margin-bottom: 12px; }
.inline-project-copy strong, .inline-project-copy span { display: block; }
.inline-project-copy strong { font-size: .85rem; color: var(--primary-darker); }
.inline-project-copy span { margin-top: 2px; color: var(--muted); font-size: .75rem; }
.task-planning-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.task-create-actions {
  position: sticky;
  bottom: 0;
  z-index: 4;
  margin: 18px -26px -24px;
  padding: 16px 26px;
  border-top: 1px solid var(--border);
  background: #fbfcfd;
}
.task-create-actions .btn-primary { min-width: 120px; }

/* ---------- Task dashboard ---------- */
.task-filter-grid {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) repeat(3, minmax(140px, 1fr));
  gap: 10px;
}
.task-row:hover, .task-row:focus { background: var(--surface-2, #f7f9fc); outline: none; }
.text-danger { color: var(--danger); }
.task-stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.task-stats-grid .stat { padding: 13px 15px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-sm); }
.task-stats-grid .stat-label { color: var(--muted); font-size: .76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .035em; }
.task-stats-grid .stat-value { margin-top: 3px; color: var(--ink); font-size: 1.5rem; font-weight: 750; line-height: 1.15; }
.task-view-switch { display: inline-flex; gap: 5px; padding: 3px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.task-kanban-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 320px);
  gap: 12px;
  align-items: start;
  overflow-x: auto;
  padding: 2px 2px 14px;
  scroll-snap-type: x proximity;
  scrollbar-color: var(--border-strong) transparent;
}
.kanban-column {
  min-height: 260px;
  max-height: calc(100vh - 250px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #eef2f7;
  scroll-snap-align: start;
  transition: border-color .14s, background .14s, box-shadow .14s;
}
.kanban-column.drop-target { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(38, 159, 222, .13); }
.kanban-column-head { display: flex; align-items: center; gap: 8px; padding: 11px 12px; border-bottom: 1px solid var(--border); }
.kanban-column-head strong { flex: 1; font-size: .85rem; }
.kanban-column-head span { min-width: 24px; padding: 1px 7px; border-radius: 999px; background: #fff; color: var(--muted); text-align: center; font-size: .73rem; font-weight: 700; }
.kanban-column-body { min-height: 205px; padding: 9px; overflow-y: auto; }
.kanban-card {
  margin-bottom: 9px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: grab;
  transition: border-color .12s, box-shadow .12s, opacity .12s, transform .12s;
}
.kanban-card:hover, .kanban-card:focus { border-color: #9fcde8; box-shadow: var(--shadow); outline: none; transform: translateY(-1px); }
.kanban-card.dragging { opacity: .45; cursor: grabbing; transform: rotate(1deg); }
.kanban-card-top, .kanban-card-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kanban-card-top { margin-bottom: 8px; }
.kanban-card-title { display: block; margin-bottom: 3px; line-height: 1.35; }
.kanban-type { color: var(--primary-darker); font-size: .72rem; font-weight: 750; text-transform: uppercase; letter-spacing: .035em; }
.kanban-system { margin: 8px 0; padding: 5px 7px; border-radius: 6px; background: var(--bg); color: var(--ink-soft); font-size: .73rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kanban-card-meta { margin-top: 9px; color: var(--muted); font-size: .75rem; }
.kanban-quick-status { width: 100%; margin-top: 10px; padding: 6px 8px; border: 1px solid var(--border-strong); border-radius: 7px; background: #fff; color: var(--ink-soft); font: inherit; font-size: .76rem; cursor: pointer; }
.kanban-empty { min-height: 90px; display: grid; place-items: center; border: 1px dashed var(--border-strong); border-radius: 9px; color: var(--muted); font-size: .78rem; }

.project-kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(250px, 1fr));
  gap: 12px;
  align-items: start;
  overflow-x: auto;
  padding: 2px 2px 14px;
  scroll-snap-type: x proximity;
}
.project-kanban-column {
  min-height: 300px;
  max-height: calc(100vh - 190px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f6f8fb;
  scroll-snap-align: start;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.project-kanban-column.is-drag-over { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(38, 159, 222, .13); }
.project-kanban-header { display: flex; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.project-kanban-header strong { flex: 1; font-size: .86rem; }
.project-kanban-header span { min-width: 25px; padding: 2px 7px; border-radius: 999px; background: #fff; color: var(--muted); text-align: center; font-size: .74rem; font-weight: 750; }
.project-kanban-cards { min-height: 230px; padding: 9px; overflow-y: auto; }
.project-kanban-card { margin-bottom: 9px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, .04); cursor: grab; transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease; }
.project-kanban-card:hover, .project-kanban-card:focus { border-color: #9fcde8; box-shadow: var(--shadow); outline: none; transform: translateY(-1px); }
.project-kanban-card.is-dragging { opacity: .45; cursor: grabbing; }
.project-kanban-card-title { margin-bottom: 7px; color: var(--ink); font-weight: 750; line-height: 1.35; }
.project-kanban-description { display: -webkit-box; margin-bottom: 10px; overflow: hidden; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.project-kanban-meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 7px; color: var(--muted); font-size: .76rem; }
.project-kanban-meta strong { color: var(--ink-soft); text-align: right; }
.project-kanban-status { width: 100%; margin-top: 11px; padding: 7px 8px; font-size: .78rem; }
.project-kanban-empty { min-height: 105px; display: grid; place-items: center; border: 1px dashed var(--border-strong); border-radius: 9px; color: var(--muted); font-size: .78rem; }
.project-list-view { display: grid; gap: 10px; }
.project-list-card { margin: 0; padding: 14px 16px; cursor: pointer; }
.project-list-card-main { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.project-list-card-title { margin-bottom: 4px; color: var(--ink); font-size: 1rem; font-weight: 750; }
.project-list-card-meta { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 10px; color: var(--muted); font-size: .79rem; }
.project-list-card-meta strong { color: var(--ink-soft); }
.project-color-accent { border-left: 5px solid var(--project-color, #94a3b8) !important; }
.project-color-dot { width: 14px; height: 14px; flex: 0 0 14px; display: inline-block; border-radius: 999px; background: var(--project-color, #94a3b8); box-shadow: 0 0 0 3px color-mix(in srgb, var(--project-color, #94a3b8) 20%, transparent); }
.project-task-row { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; padding: 8px 0 8px 10px; border-bottom: 1px solid var(--border, #e5e7eb); }
.ticket-queue-table .table { min-width: 1180px; }
.ticket-open-date, .ticket-elapsed { white-space: nowrap; }
.ticket-elapsed { color: var(--ink-soft); }
.project-thread-card { margin-top: 14px; }
.project-thread-card-embedded { margin: 16px 0 4px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.project-thread-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.project-thread-heading h3 { margin: 0; }
.project-thread-heading p { margin: 3px 0 0; color: var(--muted); font-size: .78rem; }
.project-thread-list { max-height: 220px; min-height: 110px; overflow-y: auto; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: #f7f9fc; }
.project-thread-message { width: fit-content; max-width: min(72%, 760px); margin: 0 auto 9px 0; padding: 9px 11px; border: 1px solid var(--border); border-radius: 10px 10px 10px 3px; background: #fff; }
.project-thread-message.mine { margin-right: 0; margin-left: auto; border-color: #abd8ef; border-radius: 10px 10px 3px 10px; background: var(--primary-soft); }
.project-thread-message-head { display: flex; justify-content: space-between; gap: 14px; margin-bottom: 5px; color: var(--muted); font-size: .7rem; }
.project-thread-message-head strong { color: var(--ink-soft); }
.project-thread-message-body { color: var(--ink); font-size: .88rem; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.project-thread-empty { min-height: 85px; padding: 24px 10px; }
.project-thread-composer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; align-items: end; margin-top: 9px; }
.project-thread-composer .textarea { min-height: 62px; resize: vertical; }
.task-open { appearance: none; display: inline; padding: 0; border: 0; background: none; color: var(--primary-darker); font: inherit; text-align: left; cursor: pointer; }
.task-open:hover, .task-open:focus-visible { text-decoration: underline; outline: none; }

@media (max-width: 760px) {
  .task-stats-grid { grid-template-columns: 1fr 1fr; }
  .task-view-switch { order: 3; width: 100%; }
  .task-view-switch .btn { flex: 1; justify-content: center; }
  .task-kanban-board { grid-auto-columns: minmax(260px, 84vw); margin-right: -24px; padding-right: 24px; }
  .kanban-column { max-height: calc(100vh - 220px); }
  .project-kanban-board { grid-template-columns: repeat(5, minmax(250px, 84vw)); margin-right: -24px; padding-right: 24px; }
  .project-kanban-column { max-height: calc(100vh - 210px); }
  .project-thread-composer { grid-template-columns: 1fr; }
  .project-thread-composer .btn { width: 100%; }
  .project-thread-message { max-width: 92%; }
}

/* ---------- Customer dashboard ---------- */
.dashboard-root { max-width: 1500px; margin: 0 auto; }
.dashboard-page-head { margin-bottom: 20px; }
.dashboard-page-head h1 { margin-bottom: 2px; }
.dashboard-live-label { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .78rem; font-weight: 650; }
.dashboard-live-label > span { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px var(--success-soft); }
.dashboard-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.dashboard-summary-card { min-width: 0; padding: 17px 18px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); cursor: pointer; text-align: left; transition: border-color .15s, box-shadow .15s, transform .15s; }
.dashboard-summary-card:hover { border-color: #acd7ed; box-shadow: var(--shadow); transform: translateY(-1px); }
.dashboard-summary-card:focus-visible, .dashboard-update-item:focus-visible { outline: 3px solid rgba(38, 159, 222, .35); outline-offset: 2px; }
.dashboard-summary-card > span { display: block; color: var(--muted); font-size: .78rem; font-weight: 700; }
.dashboard-summary-card > strong { display: block; margin: 5px 0 1px; color: var(--ink); font-size: 1.8rem; line-height: 1.05; }
.dashboard-summary-card > small { color: var(--primary-dark); font-weight: 650; }
.client-dashboard-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.dashboard-panel { padding: 0; overflow: hidden; }
.dashboard-panel-head { min-height: 82px; display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.dashboard-panel-head > div { flex: 1; min-width: 0; }
.dashboard-panel-head h2 { margin: 0 0 2px; }
.dashboard-panel-head p { margin: 0; color: var(--muted); font-size: .78rem; }
.dashboard-update-list { display: flex; flex-direction: column; min-width: 0; }
.dashboard-update-item { width: 100%; min-width: 0; display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 14px 18px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.dashboard-update-item:last-child { border-bottom: 0; }
.dashboard-update-item:hover { background: #f8fbfd; }
.dashboard-update-icon { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; color: var(--primary-darker); background: var(--primary-soft); font-weight: 800; }
.dashboard-update-item.project .dashboard-update-icon { color: #5b42c7; background: var(--violet-soft); }
.dashboard-update-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.dashboard-update-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dashboard-update-title strong { margin-right: 4px; }
.dashboard-update-meta, .dashboard-progress-copy { color: var(--muted); font-size: .74rem; overflow-wrap: anywhere; }
.dashboard-update-state { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.dashboard-update-state small { color: var(--muted); text-transform: capitalize; }
.dashboard-progress { width: 100%; height: 5px; overflow: hidden; border-radius: 999px; background: var(--border); }
.dashboard-progress > span { display: block; height: 100%; border-radius: inherit; background: var(--success); }
.dashboard-empty { padding: 35px 18px; color: var(--muted); text-align: center; }

@media (max-width: 1050px) {
  .dashboard-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .client-dashboard-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .dashboard-summary-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .client-dashboard-grid { grid-template-columns: 1fr; }
  .dashboard-summary-card { padding: 14px; }
  .dashboard-update-item { grid-template-columns: 34px minmax(0, 1fr); padding: 13px 14px; }
  .dashboard-update-icon { width: 32px; height: 32px; }
  .dashboard-update-state { grid-column: 2; flex-direction: row; align-items: center; justify-content: flex-start; }
  .dashboard-panel-head { align-items: flex-start; }
}

@media (max-width: 470px) {
  .dashboard-summary-grid { grid-template-columns: 1fr; }
  .dashboard-live-label { width: 100%; }
}

/* ---------- Toasts ---------- */
#toasts { position: fixed; top: 18px; right: 18px; z-index: 999; display: flex; flex-direction: column; gap: 10px; }
.toast {
  background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 10px;
  box-shadow: var(--shadow-lg); font-size: .9rem; max-width: 360px;
  animation: slidein .18s ease;
}
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }
@keyframes slidein { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(16, 28, 42, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; padding: 24px;
}
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-head .spacer { flex: 1; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---------- Misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 2.2rem; margin-bottom: 6px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.team-member-picker { display: grid; gap: 6px; max-height: 210px; padding: 8px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); }
.team-member-option { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: 7px; cursor: pointer; }
.team-member-option:hover { background: var(--primary-soft); }
.team-member-option input { width: 17px; height: 17px; margin: 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; row-gap: 8px; column-gap: 12px; align-items: baseline; }
.kv dt { color: var(--muted); font-size: .82rem; font-weight: 600; }
.kv dd { margin: 0; }
.ticket-meta-card { padding: 10px 12px; margin-bottom: 12px; }
.ticket-meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 10px; margin: 0; }
.ticket-meta-item { min-width: 0; min-height: 30px; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 6px; padding: 4px 7px; border-radius: 7px; background: #f7fafc; }
.ticket-meta-item dt { color: var(--muted); font-size: .68rem; font-weight: 700; line-height: 1.1; }
.ticket-meta-item dd { min-width: 0; margin: 0; font-size: .82rem; line-height: 1.2; overflow-wrap: anywhere; }
.ticket-meta-item .badge { font-size: .64rem; padding: 2px 6px; }

.hidden { display: none !important; }
.spin { display: inline-block; width: 16px; height: 16px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* type-to-confirm */
.confirm-row { display: flex; gap: 10px; align-items: center; }
.confirm-row .input { width: auto; min-width: 200px; }

/* Unified omnichannel inbox */
.inbox-toolbar { display: grid; grid-template-columns: minmax(240px, 1fr) 190px auto; gap: 10px; align-items: center; margin-bottom: 12px; }
.inbox-shell { display: grid; grid-template-columns: minmax(280px, 360px) minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); height: calc(100vh - 205px); min-height: 560px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: var(--shadow-sm); }
.inbox-thread-list { overflow-y: auto; border-right: 1px solid var(--border); background: #f8fbfd; }
.inbox-thread { width: 100%; display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 10px; padding: 14px; border: 0; border-bottom: 1px solid var(--border); background: transparent; color: inherit; text-align: left; cursor: pointer; }
.inbox-thread:hover, .inbox-thread:focus-visible { background: #edf7fb; outline: none; }
.inbox-thread.active { background: #e1f3f8; box-shadow: inset 4px 0 var(--primary); }
.inbox-avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: #d8edf3; color: #12536a; font-weight: 750; }
.inbox-thread-copy, .inbox-thread-meta { min-width: 0; display: flex; flex-direction: column; }
.inbox-thread-title { font-weight: 750; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-thread-subject, .inbox-thread-preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-thread-subject { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.inbox-thread-preview { font-size: .86rem; color: #3c5664; margin-top: 5px; }
.inbox-thread-meta { align-items: flex-end; gap: 6px; font-size: .68rem; color: var(--muted); white-space: nowrap; }
.inbox-new-dot { display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #e03737; }
.inbox-message-pane { min-width: 0; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: #fff; }
.inbox-empty { display: flex; flex-direction: column; gap: 8px; place-self: center; color: var(--muted); text-align: center; }
.inbox-chat-head { min-height: 68px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.inbox-chat-head div { display: flex; flex-direction: column; gap: 3px; }
.inbox-chat-head span { color: var(--muted); font-size: .82rem; }
.inbox-chat-head .inbox-project-head-copy { flex: 1; min-width: 0; gap: 4px; }
.inbox-chat-head .inbox-project-summary { display: flex; flex-direction: row; flex-wrap: wrap; gap: 5px 10px; margin-top: 3px; }
.inbox-project-summary > span { padding: 2px 7px; border-radius: 999px; background: var(--primary-soft); color: var(--ink-soft); white-space: nowrap; }
.inbox-project-task-preview { display: block; max-width: 100%; color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-project-task-preview > span { color: var(--primary); font-weight: 700; }
.message-delivery { border-radius: 999px; padding: 2px 7px; font-size: .72rem; font-weight: 800; }
.delivery-failed { color: #b42318; background: #fee4e2; }
.delivery-pending { color: #92400e; background: #fef3c7; }
.inbox-chat-head .inbox-head-actions { display: flex; flex-direction: row; align-items: center; gap: 7px; }
.inbox-messages { overflow-y: auto; padding: 20px; background: linear-gradient(180deg, #f6fafc, #fff); display: flex; flex-direction: column; gap: 4px; }
.inbox-messages .msg { width: fit-content; max-width: min(72%, 680px); padding: 10px 13px; border-radius: 18px; line-height: 1.42; overflow-wrap: anywhere; box-shadow: 0 1px 2px rgba(20, 48, 63, .08); }
.inbox-messages .msg + .msg:not(.joined-prev) { margin-top: 9px; }
.inbox-messages .msg-in { align-self: flex-start; background: #fff; border: 1px solid #dbe5ea; border-bottom-left-radius: 5px; }
.inbox-messages .msg-out { align-self: flex-end; background: #dff2fb; border: 1px solid #c5e5f3; border-bottom-right-radius: 5px; }
.inbox-messages .msg-in.joined-prev { border-top-left-radius: 7px; }
.inbox-messages .msg-in.joined-next { border-bottom-left-radius: 7px; }
.inbox-messages .msg-out.joined-prev { border-top-right-radius: 7px; }
.inbox-messages .msg-out.joined-next { border-bottom-right-radius: 7px; }
.inbox-messages .msg .meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; font-size: .7rem; color: var(--muted); }
.inbox-messages .msg .meta strong { color: #254957; }
.inbox-messages .msg-body { white-space: pre-wrap; }
.inbox-composer { position: relative; padding: 12px 16px 16px; border-top: 1px solid var(--border); background: #fff; }
.inbox-composer > label { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: .8rem; color: var(--muted); }
.inbox-composer select { width: auto; padding: 6px 30px 6px 8px; }
.inbox-project-delivery { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.inbox-project-delivery label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .8rem; }
.inbox-popout-page .inbox-toolbar, .inbox-popout-page .inbox-thread-list { display: none; }
.inbox-popout-page .inbox-shell { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 205px); min-height: 0; }
.inbox-compose-row, .composer-with-emoji { position: relative; display: flex; align-items: flex-end; gap: 8px; }
.inbox-compose-row textarea, .composer-with-emoji textarea { flex: 1; resize: vertical; }
.composer-key-hint { margin-top: 5px; color: var(--muted); font-size: .72rem; line-height: 1.2; }
.emoji-trigger { flex: 0 0 auto; font-size: 1.15rem; line-height: 1; }
.emoji-popover { position: absolute; right: 54px; bottom: calc(100% + 8px); z-index: 65; border-radius: 12px; box-shadow: 0 16px 45px rgba(18, 43, 55, .24); }
.composer-with-emoji .emoji-popover { right: 0; }
emoji-picker { width: min(360px, 84vw); height: 410px; --border-radius: 12px; --category-emoji-size: 1.35rem; }

.activity-card { overflow: hidden; }
.activity-project-panel { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
.activity-project-panel > h3 { margin: 0 0 10px; }
.activity-filter-bar { display: flex; gap: 7px; margin: 4px 0 18px; padding-bottom: 2px; overflow-x: auto; scrollbar-width: thin; }
.activity-filter-bar .btn { flex: 0 0 auto; text-transform: capitalize; }
.activity-timeline { position: relative; display: grid; grid-template-columns: 1fr; padding: 0 0 4px 8px; }
.activity-timeline::before { content: ""; position: absolute; top: 37px; bottom: 13px; left: 24px; width: 2px; border-radius: 2px; background: linear-gradient(180deg, #2563eb, #7c3aed 48%, #14b8a6); opacity: .32; }
.activity-date-group { position: relative; z-index: 1; margin: 15px 0 9px 43px; color: var(--muted); font-size: .73rem; font-weight: 800; letter-spacing: .055em; text-transform: uppercase; }
.activity-date-group:first-child { margin-top: 0; }
.activity-event { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; min-width: 0; padding: 5px 0 13px; }
.activity-event-dot { position: relative; z-index: 2; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 3px solid var(--surface, #fff); border-radius: 50%; background: #eef4ff; color: #315bd6; box-shadow: 0 2px 9px rgba(31, 71, 136, .14); font-size: .78rem; font-weight: 900; }
.activity-event-body { min-width: 0; padding: 5px 12px 8px 0; }
.activity-event-title { color: var(--text); font-size: .94rem; font-weight: 750; line-height: 1.25; }
.activity-event-summary { margin-top: 3px; color: var(--muted); font-size: .84rem; line-height: 1.4; overflow-wrap: anywhere; }
.activity-event-meta { display: flex; flex-wrap: wrap; gap: 5px 12px; margin-top: 5px; color: var(--muted); font-size: .72rem; }
.activity-event-meta span::before { content: "•"; margin-right: 8px; opacity: .55; }
.activity-empty { padding: 22px; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted); text-align: center; }

@media (max-width: 760px) {
  .inbox-toolbar { grid-template-columns: 1fr; }
  .inbox-shell { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .inbox-thread-list { max-height: 310px; border-right: 0; border-bottom: 1px solid var(--border); }
  .inbox-message-pane { min-height: 560px; }
  .inbox-messages { padding: 14px; }
  .inbox-messages .msg { max-width: 88%; }
  .inbox-compose-row { flex-wrap: wrap; }
  .inbox-compose-row textarea { flex-basis: 100%; }
  .activity-filter-bar { flex-wrap: wrap; overflow-x: visible; }
  .activity-filter-bar .btn { padding-inline: 10px; }
  .activity-event { grid-template-columns: 30px minmax(0, 1fr); gap: 9px; }
  .activity-event-dot { width: 30px; height: 30px; }
  .activity-timeline::before { left: 22px; }
  .activity-date-group { margin-left: 39px; }
}

@media (max-width: 1050px) {
  .calendar-shell { grid-template-columns: 1fr; }
  .calendar-agenda { position: static; max-height: none; }
}

@media (max-width: 820px) {
  .mobile-menu-btn { display: inline-flex; align-items: center; justify-content: center; }
  .sidebar {
    display: block;
    position: fixed;
    top: 60px;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: min(82vw, 280px);
    overflow-y: auto;
    box-shadow: 14px 0 35px rgba(24, 44, 65, .18);
    transform: translateX(-105%);
    transition: transform .18s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 60px 0 0; z-index: 35; background: rgba(22, 38, 52, .36); opacity: 0; pointer-events: none; transition: opacity .18s ease; }
  body.nav-open .sidebar-backdrop { display: block; opacity: 1; pointer-events: auto; }
  .appbar { padding: 0 10px; gap: 8px; }
  .appbar .user-chip .small { display: none; }
  .msg { max-width: 95%; }
  .kv { grid-template-columns: 1fr; }
  .task-filter-grid { grid-template-columns: 1fr 1fr; }
  .calendar-page-head, .calendar-toolbar { align-items: stretch; flex-direction: column; }
  .calendar-toolbar { display: flex; }
  .calendar-month-panel { overflow-x: auto; }
  .calendar-weekdays, .calendar-grid { min-width: 760px; }
  .calendar-filters { justify-content: flex-start; }
}

@media (max-width: 520px) {
  .task-stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .task-stats-grid .stat { padding: 10px 12px; }
  .task-filter-grid { grid-template-columns: 1fr; }
  .task-create-modal .modal-head { padding: 18px 18px 14px; }
  .task-create-modal #m-form { padding: 16px 18px 20px; }
  .project-picker-row, .task-planning-grid { grid-template-columns: 1fr; }
  .task-create-actions { bottom: 0; margin: 16px -18px -20px; padding: 14px 18px; }
  .task-create-actions .btn { flex: 1; }
}
