:root {
  color-scheme: light;
  --paper: #f5f5f1;
  --surface: #fff;
  --ink: #28232c;
  --muted: #69646c;
  --faint: #89848b;
  --line: #dfdfd9;
  --plum: #30243a;
  --plum-deep: #221c28;
  --purple: #69507f;
  --purple-wash: #efebf4;
  --lavender: #d8c6e6;
  --lime: #d4ee9b;
  --green: #3d6849;
  --red: #9d443c;
  --amber: #865b26;
  --radius: 16px;
  --nav-width: 242px;
  font: 400 100%/1.48 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  background: var(--paper);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; min-width: 300px; background: var(--paper); color: var(--ink); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
button, [type="button"], [type="submit"] { cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: not-allowed; opacity: .55; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #9968bc; outline-offset: 3px; }
a { color: var(--purple); text-underline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3, h4 { line-height: 1.16; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 3.3vw, 3.1rem); font-weight: 620; letter-spacing: -.054em; }
h2 { font-size: clamp(1.25rem, 1.7vw, 1.65rem); font-weight: 620; letter-spacing: -.035em; }
h3 { font-size: 1.08rem; font-weight: 650; letter-spacing: -.025em; }
small, .muted, .secondary-text { color: var(--muted); }
small { font-size: .8125rem; }
hr { border: 0; border-top: 1px solid var(--line); }
[hidden], .hidden { display: none !important; }
button, .btn { min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: .52rem; padding: .58rem .92rem; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); font-size: .9rem; font-weight: 570; line-height: 1.25; text-decoration: none; transition: background .15s, border-color .15s, transform .15s; }
button:hover:not(:disabled), .btn:hover { background: #f0eee9; border-color: #beb9c2; }
button:active:not(:disabled) { transform: translateY(1px); }
button.primary, .btn.primary, .btn-primary, form button[type="submit"] { color: white; background: var(--plum); border-color: var(--plum); }
button.primary:hover:not(:disabled), .btn.primary:hover, .btn-primary:hover, form button[type="submit"]:hover:not(:disabled) { background: #4c375a; border-color: #4c375a; }
button.ghost, .btn.ghost, button.link, .text-button { background: transparent; border-color: transparent; color: var(--purple); }
button.danger { color: var(--red); }
.icon-btn, .icon-button { padding: .52rem; width: 39px; min-height: 39px; flex: none; }
svg.icon, .icon svg { width: 1.14em; height: 1.14em; flex: none; vertical-align: -.18em; }
input:not([type="checkbox"]):not([type="radio"]), textarea, select { width: 100%; min-width: 0; padding: .68rem .78rem; color: var(--ink); border: 1px solid #cecdc8; background-color: #fff; border-radius: 8px; font-size: .95rem; line-height: 1.35; }
input[type="number"], input[type="date"], input[type="month"], .num, .amount, .money, td { font-variant-numeric: tabular-nums; }
input::placeholder, textarea::placeholder { color: #848087; }
input[type="checkbox"], input[type="radio"] { width: 1.05rem; height: 1.05rem; accent-color: var(--purple); vertical-align: middle; }
input[type="file"] { font-size: .86rem !important; }
input::file-selector-button { border: 0; border-radius: 5px; padding: .33rem .55rem; margin-right: .55rem; color: var(--plum); background: var(--purple-wash); }
select { appearance: none; padding-right: 2.1rem; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' width='14' height='14' fill='none' stroke='%23625969' stroke-width='1.65' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .68rem center; }
select[multiple] { background-image: none; padding-right: .75rem; }
textarea { min-height: 86px; resize: vertical; }
label { min-width: 0; font-size: .885rem; font-weight: 550; color: #48424c; }
label > input:not([type="checkbox"]):not([type="radio"]), label > select, label > textarea { display: block; margin-top: .34rem; font-weight: 400; }
fieldset { min-width: 0; border: 1px solid var(--line); margin: 0; border-radius: 10px; padding: 1rem; }
legend { padding: 0 .38rem; font-weight: 600; }
details { min-width: 0; }
summary { cursor: pointer; font-weight: 580; color: var(--plum); }
.table-wrap, .table-scroll, .table-container { overflow-x: auto; width: 100%; }
table { width: 100%; border-spacing: 0; border-collapse: collapse; font-size: .9rem; text-align: left; }
th { font-size: .785rem; font-weight: 550; color: var(--muted); background: #f8f8f5; }
th, td { padding: .8rem .95rem; border-bottom: 1px solid #e9e8e4; vertical-align: middle; }
th:first-child, td:first-child { padding-left: 1.25rem; }
th:last-child, td:last-child { padding-right: 1.25rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:has(a,button):hover { background: #faf9f7; }
table button { min-height: 32px; font-size: .8rem; padding: .38rem .62rem; }
pre, code { font-family: ui-monospace, monospace; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition: none !important; } }

/* Owner's workspace */
.shell { min-height: 100dvh; display: grid; grid-template-columns: var(--nav-width) minmax(0,1fr); }
.sidebar { position: sticky; top: 0; height: 100dvh; display: flex; flex-direction: column; gap: 0; padding: 25px 15px 15px; overflow-y: auto; scrollbar-width: thin; color: #f8f7f8; background: var(--plum-deep); }
.brand { display: flex; align-items: center; gap: 12px; min-height: 45px; padding: 0 11px; color: inherit; text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; flex: 0 0 auto; width: 37px; height: 37px; overflow: hidden; border-radius: 10px; color: var(--plum-deep); background: var(--lime); }
.brand-mark svg { display: block; width: 28px; height: 28px; }
.brand-type { display: flex; flex-direction: column; font-weight: 660; font-size: 1.5rem; line-height: 1.08; letter-spacing: -.055em; }
.brand-type small, .brand-type span + span { color: #c3bdc7; margin-top: 4px; font-size: .76rem; line-height: 1.2; font-weight: 400; letter-spacing: 0; }
.nav-label { margin: 40px 11px 9px; color: #b9aebf; font-size: .735rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar .finance-nav-label { margin-top: 20px; }
.sidebar .finance-nav { padding-left: 8px; border-left: 1px solid #51425a; margin-left: 8px; }
.nav-item { display: flex; width: 100%; min-height: 44px; justify-content: flex-start; gap: 12px; padding: 10px 12px; border: 1px solid transparent; border-radius: 9px; text-decoration: none; font-size: .9375rem; font-weight: 480; text-align: left; line-height: 1.3; color: #d6d1da; background: transparent; }
.nav-item svg { flex: none; width: 19px; height: 19px; color: #c6bfc9; }
.nav-item:hover:not(:disabled) { background: #332a3b; border-color: transparent; color: white; }
.nav-item.active, .nav-item.active:hover { color: white; background: #46384f; border-color: #51425a; font-weight: 580; }
.nav-item.active svg { color: var(--lime); }
.sidebar-footer { margin-top: auto; padding-top: 25px; }
.sidebar-footer > :first-child { border-top-color: #463c4c; }
.sidebar-footer small { color: #c9c2ce; }
.workspace { min-width: 0; }
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 14px; min-height: 65px; padding: 9px clamp(20px,3vw,52px); background: rgba(255,255,255,.5); border-bottom: 1px solid var(--line); }
.crumbs, .profile { display: flex; align-items: center; gap: .65rem; min-width: 0; font-size: .86rem; }
.crumbs { color: var(--muted); }
.crumbs a { display: inline-flex; align-items: center; gap: .65rem; color: inherit; text-decoration: none; }
.crumbs a:last-child { color: var(--ink); font-weight: 560; }
.crumbs a:hover { text-decoration: underline; }
.crumbs svg, .profile svg { flex: none; width: 17px; height: 17px; }
.profile { color: #514955; font-weight: 550; }
.profile .avatar, .avatar { display: inline-grid; flex: none; place-items: center; background: #e8e0ef; color: #604b6c; height: 32px; min-width: 32px; border: 1px solid #dcd1e4; border-radius: 50%; font-size: .88rem; font-weight: 620; }
main.content { width: 100%; max-width: 1760px; margin: 0 auto; padding: clamp(24px,3vw,47px) clamp(20px,3vw,52px) 58px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; gap: 16px; margin: 0 0 25px; }
.page-head > div:first-child { min-width: 0; }
.subtitle { margin-top: 6px; color: var(--muted); font-size: .96rem; }
.actions, .toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions > *, .toolbar > * { flex: 0 1 auto; }
.actions .btn, .period { white-space: nowrap; }
.btn.secondary { color: var(--ink); background-color: var(--surface); border-color: #cccac8; }
.btn.secondary:hover { background-color: #f5f3f1; }
.btn.small, .btn-sm { min-height: 31px; padding: .33rem .6rem; font-size: .805rem; border-radius: 7px; }
.btn svg, .icon-btn svg, .period svg { width: 17px; height: 17px; flex: none; }
.period { display: inline-flex; gap: .5rem; align-items: center; color: #443a4c; }
.period input[type="month"], input.period, select.period { width: auto; min-height: 40px; font-size: .9rem; }
.switcher, .tabs { display: inline-flex; gap: 3px; align-items: center; flex-wrap: wrap; width: fit-content; max-width: 100%; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: #ebeae5; }
.tab, .switcher button { min-height: 32px; color: #69636c; padding: .42rem .75rem; font-size: .86rem; font-weight: 550; border-radius: 7px; border: 0; background: transparent; }
.tab:hover:not(:disabled), .switcher button:hover:not(:disabled) { background: #f4f3ee; }
.tab.active, .switcher button.active { color: var(--plum-deep); background: white; box-shadow: 0 1px 3px #2a223220; }
.toolbar { margin: 0 0 16px; }
.toolbar input:not([type="checkbox"]), .toolbar select { width: auto; max-width: 100%; min-height: 39px; font-size: .9rem; }

/* Month overview */
.kpi-grid { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 13px; margin-bottom: 18px; }
.dashboard-kpis { grid-template-columns: repeat(auto-fit,minmax(min(100%,13rem),1fr)); }
.outflow-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,12rem),1fr)); gap: 10px; }
.outflow-grid .kpi { min-height: 130px; justify-content: flex-start; gap: 0; text-align: left; }
.outflow-grid .kpi-icon { margin-bottom: 8px; }
.pricing-table td, .pricing-table th { padding-inline: .55rem; }
.pricing-table input[data-price-field]:is([type="number"],[type="text"]) { min-height: 30px; padding: 4px 6px; border-radius: 5px; font-size: .85rem; }
.pricing-table input[type="number"] { width: 5.1rem; min-width: 0; appearance: textfield; }
.pricing-table input[type="number"]::-webkit-inner-spin-button { appearance: none; }
.pricing-table input[data-price-field="discount"] { width: 3.6rem; }
.pricing-table input[type="text"] { min-width: 8rem; }
.pricing-net { color: var(--muted); white-space: nowrap; }
.pricing-net:not([hidden]) { display: block; margin-top: 3px; }
.pricing-value { white-space: nowrap; font-variant-numeric: tabular-nums; }
.pricing-value[data-price-result="profit"], .pricing-value[data-price-result="margin"] { font-weight: 650; }
.pricing-value .badge { display: table; margin-top: 3px; }
.pricing-table tbody tr:has(input[data-price-field="name"]):not(:first-child) td { border-top: 2px solid var(--line); }
.pricing-excluded { margin-top: 12px; }
.pricing-excluded summary { cursor: pointer; color: var(--purple); }
.pricing-excluded ul { display: grid; gap: 6px; padding-left: 20px; }
.pricing-excluded li .btn { margin-left: 8px; }
.pilot-notes dd { white-space: pre-wrap; }
/* Chats share the same layout inside a project and in the messenger. */
.shell:has(.conversation) { height: 100dvh; min-height: 0; }
.workspace:has(.conversation), .chat-main, .chat-panel, .conversation { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.workspace:has(.conversation) { overflow: auto; }
.workspace:has(.conversation) > .topbar { flex: none; }
main.content:has(.conversation) { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-block: 16px; }
main.content:has(.conversation) > .page-head { flex: none; margin-bottom: 14px; }
.panel.chat-panel { flex: 1; margin-bottom: 0; padding: 14px; }
.chat-panel .panel-head { flex: none; margin-bottom: 9px; }
.chat-panel .panel-head h2 { overflow-wrap: anywhere; }
.conversation { flex: 1; border-radius: 10px; background: #efedf4; }
.chat-history {
  display: flex; flex: 1; flex-direction: column; gap: 7px; min-height: 6rem;
  padding: 14px clamp(10px, 3vw, 34px); overflow-y: auto; overscroll-behavior: contain;
  background: radial-gradient(ellipse at 20% 0, #f2eef8, transparent 55%), linear-gradient(155deg, #f0edea, #e6e7f3);
}
.chat-day {
  align-self: center; flex: none; margin: 3px 0 5px; padding: 3px 9px; border-radius: 999px;
  color: #50485c; background: #fffc; font-size: .75rem; font-weight: 550;
}
.chat-history > .chat-day:first-child { margin-top: auto; }
.chat-message {
  align-self: flex-end; flex: none; width: fit-content; min-width: min(7rem, 100%); max-width: min(84%, 44rem);
  padding: 8px 10px 4px; border-radius: 12px 12px 4px 12px; border: 1px solid #dacfe8;
  background: #f9f5ff; box-shadow: 0 1px 2px #32273312;
}
.chat-message:focus { outline: 2px solid var(--purple); outline-offset: 2px; }
.chat-message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.chat-message-meta { display: flex; justify-content: flex-end; align-items: center; gap: 6px; color: var(--muted); font-size: .74rem; }
.chat-actions summary { width: 23px; border-radius: 5px; text-align: center; cursor: pointer; font-size: .95rem; }
.chat-actions summary:hover { background: #ebe1f4; }
.chat-actions[open] { min-width: min(142px, 100%); }
.chat-popover { display: grid; min-width: 152px; gap: 2px; padding: 5px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); box-shadow: 0 6px 20px #34283c20; }
.chat-popover .btn { justify-content: flex-start; min-height: 34px; padding: 5px 8px; text-align: left; white-space: nowrap; }
.chat-popover .icon { width: 16px; height: 16px; }
.chat-actions .chat-popover { margin-block: 4px; box-shadow: none; }
.chat-actions summary, .chat-tools summary, .chat-emoji summary { list-style: none; }
.chat-actions summary::-webkit-details-marker, .chat-tools summary::-webkit-details-marker, .chat-emoji summary::-webkit-details-marker { display: none; }
.chat-empty, .chat-unselected { margin: auto; }
.chat-notice { font-size: .85rem; margin: 8px 10px; }
.chat-pin, .chat-reply-draft:not([hidden]) { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chat-pin { flex: none; padding: 5px 10px; background: #fff; border-bottom: 1px solid var(--line); }
.chat-pin > button:first-child, .chat-quote { display: block; min-width: 0; min-height: 0; padding: 3px 8px; border: 0; border-left: 3px solid var(--purple); border-radius: 0; text-align: left; background: transparent; font-weight: 400; }
.chat-pin > button:first-child { flex: 1; }
.chat-quote { max-width: 100%; width: 100%; margin-bottom: 5px; background: #eee4f7; border-radius: 3px 6px 6px 3px; }
.chat-pin strong, .chat-quote strong, .chat-reply-draft strong { display: block; color: var(--purple); font-size: .78rem; }
.chat-pin span, .chat-quote span, .chat-reply-draft span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .82rem; }
.chat-reply-draft { grid-column: 1 / -1; padding: 2px 0 5px 8px; border-left: 3px solid var(--purple); }
.chat-reply-draft > div { flex: 1; min-width: 0; }
.chat-compose {
  display: grid; flex: none; grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 5px; align-items: end; margin: 8px 12px 12px; padding: 5px;
  border: 1px solid #d8cfe5; border-radius: 12px; background: var(--surface);
}
.chat-compose textarea { min-height: 36px; max-height: 96px; padding: 7px 9px; border: 0; resize: vertical; }
.chat-icon, .chat-send { display: grid; place-items: center; width: 36px; min-height: 36px; padding: 0; border-radius: 8px; }
.chat-icon { background: transparent; border: 1px solid transparent; color: var(--purple); cursor: pointer; }
.chat-icon:hover { background: var(--purple-wash); }
.chat-icon .icon, .chat-send .icon { width: 18px; height: 18px; }
.chat-tools { display: flex; gap: 4px; }
.chat-attach, .chat-emoji { position: relative; }
.chat-attach .chat-popover, .chat-emoji-options { position: absolute; z-index: 2; bottom: calc(100% + 6px); }
.chat-attach .chat-popover { left: 0; }
.chat-emoji-options { right: 0; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 5px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.chat-emoji-options button { min-height: 28px; padding: 3px; }
.chat-attachment { grid-column: 1 / -1; overflow-wrap: anywhere; }
.chat-attachment:not([hidden]) { display: flex; gap: 8px; align-items: baseline; font-size: .85rem; }
.chat-file { display: inline-flex; align-items: center; gap: 5px; margin-top: 5px; overflow-wrap: anywhere; }
.chat-file .icon { flex: none; width: 15px; height: 15px; }
.chat-compose .error { grid-column: 1 / -1; }
.chat-compose .error:empty { display: none; }

/* Full-height messenger. */
.shell-messenger { height: 100dvh; min-height: 0; grid-template-columns: 86px minmax(0, 1fr); }
.shell-messenger > .sidebar { padding: 14px 6px; align-items: stretch; }
.shell-messenger .brand { min-height: 44px; justify-content: center; padding: 0; }
.shell-messenger .brand-type, .shell-messenger .nav-label { display: none; }
.shell-messenger .nav-item { flex-direction: column; align-items: center; gap: 4px; min-height: 46px; text-align: center; font-size: .68rem; padding: 7px 2px; }
.shell-messenger .sidebar > nav { margin-top: 14px; }
.shell-messenger > .workspace { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.shell-messenger .topbar { flex: none; min-height: 44px; padding: 5px 14px; }
.shell-messenger main.content { flex: 1; min-height: 0; display: flex; width: 100%; max-width: none; padding: 0; }
.messenger { display: grid; flex: 1; min-width: 0; min-height: 0; grid-template-columns: clamp(236px, 28vw, 370px) minmax(0, 1fr); }
.chat-directory { display: flex; flex-direction: column; min-height: 0; min-width: 0; border-right: 1px solid var(--line); background: var(--surface); }
.chat-directory-head { flex: none; padding: 12px 12px 8px; border-bottom: 1px solid var(--line); }
.chat-directory-title { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 5px; margin-bottom: 9px; }
.chat-directory h1 { margin: 0; font-size: 1.2rem; letter-spacing: -.02em; }
.chat-directory input[type="search"] { padding: 7px 9px; border-radius: 8px; }
.chat-filters { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.chat-filters .btn { padding: 3px 7px; min-height: 27px; font-size: .78rem; }
.chat-filters [aria-pressed="true"] { color: var(--plum); background: var(--purple-wash); border-color: #d9cbe4; }
.chat-list { flex: 1; min-height: 0; overflow: auto; padding: 5px 7px; }
.chat-list-empty { margin: 8px; }
.chat-link { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 8px; border-radius: 8px; padding: 7px; color: var(--ink); text-decoration: none; }
.chat-link[hidden] { display: none; }
.chat-link:hover { background: #f4f1f6; }
.chat-link[aria-current="page"] { background: #eae0f2; color: var(--plum); }
.chat-avatar { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 11px; background: #e5d9ef; color: #4c365e; font-size: .8rem; font-weight: 670; }
.chat-avatar-project { background: #e2ead8; color: #40522e; }
.chat-avatar-client { background: #d9e9ee; color: #254e60; }
.chat-avatar-task { background: #ece4d2; color: #5a4929; }
.chat-link-text { min-width: 0; }
.chat-link-text strong, .chat-link-text small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-link-text strong { font-size: .88rem; font-weight: 625; }
.chat-link-text small, .chat-link time { color: var(--muted); font-size: .75rem; }
.chat-link time { align-self: start; white-space: nowrap; }
.messenger .panel.chat-panel { min-width: 0; border: 0; border-radius: 0; padding: 0; }
.messenger .conversation { border-radius: 0; }
.chat-header { display: flex; align-items: center; flex: none; gap: 9px; min-width: 0; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.chat-title { flex: 1; min-width: 0; }
.chat-title h2, .chat-title p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-title h2 { font-size: 1rem; }
.chat-title p { margin: 2px 0 0; color: var(--muted); font-size: .78rem; }
.chat-context-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
.chat-client-body { padding: 20px; overflow: auto; }
.chat-client-body p { margin-bottom: 9px; }
.chat-back { display: none; }
.messenger.chat-with-project { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.messenger.chat-with-project .chat-directory { display: none; }
.messenger.chat-project-expanded { grid-template-columns: minmax(0, 1fr); }
.messenger.chat-project-expanded .chat-main { display: none; }
.chat-project-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--paper); border-left: 1px solid var(--line); }
.chat-project-header { display: flex; align-items: center; justify-content: space-between; flex: none; flex-wrap: wrap; gap: 5px 12px; padding: 10px 13px; background: var(--surface); border-bottom: 1px solid var(--line); }
.chat-project-header h2 { font-size: 1rem; overflow-wrap: anywhere; }
.chat-project-tabs.tabs { flex: none; align-self: flex-start; flex-wrap: wrap; margin: 8px 12px; }
.chat-project-content { min-height: 0; overflow: auto; overscroll-behavior: contain; padding: 2px 12px 12px; }
.chat-project-content .panel { padding: 12px; margin-bottom: 10px; }
@media (max-width: 760px) {
  .shell-messenger > .sidebar { flex: none; flex-direction: row; align-items: center; padding: 5px 8px; }
  .shell-messenger .brand { min-height: 35px; }
  .shell-messenger .sidebar > nav { margin: 0; flex: 1; }
  .shell-messenger .sidebar .nav-item { flex-direction: row; min-height: 34px; font-size: .76rem; padding-inline: 5px; }
  .shell-messenger .sidebar-footer { display: none; }
  .shell:has(.conversation) > .workspace, .shell-messenger > .workspace { flex: 1; min-height: 0; }
  .shell-messenger .topbar { min-height: 35px; }
  .messenger { grid-template-columns: minmax(0, 1fr); }
  .messenger:not(.chat-open) .chat-main, .messenger.chat-open .chat-directory { display: none; }
  .chat-back { display: inline-flex; }
  .chat-emoji-options { grid-template-columns: repeat(6, 1fr); }
  .chat-message { max-width: 93%; }
  .chat-header { padding-inline: 7px; }
  .chat-header:has(.chat-context-links) { flex-wrap: wrap; }
  .chat-header .chat-context-links { flex-basis: 100%; justify-content: flex-start; }
  .messenger.chat-with-project { grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(2, minmax(0, 1fr)); }
  .messenger.chat-project-expanded { grid-template-rows: minmax(0, 1fr); }
  .chat-project-pane { border-left: 0; border-top: 1px solid var(--line); }
  .chat-project-header { padding-block: 4px; }
  .chat-with-project .chat-history { min-height: 0; }
}
input[data-task-done] {
  width: 18px;
  height: 18px;
  margin: 0;
  vertical-align: middle;
  accent-color: var(--purple);
}
input[data-task-done]:disabled { opacity: .8; }
.kpi, .panel { min-width: 0; position: relative; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.kpi { min-height: 162px; padding: 17px 19px 16px; display: flex; flex-direction: column; align-items: flex-start; overflow: hidden; }
.kpi > *, .kpi .kpi-value { z-index: 1; }
.kpi-icon { display: inline-grid; place-items: center; flex: none; width: 31px; height: 31px; margin-bottom: 14px; color: #685575; background: #f0ebf4; border-radius: 9px; }
.kpi-icon svg { width: 17px; height: 17px; }
.kpi:nth-child(2) .kpi-icon { color: #4a655f; background: #ecf1ee; }
.kpi:nth-child(3) .kpi-icon { color: #8c654b; background: #f6eee6; }
.kpi:nth-child(4) .kpi-icon { color: #655c7c; background: #eeedf5; }
.kpi-label { font-size: .84rem; color: #675f69; font-weight: 525; line-height: 1.3; }
.kpi-value { display: block; color: var(--ink); font-size: clamp(1.32rem, 2.15vw, 2.45rem); font-variant-numeric: tabular-nums; font-weight: 610; line-height: 1.12; letter-spacing: -.052em; margin-top: 5px; max-width: 100%; overflow-wrap: anywhere; }
.kpi-foot { color: #79737b; font-size: .785rem; font-weight: 435; line-height: 1.35; margin-top: auto; padding-top: 9px; }
.kpi.featured { color: white; background: #382a42; border-color: #382a42; }
.kpi.featured::after { content: ''; position: absolute; width: 156px; height: 156px; top: -86px; right: -62px; border-radius: 50%; border: 1px solid #786384; box-shadow: 0 0 0 12px #382a42,0 0 0 13px #685572,0 0 0 25px #382a42,0 0 0 26px #5c4a66,0 0 0 38px #382a42,0 0 0 39px #54435e; opacity: .8; pointer-events: none; }
.kpi.featured .kpi-icon { background: var(--lime); color: #34402b; }
.kpi.featured .kpi-label { color: #e4dce9; }
.kpi.featured .kpi-value { color: #fff; }
.kpi.featured .kpi-foot { color: #d2c5d8; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0,1.65fr) minmax(270px,1fr); align-items: stretch; gap: 18px; margin: 0 0 18px; }
.panel { padding: clamp(16px,1.6vw,26px); margin-bottom: 18px; }
.dashboard-grid > .panel { margin-bottom: 0; }
.panel > :last-child, .panel-head > :last-child { margin-bottom: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 9px; margin: 0 0 17px; }
.panel-head h2 { font-size: clamp(1.14rem,1.55vw,1.5rem); }
.panel-head h3 + p, .panel-head h2 + p { color: var(--muted); font-size: .85rem; margin-top: 3px; }
.panel > h2, .panel > h3 { margin-bottom: 12px; }
.chart { min-width: 0; color: #776b7e; }
.chart > svg { display: block; width: 100%; max-height: 330px; overflow: visible; }
.chart text { font-family: inherit; fill: #756f77; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 16px; margin: 8px 0; color: var(--muted); font-size: .8rem; }
.legend > span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { display: inline-block; flex: none; width: 9px; height: 9px; border-radius: 3px; background: var(--purple); }
.legend > :nth-child(2) i { background: var(--lime); }
.fund-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; justify-content: space-between; padding: 12px 0; font-size: .91rem; }
.fund-row + .fund-row { border-top: 1px solid #eeede9; }
.fund-row b, .fund-row strong { font-weight: 600; }
.progress { width: 100%; height: 6px; background: #eeece9; border-radius: 10px; overflow: hidden; }
.progress i { display: block; width: 0; max-width: 100%; height: 100%; background: var(--purple); border-radius: inherit; }
.fund-row:nth-of-type(3n) .progress i { background: #a6bf7a; }
.fund-row:nth-of-type(3n + 1) .progress i { background: #b7a2c8; }
.panel .table-wrap { border-radius: 8px; }
.panel > .table-wrap:last-child { margin-bottom: 0; }
.badge { display: inline-flex; align-items: center; justify-content: center; padding: .25rem .58rem; border-radius: 99px; font-size: .755rem; font-weight: 570; line-height: 1.3; max-width: 100%; }
.badge.good { background: #e7f1e0; color: #365c3f; }
.badge.warn { background: #fff1d8; color: #80541e; }
.badge.bad { background: #f8e6e4; color: #8b3c35; }
.badge.neutral { background: #efedf0; color: #685e70; }
.empty { color: var(--muted); font-size: .92rem; padding: 25px 15px; text-align: center; }
.empty h3, .empty strong { color: var(--ink); }
.empty p, .empty button { margin-top: 7px; }

/* Owner actions */
.modal-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 22px; background: #211a2a75; backdrop-filter: blur(3px); }
.modal { display: flex; flex-direction: column; min-width: 0; width: min(100%,690px); max-height: min(90dvh,920px); border: 1px solid #dad5df; border-radius: 18px; background: #fff; box-shadow: 0 23px 80px #21172437; overflow: hidden; }
.modal:has(.table-wrap) { width: min(100%,900px); }
.modal-head, .modal-foot { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 22px; }
.modal-head { border-bottom: 1px solid var(--line); }
.modal-head button { flex: none; }
.modal-head h2, .modal-head h3 { font-size: 1.31rem; }
.modal-body { padding: 19px 22px 22px; overflow: auto; min-height: 0; overscroll-behavior: contain; }
.modal-body > * + * { margin-top: 12px; }
.modal > form { min-height: 0; display: flex; flex-direction: column; }
.modal-foot { justify-content: flex-end; border-top: 1px solid var(--line); background: #fafaf7; flex-wrap: wrap; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; gap: 14px 16px; }
.field { display: flex; flex-direction: column; min-width: 0; gap: .32rem; }
.field > input, .field > select, .field > textarea { margin-top: 0 !important; }
.field label { font-weight: 550; }
.field :is(small, .help) { color: var(--muted); font-size: .8rem; font-weight: 400; }
.form-grid .wide { grid-column: 1 / -1; }
.form-grid > h3, .form-grid > h4, .form-grid > fieldset, .form-grid > details { grid-column: 1 / -1; }
.form-grid > h3:not(:first-child), .form-grid > h4:not(:first-child) { padding-top: 15px; border-top: 1px solid var(--line); }
.form-grid > details { padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; }
.form-grid > details[open] > summary { margin-bottom: 12px; }
.callout, .error { padding: .75rem .95rem; border-radius: 9px; font-size: .9rem; line-height: 1.45; }
.callout { color: #51415e; background: #f0ebf4; border: 1px solid #e1d8e9; }
.error { color: #8e352f; background: #faeae7; border: 1px solid #edccc6; }
.callout:empty, .error:empty { display: none; }
.toast { position: fixed; z-index: 50; right: min(3vw,30px); bottom: 23px; padding: .8rem 1.05rem; max-width: min(430px,92vw); border-radius: 11px; box-shadow: 0 5px 25px #261a2d2c; color: #fff; font-size: .91rem; background: #352a3e; }
.toast.error { color: #fff; background: #8e352f; border: 0; }
.toast:empty { display: none; }
.login { position: relative; isolation: isolate; min-height: 100dvh; display: grid; place-items: center; padding: 30px 16px; overflow: clip; background-color: #eeeae9; background-image: radial-gradient(ellipse at 0 100%, #e4e7da,transparent 55%),radial-gradient(ellipse at 100% 0%,#e9dfee,transparent 60%); }
.login::before, .login::after { content: ''; position: absolute; z-index: -1; pointer-events: none; border-radius: 50%; border: 1px solid #634c721c; }
.login::before { width: min(78vw,1100px); aspect-ratio: 1; top: -36vw; left: -29vw; box-shadow: 0 0 0 23px #eeeae9,0 0 0 24px #634c721b,0 0 0 47px #eeeae9,0 0 0 48px #634c721a; }
.login::after { width: min(64vw,850px); aspect-ratio: 1; right: -24vw; bottom: -32vw; box-shadow: 0 0 0 27px #eeeae9,0 0 0 28px #634c721b,0 0 0 55px #eeeae9,0 0 0 56px #634c721a; }
.login-card { width: min(100%,444px); padding: clamp(23px,4vw,40px); border: 1px solid #d5d0d6; border-radius: 20px; box-shadow: 0 12px 65px #3c2d4510; background: #fffffd; }
.login-card .brand { padding: 0; margin-bottom: 28px; color: var(--plum); }
.login-card .brand-type small { color: var(--muted); }
.login-card h1 { font-size: clamp(1.75rem,3.2vw,2.28rem); }
.login-card h1 + p, .login-card h2 + p { margin-top: 8px; color: var(--muted); font-size: .94rem; }
.login-card > form, .login-card form { display: grid; gap: 14px; margin-top: 23px; }
.login-card form button[type="submit"] { width: 100%; margin-top: 3px; }
.login-card > small { display: block; margin-top: 16px; }

@media (min-width: 1700px) { :root { --nav-width: 262px; } .sidebar { padding-inline: 22px; } }
@media (max-width: 1160px) {
  :root { --nav-width: 214px; }
  .sidebar { padding-inline: 10px; }
  main.content { padding-inline: 22px; }
  .topbar { padding-inline: 22px; }
  .kpi { padding: 14px; }
  .dashboard-grid { grid-template-columns: minmax(0,1.5fr) minmax(238px,1fr); gap: 13px; }
}
@media (max-width: 980px) {
  :root { --nav-width: 195px; }
  .nav-item { font-size: .88rem; gap: 9px; }
  .brand { padding-inline: 7px; }
  .kpi-grid { grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; }
  .kpi { min-height: 135px; }
  .kpi-icon { margin-bottom: 9px; }
  .kpi-value { font-size: clamp(1.6rem,3.05vw,2rem); }
  .dashboard-grid { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 760px) {
  .shell { display: flex; flex-direction: column; }
  .sidebar { position: relative; width: 100%; height: auto; padding: 12px 14px 9px; overflow: visible; gap: 5px; }
  .brand { width: fit-content; min-height: 35px; padding: 0 3px; }
  .brand-mark { width: 30px; height: 30px; border-radius: 7px; }
  .brand-mark svg { width: 23px; height: 23px; }
  .brand-type { font-size: 1.21rem; }
  .brand-type small { display: none; }
  .sidebar .nav-label { display: none; }
  .sidebar nav { display: flex; gap: 4px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: thin; padding-block: 4px; }
  .nav-item { flex: none; width: auto; min-height: 36px; padding: .45rem .65rem; gap: 6px; white-space: nowrap; font-size: .85rem; }
  .nav-item svg { width: 16px; height: 16px; }
  .sidebar-footer { margin: 0; padding-top: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
  .sidebar-footer:empty { display: none; }
  .sidebar-footer .nav-item { font-size: .8rem; min-height: 30px; }
  .topbar { min-height: 43px; padding: 6px 17px; }
  .crumbs, .profile { font-size: .8rem; }
  main.content { padding: 22px 16px 50px; }
  .page-head { gap: 11px; margin-bottom: 18px; }
  .page-head h1 { font-size: 2rem; }
  .subtitle { font-size: .9rem; }
  .kpi-grid { margin-bottom: 12px; }
  .kpi { border-radius: 12px; }
  .kpi-value { font-size: clamp(1.38rem,4.7vw,2.1rem); }
  .panel { margin-bottom: 12px; }
  .table-wrap { overscroll-behavior-x: contain; }
  .table-wrap th { white-space: nowrap; }
  .modal-backdrop { padding: 10px; }
  .modal { max-height: 94dvh; }
}
@media (max-width: 520px) {
  .form-grid { grid-template-columns: minmax(0,1fr); gap: 12px; }
  .modal-head, .modal-body, .modal-foot { padding-inline: 15px; }
  .modal-head { padding-block: 12px; }
  .modal-foot { padding-block: 11px; }
  th,td { padding: .65rem .7rem; }
  th:first-child, td:first-child { padding-left: .7rem; }
  .kpi { padding: 12px; }
  .kpi-label { font-size: .8rem; }
  .kpi-foot { font-size: .75rem; }
  .kpi-icon { width: 28px; height: 28px; }
  .login-card { border-radius: 14px; }
  .login::before,.login::after { opacity: .5; }
}
.facts{display:grid;grid-template-columns:repeat(auto-fit,minmax(195px,1fr));gap:16px 23px;margin:0}.facts div{min-width:0}.facts dt{font-size:.82rem;color:var(--muted)}.facts dd{margin:.25rem 0 0;font-weight:550;overflow-wrap:anywhere}.quick-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(185px,1fr));gap:10px}.quick-grid .btn{justify-content:flex-start;min-height:48px}.checkrow{display:flex;gap:10px;align-items:center;padding:10px 0;border-bottom:1px solid var(--line)}.checkrow span{flex:1}.checkrow small{display:block}.invoice-line+.invoice-line{margin-top:12px}.period input[type=month]{width:155px}.chart-panel .legend{margin-bottom:16px}.brand img{flex:none}.modal .error:not(:empty){margin-top:12px}.sidebar-footer .nav-item{display:flex}.profile .btn{background:#f1ecf4}.table-wrap td:has(.btn){white-space:nowrap}

.invoice-summary {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8f7fa;
}
.invoice-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; font-size: .85rem; }
.invoice-metrics { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin: 14px 0 0; }
.invoice-metrics dt { font-size: .8rem; }
.invoice-metrics dd { margin: 2px 0 0; font-size: clamp(.9rem, 3vw, 1.35rem); font-weight: 700; overflow-wrap: anywhere; }
.invoice-section { padding: 6px 0; }
.invoice-section h3 { margin: 0 0 5px; font-size: 1rem; }
.invoice-rows { list-style: none; margin: 0; padding: 0; }
.invoice-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 9px 0; }
.invoice-row + .invoice-row { border-top: 1px solid var(--line); }
.invoice-row > div { min-width: 0; overflow-wrap: anywhere; }
.invoice-row > b { white-space: nowrap; }
.invoice-row small:not(:empty) { display: block; }
.invoice-row details { margin-top: 3px; font-size: .81rem; }
.invoice-row summary, .invoice-actions summary { cursor: pointer; width: fit-content; }
.invoice-row details p { margin: 4px 0 0; }
.invoice-actions { border-top: 1px solid var(--line); padding-top: 10px; font-size: .85rem; }
.invoice-actions .actions { margin-top: 9px; flex-wrap: wrap; }

.timesheet-days { display: grid; grid-template-columns: repeat(7,minmax(0,1fr)); gap: 5px; margin: 8px 0 12px; }
.timesheet-day { position: relative; text-align: center; cursor: pointer; }
.timesheet-day input { position: absolute; opacity: 0; margin: 0; }
.timesheet-day span { display: block; padding: 5px; border: 1px solid var(--line); border-radius: 6px; }
.timesheet-day input:checked + span, .timesheet-legend i.worked { background: #28734e; border-color: #28734e; color: #fff; font-weight: 650; }
.timesheet-legend { display: flex; gap: 7px 16px; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.timesheet-legend span { display: inline-flex; align-items: center; gap: 6px; }
.timesheet-legend i { width: 13px; height: 13px; border: 1px solid var(--line); border-radius: 3px; background: var(--surface); }
.timesheet-day input:focus-visible + span { outline: 2px solid currentColor; outline-offset: 2px; }
.timesheet-totals { display: flex; align-items: end; gap: 12px; flex-wrap: wrap; }
.timesheet-day.is-paused span, .timesheet-legend i.paused { background: #d9dce0; color: #343941; border: 1px dashed #6f767e; cursor: default; }

/* Client workspace */
.client-profile { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 22px; }
.client-profile > div, .client-finance-label { min-width: 0; overflow-wrap: anywhere; }
.client-profile-title, .client-profile-contacts, .client-profile-actions,
.client-project-head > div:first-child, .client-project-actions, .client-finance-actions {
  display: flex; align-items: center; flex-wrap: wrap; gap: 7px 12px;
}
.client-profile-title h1 { font-size: clamp(1.65rem,3vw,2.45rem); }
.client-profile-contacts { margin-top: 5px; font-size: .92rem; }
.client-profile-contacts .btn { margin-left: -.35rem; }
.client-project-panel { background: transparent; border: 0; padding: 0; }
.client-project-list { display: grid; gap: 13px; }
.client-project-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(15px,2vw,24px); }
.client-project-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; }
.client-project-head h3 { margin: 0; font-size: clamp(1.16rem,2vw,1.5rem); }
.client-project-price { display: grid; gap: 2px; text-align: right; }
.client-project-price strong { font-size: 1.2rem; white-space: nowrap; }
.client-project-body { display: grid; grid-template-columns: minmax(0,2fr) minmax(0,1fr); gap: 16px 24px; margin: 16px 0; }
.client-project-body-single { grid-template-columns: minmax(0, 24rem); }
.client-project-periods, .client-project-team { display: grid; gap: 9px 16px; margin: 0; }
.client-project-periods { grid-template-columns: repeat(auto-fit,minmax(min(100%,10rem),1fr)); }
.client-project-team { grid-template-columns: repeat(auto-fit,minmax(min(100%,6.5rem),1fr)); }
.client-project-body dt, .client-project-price small, .client-finance-label small { color: var(--muted); font-size: .82rem; }
.client-project-body dd { margin: 3px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.client-project-body small { display: block; margin-top: 2px; }
.client-project-actions { border-top: 1px solid var(--line); padding-top: 11px; font-size: .9rem; }
.client-finance { margin-top: 25px; }
.client-finance-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.client-finance .panel-head { margin-bottom: 7px; }
.client-finance .panel-head h2 { font-size: 1.1rem; }
.client-finance-list { list-style: none; padding: 0; margin: 0; }
.client-finance-list li { display: grid; grid-template-columns: minmax(0,1fr) auto auto; align-items: center; gap: 6px 16px; padding: 10px 0; }
.client-finance-list li + li { border-top: 1px solid var(--line); }
.client-finance-label .btn:first-child { margin-left: -.35rem; }
.client-finance-label small { display: block; }
.client-finance-amount { white-space: nowrap; }
@media (max-width: 830px) {
 .client-project-body { grid-template-columns: 1fr; }
 .client-finance-list li { grid-template-columns: minmax(0,1fr) auto; }
 .client-finance-actions { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
 .client-profile { margin-bottom: 16px; }
 .client-project-actions, .client-profile-contacts { gap: 5px 8px; }
}

.payroll-totals { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px 16px; padding: 12px 15px; margin: 0 0 14px; border: 1px solid var(--line); border-radius: 10px; background: #f8f7fa; }
.payroll-totals dt { color: var(--muted); font-size: .85rem; }
.payroll-totals dd { margin: 3px 0 0; font-size: clamp(1rem,2vw,1.4rem); font-weight: 700; overflow-wrap: anywhere; }

.pause-results { display: grid; gap: 12px; }
.pause-summary { display: grid; grid-template-columns: repeat(auto-fit,minmax(min(100%,10rem),1fr)); gap: 8px; }
.pause-stat { display: grid; gap: 2px; padding: 10px 12px; border: 1px solid #d9dde0; background: #f6f7f7; border-radius: 9px; color: #30373d; }
.pause-stat span { font-size: .83rem; }
.pause-stat strong { font-size: 1.15rem; }
.pause-stat-days { background: #e9ecee; border-color: #d1d6da; }
.pause-stat-applied { background: #e2f0e6; border-color: #bad3c1; color: #215438; }
.pause-month h3 { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; }
.pause-month th { background: #f2f4f4; }
.pause-results details { border-top: 1px solid var(--line); padding-top: 8px; }
.pause-apply .btn.primary { background: #28734e; border-color: #28734e; color: #fff; }
.pause-apply .btn.primary:hover { background: #215f40; border-color: #215f40; }

.registry-filterbar { margin-bottom: 20px; padding: 11px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.registry-controls { margin: 0; }
.registry-controls input[type=search] { flex: 1 1 13rem; min-width: 0; }
.registry-count { color: var(--muted); font-size: .83rem; margin-left: auto; white-space: nowrap; }
.registry-group + .registry-group { margin-top: 24px; }
.registry-group h2 { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; font-size: 1.1rem; }
.registry-debt { color: #842d2d; }

.chat-message.max-incoming { align-self:flex-start; background:var(--surface); }
.chat-compose.max-compose:not(:has(.chat-tools)) { grid-template-columns:minmax(0,1fr) auto auto; }
