@import url('https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,400;14..32,450;14..32,500;14..32,600;14..32,700;14..32,800&display=swap');

:root {
  color-scheme: light;
  --header-height: 64px;
  --sidebar-width: 232px;
  /* Soft, low-glare light theme: off-white surfaces on a gentle field. */
  --bg: #e9ebef;
  --surface: #fafbfd;
  --surface-raised: #ffffff;
  --surface-soft: #eceef3;
  --text: #1c1e25;
  --muted: #676d78;
  --line: #e0e3ea;
  --line-strong: #d3d7e0;
  --primary: #3a55d9;
  --primary-hover: #2f47c2;
  --primary-soft: #e7ebfb;
  --danger: #c63d4b;
  --danger-soft: #fbeaec;
  --success: #1f8158;
  --success-soft: #e4f3ec;
  --warning: #8f6410;
  --warning-soft: #fbf1d8;
  --shadow: 0 1px 2px rgb(23 28 48 / 6%), 0 12px 34px rgb(23 28 48 / 9%);
  --shadow-sm: 0 1px 2px rgb(23 28 48 / 5%), 0 3px 10px rgb(23 28 48 / 5%);
  --radius: 14px;
  --radius-sm: 9px;
  --focus: 0 0 0 3px rgb(58 85 217 / 22%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-optical-sizing: auto;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  /* Premium near-black with a cool undertone and clean elevation steps. */
  --bg: #0d0f14;
  --surface: #16191f;
  --surface-raised: #1c2027;
  --surface-soft: #21252d;
  --text: #ecedf1;
  --muted: #969ca8;
  --line: #282d36;
  --line-strong: #333944;
  --primary: #7f97ff;
  --primary-hover: #94a8ff;
  --primary-soft: #232c4d;
  --danger: #f1848e;
  --danger-soft: #3f242a;
  --success: #6ed2a3;
  --success-soft: #1d3830;
  --warning: #e5b85f;
  --warning-soft: #3b3220;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 20px 54px rgb(0 0 0 / 46%);
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 34%), 0 6px 18px rgb(0 0 0 / 38%);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 280px; min-height: 100vh; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; letter-spacing: -.006em; }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

:focus-visible { outline: none; box-shadow: var(--focus); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 1000; left: 12px; top: -60px; padding: 10px 14px; border-radius: 8px; background: var(--primary); color: white; transition: top .2s; }
.skip-link:focus { top: 10px; }

.boot-screen { position: fixed; z-index: 2000; inset: 0; display: grid; place-items: center; background: var(--bg); }
.boot-screen__spinner { width: 30px; height: 30px; border: 3px solid var(--line); border-top-color: var(--primary); border-radius: 50%; animation: boot-spin .7s linear infinite; }
@keyframes boot-spin { to { transform: rotate(360deg); } }

.login-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 10%, var(--primary-soft), transparent 35%), var(--bg); }
.login-card { width: min(100%, 420px); display: grid; gap: 28px; padding: clamp(28px, 6vw, 44px); border: 1px solid var(--line); border-radius: 20px; background: var(--surface); box-shadow: var(--shadow); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 760; letter-spacing: -.02em; }
.brand--login { font-size: 21px; }
.brand__symbol, .brand__wordmark { display: block; flex: 0 0 auto; background: currentColor; mask: center / contain no-repeat; -webkit-mask: center / contain no-repeat; }
.brand__symbol { width: 30px; height: 35px; mask-image: url('./assets/brand-mark.png'); -webkit-mask-image: url('./assets/brand-mark.png'); }
.brand__wordmark { width: 98px; height: 14px; mask-image: url('./assets/brand-wordmark.png'); -webkit-mask-image: url('./assets/brand-wordmark.png'); }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(24px, 3vw, 32px); line-height: 1.16; letter-spacing: -.035em; }
h2 { letter-spacing: -.025em; }
.eyebrow { margin-bottom: 7px; color: var(--primary); font-size: 11px; font-weight: 750; letter-spacing: .12em; text-transform: uppercase; }
.muted { margin-bottom: 0; color: var(--muted); line-height: 1.5; }

.app { min-height: 100vh; }
.header { position: fixed; z-index: 50; inset: 0 0 auto; height: var(--header-height); display: flex; align-items: center; gap: 18px; padding: 0 24px; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(14px); }
.header__actions { position: relative; display: flex; align-items: center; gap: 8px; margin-left: auto; }
.icon-button { display: inline-grid; width: 40px; height: 40px; padding: 0; place-items: center; border: 0; border-radius: 10px; background: transparent; cursor: pointer; transition: background .18s, color .18s; }
.icon-button:hover { background: var(--surface-soft); }
.menu-button { display: none; }
.menu-button span { display: block; width: 18px; height: 1.5px; margin: 2px; border-radius: 2px; background: currentColor; transition: transform .2s, opacity .2s; }
.profile-button { display: flex; align-items: center; gap: 9px; max-width: 260px; padding: 5px 8px; border: 0; border-radius: 11px; background: transparent; color: var(--text); cursor: pointer; text-align: left; }
.profile-button:hover { background: var(--surface-soft); }
.avatar { display: grid; flex: 0 0 auto; width: 34px; height: 34px; place-items: center; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-size: 13px; font-weight: 800; }
.profile-button__copy { display: grid; min-width: 0; }
.profile-button__copy strong, .profile-button__copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-button__copy strong { font-size: 13px; }
.profile-button__copy small { color: var(--muted); font-size: 11px; }
.profile-button__chevron { color: var(--muted); font-size: 14px; }
.profile-popover { position: absolute; top: calc(100% + 10px); right: 0; z-index: 60; display: grid; gap: 4px; width: min(260px, calc(100vw - 32px)); padding: 6px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-raised); box-shadow: var(--shadow); animation: toast-in .16s ease both; }
.profile-popover__head { display: flex; align-items: center; gap: 10px; padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 2px; }
.profile-popover__id { display: grid; min-width: 0; }
.profile-popover__id strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-popover__id small { color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-popover__item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px; border: 0; border-radius: 10px; background: transparent; color: var(--text); font-size: 13px; font-weight: 640; cursor: pointer; text-align: left; transition: background .15s; }
.profile-popover__item svg { width: 18px; height: 18px; flex: 0 0 auto; }
.profile-popover__item:hover { background: var(--surface-soft); }
.profile-logout { color: var(--danger); }
.profile-logout:hover { background: var(--danger-soft); }

.sidebar { position: fixed; z-index: 40; top: var(--header-height); bottom: 0; left: 0; width: var(--sidebar-width); display: flex; flex-direction: column; padding: 14px 12px 12px; border-right: 1px solid var(--line); background: var(--surface); }
.nav { flex: 1 1 auto; display: flex; flex-direction: column; gap: 16px; overflow-y: auto; padding-bottom: 6px; scrollbar-width: thin; }
.nav::-webkit-scrollbar { width: 6px; }
.nav::-webkit-scrollbar-thumb { border-radius: 99px; background: var(--line-strong); }
.nav__group { display: grid; gap: 2px; }
.nav__label { margin: 0 0 4px; padding: 0 12px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; opacity: .8; }
.nav__item { position: relative; display: flex; min-width: 0; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border: 0; border-radius: 10px; color: var(--muted); background: transparent; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: color .16s, background .16s; }
.nav__item svg { flex: 0 0 auto; width: 19px; height: 19px; opacity: .85; }
.nav__item:hover { color: var(--text); background: var(--surface-soft); }
.nav__item.is-active { color: var(--primary); background: var(--primary-soft); font-weight: 680; }
.nav__item.is-active svg { opacity: 1; }
.nav__item.is-active::before { content: ""; position: absolute; left: -12px; top: 50%; width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--primary); transform: translateY(-50%); }
.nav__badge { min-width: 20px; margin-left: auto; padding: 2px 6px; border-radius: 99px; background: var(--surface-soft); color: var(--muted); font-size: 10px; font-weight: 700; text-align: center; }
.nav__item.is-active .nav__badge { background: color-mix(in srgb, var(--primary) 16%, transparent); color: var(--primary); }
.sidebar__footer { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.nav__item--button { width: 100%; }
.sidebar-collapse { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 40px; margin-top: 8px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; transition: color .16s, background .16s, border-color .16s; }
.sidebar-collapse:hover { color: var(--text); background: var(--surface-soft); border-color: var(--line-strong); }
.sidebar-collapse__icon { flex: 0 0 auto; width: 18px; height: 18px; transition: transform .2s ease; }
.sidebar-collapse__label { white-space: nowrap; }
.app.is-sidebar-collapsed { --sidebar-width: 74px; }
.app.is-sidebar-collapsed .sidebar { padding-inline: 8px; }
.app.is-sidebar-collapsed .nav { gap: 8px; }
.app.is-sidebar-collapsed .nav__label { height: 1px; margin: 4px 10px; padding: 0; overflow: hidden; color: transparent; background: var(--line); }
.app.is-sidebar-collapsed .nav__item { position: relative; justify-content: center; padding-inline: 8px; }
.app.is-sidebar-collapsed .nav__item.is-active::before { display: none; }
.app.is-sidebar-collapsed .nav__item > span:not(.nav__badge) { display: none; }
.app.is-sidebar-collapsed .nav__badge { position: absolute; margin: -27px 0 0 25px; padding: 1px 4px; min-width: 16px; }
.app.is-sidebar-collapsed .sidebar-collapse { justify-content: center; padding-inline: 8px; }
.app.is-sidebar-collapsed .sidebar-collapse__label { display: none; }
.app.is-sidebar-collapsed .sidebar-collapse__icon { transform: rotate(180deg); }

.main { margin-left: var(--sidebar-width); padding: calc(var(--header-height) + 32px) clamp(20px, 4vw, 52px) 48px; }
.view { display: none; width: min(100%, 1400px); margin: 0 auto; animation: view-in .22s ease both; }
.view.is-active { display: block; }
@keyframes view-in { from { opacity: 0; transform: translateY(5px); } }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 26px; }
.page-heading h1 { margin-bottom: 0; }
.page-heading__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
/* nowrap keeps a shrunken flex item from wrapping its label onto a second line, which
   made the button taller than the inputs standing next to it. */
.button { display: inline-flex; min-height: 40px; align-items: center; justify-content: center; gap: 7px; padding: 8px 15px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); font-size: 13px; font-weight: 680; white-space: nowrap; cursor: pointer; transition: transform .15s, border-color .15s, background .15s; }
.toolbar > .button, .filters > .button { flex: 0 0 auto; }
.button:hover { border-color: color-mix(in srgb, var(--muted) 55%, var(--line)); }
.button:active { transform: translateY(1px); }
.button--primary { border-color: var(--primary); background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgb(30 45 120 / 22%), inset 0 1px 0 rgb(255 255 255 / 14%); }
.button--primary:hover { border-color: var(--primary-hover); background: var(--primary-hover); box-shadow: 0 3px 12px rgb(30 45 120 / 26%), inset 0 1px 0 rgb(255 255 255 / 14%); }
.button--danger { border-color: var(--danger-soft); color: var(--danger); background: var(--danger-soft); }
.button--wide { width: 100%; }
.button[disabled] { opacity: .55; pointer-events: none; }

.toolbar, .filters { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.toolbar { justify-content: space-between; }
.audit-filters { align-items: flex-end; }
.segmented { display: inline-flex; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.segmented button { min-width: 38px; height: 38px; padding: 0 11px; border: 0; border-right: 1px solid var(--line); background: transparent; cursor: pointer; }
.segmented button:last-child { border-right: 0; }
.segmented button:hover { background: var(--surface-soft); }
.calendar-title { margin: 0; font-size: 18px; text-align: center; }
.calendar-navigation { position: relative; }
.calendar-navigation #calendar-month-trigger { min-width: 155px; font-weight: 700; }
.calendar-navigation input[type="month"] { position: absolute; inset: 0; width: 100%; opacity: 0; pointer-events: none; }
.compact-field select, .search { height: 40px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); }
.compact-field select { max-width: 210px; padding: 0 34px 0 11px; }
.search { display: flex; flex: 1 1 300px; max-width: 420px; align-items: center; gap: 8px; padding: 0 11px; }
.search svg { width: 17px; color: var(--muted); }
.search input { min-width: 0; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); }

