/* Agency CRM — design system. Plain CSS, no build step. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f9fafb;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-50: #eef2ff;
  --primary-100: #e0e7ff;
  --success: #059669;
  --success-50: #ecfdf5;
  --warning: #d97706;
  --warning-50: #fffbeb;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --info: #0284c7;
  --info-50: #f0f9ff;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .14), 0 4px 8px rgba(16, 24, 40, .06);
  --sidebar-w: 240px;
  --topbar-h: 60px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.5; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5em; line-height: 1.25; font-weight: 600; }
h1 { font-size: 22px; } h2 { font-size: 18px; } h3 { font-size: 15px; } h4 { font-size: 14px; }
p { margin: 0 0 .75em; }
img { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
code { font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); }
[hidden] { display: none !important; }
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sm .icon, .icon.sm { width: 15px; height: 15px; }

/* ---------- utilities */
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.tiny { font-size: 11.5px; }
.bold { font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.mono { font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.danger-text { color: var(--danger); }
.success-text { color: var(--success); }
.warning-text { color: var(--warning); }
.pad { padding: 16px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.flex { display: flex; align-items: center; gap: 8px; }
.flex-col { display: flex; flex-direction: column; gap: 8px; }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.gap-0 { gap: 0; } .gap-1 { gap: 4px; } .gap-3 { gap: 16px; }
.stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.color-swatch { width: 12px; height: 12px; border-radius: 4px; display: inline-block; flex-shrink: 0; }

/* ---------- app shell */
.app { display: flex; min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; color: #fff; text-decoration: none !important; height: var(--topbar-h); border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg, #6366f1, #8b5cf6); display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px; flex-shrink: 0; }
.brand-mark.lg { width: 52px; height: 52px; border-radius: 14px; font-size: 20px; }
.brand-logo { height: 30px; width: auto; max-width: 140px; object-fit: contain; }
.brand-logo-lg { height: 56px; width: auto; }
.brand-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav { flex: 1; overflow-y: auto; padding: 10px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #64748b; padding: 16px 10px 6px; font-weight: 600; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: #cbd5e1; font-weight: 500; text-decoration: none !important; margin-bottom: 1px; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(99,102,241,.22); color: #fff; }
.nav-link .icon { opacity: .9; }
.nav-badge { margin-left: auto; background: #ef4444; color: #fff; font-size: 11px; font-weight: 600; min-width: 19px; height: 19px; padding: 0 6px; border-radius: 10px; display: inline-grid; place-items: center; }
.sidebar-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-backdrop { display: none; }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; padding: 0 24px; }
.search { flex: 1; max-width: 520px; display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 0 12px; height: 38px; color: var(--muted); }
.search:focus-within { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-100); }
.search input { border: 0; background: transparent; outline: none; flex: 1; font: inherit; color: var(--text); min-width: 0; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.content { padding: 24px; width: 100%; max-width: 1280px; margin: 0 auto; }
.content-wide { max-width: none; }
.content-flush { padding: 0; max-width: none; }
.only-mobile { display: none !important; }

/* ---------- page header */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { margin: 0; }
.page-header .subtitle { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumb { font-size: 13px; color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: #fff; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; text-decoration: none !important; white-space: nowrap; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s; }
.btn:hover { background: var(--surface-2); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn-xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; position: relative; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font: inherit; font-size: 13px; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.avatar-btn { border: 0; background: none; padding: 0; cursor: pointer; border-radius: 50%; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 8px 0 0 8px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 8px 8px 0; }
.btn-group .btn.active { background: var(--primary-50); border-color: var(--primary); color: var(--primary); z-index: 1; }

/* ---------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-header h2, .card-header h3 { margin: 0; font-size: 15px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.kpi-label { color: var(--muted); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi-value { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi.danger .kpi-value { color: var(--danger); }
.kpi.success .kpi-value { color: var(--success); }

/* ---------- tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 10px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbff; }
.table tr.clickable { cursor: pointer; }
.table .num, .table th.num { text-align: right; }
.table tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border); }
.table th a { color: inherit; }
.table-compact td, .table-compact th { padding: 7px 10px; }

/* ---------- forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12px; color: var(--danger); }
.req::after { content: ' *'; color: var(--danger); }
.input, .select, .textarea, input[type=text].input, input[type=email].input {
  width: 100%; height: 38px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; font: inherit; color: var(--text); outline: none; transition: border-color .12s, box-shadow .12s; }
.textarea { height: auto; min-height: 90px; padding: 9px 12px; resize: vertical; line-height: 1.5; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.input-sm, .select-sm { height: 32px; font-size: 13px; }
select[multiple].select { height: auto; min-height: 110px; padding: 6px; background-image: none; }
.input-group { display: flex; }
.input-group .input, .input-group .select { border-radius: 0; }
.input-group > :first-child { border-radius: 8px 0 0 8px; }
.input-group > :last-child { border-radius: 0 8px 8px 0; }
.input-group > * + * { margin-left: -1px; }
.input-addon { display: inline-flex; align-items: center; padding: 0 10px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--muted); font-size: 13px; white-space: nowrap; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 400; color: var(--text); }
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.form-section { margin-top: 24px; }
.form-section-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 12px; }
input[type=color].input { padding: 3px; width: 56px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .select, .filters .input { width: auto; min-width: 140px; height: 34px; font-size: 13px; }

/* ---------- badges / chips */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; background: #f3f4f6; color: #374151; white-space: nowrap; }
.badge-task-todo { background: #f3f4f6; color: #374151; }
.badge-task-in_progress { background: #dbeafe; color: #1d4ed8; }
.badge-task-in_review { background: #fef3c7; color: #b45309; }
.badge-task-done { background: #d1fae5; color: #047857; }
.badge-priority-low { background: #f3f4f6; color: #6b7280; }
.badge-priority-normal { background: #e0e7ff; color: #4338ca; }
.badge-priority-high { background: #ffedd5; color: #c2410c; }
.badge-priority-urgent { background: #fee2e2; color: #b91c1c; }
.badge-project-active, .badge-client-active { background: #d1fae5; color: #047857; }
.badge-project-on_hold, .badge-client-paused { background: #fef3c7; color: #b45309; }
.badge-project-completed { background: #dbeafe; color: #1d4ed8; }
.badge-project-archived, .badge-client-former { background: #f3f4f6; color: #6b7280; }
.badge-client-lead { background: #ede9fe; color: #6d28d9; }
.badge-invoice-draft { background: #f3f4f6; color: #4b5563; }
.badge-invoice-sent { background: #dbeafe; color: #1d4ed8; }
.badge-invoice-partially_paid { background: #fef3c7; color: #b45309; }
.badge-invoice-paid { background: #d1fae5; color: #047857; }
.badge-invoice-void { background: #f3f4f6; color: #9ca3af; text-decoration: line-through; }
.badge-invoice-overdue, .badge-overdue { background: #fee2e2; color: #b91c1c; }
.badge-role-admin { background: #ede9fe; color: #6d28d9; }
.badge-role-manager { background: #dbeafe; color: #1d4ed8; }
.badge-role-finance { background: #d1fae5; color: #047857; }
.badge-role-member { background: #f3f4f6; color: #374151; }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); white-space: nowrap; max-width: 100%; }
.chip .dot { width: 8px; height: 8px; }
.project-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-2); }

/* ---------- avatars */
.avatar { --hue: 230; width: 32px; height: 32px; border-radius: 50%; display: inline-grid; place-items: center; font-size: 12px; font-weight: 600; color: hsl(var(--hue) 55% 30%); background: hsl(var(--hue) 70% 90%); object-fit: cover; flex-shrink: 0; }
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.xs { width: 20px; height: 20px; font-size: 9px; }
.avatar.lg { width: 56px; height: 56px; font-size: 19px; }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { border: 2px solid #fff; margin-left: -8px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.user-cell { display: flex; align-items: center; gap: 8px; min-width: 0; }

/* ---------- alerts / toasts */
.alert { padding: 11px 14px; border-radius: 9px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid; }
.alert-success { background: var(--success-50); border-color: #a7f3d0; color: #065f46; }
.alert-error, .alert-danger { background: var(--danger-50); border-color: #fecaca; color: #991b1b; }
.alert-warning { background: var(--warning-50); border-color: #fde68a; color: #92400e; }
.alert-info { background: var(--info-50); border-color: #bae6fd; color: #075985; }
.toasts { position: fixed; bottom: 20px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13.5px; max-width: 360px; animation: toast-in .2s ease; }
.toast.error { background: #b91c1c; }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- dropdowns */
.dropdown { position: relative; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 210px; background: #fff; border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 60; }
.dropdown.open > .dropdown-menu { display: block; }
.dropdown-menu.left { right: auto; left: 0; }
.dropdown-wide { width: 380px; max-width: calc(100vw - 24px); padding: 0; }
.dropdown-menu > a, .dropdown-menu > button, .dropdown-menu form > button { display: flex; width: 100%; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px; color: var(--text); background: none; border: 0; font: inherit; text-align: left; cursor: pointer; text-decoration: none !important; }
.dropdown-menu > a:hover, .dropdown-menu > button:hover, .dropdown-menu form > button:hover { background: var(--surface-2); }
.dropdown-menu .danger { color: var(--danger); }
.dropdown-head { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -6px -6px 6px; }
.dropdown-wide .dropdown-head { margin: 0; }
.dropdown-foot { display: block; text-align: center; padding: 10px; border-top: 1px solid var(--border); font-size: 13px; }
.dot-badge { position: absolute; top: 6px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #ef4444; color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid #fff; box-sizing: content-box; }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif-item { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none !important; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: #f5f7ff; }
.notif-item.unread .notif-title::before { content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--primary); margin-right: 6px; vertical-align: middle; }
.notif-title { font-weight: 500; font-size: 13.5px; }
.notif-body { color: var(--muted); font-size: 12.5px; }

/* ---------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 10px 14px; color: var(--muted); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; display: inline-flex; gap: 6px; align-items: center; background: none; border-top: 0; border-left: 0; border-right: 0; cursor: pointer; font: inherit; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; font-size: 11.5px; color: var(--muted); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- modal & drawer */
.modal, .drawer { position: fixed; inset: 0; z-index: 100; }
.modal-backdrop, .drawer-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.modal-dialog { position: relative; margin: 6vh auto; width: min(640px, calc(100vw - 24px)); max-height: 88vh; overflow-y: auto; background: #fff; border-radius: 16px; box-shadow: var(--shadow-lg); animation: pop .16s ease; }
.modal-dialog.lg { width: min(900px, calc(100vw - 24px)); }
.modal-body { padding: 22px 24px; }
.modal-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title h2 { margin: 0; }
@keyframes pop { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-panel { position: absolute; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: #fff; box-shadow: var(--shadow-lg); overflow-y: auto; animation: slide .18s ease; display: flex; flex-direction: column; }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- lightbox */
.lightbox { position: fixed; inset: 0; z-index: 150; background: rgba(0,0,0,.88); display: grid; place-items: center; padding: 24px; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 6px; }
.lightbox-close { position: absolute; top: 14px; right: 14px; color: #fff; }
.lightbox-close:hover { background: rgba(255,255,255,.12); color: #fff; }

/* ---------- empty states */
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state.big { padding: 80px 20px; }
.empty-state h2, .empty-state h3 { color: var(--text); }
.empty-icon { width: 48px; height: 48px; border-radius: 14px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; margin: 0 auto 14px; }
.empty-icon .icon { width: 24px; height: 24px; }

/* ---------- progress */
.progress { height: 8px; background: #eef0f3; border-radius: 99px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--success); border-radius: 99px; transition: width .3s; }
.progress.sm { height: 5px; }
.stacked-bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: #eef0f3; }
.stacked-bar span { height: 100%; }

/* ---------- task list rows */
.task-group { margin-bottom: 20px; }
.task-group-head { display: flex; align-items: center; gap: 8px; padding: 6px 2px; font-weight: 600; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.task-group-head .count { color: var(--muted); font-weight: 500; }
.task-group-head .icon { width: 16px; height: 16px; transition: transform .15s; }
.task-group.collapsed .task-group-head .icon { transform: rotate(-90deg); }
.task-group.collapsed .task-rows { display: none; }
.task-group.overdue .task-group-head { color: var(--danger); }
.task-rows { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.task-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) 170px 140px 92px 110px 44px; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); cursor: pointer; color: inherit; text-decoration: none !important; }
.task-row.with-assignee { grid-template-columns: 22px minmax(0, 1fr) 150px 150px 130px 92px 110px 44px; }
.task-row:last-child { border-bottom: 0; }
.task-row:hover { background: #fafbff; }
.task-row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task-row.is-done .title { color: var(--muted); text-decoration: line-through; }
.task-row .due.overdue { color: var(--danger); font-weight: 500; }
.task-row .clip { color: var(--muted); font-size: 12.5px; display: inline-flex; align-items: center; gap: 3px; }
.task-row .clip .icon { width: 14px; height: 14px; }
.status-check { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; background: #fff; cursor: pointer; padding: 0; color: transparent; }
.status-check:hover { border-color: var(--success); color: var(--success); }
.status-check.done { background: var(--success); border-color: var(--success); color: #fff; }
.status-check .icon { width: 12px; height: 12px; stroke-width: 3; }
.task-row-head { background: var(--surface-2); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); cursor: default; }
.task-row-head:hover { background: var(--surface-2); }

/* ---------- task detail */
.task-detail { display: flex; flex-direction: column; min-height: 100%; }
.task-detail-head { padding: 18px 22px 12px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; z-index: 2; }
.task-title-input { font-size: 20px; font-weight: 600; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; margin-left: -8px; width: calc(100% + 8px); font-family: inherit; color: var(--text); background: transparent; }
.task-title-input:hover:not(:disabled) { border-color: var(--border); }
.task-title-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.task-meta { display: grid; grid-template-columns: 120px 1fr; gap: 10px 12px; align-items: center; padding: 16px 22px; border-bottom: 1px solid var(--border); }
.task-meta .meta-label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.task-meta .select, .task-meta .input { height: 34px; max-width: 320px; }
.task-section { padding: 16px 22px; border-bottom: 1px solid var(--border); }
.task-section h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.checklist-item { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.checklist-item.done .text { text-decoration: line-through; color: var(--muted); }
.checklist-item .text { flex: 1; }
.checklist-item .icon-btn { opacity: 0; }
.checklist-item:hover .icon-btn { opacity: 1; }
.activity-item { display: flex; gap: 8px; font-size: 12.5px; color: var(--text-2); padding: 4px 0; }
.activity-item .when { color: var(--muted); margin-left: auto; white-space: nowrap; }

/* ---------- rich text editor */
.rte { border: 1px solid var(--border-strong); border-radius: 8px; background: #fff; }
.rte:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.rte-toolbar { display: flex; gap: 2px; padding: 4px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.rte-toolbar button { border: 0; background: none; padding: 4px 8px; border-radius: 5px; cursor: pointer; font: inherit; font-size: 13px; color: var(--text-2); min-width: 28px; }
.rte-toolbar button:hover { background: var(--surface-2); }
.rte-content { min-height: 110px; padding: 10px 12px; outline: none; line-height: 1.6; }
.rte-content:empty::before { content: attr(data-placeholder); color: var(--muted); }
.prose { line-height: 1.65; overflow-wrap: anywhere; }
.prose ul, .prose ol, .rte-content ul, .rte-content ol { padding-left: 22px; margin: 6px 0; }
.prose img, .rte-content img { max-width: 100%; border-radius: 6px; }
.prose p:last-child { margin-bottom: 0; }

/* ---------- chat */
.chat-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); height: calc(100vh - var(--topbar-h)); background: #fff; }
.chat-sidebar { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.chat-sidebar-head { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.chat-list { flex: 1; overflow-y: auto; overflow-x: hidden; }
.chat-list-item .name > :first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.chat-list-item .name > :last-child { flex-shrink: 0; }
.chat-list-item { display: flex; align-items: center; gap: 10px; padding: 10px 16px; color: var(--text); text-decoration: none !important; border-left: 3px solid transparent; }
.chat-list-item:hover { background: var(--surface-2); }
.chat-list-item.active { background: var(--primary-50); border-left-color: var(--primary); }
.chat-list-item .meta { flex: 1; min-width: 0; }
.chat-list-item .name { font-weight: 500; display: flex; justify-content: space-between; gap: 6px; }
.chat-list-item .preview { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list-section { padding: 12px 16px 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.unread-pill { background: var(--primary); color: #fff; font-size: 11px; font-weight: 600; border-radius: 10px; min-width: 19px; height: 19px; padding: 0 6px; display: inline-grid; place-items: center; }
.thread { display: flex; flex-direction: column; min-height: 0; height: 100%; }
.thread-head { padding: 12px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.thread-messages { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; background: #fbfbfd; }
.thread-embedded { border: 1px solid var(--border); border-radius: 12px; height: 520px; background: #fff; overflow: hidden; }
.msg { display: flex; gap: 10px; padding: 6px 8px; border-radius: 10px; position: relative; }
.msg:hover { background: #f3f4f8; }
.msg.grouped { padding-top: 1px; }
.msg.grouped .msg-avatar { visibility: hidden; height: 0; }
.msg.grouped .msg-head { display: none; }
.msg-avatar { width: 32px; flex-shrink: 0; }
.msg-main { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.msg-head .name { font-weight: 600; }
.msg-head .time { color: var(--muted); font-size: 11.5px; }
.msg-body { overflow-wrap: anywhere; line-height: 1.55; }
.msg-body.long { max-height: 220px; overflow: hidden; position: relative; }
.msg-body.long.expanded { max-height: none; }
.msg.deleted .msg-body { color: var(--muted); font-style: italic; }
.msg-actions { position: absolute; top: -12px; right: 10px; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); display: none; padding: 2px; }
.msg:hover .msg-actions { display: flex; }
.msg-actions button { border: 0; background: none; padding: 4px 7px; border-radius: 6px; cursor: pointer; color: var(--text-2); font-size: 12px; display: inline-flex; align-items: center; gap: 4px; }
.msg-actions button:hover { background: var(--surface-2); }
.msg-source { font-size: 11px; color: #16a34a; display: inline-flex; align-items: center; gap: 3px; }
.msg-source .icon { width: 13px; height: 13px; }
.msg-receipt { font-size: 11px; color: var(--muted); }
.mention { background: var(--primary-50); color: var(--primary-600); border-radius: 4px; padding: 0 3px; font-weight: 500; }
.day-divider { text-align: center; font-size: 11.5px; color: var(--muted); margin: 12px 0 6px; display: flex; align-items: center; gap: 10px; }
.day-divider::before, .day-divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.composer { border-top: 1px solid var(--border); padding: 10px 14px; background: #fff; }
.composer-box { border: 1px solid var(--border-strong); border-radius: 12px; padding: 6px 8px; display: flex; align-items: flex-end; gap: 6px; }
.composer-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-100); }
.composer textarea { flex: 1; border: 0; outline: none; resize: none; font: inherit; max-height: 160px; min-height: 24px; padding: 6px 4px; line-height: 1.45; background: transparent; }
.composer-files { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 0 6px; }
.composer-opts { display: flex; align-items: center; gap: 12px; padding-top: 6px; font-size: 12.5px; color: var(--muted); }
.recording { color: var(--danger); display: inline-flex; align-items: center; gap: 6px; font-weight: 500; }
.recording::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .3; } }
.mention-menu { position: absolute; bottom: 100%; left: 0; margin-bottom: 4px; background: #fff; border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); width: 240px; max-height: 220px; overflow-y: auto; padding: 4px; z-index: 10; }
.mention-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; background: none; border-radius: 6px; cursor: pointer; font: inherit; text-align: left; }
.mention-menu button.active, .mention-menu button:hover { background: var(--primary-50); }

/* ---------- attachments */
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.att-thumb { width: 120px; height: 90px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); cursor: zoom-in; background: var(--surface-2); }
.att-file { display: inline-flex; align-items: center; gap: 10px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; max-width: 280px; color: var(--text); text-decoration: none !important; }
.att-file:hover { border-color: var(--border-strong); background: var(--surface-2); }
.att-file .att-ic { width: 34px; height: 34px; border-radius: 8px; background: var(--primary-50); color: var(--primary); display: grid; place-items: center; flex-shrink: 0; }
.att-file .att-name { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-file .att-size { font-size: 11.5px; color: var(--muted); }
.att-video { max-width: 320px; width: 100%; border-radius: 10px; background: #000; }
.voice-note { display: inline-flex; align-items: center; gap: 10px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--primary-50); min-width: 220px; max-width: 320px; }
.voice-note button { width: 32px; height: 32px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.voice-note button .icon { width: 14px; height: 14px; fill: currentColor; }
.voice-bar { flex: 1; height: 4px; background: var(--primary-100); border-radius: 4px; position: relative; cursor: pointer; }
.voice-bar span { position: absolute; inset: 0 auto 0 0; background: var(--primary); border-radius: 4px; width: 0; }
.voice-time { font-size: 12px; color: var(--primary-600); font-variant-numeric: tabular-nums; min-width: 36px; }
.dropzone { border: 2px dashed var(--border-strong); border-radius: 12px; padding: 18px; text-align: center; color: var(--muted); cursor: pointer; transition: border-color .12s, background .12s; }
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-50); color: var(--primary); }
.upload-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; padding: 4px 8px; background: var(--surface-2); border-radius: 8px; border: 1px solid var(--border); }
.upload-item .progress { width: 80px; }
.att-wrap { display: inline-flex; align-items: flex-start; gap: 4px; position: relative; }
.dropzone.small { padding: 10px; font-size: 13px; }
.upload-item.done { background: var(--success-50); border-color: #a7f3d0; }
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }

/* ---------- misc layout pieces */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-plain li:last-child { border-bottom: 0; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.project-card { display: block; padding: 16px; color: inherit; text-decoration: none !important; transition: box-shadow .15s, border-color .15s; }
.project-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.project-card .stats { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); margin-top: 10px; flex-wrap: wrap; }
.project-card .stats b { color: var(--text); }
.bar-chart { width: 100%; height: auto; display: block; }
.bar-chart text { font-family: var(--font); font-size: 11px; fill: var(--muted); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sort-link { color: inherit !important; display: inline-flex; align-items: center; gap: 2px; }
.pagination { display: flex; gap: 4px; justify-content: center; margin-top: 16px; }
.pagination a, .pagination span { min-width: 32px; height: 32px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); padding: 0 8px; font-size: 13px; text-decoration: none !important; }
.pagination .active { background: var(--primary); border-color: var(--primary); color: #fff; }
.settings-layout { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 24px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 2px; position: sticky; top: calc(var(--topbar-h) + 24px); }
.settings-nav a { padding: 8px 12px; border-radius: 8px; color: var(--text-2); font-weight: 500; text-decoration: none !important; display: flex; align-items: center; gap: 8px; }
.settings-nav a:hover { background: #fff; }
.settings-nav a.active { background: #fff; color: var(--primary); box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 500; }
.status-dot::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.status-dot.ok::before { background: var(--success); }
.status-dot.bad::before { background: var(--danger); }
.status-dot.warn::before { background: var(--warning); }
.search-result { display: block; padding: 12px 16px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none !important; }
.search-result:hover { background: var(--surface-2); }
.search-result mark { background: #fef08a; padding: 0 1px; border-radius: 2px; }
.line-items { width: 100%; border-collapse: collapse; }
.line-items th { font-size: 12px; text-transform: uppercase; color: var(--muted); text-align: left; padding: 6px 6px; font-weight: 600; border-bottom: 1px solid var(--border); }
.line-items td { padding: 6px; vertical-align: top; }
.line-items .input { height: 34px; }
.totals { margin-left: auto; width: 320px; max-width: 100%; }
.totals .row { display: flex; justify-content: space-between; padding: 6px 0; font-variant-numeric: tabular-nums; }
.totals .row.total { font-weight: 700; font-size: 16px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 10px; }

/* ---------- auth pages */
.auth-body { background: radial-gradient(1200px 600px at 10% -10%, #e0e7ff, transparent), radial-gradient(900px 500px at 110% 110%, #ede9fe, transparent), var(--bg); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-brand { text-align: center; margin-bottom: 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.auth-agency { font-weight: 600; font-size: 17px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow-lg); }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card .field { margin-top: 14px; }
.divider-text { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 18px 0; }
.divider-text::before, .divider-text::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.btn-google { width: 100%; }

/* ---------- responsive */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .task-row.with-assignee { grid-template-columns: 22px minmax(0, 1fr) 130px 120px 110px 44px; }
  .task-row.with-assignee .col-priority, .task-row.with-assignee .col-project { display: none; }
}
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.45); z-index: 35; }
  .main { margin-left: 0; }
  .only-mobile { display: inline-grid !important; }
  .hide-mobile { display: none !important; }
  .topbar { padding: 0 12px; gap: 6px; }
  .content { padding: 16px 12px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .task-row, .task-row.with-assignee { grid-template-columns: 22px minmax(0, 1fr) auto; grid-template-areas: "chk title clip" "chk meta meta"; row-gap: 4px; }
  .task-row > .col-check { grid-area: chk; align-self: start; margin-top: 2px; }
  .task-row > .col-title { grid-area: title; }
  .task-row > .col-clip { grid-area: clip; }
  .task-row > .col-project, .task-row > .col-assignee, .task-row > .col-priority { display: none; }
  .task-row > .col-due { grid-area: meta; font-size: 12.5px; }
  .task-row > .col-status { display: none; }
  .task-row-head { display: none; }
  .chat-layout { grid-template-columns: 1fr; height: calc(100vh - var(--topbar-h)); }
  .chat-layout.has-thread .chat-sidebar { display: none; }
  .chat-layout:not(.has-thread) .thread { display: none; }
  .task-meta { grid-template-columns: 1fr; gap: 4px; }
  .task-meta .meta-label { margin-top: 8px; }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { flex-direction: row; overflow-x: auto; position: static; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .modal-dialog { margin: 12px auto; max-height: calc(100vh - 24px); }
  .toasts { left: 12px; right: 12px; bottom: 12px; }
  .table th, .table td { padding: 9px 10px; }
  .page-header h1 { font-size: 19px; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi-value { font-size: 19px; }
  .search { display: none; }
  .topbar-actions { margin-left: auto; }
}
@media print {
  .sidebar, .topbar, .page-actions, .no-print { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
  .card { border: 0; box-shadow: none; }
}
