/* ТМ UI — общие основы клиентского кабинета и панели владельца. */
:root, :root[data-theme=light] {
  --bg:#f4f6f9; --bg2:#fff; --card:#fff; --text:#172336; --tx:#172336;
  --muted:#64748b; --mu:#64748b; --t2:#3e4c62; --t3:#64748b;
  --line:#e3e8ef; --accent:#2563eb; --lk:#1d4ed8; --navy:#142235;
  --blue:#2563eb; --green:#087665; --red:#c8393b; --danger:#c8393b; --gold:#b7791f;
  --ok:#087665; --okt:#087665; --ert:#b4233d; --wat:#8a5d00;
  --side:#142235; --cs:light; --r:12px; --sans:"Inter",Arial,sans-serif;
  --display:"Inter Display","Inter",Arial,sans-serif;
  --w03:#f8fafc; --w04:#f8fafc; --w05:#f1f5f9; --w06:#f1f5f9;
  --w07:#edf2f7; --w08:#edf2f7; --w09:#e3e8ef; --w10:#e8edf4; --w11:#e3e8ef;
  --act:#e8f0ff; --actt:#1d4ed8; --topbg:#fff; --tipbg:#fff;
  --tm-soft:#e8f0ff; --tm-hover:#edf2f7; --tm-border:#c8d2df;
  --tm-button-text:#fff; --tm-focus:#2563eb; --tm-side-text:#bfccdc;
  --shadow:rgba(20,40,90,.16); --cross:#758399;
  --tm-nav-row:36px; --tm-nav-pad-y:8px; --tm-nav-gap:2px;
  --tm-nav-active-bg:#1c3559; --tm-nav-active-text:#b8d2ff; --tm-nav-marker:#79a8ff;
}
:root[data-theme=dark] {
  --bg:#101722; --bg2:#192333; --card:#192333; --text:#edf2f9; --tx:#edf2f9;
  --muted:#a2b2c8; --mu:#a2b2c8; --t2:#c8d3e2; --t3:#a2b2c8;
  --line:#2b3b50; --accent:#93bbff; --lk:#b8d2ff; --navy:#0c1421;
  --blue:#93bbff; --green:#64d5b9; --red:#ff8b80; --danger:#ff8b80; --gold:#e3b04a;
  --ok:#64d5b9; --okt:#64d5b9; --ert:#ffa79e; --wat:#ecc873;
  --side:#0c1421; --cs:dark; --w03:#1b2739; --w04:#1e2b3d; --w05:#1e2b3d;
  --w06:#24354a; --w07:#24354a; --w08:#2b3b50; --w09:#2b3b50;
  --w10:#304157; --w11:#304157; --act:#1b3155; --actt:#b8d2ff;
  --topbg:#192333; --tipbg:#192333; --tm-soft:#1b3155; --tm-hover:#24354a;
  --tm-border:#435570; --tm-button-text:#0c1f3f; --tm-focus:#93bbff;
  --shadow:rgba(0,0,0,.4); --cross:#a2b2c8;
}
html {color-scheme:var(--cs)}
.tm-ui {font-family:var(--sans);font-size:14px;line-height:1.5}
.tm-ui .shell {display:grid;grid-template-columns:240px minmax(0,1fr)}
.tm-ui .side {background:var(--side);color:var(--tm-side-text);padding:20px 12px 16px;gap:12px;border-right:1px solid #26374e;overflow-y:auto}
.tm-ui .side .brand {color:#fff;font-size:20px;padding:0 12px;gap:10px}
.tm-ui .side .brand small {color:#9eafc5;font-size:12px}
.tm-ui .side .mark {width:32px;height:32px;flex:none;background:none;border-radius:0;filter:none}
.tm-owner .side .mk-l {display:inline-flex}
.tm-owner .side .mk-d {display:none}
.tm-ui .side nav {gap:var(--tm-nav-gap)}
.tm-ui .side nav a, .tm-ui .side nav .soon {min-height:var(--tm-nav-row);padding:var(--tm-nav-pad-y) 12px;border-radius:8px;gap:10px;font-size:14px;color:var(--tm-side-text);line-height:20px}
.tm-ui .side nav a:hover, .tm-ui .side-foot a:hover, .tm-ui .side-foot button:hover {background:#253a51;color:#fff}
.tm-ui .side nav a[aria-current=page] {background:var(--tm-nav-active-bg);color:var(--tm-nav-active-text);box-shadow:inset 3px 0 var(--tm-nav-marker);font-weight:600}
:root[data-theme] .tm-ui .side nav a[aria-current=page] {background:var(--tm-nav-active-bg);color:var(--tm-nav-active-text)}
.tm-ui .side .side-foot {border-top:1px solid #34465c;padding-top:12px}
.tm-ui .side-foot a, .tm-ui .side-foot button {color:var(--tm-side-text);border-radius:8px;min-height:var(--tm-nav-row);padding:var(--tm-nav-pad-y) 12px;font-size:14px;line-height:20px;gap:10px}
.tm-ui .datanav > summary {color:#9eafc5;font-size:12px;padding:10px 12px}
.tm-ui .side .tm-icon {width:20px;height:20px}
.tm-icon {width:20px;height:20px;flex:none;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.tm-ui .top {display:flex;min-height:64px;position:sticky;top:0;z-index:20;padding:10px 24px;gap:16px;background:var(--card);border-bottom:1px solid var(--line);backdrop-filter:none;justify-content:space-between}
.tm-ui .top .top-t {font:600 16px var(--sans);color:var(--text)}
.tm-tools {margin-left:auto;display:flex;align-items:center;gap:12px;min-width:0}
.tm-tool {display:inline-flex;align-items:center;justify-content:center;gap:6px;min-height:40px;padding:8px;border-radius:8px;color:var(--t2);font-size:13px;font-weight:500;text-decoration:none;white-space:nowrap}
:root[data-theme] .tm-ui a.tm-tool {color:var(--t2)}
.tm-tool:hover {background:var(--tm-hover)}
.tm-profile {display:flex;flex-direction:column;gap:2px;min-width:0;max-width:200px;text-decoration:none;color:var(--text);line-height:1.3}
:root[data-theme] .tm-ui .tm-profile {color:var(--text)}
.tm-profile-name {overflow:hidden;white-space:nowrap;text-overflow:ellipsis;font-weight:600;font-size:13px}
.tm-profile-role {font-size:12px;color:var(--muted)}
.tm-ui .themebtn {width:40px;height:40px;padding:0;border:1px solid var(--tm-border);border-radius:8px;background:var(--card);color:var(--text);display:inline-flex;align-items:center;justify-content:center;cursor:pointer;margin:0;flex:none}
.tm-ui .themebtn:hover {background:var(--tm-hover)}
.tm-ui .themebtn .i-sun {display:none}
:root[data-theme=dark] .tm-ui .themebtn .i-sun {display:block}
:root[data-theme=dark] .tm-ui .themebtn .i-moon {display:none}
.tm-ui .side-foot .themebtn {width:100%;height:auto;justify-content:flex-start;border:0;background:none;color:var(--tm-side-text);padding:var(--tm-nav-pad-y) 12px;gap:10px;font:500 14px/20px var(--sans)}
.tm-ui main {padding:32px 24px 64px;max-width:1440px}
.tm-ui .work {max-width:1680px}
.tm-ui .work main {min-width:0}
.tm-ui .head {margin-bottom:24px;gap:16px;align-items:center}
.tm-ui h1, .tm-ui .head h1 {font-size:32px;line-height:40px;font-weight:700;letter-spacing:-.025em}
.tm-ui h2 {font-size:20px;line-height:28px;font-weight:600}
.tm-ui .head p {font-size:14px;margin-top:6px}
.tm-ui :is(.panel,.card,.bcard,.about-card,.kpi,.big) {border:1px solid var(--line);border-radius:12px;background:var(--card);box-shadow:none}
.tm-ui :is(.panel,.card,.bcard,.about-card) {padding:24px}
.tm-ui .panel.list {padding:8px 24px}
.tm-ui .card.flush {padding:0}
.tm-ui .kpis, .tm-ui .hero3 {gap:16px;margin-bottom:24px}
.tm-ui .kpi, .tm-ui .big {padding:20px;min-width:0}
.tm-ui .kpi strong, .tm-ui .kpi > b, .tm-ui .big .n {font-size:28px;line-height:36px;font-weight:700;overflow-wrap:anywhere}
.tm-ui .kpi p, .tm-ui .kpi .lb, .tm-ui .big .lb {font-size:13px;color:var(--muted)}
.tm-ui .today-wd {color:var(--text);font-size:28px;line-height:36px}
.tm-ui :is(.btn,button.btn) {display:inline-flex;justify-content:center;align-items:center;gap:8px;min-height:40px;padding:8px 16px;border:1px solid transparent;border-radius:8px;background:var(--accent);color:var(--tm-button-text);font:600 14px/20px var(--sans);text-decoration:none}
.tm-ui .btn:hover {filter:brightness(.95)}
.tm-ui .btn.small, .tm-ui .btn.xs {min-height:32px;padding:5px 12px;font-size:13px}
.tm-ui .btn.ghost, .tm-ui .btn.ghost-b {background:var(--tm-soft);color:var(--lk);border-color:transparent}
:root[data-theme] .tm-ui a.btn {color:var(--tm-button-text)}
:root[data-theme] .tm-ui a.btn.ghost, :root[data-theme] .tm-ui a.btn.ghost-b {color:var(--lk)}
.tm-ui .btn.tg {background:#167ba6;color:#fff}
:root[data-theme] .tm-ui a.btn.tg {color:#fff}
.tm-ui .btn.wide {display:flex;width:100%}
.tm-ui .btn:disabled {opacity:.5;cursor:not-allowed}
.tm-ui :is(input:not([type]),input[type=text],input[type=email],input[type=password],input[type=search],input[type=url],input[type=tel],input[type=number],input[type=date],select,textarea) {font:400 14px/20px var(--sans);border:1px solid var(--tm-border);border-radius:8px;background:var(--card);color:var(--text);min-height:40px;padding:9px 12px;min-width:0;max-width:100%;color-scheme:var(--cs)}
.tm-ui textarea {resize:vertical}
.tm-ui input::placeholder, .tm-ui textarea::placeholder {color:var(--muted);opacity:1}
.tm-ui :is(a,button,input,textarea,select,summary):focus-visible {outline:2px solid var(--tm-focus);outline-offset:3px}
.tm-ui .seg {border-radius:8px}
.tm-ui .seg a, .tm-ui .chip {border-radius:6px;min-height:32px}
.tm-ui .seg a[aria-current=true], .tm-ui .chip.on {background:var(--accent);color:var(--tm-button-text);border-color:var(--accent)}
.tm-ui .note, .tm-ui .btn.ghost-b, .tm-ui .k-ico:not(.amber):not(.red):not(.green), .tm-ui .mono {background:var(--tm-soft);color:var(--lk);border-color:var(--line)}
.tm-ui .tbl {font-size:14px}
.tm-ui .tbl th, .tm-ui .tbl td {padding:12px 16px}
.tm-ui .tbl th {font-size:12px;color:var(--muted)}
.tm-wallet-grid {display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,300px),1fr));gap:24px}
.tm-wallet-section {margin-top:24px}
.tm-money {font:700 32px/40px var(--display);margin:12px 0}
.tm-company-list {display:grid;gap:8px;margin-top:16px}
.tm-company-row {display:flex;justify-content:space-between;align-items:center;gap:16px;padding:12px 0;border-top:1px solid var(--line)}
.tm-company-row b {overflow-wrap:anywhere;min-width:0}
.tm-company-row .btn {flex:none}
.tm-table-wrap {overflow-x:auto;margin-top:16px}
.tm-table {width:100%;border-collapse:collapse;font-size:14px}
.tm-table :is(th,td) {padding:12px 16px;text-align:left;border-bottom:1px solid var(--line)}
.tm-table th {color:var(--muted);font-size:12px;font-weight:600}
.tm-table .tm-right {text-align:right;white-space:nowrap;font-variant-numeric:tabular-nums}
.tm-ui .pager {display:flex;align-items:center;gap:12px;margin-top:16px}
.tm-ui .burger {display:none}
@media (max-width:1100px) {
  .tm-tools {gap:6px}
  .tm-profile {max-width:140px}
  .tm-ui .top {padding-inline:16px;gap:12px}
  .tm-ui .scope select {max-width:200px}
}
@media (max-width:960px) {
  .tm-ui .shell {display:block}
  .tm-ui .side {position:fixed;left:0;top:0;width:min(84vw,300px);height:100dvh;z-index:60;transform:translateX(-105%);visibility:hidden;transition:transform .2s ease,visibility 0s linear .2s}
  .tm-ui :is(.nav-toggle,.nt):checked ~ .shell .side {transform:none;visibility:visible;transition:transform .2s ease}
  .tm-ui :is(.nav-toggle,.nt):checked ~ .shell .scrim {display:block;position:fixed;inset:0;background:rgba(8,12,20,.55);z-index:50}
  .tm-ui .burger {display:inline-flex;align-items:center;justify-content:center;width:40px;height:40px;border:1px solid var(--tm-border);border-radius:8px;color:var(--text);cursor:pointer;flex:none;padding:0}
  .tm-ui .top .brand.sm {display:none}
  .tm-ui .top-t {display:none}
  .tm-ui .top {flex-wrap:wrap}
  .tm-ui .scope {order:3;flex-basis:100%;margin:0}
  .tm-ui .scope select {width:100%;max-width:100%}
  .tm-ui main {padding:24px 16px 48px}
  .tm-ui .head h1 {font-size:28px;line-height:36px}
}
@media (max-width:600px) {
  .tm-ui .top {padding:8px 12px;gap:8px}
  .tm-tool {width:40px;padding:8px}
  .tm-tool > span {position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
  .tm-tools {gap:2px}
  .tm-profile {max-width:104px;margin-left:4px}
  .tm-profile-name {font-size:12px}
  .tm-profile-role {font-size:11px}
  .tm-ui h1, .tm-ui .head h1 {font-size:24px;line-height:32px}
  .tm-ui :is(.panel,.card,.bcard,.about-card,.kpi,.big) {padding:16px}
  .tm-ui .card.flush {padding:0}
  .tm-ui .kpis, .tm-ui .hero3 {grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
  .tm-ui .hero3 > :last-child:nth-child(odd) {grid-column:1/-1}
  .tm-ui .cards, .tm-ui .fields {grid-template-columns:minmax(0,1fr)}
  .tm-ui .tm-profile {flex-shrink:1}
}
@media (max-width:359px) {.tm-profile {max-width:72px}.tm-tools {gap:0}.tm-tool,.tm-ui .themebtn {width:36px}}
@media (prefers-reduced-motion:reduce) {.tm-ui .side {transition:none}}

/* Активные служебные пункты оформляются так же, как основное меню. */
:root[data-theme] .tm-ui .side-foot a[aria-current=page] {
  background:var(--tm-nav-active-bg); color:var(--tm-nav-active-text);
  box-shadow:inset 3px 0 var(--tm-nav-marker); font-weight:600;
}
@media (max-width:960px) {
  .tm-ui {--tm-nav-row:44px; --tm-nav-pad-y:12px}
}

/* Панель действий аккаунта: настройки, события, тема, профиль. */
.tm-tools .tm-settings-link{order:0}.tm-tools .tm-notifications{order:1}.tm-tools .tm-theme{order:2}.tm-tools .tm-account{order:3}
.tm-dropdown{position:relative}.tm-dropdown summary{cursor:pointer;list-style:none}.tm-dropdown summary::-webkit-details-marker{display:none}
.tm-dropdown>summary{min-width:44px;min-height:44px;display:flex;align-items:center;justify-content:center;border-radius:8px}
.tm-dropdown summary.tm-profile{display:flex;flex-direction:row;align-items:center;gap:10px}
.tm-profile-text{display:flex;flex-direction:column;gap:2px;min-width:0;align-items:flex-start}
.tm-avatar{flex:none;width:36px;height:36px;border-radius:50%;overflow:hidden;display:inline-flex;align-items:center;justify-content:center;background:var(--accent,#2563eb);color:var(--tm-button-text,#fff);font-weight:700;font-size:15px}
.tm-avatar img{width:100%;height:100%;object-fit:cover;display:block}
.tm-dropdown-panel{position:absolute;right:0;top:calc(100% + 8px);width:280px;max-width:calc(100vw - 32px);padding:12px;border:1px solid var(--line);border-radius:12px;background:var(--card);box-shadow:0 12px 32px var(--shadow);color:var(--text);z-index:85;box-sizing:border-box}
.tm-dropdown-panel h2{font-size:16px;margin:4px 8px}.tm-dropdown-panel p{margin:8px;color:var(--muted)}
.tm-dropdown-panel a,.tm-dropdown-panel button{display:flex;align-items:center;min-height:44px;padding:10px 12px;box-sizing:border-box;width:100%;border:0;border-radius:8px;background:transparent;color:var(--text);text-decoration:none;text-align:left;font:inherit;cursor:pointer}
.tm-dropdown-panel a:hover,.tm-dropdown-panel button:hover{background:var(--tm-hover)}
.tm-notification-count{position:absolute;top:0;right:0;font-size:11px;background:var(--accent);color:var(--tm-button-text);border-radius:99px;padding:0 4px}
.tm-dropdown summary:focus-visible{outline:3px solid var(--tm-focus);outline-offset:2px}
@media(max-width:600px){.tm-notifications .tm-dropdown-panel{position:fixed;right:16px;top:72px}.tm-tools{gap:2px}.tm-tools .tm-profile{max-width:100px}}

.tm-tools .tm-settings-link{min-width:44px;min-height:44px;box-sizing:border-box}

/* События: заголовок, содержимое и отдельный служебный подвал. */
.tm-notifications .tm-notification-panel{width:352px;padding:0;border-radius:16px;overflow:hidden}
.tm-notification-heading{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:18px 20px;border-bottom:1px solid var(--line)}
.tm-notification-heading h2{margin:0;font-size:16px}
.tm-event-badge{border-radius:99px;background:var(--tm-soft);color:var(--lk);font-size:11px;font-weight:600;padding:3px 8px;white-space:nowrap}
.tm-notification-empty{display:flex;align-items:center;flex-direction:column;text-align:center;padding:28px 20px 30px;gap:8px}
.tm-empty-icon{display:grid;place-items:center;width:48px;height:48px;margin-bottom:4px;border-radius:50%;background:var(--tm-soft);color:var(--lk)}
.tm-empty-icon .tm-icon{width:24px;height:24px}
.tm-notification-empty strong{font-size:14px}.tm-notification-empty p{font-size:13px;line-height:20px;margin:0}
.tm-notification-panel .tm-notification-caption{margin:16px 20px 8px;font-size:13px}
.tm-event-list{padding:0 10px 12px}
.tm-notification-panel .tm-event-list a{gap:10px;min-height:64px;font-weight:500}
.tm-event-list a>span:first-of-type{flex:1}.tm-event-list small{display:block;color:var(--muted);font-size:12px;font-weight:400;margin-top:2px}
.tm-notification-footer{border-top:1px solid var(--line);padding:6px 10px;background:var(--bg)}
.tm-notification-panel .tm-notification-footer a{gap:8px;font-size:12px;justify-content:center;color:var(--muted)}
.tm-account .tm-dropdown-panel{width:224px;padding:6px;border-radius:12px}
.tm-account .tm-dropdown-panel form{margin:4px 0 0;border-top:1px solid var(--line);padding-top:4px}

.tm-roles-h{margin:0;padding:8px 14px 4px;font-size:12px;color:var(--muted)}.tm-roles-hr{border:0;border-top:1px solid var(--line);margin:6px 0}
.tm-dropdown-panel [aria-current=true]{font-weight:700;background:var(--tm-nav-active-bg,rgba(80,120,255,.18));color:var(--tm-nav-active-text,inherit);border-radius:8px}

.tm-avatar.big{width:96px;height:96px;font-size:36px}

/* Загрузка аватара: аватар слева, под ним выбор файла; не зависит от сетки формы */
.av-edit{grid-column:1/-1;display:flex;gap:20px;align-items:center;flex-wrap:wrap;margin:4px 0 8px}
.av-edit .tm-avatar{width:96px;height:96px;border-radius:50%;background:#2563eb;color:#fff;font-size:38px;font-weight:700;flex:none}
.av-edit .av-side{display:grid;gap:6px;min-width:0;flex:1 1 260px}
.av-edit .av-side b{font-size:14px}.av-edit .av-side small{opacity:.75;font-size:13px;line-height:1.4}
.av-edit input[type=file]{max-width:100%}
.av-edit .av-rm{display:flex;gap:8px;align-items:center;font-size:14px}
.av-pick{position:relative;display:block;cursor:pointer;border-radius:50%;flex:none;line-height:0}
.av-pick input[type=file]{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer;font-size:0}
.av-pick .tm-avatar{line-height:1}
.av-cam{position:absolute;right:0;bottom:2px;width:32px;height:32px;border-radius:50%;background:#fff;color:#0f1b3d;box-shadow:0 1px 4px rgba(0,0,0,.35);display:flex;align-items:center;justify-content:center;pointer-events:none}
.av-pick:hover .tm-avatar,.av-pick:focus-within .tm-avatar{filter:brightness(1.12)}
.av-pick:focus-within{outline:3px solid #9bbcff;outline-offset:3px}

/* Аватар: фото всегда заполняет весь кружок (обрезается по краям, не вписывается внутрь) */
.tm-avatar{position:relative}
.tm-avatar img,.av-edit .tm-avatar img,#av-img{position:absolute;inset:0;width:100%;height:100%;max-width:none;object-fit:cover;object-position:center;padding:0;margin:0;border:0;background:none;border-radius:0}

/* Шапка без названия страницы: заголовок уже есть на самой странице, инструменты справа */
.tm-ui .top .tm-tools{margin-left:auto}