.calendar-shell { overflow: hidden; border: 0; border-radius: var(--radius); background: var(--surface-soft); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.calendar-weekday { padding: 11px 8px; color: var(--muted); font-size: 10px; font-weight: 740; letter-spacing: .08em; text-align: center; text-transform: uppercase; }
.calendar-day { position: relative; min-height: 82px; padding: 7px; border: 0; background: #e7e9ed; color: #24272d; text-align: left; }
.calendar-day:nth-child(7n) { border-right: 0; }
.calendar-day.is-outside { background: #f3f4f6; color: #9398a1; }
.calendar-day.is-today { background: #343943; color: #fff; }
.calendar-day.is-today .calendar-day__number { background: transparent; color: inherit; }
:root[data-theme="dark"] .calendar-shell { background: #171a20; }
:root[data-theme="dark"] .calendar-day { background: #2b3039; color: #f2f3f5; }
:root[data-theme="dark"] .calendar-day.is-outside { background: #20232a; color: #747b87; }
:root[data-theme="dark"] .calendar-day.is-today { background: #e2e5ea; color: #16181c; }
.calendar-day.is-today .calendar-summary { background: #4a505c; color: #fff; }
:root[data-theme="dark"] .calendar-day.is-today .calendar-summary { background: #cdd1d8; color: #16181c; }
.calendar-day__number { display: grid; width: 25px; height: 25px; margin-left: auto; place-items: center; border-radius: 50%; font-size: 11px; font-weight: 690; }
.calendar-summary { display: inline-flex; align-items: center; gap: 6px; margin-top: 12px; padding: 4px 7px; border-radius: 7px; background: var(--surface-soft); font-size: 11px; }
.calendar-summary i { width: 7px; height: 7px; border-radius: 50%; background: #e5aa25; }
.calendar-summary.is-closed i { background: #2ca56c; }
.calendar-summary.is-overdue i { background: #db4d4d; }
.calendar-events { display: grid; gap: 4px; margin-top: 7px; }
.calendar-event { overflow: hidden; width: 100%; padding: 5px 6px; border: 0; border-left: 3px solid var(--event-color, var(--primary)); border-radius: 5px; background: color-mix(in srgb, var(--event-color, var(--primary)) 13%, var(--surface)); color: var(--text); font-size: 10px; text-align: left; text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.calendar-more { color: var(--muted); font-size: 10px; text-align: center; }

.table-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 12px 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 10px; font-weight: 720; letter-spacing: .07em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 15px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .15s; }
tbody tr:hover { background: color-mix(in srgb, var(--surface-soft) 55%, transparent); }
.cell-title { display: grid; min-width: 140px; gap: 3px; }
.cell-title strong { font-size: 13px; }
.cell-title small, .cell-muted { color: var(--muted); font-size: 11px; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px; border-radius: 99px; font-size: 10px; font-weight: 720; white-space: nowrap; }
.status::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.status--new { color: var(--primary); background: var(--primary-soft); }
.status--in_progress { color: var(--warning); background: var(--warning-soft); }
.status--waiting { color: #8a5ca8; background: color-mix(in srgb, #9d64bd 15%, var(--surface)); }
.status--completed { color: var(--success); background: var(--success-soft); }
.status--cancelled { color: var(--danger); background: var(--danger-soft); }
.row-action { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; transition: background .15s, color .15s, border-color .15s, transform .12s; }
.row-action svg { width: 18px; height: 18px; }
.row-action:hover { background: var(--surface-soft); color: var(--text); }
.row-action:active { transform: translateY(1px); }
.row-action--take { border: 1px solid color-mix(in srgb,var(--primary) 26%,var(--line)); background: var(--primary-soft); color: var(--primary); }
.row-action--take:hover { border-color: var(--primary); background: color-mix(in srgb,var(--primary) 16%,var(--surface)); color: var(--primary); }
.row-action--inspect { border: 1px solid var(--line); background: var(--surface-soft); color: var(--muted); }
.row-action--inspect:hover { border-color: var(--line-strong); color: var(--text); }
.quick-actions { display: flex; justify-content: flex-end; gap: 6px; }
.empty-state { padding: 55px 20px; text-align: center; }
.empty-state span { display: grid; width: 45px; height: 45px; margin: 0 auto 14px; place-items: center; border-radius: 50%; background: var(--success-soft); color: var(--success); }
.empty-state h2 { margin-bottom: 5px; font-size: 16px; }
.empty-state p { margin: 0; color: var(--muted); font-size: 13px; }

/* Applications list on mobile: rows become cards instead of a sideways-scrolling table. */
@media (max-width: 680px) {
  .applications-table thead { display: none; }
  .applications-table, .applications-table tbody, .applications-table tr { display: block; width: 100%; }
  .applications-table tbody tr { padding: 14px 16px; border-bottom: 1px solid var(--line); }
  .applications-table tbody tr:last-child { border-bottom: 0; }
  .applications-table td { display: block; padding: 0; border-bottom: 0; }
  .applications-table td + td { margin-top: 9px; }
  .applications-table td[data-label="Создана"], .applications-table td[data-label="Исполнитель"], .applications-table td[data-label="Статус"] { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .applications-table td[data-label]::before { content: attr(data-label); flex: 0 0 auto; color: var(--muted); font-size: 10px; font-weight: 720; letter-spacing: .04em; text-transform: uppercase; }
  .applications-table td[data-label="Проект"]::before { display: block; margin-bottom: 4px; }
  .applications-table td:last-child { margin-top: 12px; }
  .applications-table .quick-actions { justify-content: flex-start; }
}

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 310px), 1fr)); gap: 16px; }
.service-card { display: grid; gap: 18px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color .18s, box-shadow .18s, transform .18s; }
.service-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.service-card__head { display: flex; gap: 12px; align-items: start; }
.service-color { width: 10px; height: 38px; flex: 0 0 auto; border-radius: 5px; background: var(--service-color); }
.service-card h2 { margin: 0 0 3px; font-size: 16px; overflow-wrap: anywhere; }
.service-card p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.service-card__meta { display: flex; gap: 15px; color: var(--muted); font-size: 11px; }
.service-fields { display: flex; flex-wrap: wrap; gap: 6px; }
.service-fields > span { color: var(--muted); font-size: 11px; }
.service-fields button { display: grid; gap: 1px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); color: var(--text); font-size: 11px; text-align: left; cursor: pointer; }
.service-fields button:hover { border-color: var(--primary); }
.service-fields small { color: var(--muted); font-size: 9px; }
.service-card__actions { display: flex; flex-wrap: wrap; gap: 7px; padding-top: 15px; border-top: 1px solid var(--line); }
.project-note { margin: -8px 0 22px; padding: 16px 18px; border: 0; border-left: 3px solid var(--primary); border-radius: 0 10px 10px 0; background: var(--primary-soft); color: var(--muted); font-size: 13px; line-height: 1.55; }
.project-note strong { color: var(--text); }

.timeline { position: relative; display: grid; gap: 0; max-width: 800px; }
.timeline::before { position: absolute; inset: 14px auto 14px 15px; width: 1px; background: var(--line); content: ""; }
.timeline-item { position: relative; display: grid; grid-template-columns: 31px 1fr; gap: 14px; padding: 0 0 24px; }
.timeline-item__dot { z-index: 1; width: 31px; height: 31px; border: 7px solid var(--bg); border-radius: 50%; background: var(--primary); }
.timeline-item__content { padding: 13px 15px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.timeline-item__content p { margin: 0 0 6px; font-size: 13px; }
.timeline-item__content small { color: var(--muted); }
.audit-rows { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.audit-row { display: grid; width: 100%; grid-template-columns: minmax(180px, 1fr) minmax(240px, 2fr) 145px; gap: 18px; align-items: center; padding: 15px 18px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.audit-row:hover { background: var(--surface-soft); }
.audit-row:last-child { border-bottom: 0; }
.audit-row strong { font-size: 13px; }
.audit-row p { margin: 0; color: var(--muted); font-size: 12px; }
.audit-row time { color: var(--muted); font-size: 11px; text-align: right; }
.field--compact { display: flex; align-items: center; gap: 7px; }
.field--compact input { width: auto; }
.status-list { display: grid; gap: 9px; }
.status-row { display: grid; grid-template-columns: auto 10px minmax(160px, 1fr) auto auto; gap: 15px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.status-row.is-dragging { opacity: .45; }
.drag-handle { color: var(--muted); cursor: grab; user-select: none; }
.status-row__color { width: 10px; height: 36px; border-radius: 5px; background: var(--status-color); }
.status-row small { color: var(--muted); }
.status-kind { padding: 5px 9px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 700; }
.status-kind.is-closing { background: color-mix(in srgb, #d94a4a 13%, var(--surface)); color: #d94a4a; }
.editor-card { display: grid; gap: 18px; padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.editor-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.editor-heading .field { flex: 1; }
.table-group th { padding: 11px 14px; background: var(--surface-soft); color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.profile-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.profile-stats article { display: grid; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.profile-stats small { color: var(--muted); }
.profile-stats strong { font-size: 18px; }
/* Журнал: карточка изменения. Пара «было → стало» подписана и разделена стрелкой —
   раньше две цветные плашки стояли рядом без подписей, и направление правки читалось
   только по цвету. Цвета взяты из токенов темы: захардкоженные красный и зелёный
   не проходили по контрасту на тёмном фоне. */
.audit-changes { display: grid; gap: 14px; }
.audit-change-list { display: grid; gap: 9px; }
.audit-change { display: grid; gap: 9px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface); }
.audit-change__field { color: var(--muted); font-size: 10.5px; font-weight: 720; letter-spacing: .06em; text-transform: uppercase; }
.audit-change__diff { display: grid; grid-template-columns: 1fr auto 1fr; align-items: stretch; gap: 10px; }
.audit-change__side { display: grid; gap: 5px; min-width: 0; }
.audit-change__side small { color: var(--muted); font-size: 10.5px; font-weight: 600; }
.audit-change__arrow { align-self: center; color: var(--muted); font-size: 15px; padding-top: 14px; }
.audit-changes del, .audit-changes ins { display: block; padding: 8px 10px; border-radius: 8px; font-size: 13px; text-decoration: none; overflow-wrap: anywhere; }
.audit-changes del { border: 1px solid color-mix(in srgb, var(--danger) 26%, transparent); background: var(--danger-soft); color: var(--danger); }
.audit-changes ins { border: 1px solid color-mix(in srgb, var(--success) 30%, transparent); background: var(--success-soft); color: var(--success); }
.audit-change--single { grid-template-columns: auto 1fr; align-items: baseline; gap: 14px; }
.audit-change__value { font-size: 13.5px; font-weight: 650; text-align: right; overflow-wrap: anywhere; }
@media (max-width: 560px) {
  .audit-change__diff { grid-template-columns: 1fr; gap: 6px; }
  .audit-change__arrow { justify-self: start; padding: 0; transform: rotate(90deg); }
  .audit-change--single { grid-template-columns: 1fr; gap: 5px; }
  .audit-change__value { text-align: left; }
}
.editor-card__footer { display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.editor-card__footer small { color: var(--muted); }

.field { display: grid; gap: 4px; min-width: 0; }
.field > span { color: var(--muted); font-size: 11px; font-weight: 690; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); outline: 0; transition: border-color .18s, box-shadow .18s; }
/* Radios and checkboxes must keep their intrinsic size — stretching them to 100% pushed
   the labels on top of each other in choice dialogs. */
/* justify-self matters: .field is a grid, and a grid item stretches to the column width,
   so `width:auto` alone still rendered a full-width radio. */
.field input[type="radio"], .field input[type="checkbox"] { width: auto; flex: 0 0 auto; justify-self: start; }
.field input, .field select { height: 42px; padding: 0 11px; }
.field textarea { resize: vertical; padding: 10px 11px; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: var(--focus); }
.field input[type="checkbox"] { appearance: none; display: inline-grid; width: 18px; min-width: 18px; height: 18px; margin: 0; padding: 0; place-content: center; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); vertical-align: middle; cursor: pointer; transition: background .15s, border-color .15s; }
.field input[type="checkbox"]:hover { border-color: var(--primary); }
.field input[type="checkbox"]::before { width: 11px; height: 11px; content: ""; background: #fff; transform: scale(0); transition: transform .14s ease; clip-path: polygon(41% 67%, 12% 40%, 0 52%, 41% 91%, 100% 22%, 88% 12%); }
.field input[type="checkbox"]:checked { border-color: var(--primary); background: var(--primary); }
.field input[type="checkbox"]:checked::before { transform: scale(1); }
.field input[type="checkbox"]:focus-visible { outline: none; box-shadow: var(--focus); }
.check-row { display: flex; align-items: center; gap: 9px; min-height: 34px; color: var(--text) !important; cursor: pointer; }
.color-control { position: relative; }
.color-control input[type="text"] { padding-right: 48px; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; text-transform: uppercase; }
.color-control input[type="color"] { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; padding: 2px; border-radius: 7px; cursor: pointer; }
.tag-picker { min-width: 0; margin: 0; padding: 0; border: 0; }
.tag-picker legend { margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 690; }
.tag-picker > div { display: flex; flex-wrap: wrap; gap: 7px; }
.tag-option { position: relative; }
.tag-option input { position: absolute; opacity: 0; pointer-events: none; }
.tag-option span { display: inline-flex; align-items: center; gap: 6px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); font-size: 12px; cursor: pointer; }
.tag-option span::before { width: 7px; height: 7px; border-radius: 50%; background: var(--tag-color); content: ""; }
.tag-option input:checked + span { border-color: var(--tag-color); background: color-mix(in srgb, var(--tag-color) 13%, var(--surface)); }
.project-combobox { position: relative; z-index: 4; }
.project-combobox__control { position: relative; display: flex; align-items: center; }
.project-combobox__control > svg { position: absolute; left: 12px; width: 17px; color: var(--muted); pointer-events: none; }
.project-combobox__control input { padding-right: 40px; padding-left: 38px; border-color: color-mix(in srgb, var(--line) 52%, transparent); border-radius: 14px; background: color-mix(in srgb, var(--surface) 82%, transparent); }
.project-combobox__control button { position: absolute; right: 7px; display: grid; width: 28px; height: 28px; padding: 0; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 20px; cursor: pointer; }
.project-combobox__control button:hover { background: var(--surface-soft); color: var(--text); }
.project-combobox__results { position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; left: 0; max-height: 260px; overflow-y: auto; padding: 6px; border: 1px solid color-mix(in srgb, var(--line) 58%, transparent); border-radius: 14px; background: var(--surface-raised); box-shadow: var(--shadow); }
.project-combobox__results .project-option { position: relative; display: block; }
.project-combobox__results .project-option input { position: absolute; opacity: 0; pointer-events: none; }
.project-combobox__results .project-option span { display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 8px 10px; border-radius: 7px; color: var(--text); font-size: 13px; cursor: pointer; }
.project-combobox__results .project-option span::before { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--tag-color); content: ""; }
.project-combobox__results .project-option:hover span, .project-combobox__results .project-option input:checked + span { background: var(--primary-soft); }
.project-combobox__empty { display: block; padding: 12px 10px; color: var(--muted); font-size: 12px; }
.day-orders { display: grid; gap: 8px; }
.day-order { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); text-align: left; cursor: pointer; }
.day-order small { color: var(--muted); }
.day-order small { display: block; margin-top: 7px; }
.nav__badge { transition: background .2s, color .2s, box-shadow .2s; }
.nav__badge.is-new { background: #ff3b4f; color: #fff; box-shadow: 0 0 0 4px color-mix(in srgb, #ff3b4f 18%, transparent); }
.status-flags { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.roles-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); }
.role-card { position: relative; overflow: hidden; display: grid; grid-template-rows: auto auto 1fr auto; gap: 14px; min-height: 210px; padding: 20px 20px 20px 23px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); transition: border-color .18s, box-shadow .18s, transform .18s; }
.role-card::after { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--role-color); }
.role-card:hover { border-color: var(--line-strong); box-shadow: var(--shadow); transform: translateY(-2px); }
.role-card__head { display: flex; align-items: center; gap: 11px; }
.role-card__dot { width: 12px; height: 12px; flex: 0 0 auto; border-radius: 50%; background: var(--role-color); box-shadow: 0 0 0 4px color-mix(in srgb, var(--role-color) 16%, transparent); }
.role-card__title { display: grid; gap: 2px; min-width: 0; }
.role-card__title h2 { margin: 0; font-size: 16px; }
.role-card__title code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11px; color: var(--muted); }
.role-card__tag { margin-left: auto; padding: 4px 9px; border-radius: 99px; background: var(--surface-soft); color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.role-card__count { color: var(--muted); font-size: 12px; font-weight: 640; }
.role-card__actions { align-self: end; }
.role-permissions { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 6px; }
.badge { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 4px 9px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge--accent { border-color: color-mix(in srgb, var(--primary) 30%, var(--line)); background: var(--primary-soft); color: var(--primary); }
.badge--more { background: transparent; color: var(--muted); font-weight: 700; }
.permissions-list { display: grid; gap: 9px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; }
.permissions-list legend { padding: 0 5px; color: var(--muted); font-size: 12px; }
.permissions-list .is-inherited { color:var(--muted); opacity:.78; }
.audit-application { display: grid; gap: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; }
.audit-application h3 { margin: 0; padding: 13px; background: var(--surface-soft); font-size: 14px; }
.audit-application div { display: grid; grid-template-columns: minmax(110px, .7fr) 1.5fr; gap: 12px; padding: 10px 13px; border-top: 1px solid var(--line); }
.audit-application span { color: var(--muted); font-size: 12px; }
.audit-application__table { display: grid !important; grid-template-columns: repeat(4, minmax(110px, 1fr)) !important; gap: 0 !important; padding: 0 !important; }
.audit-application__table > span { display: grid; gap: 4px; padding: 13px; border-right: 1px solid var(--line); color: var(--text); }
.audit-application__table > span:last-child { border-right: 0; }
.audit-application__table small { color: var(--muted); font-size: 10px; }
.form-stack { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.field--full { grid-column: 1 / -1; }
.form-error { min-height: 18px; margin: 0; color: var(--danger); font-size: 12px; }
.dynamic-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.dynamic-field { grid-template-rows: auto 30px auto; align-content: start; gap: 2px; }
.field-hint { min-height: 15px; overflow: hidden; color: var(--muted); font-size: 11px; line-height: 1.35; display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2; }
.status-kind--auto{background:var(--primary-soft);color:var(--primary)}
.project-edit-button { width: 100%; margin-top: auto; }
.project-card { display: flex; min-height: 260px; flex-direction: column; }
.advanced-search { display: grid; gap: 16px; margin-bottom: 14px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); animation: toast-in .16s ease both; }
.advanced-search__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.advanced-search__head h3 { margin: 0; font-size: 15px; }
.advanced-search__head .eyebrow { margin-bottom: 2px; }
.advanced-search__grid { display: grid; grid-template-columns: repeat(2, minmax(140px, 220px)) 1fr; align-items: end; gap: 16px; }
.advanced-search__grid .switch { justify-self: start; height: 42px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
.switch { display: inline-flex; align-items: center; gap: 11px; cursor: pointer; }
.switch > input { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.switch__track { position: relative; flex: 0 0 auto; width: 40px; height: 23px; border-radius: 99px; background: var(--line-strong); transition: background .18s; }
.switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / 28%); transition: transform .18s; }
.switch > input:checked + .switch__track { background: var(--primary); }
.switch > input:checked + .switch__track::after { transform: translateX(17px); }
.switch > input:focus-visible + .switch__track { box-shadow: var(--focus); }
.switch__text { display: grid; gap: 1px; font-size: 13px; font-weight: 640; line-height: 1.25; }
.switch__text small { color: var(--muted); font-weight: 500; font-size: 11px; }
/* Stands in for the missing <span>label</span> row on label-less switch fields, so their
   track lines up with the input box of a sibling field in the same grid row instead of
   sitting a row higher (align-items: start can't fix this — the rows are genuinely different
   heights without it). */
.field-label-spacer { visibility: hidden; }
/* Track+text alone (~23px) reads as floating above a 42px-tall sibling input/select even
   once the top edges line up — matching the height (like .field input) centers it in the
   same space so it visually sits level with its neighbour, not just top-aligned with it. */
.editor-section__grid .switch, .form-grid .switch { height: 42px; }
.assign-trigger { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 640; text-align: left; cursor: pointer; transition: border-color .15s, background .15s; }
.assign-trigger:hover { border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); background: var(--surface-soft); }
.assign-trigger__label { display: grid; gap: 3px; }
.assign-trigger__arrow { flex: 0 0 auto; color: var(--muted); font-size: 16px; transition: transform .15s, color .15s; }
.assign-trigger:hover .assign-trigger__arrow { transform: translateX(3px); color: var(--primary); }
.assign-count { display: block; color: var(--muted); font-size: 11px; font-weight: 500; }
.assign-picker { display: grid; gap: 12px; }
.assign-picker__all { padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.assign-picker__list { display: grid; gap: 2px; min-height: 296px; max-height: 320px; overflow-y: auto; align-content: start; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 5px; padding: 10px; border-top: 1px solid var(--line); }
.pagination__pages { display: flex; gap: 4px; }
.pagination__button { display: inline-grid; width: 30px; height: 30px; padding: 0; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer; transition: background .15s, color .15s; }
.pagination__button:hover:not(:disabled) { background: var(--surface-soft); color: var(--text); }
.pagination__button.is-active { background: var(--primary-soft); color: var(--primary); font-weight: 750; }
.pagination__button:disabled { opacity: .3; cursor: default; }
.status-filter { position: relative; }
.status-filter__trigger { position: relative; max-width: min(280px, 75vw); height: 40px; overflow: hidden; padding: 0 30px 0 11px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); color: var(--text); text-overflow: ellipsis; white-space: nowrap; cursor: pointer; }
.status-filter__trigger::after { position: absolute; top: 15px; right: 11px; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1px 1px 0; content: ""; transform: rotate(45deg); }
.status-filter__menu { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; display: grid; min-width: 220px; max-height: 280px; overflow-y: auto; padding: 7px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-raised); box-shadow: var(--shadow); }
.status-filter__menu[hidden] { display: none; }
.status-filter__option { display: grid; grid-template-columns: 18px 8px 1fr; gap: 8px; align-items: center; min-height: 38px; padding: 5px 8px; border-radius: 7px; font-size: 12px; cursor: pointer; }
.status-filter__option:hover { background: var(--surface-soft); }
.status-filter__option input { width: 16px; height: 16px; margin: 0; accent-color: var(--primary); }
.status-filter__option i { width: 7px; height: 7px; border-radius: 50%; background: var(--status-color); }
.project-tags-editor { display: grid; gap: 6px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-soft); }
/* Fixed columns: a flex row let the variable-width name chip push price and payout to
   different x positions on every line. */
.project-tag-row { display: grid; grid-template-columns: minmax(0,1fr) 92px 132px auto; align-items: center; gap: 10px; min-height: 42px; padding: 5px 7px 5px 10px; border-radius: 8px; background: var(--surface); }
.project-tag-row > strong{text-align:right;font-size:12px;font-variant-numeric:tabular-nums}
.project-tag-row > small{color:var(--muted);font-size:10.5px;text-align:right}
.project-tag-row__actions{display:flex;align-items:center;gap:4px}
.project-tag-row .badge{min-width:0;overflow:hidden}
.project-tag-row .badge span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.project-tag-row .badge { display: inline-flex; align-items: center; gap: 7px; }
.project-tag-row .badge i { width: 8px; height: 8px; border-radius: 50%; }
.row-action--danger { color: var(--danger); }
.tag-add-button { width: max-content; margin-top: 8px; }
.phone-control { display: flex; gap: 7px; }
.phone-control input { flex: 1; }
.call-button, .table-call { display: none; }
.project-fields-heading { margin-top: 28px; }
.project-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 9px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.project-fields button { display: grid; gap: 5px; padding: 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); color: var(--text); text-align: left; cursor: pointer; }
.schedule-row { display: grid; grid-template-columns: minmax(105px, 1fr) 1fr 1fr auto; align-items: end; gap: 10px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.schedule-row:last-child { padding-bottom: 0; border-bottom: 0; }
.schedule-row strong { align-self: center; font-size: 12px; }

.modal { width: min(94vw, 680px); max-height: min(90vh, 800px); padding: 0; border: 0; border-radius: 17px; background: var(--surface-raised); color: var(--text); box-shadow: var(--shadow); }
.modal--small { width: min(94vw, 480px); }
.modal::backdrop { background: rgb(8 10 15 / 52%); backdrop-filter: blur(2px); }
.modal[open] { animation: modal-in .2s ease both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.985); } }
.modal__surface { display: flex; max-height: min(90vh, 800px); flex-direction: column; }
.modal__header, .modal__footer { display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; }
.modal__header { border-bottom: 1px solid var(--line); }
.modal__header h2 { margin: 0; font-size: 19px; }
.modal__header .eyebrow { margin-bottom: 3px; }
.modal__body { overflow-y: auto; padding: 22px; overscroll-behavior: contain; }
.modal__footer { justify-content: flex-end; border-top: 1px solid var(--line); }
.modal__spacer { flex: 1; }
.modal-error { padding: 0 22px; }

.toast-region { position: fixed; z-index: 100; right: 18px; top: calc(var(--header-height) + 14px); display: grid; gap: 8px; width: min(360px, calc(100vw - 36px)); }
.toast { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised); box-shadow: var(--shadow); font-size: 13px; cursor: pointer; animation: toast-in .22s ease both; }
.toast--error { border-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
.loading { min-height: 200px; display: grid; place-items: center; color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .menu-button { display: inline-grid; }
  .header { padding: 0 16px; }
  .sidebar { width: min(82vw, 290px); transform: translateX(-105%); box-shadow: var(--shadow); transition: transform .24s cubic-bezier(.2,.7,.2,1); }
  .sidebar.is-open { transform: translateX(0); }
  .mobile-backdrop { position: fixed; z-index: 35; inset: var(--header-height) 0 0; background: rgb(5 7 12 / 42%); }
  .main { margin-left: 0; padding-inline: 18px; }
  .profile-button { max-width: 190px; }
}

@media (max-width: 680px) {
  .header { gap: 9px; }
  .brand { font-size: 16px; }
  .brand__wordmark { display: none; }
  .profile-button { max-width: 155px; }
  .brand__mark { width: 31px; height: 31px; }
  .main { padding-top: calc(var(--header-height) + 22px); padding-bottom: 30px; }
  .page-heading { align-items: stretch; flex-direction: column; margin-bottom: 20px; }
  .page-heading .button { width: 100%; }
  .toolbar { align-items: stretch; flex-wrap: wrap; }
  .calendar-title { order: -1; width: 100%; text-align: left; }
  .toolbar .compact-field { width: 100%; margin-left: auto; }
  .filters { align-items: stretch; flex-direction: column; }
  .search, .compact-field select { width: 100%; max-width: none; }
  .calendar-shell { overflow: hidden; border-radius: 10px; }
  .calendar-grid { min-width: 0; }
  .calendar-day { min-height: 60px; padding: 4px; }
  .calendar-summary { margin-top: 4px; padding: 3px 5px; }
  .form-grid, .dynamic-fields { grid-template-columns: 1fr; }
  .schedule-row { grid-template-columns: 1fr 1fr; }
  .schedule-row strong { grid-column: 1 / -1; }
  .field--full { grid-column: auto; }
  .modal { width: 100%; max-width: none; max-height: calc(100vh - var(--header-height)); margin: auto 0 0; border-radius: 17px 17px 0 0; }
  .modal__surface { max-height: calc(100vh - var(--header-height)); }
  .modal[open] { animation-name: sheet-in; }
  .call-button { display: inline-grid; flex: 0 0 42px; }
  .table-call { display: inline; color: var(--primary); text-decoration: none; }
  .advanced-search__grid { grid-template-columns: 1fr 1fr; }
  .advanced-search__grid .switch { grid-column: 1 / -1; }
  .status-filter, .status-filter__trigger { width: 100%; max-width: none; }
  .status-filter__menu { right: 0; min-width: 100%; }
  .audit-application__table { grid-template-columns: 1fr 1fr !important; }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(30px); } }
}

@media (max-width: 720px) {
  .audit-row { grid-template-columns: 1fr; gap: 5px; }
  .audit-row time { text-align: left; }
  .status-row { grid-template-columns: auto 8px 1fr auto; }
  .status-row .status-kind { display: none; }
  .profile-stats { grid-template-columns: 1fr; }
  .editor-heading { align-items: stretch; flex-direction: column; }
  .editor-card__footer { align-items: stretch; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
/* Immutable application activity feed */
.queue-summary{display:grid;grid-template-columns:repeat(4,1fr);gap:12px;margin:0 0 18px}.queue-summary article{padding:16px 18px;border:1px solid var(--line);border-radius:12px;background:var(--surface);box-shadow:var(--shadow-sm)}.queue-summary small{display:block;color:var(--muted);margin-bottom:6px}.queue-summary strong{font-size:26px}.queue-summary article:last-child strong{color:var(--danger)}#queue-unassigned{color:var(--text)}#queue-unassigned.has-items{color:var(--primary)}@media(max-width:800px){.queue-summary{grid-template-columns:1fr 1fr}}
.application-feed{margin-top:8px;padding:20px;border:1px solid var(--line);border-radius:14px;background:color-mix(in srgb,var(--surface-soft) 45%,var(--surface))}.application-feed__head{display:flex;justify-content:space-between;align-items:center;gap:16px;margin-bottom:16px}.application-feed__head strong{font-size:15px}.application-feed__head small{color:var(--muted)}.application-feed__items{display:grid;gap:10px;max-height:280px;overflow:auto;margin-bottom:16px;padding-right:4px}.feed-entry{padding:13px 15px;border:1px solid var(--line);border-radius:12px;background:var(--surface);box-shadow:0 2px 8px rgba(0,0,0,.04)}.feed-entry__meta{display:flex;justify-content:space-between;gap:12px;margin-bottom:7px;font-size:11px;color:var(--muted)}.feed-entry p{white-space:pre-wrap;margin:0;line-height:1.55}.feed-kind{display:inline-flex;padding:2px 7px;border-radius:99px;background:var(--primary-soft);color:var(--primary);font-weight:700}.application-feed__composer{display:grid;grid-template-columns:170px 1fr auto;gap:10px;align-items:stretch;padding-top:14px;border-top:1px solid var(--line)}.application-feed__composer textarea,.application-feed__composer select{width:100%;min-height:44px;border:1px solid var(--line);border-radius:10px;background:var(--surface);color:var(--text);padding:10px 12px}.application-feed__composer textarea{resize:vertical}.application-feed__composer .button{align-self:stretch}@media(max-width:700px){.application-feed__composer{grid-template-columns:1fr}.application-feed__head{align-items:flex-start;flex-direction:column}}

/* Application timeline */
.application-feed{padding:0;overflow:hidden;border-radius:16px;background:var(--surface)}
.application-feed__head{margin:0;padding:18px 20px;border-bottom:1px solid var(--line);background:var(--surface-soft)}
.application-feed__head>div{display:grid;gap:2px}.application-feed__head strong{font-size:16px}.application-feed__head small{display:block}.feed-lock{padding:5px 9px;border:1px solid var(--line);border-radius:99px;color:var(--muted);font-size:10px;font-weight:650}
.application-feed__items{position:relative;gap:0;max-height:320px;margin:0;padding:8px 20px 8px 24px}.application-feed__items:before{content:"";position:absolute;top:18px;bottom:18px;left:43px;width:1px;background:var(--line)}
.feed-entry{position:relative;display:grid;grid-template-columns:38px 1fr;gap:12px;padding:12px 0;border:0;border-radius:0;background:transparent;box-shadow:none}.feed-entry__avatar{position:relative;z-index:1;display:grid;place-items:center;width:38px;height:38px;border:3px solid var(--surface);border-radius:50%;background:var(--primary-soft);color:var(--primary);font-size:11px;font-weight:800}.feed-entry--result .feed-entry__avatar{background:var(--success-soft);color:var(--success)}.feed-entry--client .feed-entry__avatar{background:var(--warning-soft);color:var(--warning)}
.feed-entry__body{min-width:0;padding:11px 13px;border:1px solid var(--line);border-radius:4px 12px 12px 12px;background:var(--surface-soft)}.feed-entry__meta{align-items:center;margin-bottom:6px}.feed-entry__meta>span{display:flex;align-items:center;flex-wrap:wrap;gap:7px}.feed-kind{padding:2px 7px;font-size:9px;letter-spacing:.02em}.feed-entry p{font-size:13px}.feed-empty{display:grid;place-items:center;gap:3px;padding:34px;color:var(--muted);text-align:center}.feed-empty>span{font-size:24px}.feed-empty strong{color:var(--text)}.feed-empty small{font-size:11px}
.application-feed__composer{display:block;padding:16px 20px 18px;border-top:1px solid var(--line);background:var(--surface-soft)}.application-feed__composer textarea{display:block;min-height:82px;margin:0 0 12px;padding:12px 14px;border-radius:12px;background:var(--surface)}.application-feed__actions{display:flex;align-items:flex-end;justify-content:space-between;gap:14px}.application-feed__actions label{display:grid;gap:5px;min-width:190px}.application-feed__actions label>span{color:var(--muted);font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em}.application-feed__actions select{height:40px;min-height:40px}.application-feed__actions .button{min-width:190px}
@media(max-width:700px){.feed-lock{display:none}.application-feed__actions{align-items:stretch;flex-direction:column}.application-feed__actions label,.application-feed__actions .button{width:100%;min-width:0}.application-feed__items{padding-inline:14px}.application-feed__items:before{left:33px}.feed-entry{grid-template-columns:38px 1fr}}

/* Stable notes layout: overrides the legacy composer grid. */
.application-feed__items{display:grid;gap:10px;padding:14px 18px;overflow-x:hidden}
.application-feed__items::before{display:none}
.feed-entry{display:grid;grid-template-columns:34px minmax(0,1fr);gap:10px;padding:0}
.feed-entry__avatar{width:34px;height:34px;border-width:2px}
.feed-entry__body{width:100%;padding:12px 14px;border-radius:12px}
.feed-entry__meta{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
.feed-entry__meta>span{min-width:0}.feed-entry__meta time{flex:none;white-space:nowrap}
.application-feed__composer{display:block;width:100%;padding:16px 18px 18px}
.application-feed__composer>textarea{box-sizing:border-box;width:100%;min-height:88px;margin:0 0 12px}
.application-feed__actions{display:grid;grid-template-columns:minmax(180px,240px) max-content;align-items:end;justify-content:space-between;gap:12px;width:100%}
.application-feed__actions label{display:grid;grid-template-columns:1fr;gap:5px;width:100%;min-width:0}
.application-feed__actions select{box-sizing:border-box;width:100%}
.application-feed__actions .button{width:auto;min-width:190px;align-self:end}
#application-feed .application-feed__composer{display:block!important;visibility:visible!important;min-height:160px}
.application-comment-editor{display:grid!important;visibility:visible!important;gap:12px;padding:18px;border:1px solid var(--line);border-radius:14px;background:var(--surface-soft)}.application-comment-editor[hidden]{display:none!important}.application-comment-editor__title{display:grid;gap:2px}.application-comment-editor__title strong{font-size:15px}.application-comment-editor__title small{color:var(--muted);font-size:11px}.application-comment-editor>textarea{box-sizing:border-box;display:block;width:100%;min-height:96px;padding:12px 14px;border:1px solid var(--line);border-radius:11px;background:var(--surface);color:var(--text);font:inherit;resize:vertical}.application-comment-editor>textarea:focus{border-color:var(--primary);box-shadow:0 0 0 3px var(--primary-soft);outline:0}

/* Table chronology and messenger composer */
.chronology-table{max-height:300px;overflow:auto}.chronology-table table{width:100%;table-layout:fixed;border-collapse:collapse}.chronology-table th{position:sticky;top:0;z-index:1;padding:10px 16px;border-bottom:1px solid var(--line);background:var(--surface-soft);color:var(--muted);font-size:10px;letter-spacing:.05em;text-align:left;text-transform:uppercase}.chronology-table th:first-child{width:34%}.chronology-table td{padding:13px 16px;border-bottom:1px solid var(--line);vertical-align:top;white-space:normal;overflow-wrap:anywhere}.chronology-table tr:last-child td{border-bottom:0}.chronology-table td:first-child strong{display:block;font-size:12px}.chronology-table td:first-child time{display:block;margin-top:3px;color:var(--muted);font-size:10px}.chronology-table td:last-child{font-size:13px;line-height:1.5}.chronology-empty td{padding:28px!important;color:var(--muted);text-align:center}
.application-comment-editor{grid-template-columns:minmax(0,1fr) 42px!important;align-items:end;gap:8px!important;padding:10px!important;border-radius:14px!important;background:var(--surface)!important}.application-comment-editor>textarea{min-height:42px;max-height:130px;padding:10px 13px;border:0;border-radius:10px;background:var(--surface-soft);line-height:1.45;resize:none}.application-comment-editor>textarea:focus{box-shadow:none}.comment-send{display:grid;width:42px;height:42px;place-items:center;border:0;border-radius:50%;background:var(--primary);color:#fff;font-size:16px;cursor:pointer;transition:background .15s,transform .15s}.comment-send:hover{background:var(--primary-hover)}.comment-send:active{transform:scale(.95)}.comment-send:disabled{opacity:.5;cursor:default}@media(max-width:600px){.chronology-table th:first-child{width:40%}.chronology-table th,.chronology-table td{padding-inline:11px}}
@media(max-width:700px){.application-feed__head{align-items:flex-start}.application-feed__actions{grid-template-columns:1fr}.application-feed__actions .button{width:100%;min-width:0}.feed-entry__meta{flex-direction:column;gap:4px}.feed-entry__meta time{white-space:normal}}

/* Full application page with activity chat */
.application-page{inset:0;width:100vw;max-width:none;height:100vh;max-height:none;margin:0;padding:0;border-radius:0}.application-page::backdrop{background:var(--surface)}.application-page[open]{animation:none}.application-page__surface{display:grid;grid-template-columns:minmax(0,1fr) minmax(340px,400px);grid-template-rows:auto minmax(0,1fr) auto;width:100%;height:100vh;max-height:none;background:var(--surface-raised)}.application-page__header{grid-column:1;grid-row:1;justify-content:flex-start;border-bottom:1px solid var(--line)}.application-back{display:grid;width:38px;height:38px;place-items:center;border:1px solid var(--line);border-radius:10px;background:var(--surface);color:var(--text);font-size:20px;cursor:pointer}.application-page .modal__body{grid-column:1;grid-row:2;padding:28px clamp(22px,4vw,56px)}.application-page .modal__footer{grid-column:1;grid-row:3}.application-activity{display:grid;grid-column:2;grid-row:1/4;grid-template-rows:auto minmax(0,1fr) auto;min-width:0;border-left:1px solid var(--line);background:var(--surface-soft)}.application-activity .application-feed__head{margin:0;padding:22px;border-bottom:1px solid var(--line)}.application-chat{display:flex;min-height:0;flex-direction:column;gap:12px;overflow-y:auto;padding:20px}.chat-event{display:grid;justify-items:center;gap:4px;margin:3px 0;color:var(--muted);font-size:11px;text-align:center}.chat-event span{padding:7px 11px;border:1px solid var(--line);border-radius:99px;background:var(--surface)}.chat-event strong{color:var(--text)}.chat-event time{font-size:9px}.chat-message{display:flex;justify-content:flex-start}.chat-message.is-own{justify-content:flex-end}.chat-message__bubble{max-width:82%;padding:10px 12px;border:1px solid var(--line);border-radius:14px 14px 14px 4px;background:var(--surface);box-shadow:0 2px 8px rgba(0,0,0,.04)}.chat-message.is-own .chat-message__bubble{border-color:transparent;border-radius:14px 14px 4px 14px;background:var(--primary-soft)}.chat-message__bubble strong{display:block;margin-bottom:4px;color:var(--primary);font-size:11px}.chat-message__bubble p{margin:0;white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px;line-height:1.5}.chat-message__bubble time{display:block;margin-top:5px;color:var(--muted);font-size:9px;text-align:right}.chat-empty{margin:auto;color:var(--muted);font-size:13px}.application-activity .application-comment-editor{margin:0;padding:14px!important;border:0;border-top:1px solid var(--line);border-radius:0!important;background:var(--surface)!important}
@media(max-width:850px){.application-page__surface{display:flex;overflow-y:auto;flex-direction:column;height:100vh}.application-page .modal__body{overflow:visible}.application-page .modal__footer{order:3}.application-activity{order:2;min-height:520px;border-top:1px solid var(--line);border-left:0}.application-page .modal__footer{order:4}.application-chat{min-height:340px}.application-page{max-height:none;border-radius:0}}

/* Log toggle: on mobile the log stays out of the way until the button opens it as its
   own full-screen layer above the (still open) application, instead of stacking inline. */
.log-toggle{display:none;align-items:center;gap:6px;height:34px;padding:0 12px;border:1px solid var(--line);border-radius:9px;background:var(--surface);color:var(--text);font-size:12px;font-weight:650;white-space:nowrap;cursor:pointer}
.log-toggle svg{width:16px;height:16px}
.log-close{display:none;width:32px;height:32px;flex:0 0 auto;margin-left:auto;border:1px solid var(--line);border-radius:9px;background:var(--surface);color:var(--text);font-size:18px;line-height:1;cursor:pointer}
@media(max-width:850px){
  .log-toggle:not([hidden]){display:inline-flex}
  .application-activity{display:none}
  .application-activity.is-log-open{display:grid;position:fixed;inset:0;z-index:30;min-height:0;height:100vh;height:100dvh;border-top:0}
  .log-close{display:inline-grid;place-items:center}
}

.application-page__surface:has(.application-activity.is-expanded){grid-template-columns:minmax(0,1fr) minmax(520px,48vw)}.chat-expand{display:grid;width:32px;height:32px;flex:0 0 auto;place-items:center;border:1px solid var(--line);border-radius:9px;background:var(--surface);color:var(--text);font-size:16px;cursor:pointer}.application-chat,.application-comment-editor textarea{scrollbar-width:thin;scrollbar-color:color-mix(in srgb,var(--muted) 55%,transparent) transparent}.application-chat::-webkit-scrollbar,.application-comment-editor textarea::-webkit-scrollbar{width:5px}.application-chat::-webkit-scrollbar-thumb,.application-comment-editor textarea::-webkit-scrollbar-thumb{border-radius:99px;background:color-mix(in srgb,var(--muted) 55%,transparent)}.application-comment-editor{grid-template-columns:38px minmax(0,1fr) 42px!important}.application-comment-editor>textarea{min-height:42px;max-height:120px!important;overflow-y:auto;resize:none}.comment-attach{display:grid;width:38px;height:42px;place-items:center;border:1px solid var(--line);border-radius:10px;background:var(--surface-soft);color:var(--muted);font-size:21px;cursor:pointer}.comment-attach:hover{border-color:var(--primary);color:var(--primary)}.comment-attach input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}.comment-file-name{grid-column:1/4;overflow:hidden;padding:7px 9px;border-radius:8px;background:var(--primary-soft);color:var(--primary);font-size:11px;text-overflow:ellipsis;white-space:nowrap}.chat-file{display:flex;align-items:center;gap:9px;margin-top:7px;padding:9px 11px;border:1px solid var(--line);border-radius:9px;background:var(--surface);color:var(--text);text-decoration:none;transition:border-color .15s,background .15s}.chat-file:hover{border-color:var(--primary);background:var(--primary-soft)}.chat-file__icon{flex:0 0 auto;font-size:15px}.chat-file__body{display:grid;gap:1px;min-width:0}.chat-file__body strong{overflow:hidden;font-size:12.5px;font-weight:650;text-overflow:ellipsis;white-space:nowrap}.chat-file__body small{color:var(--muted);font-size:10.5px}@media(max-width:850px){.application-page__surface:has(.application-activity.is-expanded){display:flex}.chat-expand{display:none}}
.comment-file-name,.comment-reply-preview{align-items:center;justify-content:space-between;gap:10px}
.comment-file-name:not([hidden]),.comment-reply-preview:not([hidden]){display:flex}
.comment-file-name button,.comment-reply-preview button{width:24px;height:24px;flex:0 0 auto;border:0;border-radius:7px;background:transparent;color:inherit;font-size:18px;cursor:pointer}
.comment-file-name button:hover,.comment-reply-preview button:hover{background:color-mix(in srgb,var(--primary) 12%,transparent)}
.comment-reply-preview{grid-column:1/4;padding:8px 10px;border-left:3px solid var(--primary);border-radius:8px;background:var(--surface-soft);color:var(--muted);font-size:11px}
.chat-event--system span{border-color:color-mix(in srgb,var(--primary) 22%,var(--line));background:color-mix(in srgb,var(--primary-soft) 55%,var(--surface))}
.chat-event--system strong{color:var(--primary)}

.dashboard-cards{display:grid;grid-template-columns:repeat(6,minmax(130px,1fr));gap:12px;margin-bottom:18px}.dashboard-cards article{display:grid;gap:7px;padding:18px;border:1px solid var(--line);border-radius:12px;background:var(--surface)}.dashboard-cards small{color:var(--muted)}.dashboard-cards strong{font-size:24px}.dashboard-grid{display:grid;grid-template-columns:1fr 1fr;gap:18px}.dashboard-panel{padding:18px}.dashboard-panel h2{margin:0 0 14px;font-size:15px}.metric-row,.risk-row{display:flex;width:100%;align-items:center;justify-content:space-between;gap:12px;padding:10px 0;border:0;border-bottom:1px solid var(--line);background:transparent;color:var(--text);text-align:left}.risk-row{cursor:pointer}.risk-row small{color:var(--muted)}.queue-board{display:grid;gap:10px}.queue-card{display:grid;grid-template-columns:minmax(240px,1fr) minmax(180px,1fr) auto;align-items:center;gap:18px;padding:16px 18px;border:1px solid var(--line);border-radius:12px;background:var(--surface)}.queue-card.is-overdue{border-left:4px solid var(--danger)}.queue-card>div:first-child{display:grid;gap:4px}.queue-card small{color:var(--muted)}.priority{width:max-content;padding:3px 7px;border-radius:99px;background:var(--surface-soft);color:var(--muted);font-size:9px;font-weight:750;text-transform:uppercase}.priority--urgent{background:var(--danger-soft);color:var(--danger)}.priority--high{background:#fff0d7;color:#9b6200}.queue-card__flags{display:flex;flex-wrap:wrap;gap:5px}.queue-card__flags span{padding:4px 7px;border-radius:7px;background:var(--danger-soft);color:var(--danger);font-size:10px}.queue-card__actions,.quick-actions{display:flex;gap:6px}.responsibility-strip{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}.responsibility-strip>span{display:grid;gap:2px;padding:10px;border:1px solid var(--line);border-radius:9px;background:var(--surface-soft)}.responsibility-strip small,.responsibility-strip time{color:var(--muted);font-size:9px}.chat-event span{white-space:pre-line}@media(max-width:1050px){.dashboard-cards{grid-template-columns:repeat(3,1fr)}.queue-card{grid-template-columns:1fr}.queue-card__actions{justify-content:flex-start}}@media(max-width:700px){.dashboard-cards{grid-template-columns:1fr 1fr}.dashboard-grid{grid-template-columns:1fr}.responsibility-strip{grid-template-columns:1fr}}
.responsibility-strip[hidden]{display:none}
.responsibility-strip>span{position:relative;padding-right:34px}
.responsibility-icon{position:absolute;top:8px;right:8px;display:flex;width:22px;height:22px;align-items:center;justify-content:center;border:0;border-radius:50%;cursor:default}
.responsibility-icon svg{width:13px;height:13px;stroke:currentColor;stroke-width:2.5;fill:none;stroke-linecap:round;stroke-linejoin:round}
button.responsibility-icon{cursor:pointer;transition:transform .15s}
button.responsibility-icon:hover{transform:scale(1.1)}
.responsibility-icon.is-pending{background:var(--warning-soft);color:var(--warning)}
.responsibility-icon.is-success{background:var(--success-soft);color:var(--success)}
.responsibility-icon.is-penalty{background:var(--danger-soft);color:var(--danger)}
.comment-reply-preview{grid-column:1/4;padding:7px 10px;border-left:3px solid var(--primary);border-radius:6px;background:var(--primary-soft);color:var(--muted);font-size:11px}.chat-message__bubble blockquote{margin:2px 0 7px;padding:6px 8px;border-left:2px solid var(--primary);border-radius:5px;background:var(--surface-soft);color:var(--muted);font-size:11px}.chat-message__bubble footer{display:flex;align-items:center;justify-content:flex-end;gap:8px;margin-top:6px}.chat-message__bubble footer button{margin-right:auto;padding:0;border:0;background:transparent;color:var(--primary);font-size:9px;cursor:pointer}.chat-message__bubble footer span{color:var(--muted);font-size:9px}.chat-message__bubble footer time{margin:0}
.sla-toggle{display:flex;min-height:40px;align-items:center;gap:8px;padding:0 11px;border:1px solid var(--line);border-radius:9px;background:var(--surface);color:var(--muted);font-size:11px;font-weight:650;white-space:nowrap}.sla-toggle input{accent-color:var(--primary)}.application-row--sla{background:color-mix(in srgb,var(--danger-soft) 35%,transparent)}.application-row--sla td:first-child{box-shadow:inset 3px 0 var(--danger)}.application-row--own{background:color-mix(in srgb,var(--primary-soft) 55%,var(--surface))}.application-row--own td:first-child{box-shadow:inset 3px 0 var(--primary)}.application-row--new{background:color-mix(in srgb,var(--success-soft) 45%,transparent)}.application-row--new td:first-child{box-shadow:inset 3px 0 var(--success)}.sla-warnings{display:flex;flex-wrap:wrap;gap:4px;margin-top:5px}.sla-warning{padding:3px 6px;border-radius:6px;background:var(--danger-soft);color:var(--danger);font-size:9px;font-weight:700}.queue-summary__alert strong{color:var(--danger)}
.chat-event span{box-sizing:border-box;width:min(100%,340px);padding:8px 10px;border-radius:7px;text-align:left;line-height:1.45}.chat-event time{margin-top:1px}
.application-save-state{margin-left:auto;color:var(--muted);font-size:11px}
.application-actions-footer:empty,.application-actions-footer:not(:has(button:not([hidden]))){display:none}
.project-combobox__label{display:block;padding:8px 10px 4px;color:var(--muted);font-size:10px;font-weight:800;text-transform:uppercase;letter-spacing:.05em}
.role-chip{display:inline-flex;align-items:center;gap:7px;padding:5px 9px;border-radius:99px;background:color-mix(in srgb,var(--role-color) 13%,var(--surface));color:var(--role-color);font-size:11px;font-weight:750}
.role-chip::before{width:7px;height:7px;border-radius:50%;background:var(--role-color);content:""}
.role-card__color{width:12px;height:12px;flex:0 0 auto;border-radius:50%;background:var(--role-color)}
.irrelevant-dialog{display:grid;gap:16px;min-width:0}.irrelevant-dialog textarea{box-sizing:border-box;width:100%;resize:vertical}
.reason-list{display:grid;gap:6px;max-height:280px;overflow:auto;margin:0;padding:12px;border:1px solid var(--line);border-radius:9px}
.reason-list legend{padding:0 5px;color:var(--muted);font-size:12px}
.reason-option{display:flex;align-items:flex-start;gap:10px;padding:9px 11px;border:1px solid transparent;border-radius:8px;cursor:pointer;transition:background .15s,border-color .15s}
.reason-option:hover{background:var(--surface-soft)}
.reason-option input{flex:0 0 auto;width:auto;margin-top:2px}
.reason-option span{flex:1;min-width:0;color:var(--text);font-size:13px;line-height:1.35;text-align:left;overflow-wrap:anywhere}
.reason-option:has(input:checked){border-color:var(--primary);background:var(--primary-soft)}
.dashboard-explanation{margin:0 0 12px;color:var(--muted);font-size:11px;line-height:1.45}
.metric-row--workload span{display:grid;min-width:0;flex:1;gap:6px}.metric-row--workload i{display:block;width:var(--workload);height:4px;border-radius:99px;background:var(--primary)}
.profile-payout:disabled{cursor:default;opacity:1}.profile-payout:disabled:hover{border-color:var(--line)}
.developer-tools{max-width:760px}.developer-tools h2{margin-top:0}
/* Stacked developer cards need their own spacing — they sat flush against each other. */
.developer-tools+.developer-tools{margin-top:16px}.developer-tools .form-grid{margin-top:16px}.developer-tools>.muted{margin-top:6px}
.application-amounts{display:flex;flex-wrap:wrap;gap:10px}.application-amounts>span{display:grid;min-width:180px;gap:3px;padding:12px 14px;border:1px solid var(--line);border-radius:9px;background:var(--surface-soft)}.application-amounts small{color:var(--muted);font-size:10px}.application-amounts strong{font-size:17px}.profile-payouts{margin-top:18px}.profile-payouts h3{margin:0 0 8px;font-size:13px}.profile-payouts>div{display:grid;gap:6px}.profile-payout{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;padding:10px 12px;border:1px solid var(--line);border-radius:9px;background:var(--surface);color:var(--text);text-align:left;cursor:pointer}.profile-payout span{display:grid;gap:2px}.profile-payout small{color:var(--muted);font-size:10px}.profile-payout b{color:var(--primary)}
@media(max-width:700px){.project-tag-row{flex-wrap:wrap}.project-tag-row>strong,.project-tag-row>small{min-width:0;text-align:left}.application-amounts>span{flex:1 1 140px}}
.section-heading{display:flex;align-items:end;justify-content:space-between;gap:18px}.section-heading h2{margin-bottom:0}.profile-stats--page{grid-template-columns:repeat(3,minmax(0,1fr));margin-bottom:22px}.profile-stats--page article{min-height:110px;justify-content:space-between;padding:20px}.profile-stats--page strong{font-size:26px}.home-admin{margin-top:34px}.home-admin>.section-heading{margin-bottom:14px}.profile-payouts.table-card{padding:20px}.profile-payouts .section-heading{margin-bottom:14px}
.callback-queue{margin-bottom:20px;padding:18px;border:1px solid color-mix(in srgb,#cf8306 45%,var(--line));border-left:4px solid #cf8306;border-radius:10px;background:color-mix(in srgb,#cf8306 8%,var(--surface))}.callback-queue .section-heading{margin-bottom:0}.callback-queue .section-heading strong{display:grid;min-width:34px;height:34px;place-items:center;border-radius:8px;background:#cf8306;color:#fff}#callback-list{display:grid;gap:8px}.callback-card{display:grid;grid-template-columns:auto 1fr auto auto;align-items:center;gap:14px;width:100%;padding:12px 14px;border:1px solid var(--line);border-radius:8px;background:var(--surface);color:var(--text);text-align:left;cursor:pointer}.callback-card>span{display:grid;gap:2px}.callback-card small{color:var(--muted)}.callback-card time{color:#cf8306;font-weight:750}
/* Личная очередь: то, что сотрудник держит в руках прямо сейчас. Отдельный блок над общей
   очередью — раньше это была одна подсвеченная строка внутри общего списка, и «что у меня в
   работе» приходилось выцеплять глазами. */
.own-queue { margin-bottom: 20px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--primary) 42%, var(--line)); border-left: 4px solid var(--primary); border-radius: 10px; background: color-mix(in srgb, var(--primary) 7%, var(--surface)); }
.own-queue__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 15px 18px; }
.own-queue__head h2 { margin-bottom: 0; font-size: 17px; }
.own-queue__count { display: grid; min-width: 30px; height: 30px; place-items: center; padding: 0 9px; border-radius: 99px; background: var(--primary); color: #fff; font-size: 13px; font-weight: 750; }
.own-queue .applications-table { background: transparent; }
.own-queue .applications-table thead th { border-top: 1px solid color-mix(in srgb, var(--primary) 22%, var(--line)); }
/* Подложка строки здесь не нужна — весь блок уже выделен. */
.own-queue .application-row--own { background: transparent; }
.own-queue .application-row--own td:first-child { box-shadow: none; }
.own-queue tbody tr:last-child td { border-bottom: 0; }
.callback-queue__head{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;padding:0;border:0;background:transparent;color:inherit;font:inherit;cursor:pointer;text-align:left}
.callback-queue__head .section-heading{flex:1;min-width:0}
.callback-queue__chevron{width:18px;height:18px;flex:0 0 auto;color:#cf8306;transition:transform .18s}
.callback-queue.is-collapsed .callback-queue__chevron{transform:rotate(-90deg)}
.callback-queue__body{display:grid;gap:10px;margin-top:12px}
.callback-queue.is-collapsed .callback-queue__body{display:none}
.callback-queue__all{width:100%;justify-content:center}
.callback-card--pending{cursor:default;opacity:.7}
.callback-card__wait{grid-column:1/-1;color:var(--muted);font-style:italic}
.callback-queue__empty{margin:0;padding:10px 0;color:var(--muted);font-size:12px}
.callback-modal-list{display:grid;gap:8px;max-height:60vh;overflow:auto}
.operator-actions{display:flex;flex-wrap:wrap;gap:8px;padding:12px;border:1px solid var(--line);border-radius:9px;background:var(--surface-soft)}
/* Every action button carries its own solid background: a missing one used to leave white
   text on a light surface, making the button effectively invisible. */
.operator-actions button{min-height:38px;padding:8px 13px;border:0;border-radius:6px;background:#4b5563;color:#fff;font-weight:750;text-shadow:0 1px 1px rgb(0 0 0 / 22%);cursor:pointer;transition:filter .15s}
.operator-actions button:hover{filter:brightness(1.08)}
.operator-actions [data-operator-action="callback"]{background:#9a5f08}.operator-actions [data-operator-action="no_answer"]{background:#a83b0d}.operator-actions [data-operator-action="invalid_data"]{background:#b23c00}.operator-actions [data-operator-action="not_relevant"]{background:#566065}.operator-actions [data-operator-action="duplicate"]{background:#6d5bbd}.operator-actions [data-operator-action="success"]{margin-left:auto;background:#12813d}
/* Fixed hue rather than var(--primary): in the dark theme the primary is a light blue and
   white button text on it drops to ~2.7:1 contrast. */
.moderation-actions [data-application-moderate="success"]{background:#2f47c2}
.moderation-actions [data-application-moderate="partial"]{border:1px solid var(--line);background:var(--surface);color:var(--text)}
.moderation-actions [data-application-moderate="penalty"]{border:1px solid color-mix(in srgb,var(--danger) 40%,var(--line));background:var(--surface);color:var(--danger)}
.moderation-toolbar{display:grid;gap:14px;margin-bottom:18px}.moderation-tabs{display:inline-flex;width:max-content;max-width:100%;gap:4px;padding:4px;border:1px solid var(--line);border-radius:12px;background:var(--surface)}.moderation-tabs button{display:inline-flex;min-height:42px;align-items:center;gap:9px;padding:8px 14px;border:0;border-radius:8px;background:transparent;color:var(--muted);font-size:13px;font-weight:750;cursor:pointer}.moderation-tabs button:hover{background:var(--surface-soft);color:var(--text)}.moderation-tabs button.is-active{background:var(--primary-soft);color:var(--primary)}.moderation-tabs button span{display:inline-grid;min-width:21px;height:21px;padding:0 6px;place-items:center;border-radius:99px;background:var(--surface-soft);font-size:10px}.moderation-tabs button.is-active span{background:var(--primary);color:#fff}.moderation-filters{display:flex;align-items:center;gap:10px}.moderation-filters .search{margin:0}.moderation-filters .compact-field select{height:40px}.moderation-grid{display:grid;gap:12px}.moderation-card{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:18px;padding:18px;border:1px solid var(--line);border-radius:10px;background:var(--surface)}.moderation-card h2{margin:0 0 5px;font-size:18px}.moderation-card p{margin:0;color:var(--muted)}.moderation-card__meta{display:flex;flex-wrap:wrap;gap:8px 16px;margin-top:12px;font-size:12px}.moderation-card__actions{display:flex;align-items:center;gap:7px}.moderation-card__actions button{white-space:nowrap}.moderation-card__actions .is-penalty{color:var(--danger)}
.moderation-claimed{padding:7px 10px;border-radius:8px;background:var(--surface-soft);color:var(--muted);font-size:11px}

/* Readable application activity timeline */
.application-chat{
  position:relative;
  gap:0;
  padding:18px 18px 24px;
}
.application-chat::before{
  position:absolute;
  top:27px;
  bottom:27px;
  left:33px;
  width:1px;
  background:color-mix(in srgb,var(--line) 75%,transparent);
  content:"";
}
.chat-event{
  position:relative;
  display:grid;
  grid-template-columns:30px minmax(0,1fr);
  gap:10px;
  justify-items:stretch;
  margin:0;
  padding:7px 0;
  color:var(--text);
  text-align:left;
}
.chat-event>.chat-event__marker{
  z-index:1;
  display:grid;
  width:30px;
  height:30px;
  box-sizing:border-box;
  place-items:center;
  border:1px solid color-mix(in srgb,var(--event-color,var(--muted)) 34%,var(--line));
  border-radius:9px;
  background:color-mix(in srgb,var(--event-color,var(--muted)) 12%,var(--surface));
  color:var(--event-color,var(--muted));
  font-size:14px;
  font-weight:850;
  line-height:1;
  padding:0;
  text-align:center;
  white-space:normal;
}
.chat-event__content{
  min-width:0;
  padding:2px 0 9px;
}
.chat-event__content header{
  display:flex;
  min-width:0;
  align-items:center;
  gap:6px;
  margin-bottom:5px;
  line-height:1.2;
}
.chat-event__content header strong{
  overflow:hidden;
  color:var(--text);
  font-size:11px;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.chat-event__content header>span{
  width:auto;
  box-sizing:border-box;
  padding:2px 5px;
  border-radius:5px;
  background:color-mix(in srgb,var(--event-color,var(--muted)) 10%,transparent);
  color:var(--event-color,var(--muted));
  font-size:8px;
  font-weight:750;
  letter-spacing:.04em;
  text-transform:uppercase;
}
.chat-event__content header time{
  flex:none;
  margin:0 0 0 auto;
  color:var(--muted);
  font-size:9px;
  white-space:nowrap;
}
.chat-event__content p{
  margin:0;
  color:var(--text);
  font-size:12px;
  line-height:1.45;
}
.chat-event__content ul{
  display:grid;
  gap:4px;
  margin:7px 0 0;
  padding:8px 10px;
  border-left:2px solid color-mix(in srgb,var(--event-color,var(--muted)) 45%,var(--line));
  border-radius:0 7px 7px 0;
  background:color-mix(in srgb,var(--surface) 55%,transparent);
  list-style:none;
}
.chat-event__content li{
  display:grid;
  grid-template-columns:minmax(72px,.55fr) minmax(0,1fr);
  gap:8px;
  line-height:1.35;
}
.chat-event__content li small{
  color:var(--muted);
  font-size:9px;
  text-transform:capitalize;
}
.chat-event__content li span{
  width:auto;
  padding:0;
  border:0;
  border-radius:0;
  background:transparent;
  min-width:0;
  color:var(--text);
  font-size:10px;
  line-height:1.35;
  text-align:left;
  white-space:normal;
  overflow-wrap:anywhere;
}
.chat-event--created{--event-color:var(--primary)}
.chat-event--changed{--event-color:#b078e6}
.chat-event--status{--event-color:#d58a20}
.chat-event--closed{--event-color:var(--success)}
.chat-event--payment{--event-color:#30a872}
.chat-event--system{--event-color:var(--muted)}
.chat-event--system .chat-event__content{padding-block:2px 9px}
@media(max-width:500px){
  .application-chat{padding-inline:12px}
  .application-chat::before{left:27px}
  .chat-event{grid-template-columns:30px minmax(0,1fr)}
  .chat-event__content header{flex-wrap:wrap}
  .chat-event__content header time{width:100%;margin-left:0}
}
.chat-event--preview{
  margin:auto 0;
}
.chat-event--preview .chat-event__content{
  align-self:center;
  padding-bottom:2px;
}
.chat-event--preview .chat-event__content header{
  margin-bottom:4px;
}

.business-heading{align-items:flex-start}.business-heading .muted{margin-top:8px}.business-heading__actions{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px}.business-analytics{display:grid;gap:16px;margin-bottom:22px}.business-kpis{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.business-kpis article{display:grid;gap:7px;min-height:126px;padding:20px;border:1px solid color-mix(in srgb,var(--line) 72%,transparent);border-radius:16px;background:linear-gradient(145deg,var(--surface),color-mix(in srgb,var(--surface-soft) 48%,var(--surface)))}.business-kpis small,.business-kpis span,.business-payouts small{color:var(--muted);font-size:11px}.business-kpis strong{font-size:28px;letter-spacing:-.04em}.business-kpis .business-kpi--accent{border-color:color-mix(in srgb,var(--primary) 28%,var(--line));background:linear-gradient(145deg,var(--primary-soft),var(--surface))}.business-kpi--accent strong{color:var(--primary)}.business-insights{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(260px,.7fr);gap:12px}.business-panel{overflow:hidden;padding:20px;border:1px solid var(--line);border-radius:16px;background:var(--surface)}.business-panel .section-heading{margin-bottom:13px}.business-panel h2{margin:0;font-size:17px}.business-projects{display:grid}.business-project-row{display:grid;grid-template-columns:minmax(140px,1fr) repeat(3,minmax(82px,.35fr));gap:12px;align-items:center;padding:12px 0;border-top:1px solid var(--line);font-size:12px}.business-project-row:first-child{border-top:0}.business-project-row span{color:var(--muted);text-align:right}.business-project-row strong{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.business-payouts{display:grid;align-content:center;gap:0;padding-block:10px}.business-payouts div{display:grid;gap:8px;padding:22px 10px}.business-payouts div+div{border-top:1px solid var(--line)}.business-payouts strong{font-size:25px;letter-spacing:-.03em}.business-settings{display:grid;gap:20px}.business-settings__heading{margin:0;padding-bottom:16px;border-bottom:1px solid var(--line)}.business-settings__heading h2{margin:0;font-size:19px}@media(max-width:1000px){.business-kpis{grid-template-columns:1fr 1fr}.business-insights{grid-template-columns:1fr}}@media(max-width:620px){.business-kpis{grid-template-columns:1fr}.business-heading__actions{width:100%;justify-content:flex-start}.business-project-row{grid-template-columns:1fr auto}.business-project-row span:nth-of-type(2),.business-project-row span:nth-of-type(3){display:none}.moderation-card{grid-template-columns:1fr}.moderation-card__actions{flex-wrap:wrap}}
@media(max-width:760px){.sidebar-collapse{display:none}.profile-stats--page{grid-template-columns:1fr}.callback-card{grid-template-columns:auto 1fr}.callback-card time,.callback-card>small{grid-column:2}.moderation-tabs{width:100%}.moderation-tabs button{flex:1;justify-content:center}.moderation-filters{align-items:stretch;flex-direction:column}.moderation-filters .search,.moderation-filters .compact-field select{width:100%;max-width:none}.moderation-card{grid-template-columns:1fr}.moderation-card__actions{flex-wrap:wrap}.operator-actions [data-operator-action="success"]{margin-left:0}.brand__wordmark{width:78px}}
.master-actions [data-master-status]{background:#2f47c2}.master-actions [data-master-status-request]{background:#566065}.master-actions [data-master-decline]{margin-left:auto;background:#a83b0d}.master-actions button:disabled{opacity:.62;cursor:not-allowed}

/* Staff report (Сотрудники → Загрузка и риски) */
.segmented-tabs { display: inline-flex; gap: 4px; margin-bottom: 18px; padding: 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-sm); }
.segmented-tab { min-height: 38px; padding: 8px 16px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-size: 13px; font-weight: 680; cursor: pointer; transition: background .15s, color .15s; }
.segmented-tab:hover { color: var(--text); background: var(--surface-soft); }
.segmented-tab.is-active { color: var(--primary); background: var(--primary-soft); }
.staff-panel[hidden] { display: none; }
.staff-report__meta { margin: 0 0 14px; color: var(--muted); font-size: 12px; }
/* Capped at a max width so a row of just 1-2 tiles (payouts KPIs, traffic KPIs) stays compact
   instead of auto-fit stretching each one to fill the whole row. */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 220px)); gap: 12px; margin-bottom: 18px; }
.stat-tile { display: grid; gap: 8px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-sm); }
.stat-tile small { color: var(--muted); font-size: 12px; }
.stat-tile strong { font-size: 24px; letter-spacing: -.02em; }
.stat-tile.is-alert { border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); background: var(--danger-soft); }
.stat-tile.is-alert strong { color: var(--danger); }
.staff-report__table { margin-bottom: 18px; }
.staff-report__table th.num, .staff-report__table td.num { text-align: right; white-space: nowrap; }
.staff-report__table td.num { font-variant-numeric: tabular-nums; }
.staff-report__table tbody tr.is-total td { border-top: 2px solid var(--line-strong); background: var(--surface-soft); font-weight: 700; }
.staff-report__table tbody tr.is-total:hover { background: var(--surface-soft); }
.num-alert { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 99px; background: var(--danger-soft); color: var(--danger); font-weight: 700; font-size: 12px; }
.cell-user { display: inline-flex; align-items: center; gap: 10px; }
.avatar--xs { width: 28px; height: 28px; font-size: 11px; }
#staff-risks .risk-row { justify-content: flex-start; gap: 11px; align-items: flex-start; padding: 12px 4px; }
#staff-risks .risk-row:last-child { border-bottom: 0; }
.risk-row__dot { flex: 0 0 auto; width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--muted); }
.risk-row__dot.risk-row--warning { background: var(--warning); }
.risk-row__dot.risk-row--info { background: var(--primary); }
.risk-row__body { display: grid; gap: 2px; text-align: left; }
.risk-row__body strong { font-size: 13px; font-weight: 600; }
.risk-row__body small { color: var(--muted); font-size: 11px; }
@media (max-width: 760px) { .segmented-tabs { width: 100%; } .segmented-tab { flex: 1; } }

/* Role-sectioned workload report */
.report-tabs { margin-bottom: 12px; }
.report-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 14px; }
.report-toolbar .search { width: min(280px, 100%); }
.report-toolbar .switch { white-space: nowrap; }
.report-toolbar .switch .switch__text { color: var(--muted); font-size: 12.5px; font-weight: 500; }
.report-toolbar .staff-report__meta { margin: 0 0 0 auto; }
@media (min-width: 761px) { #report-refresh, #payouts-refresh { margin-left: 10px; } }
th.is-sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.is-sortable:hover { color: var(--primary); }
.staff-report { display: grid; gap: 16px; margin-bottom: 18px; }
/* No horizontal padding on the card itself, so the «Итого» row's background reaches both edges. */
.staff-report__section { padding: 0; }
.staff-report__section + .staff-report__section { margin-top: 20px; }
.staff-report__section .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 18px 18px 14px; }
.staff-report__section .section-heading h2 { margin: 0; font-size: 17px; }
.staff-report__count { flex: 0 0 auto; padding: 4px 10px; border-radius: 99px; background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 700; }
.staff-report__note { margin: 0 18px 14px; padding: 9px 12px; border-radius: 10px; background: var(--warning-soft, var(--surface-soft)); color: var(--muted); font-size: 12px; line-height: 1.4; }
.staff-report__empty { padding: 14px 18px; }
.staff-report__section th.num, .staff-report__section td.num { text-align: right; white-space: nowrap; }
.staff-report__section td.num { font-variant-numeric: tabular-nums; }
.staff-report__section tbody tr.is-total td { border-top: 2px solid var(--line-strong); background: var(--surface-soft); font-weight: 700; }
.staff-report__section tbody tr.is-total:hover { background: var(--surface-soft); }

/* Business hub — card grid of management sections */
/* Inline notice explaining a blocked workflow (e.g. no projects configured) */
.notice { display: flex; align-items: flex-start; gap: 13px; margin-bottom: 18px; padding: 15px 17px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.notice--warning { border-color: color-mix(in srgb, var(--warning) 45%, var(--line)); background: var(--warning-soft); }
.notice__icon { display: grid; flex: 0 0 auto; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--warning); color: #fff; font-size: 14px; font-weight: 800; }
.notice__body { flex: 1; min-width: 0; display: grid; gap: 4px; }
.notice__body strong { font-size: 14px; }
.notice__body p { margin: 0; color: var(--muted); font-size: 12.5px; line-height: 1.45; }
.notice .button { flex: 0 0 auto; align-self: center; }
@media (max-width: 620px) { .notice { flex-wrap: wrap; } .notice .button { width: 100%; } }

/* Deactivated projects stay listed but read as switched off */
.project-card.is-inactive { opacity: .72; border-style: dashed; }
.project-state { padding: 2px 8px; border-radius: 99px; background: var(--surface-soft); color: var(--muted); font-size: 10.5px; font-weight: 700; vertical-align: middle; }
.workflow-badge { padding: 2px 8px; border-radius: 99px; font-size: 10.5px; font-weight: 700; vertical-align: middle; }
.workflow-badge--service_center { background: color-mix(in srgb, #2563eb 16%, var(--surface)); color: #2563eb; }
.workflow-badge--shop { background: color-mix(in srgb, #c026d3 16%, var(--surface)); color: #c026d3; }
.project-card__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.project-card__actions .button { flex: 1 1 auto; }

.history-tabs { margin-bottom: 14px; }
.history-summary { margin-bottom: 16px; }
#view-business > .section-heading { margin: 26px 0 14px; }
/* The "no project" bucket is not a direction — set it apart from real projects. */
.business-project-row.is-unassigned { border-top-style: dashed; }
.business-project-row.is-unassigned strong { color: var(--muted); font-style: italic; font-weight: 600; }
.business-hub { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.business-card { display: flex; align-items: center; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); color: var(--text); text-decoration: none; transition: transform .15s, border-color .15s, box-shadow .15s; }
.business-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--primary) 40%, var(--line)); box-shadow: var(--shadow); }
.business-card__icon { display: grid; flex: 0 0 auto; place-items: center; width: 46px; height: 46px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); }
.business-card__icon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.business-card__body { display: grid; gap: 3px; min-width: 0; }
.business-card__body strong { font-size: 14.5px; }
.business-card__body small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.business-card__arrow { flex: 0 0 auto; margin-left: auto; color: var(--muted); font-size: 18px; transition: transform .15s, color .15s; }
.business-card:hover .business-card__arrow { transform: translateX(3px); color: var(--primary); }
@media (max-width: 620px) { .business-hub { grid-template-columns: 1fr; } }

/* История заявок */
.history-filter { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
/* .field--compact keeps its label above the input (like .field), so it's taller than the
   plain .search box and the reset .button — align on the bottom edge to keep every control
   in one visual row instead of centering them against the taller date fields. */
.history-search { align-items: flex-end; }
.chip { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 6px 14px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--muted); font-size: 12.5px; font-weight: 640; cursor: pointer; transition: border-color .15s, background .15s, color .15s; }
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip::before { width: 8px; height: 8px; border-radius: 50%; background: currentColor; content: ""; opacity: .8; }
.chip[data-history-result="all"]::before { display: none; }
.chip--success { color: var(--success); }
.chip--partial { color: var(--warning); }
.chip--penalty { color: var(--danger); }
.chip.is-active { border-color: currentColor; background: color-mix(in srgb, currentColor 12%, var(--surface)); }
.chip[data-history-result="all"].is-active { color: var(--primary); border-color: var(--primary); background: var(--primary-soft); }
.history-table th.num, .history-table td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.history-id { font-weight: 700; font-variant-numeric: tabular-nums; }
.history-earn { display: block; margin-top: 2px; color: var(--success); font-weight: 600; font-size: 11px; }
.history-comment { max-width: 280px; color: var(--muted); font-size: 12px; }
.result-pill { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.result-pill::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.result-pill--success { color: var(--success); background: var(--success-soft); }
.result-pill--partial { color: var(--warning); background: var(--warning-soft); }
.result-pill--penalty { color: var(--danger); background: var(--danger-soft); }
@media (max-width: 760px) { .history-comment { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } }

/* Employee editor */
.editor-head { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.avatar--lg { width: 52px; height: 52px; font-size: 18px; }
.editor-head__body { display: grid; gap: 7px; min-width: 0; }
.editor-head__body > strong { font-size: 18px; letter-spacing: -.02em; }
.editor-head__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.editor-head__meta code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; color: var(--muted); }
.editor-head__id { color: var(--muted); font-size: 12px; }
.status-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 640; }
.status-dot::before { width: 7px; height: 7px; border-radius: 50%; content: ""; }
.status-dot.is-on { color: var(--success); } .status-dot.is-on::before { background: var(--success); }
.status-dot.is-off { color: var(--muted); } .status-dot.is-off::before { background: var(--muted); }
.editor-sections { display: grid; gap: 22px; }
.editor-section { display: grid; gap: 14px; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.editor-section:last-of-type { padding-bottom: 0; border-bottom: 0; }
.editor-section__head h3 { margin: 0; font-size: 14px; }
.editor-section__head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.editor-section__grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.editor-section--danger { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 18px; border: 1px solid color-mix(in srgb, var(--danger) 28%, var(--line)); border-radius: 12px; background: var(--danger-soft); }
/* This is always the last .editor-section, so :last-of-type's higher-specificity
   border-bottom:0/padding-bottom:0 was winning and flattening just the bottom edge of an
   otherwise fully-rounded box. Restate both explicitly for the last-of-type case. */
.editor-section--danger:last-of-type { border-bottom: 1px solid color-mix(in srgb, var(--danger) 28%, var(--line)); padding-bottom: 16px; }
.editor-section--danger .editor-section__danger-copy strong { font-size: 14px; }
.editor-section--danger .editor-section__danger-copy p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.editor-section--danger .button { flex: 0 0 auto; }
/* The plain --danger button is a soft-red pill meant for a neutral surface — inside this
   section, whose background is that same soft red, it vanished into the box with no
   visible edge. Give it a solid fill here so it still reads as a button. */
.editor-section--danger .button--danger { border-color: var(--danger); background: var(--danger); color: #fff; }
.editor-section--danger .button--danger:hover { border-color: color-mix(in srgb, var(--danger) 82%, black); background: color-mix(in srgb, var(--danger) 82%, black); }
@media (max-width: 620px) { .editor-section__grid { grid-template-columns: 1fr; } .editor-section--danger { flex-direction: column; align-items: stretch; } }

/* Audit rework */
#audit-list.audit-rows { border: 0; border-radius: 0; background: transparent; overflow: visible; display: grid; gap: 22px; }
.audit-day__label { position: sticky; top: calc(var(--header-height) + 6px); z-index: 1; width: max-content; margin: 0 0 10px; padding: 4px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; box-shadow: var(--shadow-sm); }
.audit-day__items { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.audit-entry { display: grid; grid-template-columns: 40px minmax(0, 1fr) minmax(120px, auto) 62px; align-items: center; gap: 14px; width: 100%; padding: 13px 16px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; cursor: pointer; transition: background .14s; }
.audit-entry:last-child { border-bottom: 0; }
.audit-entry:hover { background: var(--surface-soft); }
.audit-entry__icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-soft); color: var(--muted); }
.audit-entry__icon svg { width: 18px; height: 18px; }
.audit-entry--create { background: var(--success-soft); color: var(--success); }
.audit-entry--update { background: var(--primary-soft); color: var(--primary); }
.audit-entry--delete { background: var(--danger-soft); color: var(--danger); }
.audit-entry--payment { background: var(--success-soft); color: var(--success); }
.audit-entry--comment { background: var(--warning-soft); color: var(--warning); }
.audit-entry__body { display: grid; gap: 2px; min-width: 0; }
.audit-entry__body strong { font-size: 13px; font-weight: 620; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-entry__body small { color: var(--muted); font-size: 11px; }
.audit-entry__actor { display: inline-flex; align-items: center; gap: 8px; min-width: 0; color: var(--muted); font-size: 12px; }
.audit-entry__actor > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-entry time { color: var(--muted); font-size: 11px; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .audit-entry { grid-template-columns: 36px 1fr auto; } .audit-entry__actor { display: none; } }

/* Application log — reworked unified threaded feed */
#application-comments.application-chat { display: flex; flex-direction: column; gap: 0; padding: 14px 18px 22px; }
#application-comments.application-chat::before { content: none; }
.log-entry { position: relative; display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 9px 0; }
.log-entry__rail { position: relative; display: flex; justify-content: center; }
.log-entry:not(:last-child) .log-entry__rail::before { content: ""; position: absolute; top: 34px; bottom: -9px; left: 50%; width: 1px; transform: translateX(-50%); background: color-mix(in srgb, var(--line) 82%, transparent); }
.log-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; border: 1px solid color-mix(in srgb, var(--event-color, var(--muted)) 30%, var(--line)); background: color-mix(in srgb, var(--event-color, var(--muted)) 12%, var(--surface)); color: var(--event-color, var(--muted)); }
.log-icon svg { width: 16px; height: 16px; }
.log-avatar { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-soft); color: var(--muted); font-size: 11px; font-weight: 800; }
.log-entry.is-own .log-avatar { border-color: color-mix(in srgb, var(--primary) 26%, var(--line)); background: var(--primary-soft); color: var(--primary); }
.log-entry__main { min-width: 0; padding-top: 1px; }
.log-entry__head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.log-entry__head strong { min-width: 0; overflow: hidden; font-size: 12.5px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.log-entry__head time { flex: none; margin-left: auto; color: var(--muted); font-size: 10px; white-space: nowrap; }
.log-tag { flex: none; padding: 2px 7px; border-radius: 99px; background: color-mix(in srgb, var(--event-color, var(--muted)) 13%, transparent); color: var(--event-color, var(--muted)); font-size: 9px; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
.log-tag--you { background: var(--primary-soft); color: var(--primary); }
.log-text { margin: 0; color: var(--text); font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; }
.log-details { display: grid; gap: 5px; margin-top: 8px; padding: 9px 12px; border-radius: 9px; border-left: 2px solid color-mix(in srgb, var(--event-color, var(--muted)) 45%, var(--line)); background: var(--surface-soft); }
.log-detail { display: grid; grid-template-columns: minmax(72px, .5fr) minmax(0, 1fr); gap: 8px; font-size: 11px; line-height: 1.4; }
.log-detail small { color: var(--muted); }
.log-detail > span { color: var(--text); overflow-wrap: anywhere; }
.log-was { color: var(--muted); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 55%, transparent); }
.log-arrow { margin: 0 6px; color: var(--muted); }
.log-val { color: var(--text); font-weight: 550; }

/* Busy state — spinner overlay that preserves the button's size (no layout shift) */
@keyframes spin { to { transform: rotate(360deg); } }
.button.is-busy { position: relative; color: transparent !important; pointer-events: none; }
.button.is-busy > * { visibility: hidden; }
.button.is-busy::after { content: ""; position: absolute; top: calc(50% - 8px); left: calc(50% - 8px); width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgb(255 255 255 / .4); border-top-color: #fff; animation: spin .6s linear infinite; }
.button:not(.button--primary):not(.button--danger).is-busy::after { border-color: color-mix(in srgb, var(--text) 22%, transparent); border-top-color: var(--text); }
.button--danger.is-busy::after { border-color: color-mix(in srgb, var(--danger) 30%, transparent); border-top-color: var(--danger); }

/* New-item emphasis on sidebar counters + notification settings */
.nav__badge.is-new { animation: badge-pulse 1.8s ease-in-out infinite; }
@keyframes badge-pulse { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, #ff3b4f 55%, transparent); } 60% { box-shadow: 0 0 0 6px transparent; } }
.sound-settings { margin-bottom: 22px; }
.sound-settings .section-heading { margin-bottom: 14px; }
.sound-settings__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 12px; }
.sound-toggle { padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: var(--shadow-sm); }
.icon-button-labeled svg { width: 16px; height: 16px; }

/* Recent-project quick pick inside a new application */
.project-recent { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 9px; }
.project-recent[hidden] { display: none; }
.project-recent__label { color: var(--muted); font-size: 11px; font-weight: 640; }
.project-recent__chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface); color: var(--text); font-size: 12px; font-weight: 600; cursor: pointer; transition: border-color .15s, background .15s; }
.project-recent__chip::before { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: var(--tag-color, var(--primary)); content: ""; }
.project-recent__chip:hover { border-color: var(--tag-color, var(--primary)); background: color-mix(in srgb, var(--tag-color, var(--primary)) 10%, var(--surface)); }
.log-event--created { --event-color: var(--primary); }
.log-event--changed { --event-color: #8b6fd6; }
.log-event--status { --event-color: var(--warning); }
.log-event--closed { --event-color: var(--success); }
.log-event--payment { --event-color: var(--success); }
.log-event--system { --event-color: var(--muted); }
.log-reply { margin: 0 0 6px; padding: 6px 10px; border-left: 2px solid var(--primary); border-radius: 0 7px 7px 0; background: var(--surface-soft); color: var(--muted); font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-bubble { padding: 9px 12px; border: 1px solid var(--line); border-radius: 4px 12px 12px 12px; background: var(--surface); }
.log-bubble > :first-child { margin-top: 0; }
.log-entry.is-own .log-bubble { border-color: color-mix(in srgb, var(--primary) 20%, var(--line)); background: var(--primary-soft); }
.log-bubble p { margin: 0; font-size: 13px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.log-entry__foot { display: flex; align-items: center; gap: 12px; margin-top: 5px; }
.log-entry__foot button { padding: 0; border: 0; background: transparent; color: var(--primary); font-size: 11px; font-weight: 600; cursor: pointer; }
.log-entry__foot button:hover { text-decoration: underline; }
.log-read { color: var(--muted); font-size: 10px; }
.log-empty { margin: auto; display: grid; justify-items: center; gap: 7px; padding: 44px 20px; color: var(--muted); text-align: center; }
.log-empty svg { width: 26px; height: 26px; opacity: .55; }
.log-empty strong { color: var(--text); font-size: 13px; }
.log-empty small { font-size: 11px; max-width: 220px; }
@media (max-width: 500px) { #application-comments.application-chat { padding-inline: 12px; } }

/* ============================================================
   Кнопка бокового меню (мобильная версия)
   Три полоски превращаются в крестик по aria-expanded, который
   уже переключает app.js — отдельный класс состояния не нужен.
   ============================================================ */
.menu-button { position: relative; flex: 0 0 auto; width: 42px; height: 42px; border: 0; border-radius: 13px; background: transparent; color: var(--text); box-shadow: none; transition: background .2s, color .2s, transform .14s; }
.menu-button:hover { background: var(--surface-soft); }
.menu-button:active { transform: scale(.93); }
.menu-button span { position: absolute; left: 50%; display: block; width: 17px; height: 2px; margin: 0 0 0 -8.5px; border-radius: 99px; background: currentColor; transition: transform .34s cubic-bezier(.4,.01,.2,1), width .28s ease, opacity .16s ease; }
/* Центры полосок — 14 / 21 / 28, середина кнопки 42px — тоже 21, отсюда сдвиг ±7 в крестик. */
.menu-button span:nth-child(1) { top: 13px; }
.menu-button span:nth-child(2) { top: 20px; width: 11px; }
.menu-button span:nth-child(3) { top: 27px; }
.menu-button:hover span:nth-child(2) { width: 17px; }
.menu-button[aria-expanded="true"] { background: var(--primary-soft); color: var(--primary); }
.menu-button[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-button[aria-expanded="true"] span:nth-child(2) { width: 0; opacity: 0; }
.menu-button[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
/* Пока меню закрыто, счётчики новых заявок не видны — выносим их точкой на саму кнопку. */
.menu-button::after { content: ""; position: absolute; top: -3px; right: -3px; width: 10px; height: 10px; border: 2px solid var(--surface); border-radius: 50%; background: #ff3b4f; opacity: 0; transform: scale(.4); transition: opacity .2s, transform .2s; }
body:has(.nav__badge.is-new) .menu-button::after { opacity: 1; transform: scale(1); }
.menu-button[aria-expanded="true"]::after { opacity: 0; transform: scale(.4); }

/* ============================================================
   Адаптация
   ============================================================ */
html { -webkit-text-size-adjust: 100%; }
img, video { max-width: 100%; height: auto; }
/* dvh: на телефонах адресная строка съедает часть 100vh. Порядок правил повторяет
   исходный каскад — иначе общая высота модалки перебьёт лист снизу и полноэкранную заявку. */
.app, .login-screen { min-height: 100vh; min-height: 100dvh; }
.modal, .modal__surface { max-height: min(90vh, 800px); max-height: min(90dvh, 800px); }
@media (max-width: 680px) {
  .modal, .modal__surface { max-height: calc(100vh - var(--header-height)); max-height: calc(100dvh - var(--header-height)); }
}
.application-page, .application-page__surface { width: 100%; max-height: none; margin: 0; height: 100vh; height: 100dvh; }
.table-wrap { -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
/* Фон не должен уезжать под открытым мобильным меню. */
html:has(#sidebar.is-open) { overflow: hidden; }
/* Длинные названия разрешений раздвигали карточку шире её колонки в сетке. */
.role-card { grid-template-columns: minmax(0, 1fr); }
.role-card > * { min-width: 0; }
/* Фильтр статусов притворяется выпадающим списком, но это button — по умолчанию он
   центрировал подпись, и в колонке фильтров «Все статусы» выбивалось из ряда. */
.status-filter__trigger { text-align: left; }

@media (max-width: 900px) {
  .header { gap: 12px; padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right)); }
  .sidebar { padding-bottom: max(12px, env(safe-area-inset-bottom)); overscroll-behavior: contain; }
  .main { padding-inline: max(18px, env(safe-area-inset-left)) max(18px, env(safe-area-inset-right)); }
  .toast-region { right: max(12px, env(safe-area-inset-right)); width: min(360px, calc(100vw - 24px)); }
  /* Свернуть можно только закреплённую панель. Сохранённое с десктопа состояние
     оставляло в выдвижном меню 290px иконок без подписей — сбрасываем его здесь. */
  .sidebar-collapse { display: none; }
  .app.is-sidebar-collapsed .sidebar { padding-inline: 12px; }
  .app.is-sidebar-collapsed .nav { gap: 16px; }
  .app.is-sidebar-collapsed .nav__label { height: auto; margin: 0 0 4px; padding: 0 12px; color: var(--muted); background: none; }
  .app.is-sidebar-collapsed .nav__item { justify-content: flex-start; padding-inline: 12px; }
  .app.is-sidebar-collapsed .nav__item.is-active::before { display: block; }
  .app.is-sidebar-collapsed .nav__item > span:not(.nav__badge) { display: inline; }
  .app.is-sidebar-collapsed .nav__badge { position: static; min-width: 20px; margin: 0 0 0 auto; padding: 2px 6px; }
}

@media (max-width: 850px) {
  /* Страница заявки прокручивается целиком — иначе кнопка «назад» уезжает вверх. */
  .application-page__header { position: sticky; top: 0; z-index: 2; background: var(--surface-raised); }
}

/* Узкие вкладки лучше прокручивать, чем сжимать до нечитаемых. */
@media (max-width: 760px) {
  .segmented-tabs, .moderation-tabs { width: 100%; max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .segmented-tabs::-webkit-scrollbar, .moderation-tabs::-webkit-scrollbar { display: none; }
  .segmented-tab, .moderation-tabs button { flex: 1 0 auto; white-space: nowrap; }
  .report-toolbar .search { width: 100%; }
  .report-toolbar .staff-report__meta { margin: 0; }
  .moderation-filters .search { flex: 0 0 auto; }
}

@media (max-width: 680px) {
  /* .filters здесь становится колонкой, а в колоночном flex-контейнере flex-basis задаёт
     ВЫСОТУ: из-за `flex: 1 1 300px` поле поиска вытягивалось в блок высотой 300px. */
  .filters .search { flex: 0 0 auto; }
  /* Ширину задают обе вставки сразу — тогда уведомление не может вылезти за экран
     ни при какой ширине окна и ни при каком вырезе. */
  .toast-region { left: max(12px, env(safe-area-inset-left)); right: max(12px, env(safe-area-inset-right)); width: auto; }
  .modal__header, .modal__footer { padding: 14px 16px; }
  .modal__body, .application-page .modal__body { padding: 16px; }
  .modal-error { padding: 0 16px; }
  .editor-card { padding: 16px; }
  /* Сетка из четырёх колонок не помещалась: имя и кнопки сверху, цены — строкой ниже. */
  .project-tag-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name actions" "price payout"; gap: 4px 10px; padding: 9px 10px; }
  .project-tag-row > .badge { grid-area: name; }
  .project-tag-row > strong { grid-area: price; text-align: left; }
  .project-tag-row > small { grid-area: payout; text-align: right; }
  .project-tag-row__actions { grid-area: actions; }
  .project-fields { padding: 12px; }
  .business-payouts div { padding: 18px 10px; }
}

@media (max-width: 520px) {
  .header { gap: 8px; }
  /* Имя и роль остаются в поповере профиля — в шапке для них нет места. */
  .profile-button__copy, .profile-button__chevron { display: none; }
  .profile-button { max-width: none; padding: 4px; }
  /* Освободившееся место отдаём логотипу: без надписи в шапке оставался один знак. */
  .brand__wordmark { display: block; }
  .main { padding-inline: max(14px, env(safe-area-inset-left)) max(14px, env(safe-area-inset-right)); }
  .advanced-search { padding: 14px; }
  .advanced-search__grid { grid-template-columns: 1fr; }
  .advanced-search__grid .switch { justify-self: stretch; }
  .calendar-day { min-height: 54px; padding: 3px; }
  .calendar-day__number { width: 22px; height: 22px; font-size: 10.5px; }
  .calendar-weekday { padding: 9px 2px; font-size: 9px; }
  .calendar-summary { margin-top: 6px; gap: 4px; }
  .operator-actions { padding: 10px; }
  .operator-actions button { flex: 1 1 132px; }
  .empty-state { padding: 40px 16px; }
  .editor-head { flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
  .queue-summary strong { font-size: 22px; }
  .dashboard-cards strong, .business-kpis strong { font-size: 22px; }
  .stat-tile strong, .profile-stats--page strong { font-size: 21px; }
}

/* ── Статистика по проектам ──────────────────────────────────────────────
   `.panel` заменяет `.table-card` на этих экранах: у карточки-таблицы нет
   внутренних отступов, поэтому заголовки и графики упирались в рамку. */
.panel { margin-bottom: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.panel__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; padding: 18px 20px 16px; border-bottom: 1px solid var(--line); }
.panel__head h2 { margin-bottom: 0; font-size: 17px; }
.panel__head .segmented-tabs { margin-bottom: 0; box-shadow: none; background: var(--surface-soft); }
.panel__body { padding: 18px 20px 20px; }
.panel__body > .stat-tiles:last-child, .panel__body > .chart-summary:last-child { margin-bottom: 0; }
.panel__subhead { margin: 0 0 12px; font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.panel__subhead span { font-weight: 500; text-transform: none; letter-spacing: 0; }
.panel__hint { color: var(--muted); font-size: 11.5px; }
.panel__note { margin-top: 14px; font-size: 12px; }
.panel__split { display: grid; gap: 20px; }
.panel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 16px; align-items: start; }
.panel-grid .panel { margin-bottom: 18px; }
.project-report__heading { margin: 24px 0 14px; align-items: baseline; }
.stat-tiles--wide { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat-tile__hint { color: var(--muted); font-size: 11px; line-height: 1.35; }
.stat-tile--good { border-color: color-mix(in srgb, var(--success) 36%, var(--line)); }
.stat-tile--good strong { color: var(--success); }
.stat-tile--warn { border-color: color-mix(in srgb, var(--warning) 36%, var(--line)); }
.stat-tile--bad { border-color: color-mix(in srgb, var(--danger) 32%, var(--line)); }

/* Графики. Рисуются в реальных пикселях (1 unit = 1px), поэтому размеры
   подписей задаются здесь и не зависят от масштабирования viewBox. */
/* Один источник правды для «цвета столбца»: график, легенда и тултип берут его
   отсюда, а тёмная тема поднимает насыщенность — 40% поверх near-black тонет. */
.chart-figure, .chart-legend { --chart-bar: color-mix(in srgb, var(--chart-accent, var(--primary)) 42%, transparent); }
:root[data-theme="dark"] .chart-figure, :root[data-theme="dark"] .chart-legend { --chart-bar: color-mix(in srgb, var(--chart-accent, var(--primary)) 66%, transparent); }
.chart-figure { position: relative; margin-bottom: 14px; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
/* Пунктирная сетка вместо сплошной: столбцы и линия выручки должны читаться
   как передний план, а не спорить с разлиновкой. */
.chart__grid { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 5; shape-rendering: crispEdges; }
.chart__baseline { stroke: var(--line-strong); stroke-width: 1; shape-rendering: crispEdges; }
.chart__axis { fill: var(--muted); font-size: 10.5px; font-weight: 600; font-variant-numeric: tabular-nums; stroke: none; }
.chart__axis--revenue { fill: color-mix(in srgb, var(--warning) 82%, var(--muted)); }
.chart__weekend { fill: var(--surface-soft); opacity: .55; }
.chart__focus { fill: color-mix(in srgb, var(--text) 8%, transparent); transition: opacity .1s; pointer-events: none; }
.chart__bar { fill: var(--chart-bar); }
.chart__bar--done { fill: var(--success); }
.chart__line { fill: none; stroke: var(--warning); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__area { fill: color-mix(in srgb, var(--warning) 12%, transparent); stroke: none; }
.chart__dot { fill: var(--surface); stroke: var(--warning); stroke-width: 2; }
.chart__bar--visits { fill: color-mix(in srgb, var(--primary) 62%, transparent); }
:root[data-theme="dark"] .chart__bar--visits { fill: color-mix(in srgb, var(--primary) 78%, transparent); }
.chart-empty { padding: 28px 0; text-align: center; }

.chart-tip { position: absolute; z-index: 5; top: 8px; display: grid; gap: 3px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-raised); box-shadow: var(--shadow); font-size: 12px; white-space: nowrap; pointer-events: none; transform: translateX(10px); }
.chart-tip--flip { transform: translateX(calc(-100% - 10px)); }
.chart-tip strong { font-size: 12px; text-transform: capitalize; }
.chart-tip span { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.chart-tip b { margin-left: auto; padding-left: 10px; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-tip__swatch { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 3px; background: var(--chart-bar, var(--primary)); }
.chart-tip__swatch--done { background: var(--success); }
.chart-tip__swatch--line { height: 3px; border-radius: 2px; background: var(--warning); }
.chart-tip__swatch--visits { background: color-mix(in srgb, var(--primary) 70%, transparent); }

.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-bottom: 14px; }
.chart-legend__item { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 600; }
.chart-legend__item--muted { opacity: .75; font-weight: 500; }
.chart-legend__swatch { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 3px; background: var(--primary); }
.chart-legend__swatch--bar { background: var(--chart-bar); }
.chart-legend__swatch--done { background: var(--success); }
.chart-legend__swatch--line { height: 3px; border-radius: 2px; background: var(--warning); }
.chart-legend__swatch--weekend { background: var(--surface-soft); border: 1px solid var(--line-strong); }

/* Разделители рисует кольцо box-shadow вокруг каждой ячейки, а не подложка
   контейнера: при переносе на вторую строку пустая ячейка иначе заливалась
   цветом линии сплошным прямоугольником. Кольца соседей делят один пиксель
   зазора, крайние — обрезаются overflow: hidden. */
.chart-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 1px; margin-top: 4px; overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.chart-summary--tight { grid-template-columns: repeat(2, 1fr); margin-top: 16px; }
.chart-summary__item { display: grid; gap: 4px; padding: 12px 14px; background: var(--surface); box-shadow: 0 0 0 1px var(--line); }
.chart-summary__item small { color: var(--muted); font-size: 11px; }
.chart-summary__item strong { font-size: 16px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.chart-summary__item .is-positive { color: var(--success); }
.chart-summary__item .is-negative { color: var(--danger); }

/* Списки-бары (города, статусы). Заголовок больше не режется фиксированной
   колонкой в 140px — он занимает свободное место и переносится при нехватке.
   Колонка значений разбита на две ФИКСИРОВАННЫЕ ячейки: при общем выравнивании
   по правому краю счётчик уезжал влево, когда процент оказывался шире
   («5 41.7%» против «3 25%»), и цифры гуляли от строки к строке. */
.bar-list { display: grid; gap: 3px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 1.1fr) minmax(60px, 2fr) 94px; align-items: center; gap: 12px; padding: 5px 8px; border-radius: 8px; transition: background .15s; }
.bar-row:hover, .bar-row.is-active { background: var(--surface-soft); }
.bar-row__label { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-row__label i { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 3px; }
.bar-row__track { height: 9px; border-radius: 99px; background: color-mix(in srgb, var(--line) 65%, var(--surface)); overflow: hidden; }
.bar-row:hover .bar-row__track, .bar-row.is-active .bar-row__track { background: color-mix(in srgb, var(--line-strong) 70%, var(--surface)); }
.bar-row__track span { display: block; height: 100%; border-radius: 99px; transition: width .25s; }
.bar-row__value { display: grid; grid-template-columns: 1fr 44px; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.bar-row__value b { font-size: 13px; font-weight: 700; text-align: right; }
.bar-row__value small { color: var(--muted); font-size: 11px; text-align: right; }
#traffic-cities-more { margin-top: 12px; }
.button--quiet { border-color: transparent; background: var(--surface-soft); color: var(--muted); }
.button--quiet:hover { color: var(--text); }

.donut-block { display: grid; grid-template-columns: auto minmax(180px, 1fr); align-items: center; gap: 22px; }
.donut { width: 176px; height: 176px; flex: 0 0 auto; }
.donut__track { fill: none; stroke: color-mix(in srgb, var(--line) 70%, var(--surface)); }
.donut__arc { fill: none; cursor: pointer; transition: stroke-width .16s, opacity .16s; }
.donut__arc.is-active { stroke-width: 34; }
.donut__arc.is-dim { opacity: .22; }
.donut__value { fill: var(--text); font-size: 30px; font-weight: 750; letter-spacing: -.03em; stroke: none; }
.donut__label { fill: var(--muted); font-size: 11.5px; font-weight: 600; stroke: none; }
.bar-list--legend { max-height: 236px; overflow-y: auto; }

.money-bar { display: grid; gap: 12px; }
.money-bar__row { display: grid; grid-template-columns: 74px 1fr auto; align-items: center; gap: 12px; }
.money-bar__row small { color: var(--muted); font-size: 12px; }
.money-bar__row b { font-size: 13.5px; font-variant-numeric: tabular-nums; }
.money-bar__track { display: flex; height: 14px; border-radius: 99px; background: var(--surface-soft); overflow: hidden; }
.money-bar__fill { height: 100%; transition: width .3s; }
.money-bar__fill--revenue { background: var(--success); }
.money-bar__fill--operators { background: var(--primary); }
.money-bar__fill--masters { background: var(--warning); }

.project-report { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.project-report-card { display: grid; gap: 13px; padding: 16px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); text-align: left; cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .12s; }
.project-report-card:hover { border-color: color-mix(in srgb, var(--project-color, var(--primary)) 55%, var(--line)); box-shadow: var(--shadow); transform: translateY(-1px); }
.project-report-card__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.project-report-card__name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.project-report-card__name strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-report-card__dot { width: 10px; height: 10px; flex: 0 0 auto; border-radius: 3px; background: var(--project-color, var(--primary)); }
.pill { flex: 0 0 auto; padding: 4px 9px; border-radius: 99px; font-size: 11.5px; font-weight: 750; font-variant-numeric: tabular-nums; }
.pill--good { background: var(--success-soft); color: var(--success); }
.pill--warn { background: var(--warning-soft); color: var(--warning); }
.pill--bad { background: var(--danger-soft); color: var(--danger); }
.project-report-card__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.project-report-card__stats div { display: grid; gap: 3px; min-width: 0; padding: 9px 10px; border-radius: 9px; background: var(--surface-soft); }
.project-report-card__stats small { color: var(--muted); font-size: 9.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.project-report-card__stats strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-strip { display: flex; height: 6px; gap: 2px; border-radius: 99px; overflow: hidden; }
.status-strip span { min-width: 3px; border-radius: 99px; }
.project-report-card__foot { display: flex; align-items: center; gap: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.project-report-card__spark { flex: 1 1 auto; min-width: 0; }
.project-report-card__trend { display: flex; flex: 0 0 auto; align-items: center; gap: 8px; }
.project-report-card__trend small { color: var(--muted); font-size: 11px; white-space: nowrap; }
.sparkline { display: block; width: 100%; height: 40px; }
.sparkline__bar { fill: color-mix(in srgb, var(--spark, var(--primary)) 45%, transparent); stroke: none; }
.sparkline__bar.is-peak { fill: var(--spark, var(--primary)); }
.sparkline__empty { stroke: var(--line); stroke-width: 1; }
:root[data-theme="dark"] .sparkline__bar { fill: color-mix(in srgb, var(--spark, var(--primary)) 62%, transparent); }
.trend { padding: 3px 7px; border-radius: 7px; font-size: 11px; font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }
.trend--up { background: var(--success-soft); color: var(--success); }
.trend--down { background: var(--danger-soft); color: var(--danger); }
.trend--flat { background: var(--surface-soft); color: var(--muted); }

@media (max-width: 900px) {
  .panel-grid { grid-template-columns: 1fr; }
  .donut-block { grid-template-columns: 1fr; justify-items: center; gap: 18px; }
  .bar-list--legend { width: 100%; max-height: none; }
}
@media (max-width: 620px) {
  .panel__head { align-items: stretch; padding: 16px 14px 14px; }
  .panel__body { padding: 14px; }
  .panel__head .segmented-tabs { width: 100%; }
  .project-report-card__stats { grid-template-columns: repeat(2, 1fr); }
  .bar-row { grid-template-columns: minmax(0, 1fr) 94px; gap: 8px 12px; }
  .bar-row__track { grid-column: 1 / -1; order: 3; }
  .donut { width: 160px; height: 160px; }
  .chart-tip { white-space: normal; max-width: 200px; }
}
