:root {
  --radius: 18px;
  --radius-sm: 12px;
  --font: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --accent1: #5b6cff;
  --accent2: #7c5cfc;
  --accent: var(--accent1);
  --accent-soft: rgba(91, 108, 255, .14);
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --ring: rgba(91, 108, 255, .3);
  --glow: 0 6px 18px rgba(91, 108, 255, .35);
  --glow-danger: 0 6px 18px rgba(248, 113, 113, .3);
  --ease: cubic-bezier(.2, .7, .3, 1);
}

html[data-theme="dark"] {
  --bg: #0a0c14;
  --bg2: #0e111b;
  --card: #131722;
  --card2: #191e2d;
  --border: rgba(255, 255, 255, .07);
  --text: #eef0f6;
  --muted: #8b90a5;
  --shadow: 0 14px 44px rgba(0, 0, 0, .55);
  --nav-bg: rgba(14, 17, 27, .78);
  --topbar-bg: rgba(10, 12, 20, .62);
  --glass-bg: rgba(255, 255, 255, .06);
  --glass-bg-hover: rgba(255, 255, 255, .1);
  --glass-border: rgba(255, 255, 255, .14);
  --glass-hi: rgba(255, 255, 255, .12);
  --glass-shadow: 0 2px 10px rgba(0, 0, 0, .14);
  --glass-shadow-hover: 0 6px 18px rgba(91, 108, 255, .25);
  --glass-accent1: rgba(91, 108, 255, .6);
  --glass-accent2: rgba(124, 92, 252, .55);
  --glass-danger1: rgba(248, 113, 113, .6);
  --glass-danger2: rgba(239, 68, 68, .5);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f4f6fb;
  --bg2: #ffffff;
  --card: #ffffff;
  --card2: #f3f5fb;
  --border: #e5e9f4;
  --text: #171b26;
  --muted: #67718a;
  --shadow: 0 10px 34px rgba(35, 48, 95, .10);
  --nav-bg: rgba(255, 255, 255, .82);
  --topbar-bg: rgba(244, 246, 251, .72);
  --glass-bg: rgba(255, 255, 255, .6);
  --glass-bg-hover: rgba(255, 255, 255, .82);
  --glass-border: rgba(197, 208, 236, .8);
  --glass-hi: rgba(255, 255, 255, .9);
  --glass-shadow: 0 2px 12px rgba(35, 48, 95, .12);
  --glass-shadow-hover: 0 6px 18px rgba(91, 108, 255, .2);
  --glass-accent1: rgba(91, 108, 255, .82);
  --glass-accent2: rgba(124, 92, 252, .75);
  --glass-danger1: rgba(248, 113, 113, .82);
  --glass-danger2: rgba(239, 68, 68, .72);
  color-scheme: light;
}

html[data-theme="gold"] {
  --accent1: #d4af37;
  --accent2: #f0d47a;
  --accent: var(--accent1);
  --accent-soft: rgba(212, 175, 55, .16);
  --ring: rgba(212, 175, 55, .32);
  --glow: 0 6px 18px rgba(212, 175, 55, .35);
  --bg: #131007;
  --bg2: #191509;
  --card: #1e1910;
  --card2: #272115;
  --border: rgba(212, 175, 55, .14);
  --text: #f2e8cf;
  --muted: #a4936c;
  --shadow: 0 14px 44px rgba(0, 0, 0, .55);
  --nav-bg: rgba(25, 21, 9, .82);
  --topbar-bg: rgba(19, 16, 7, .64);
  --glass-bg: rgba(212, 175, 55, .07);
  --glass-bg-hover: rgba(212, 175, 55, .12);
  --glass-border: rgba(212, 175, 55, .22);
  --glass-hi: rgba(240, 212, 122, .14);
  --glass-shadow: 0 2px 10px rgba(0, 0, 0, .16);
  --glass-shadow-hover: 0 6px 18px rgba(212, 175, 55, .22);
  --glass-accent1: rgba(212, 175, 55, .6);
  --glass-accent2: rgba(240, 212, 122, .5);
  --glass-danger1: rgba(248, 113, 113, .6);
  --glass-danger2: rgba(239, 68, 68, .5);
  color-scheme: dark;
}

html[data-theme="orange"] {
  --accent1: #ff8a2e;
  --accent2: #ff6a3d;
  --accent: var(--accent1);
  --accent-soft: rgba(255, 138, 46, .16);
  --ring: rgba(255, 138, 46, .32);
  --glow: 0 6px 18px rgba(255, 138, 46, .35);
  --bg: #141d36;
  --bg2: #182347;
  --card: #1e2a52;
  --card2: #263364;
  --border: rgba(255, 255, 255, .08);
  --text: #eef2ff;
  --muted: #97a3c9;
  --shadow: 0 14px 44px rgba(0, 0, 0, .5);
  --nav-bg: rgba(24, 35, 71, .82);
  --topbar-bg: rgba(20, 29, 54, .64);
  --glass-bg: rgba(255, 138, 46, .07);
  --glass-bg-hover: rgba(255, 138, 46, .12);
  --glass-border: rgba(255, 255, 255, .15);
  --glass-hi: rgba(255, 255, 255, .12);
  --glass-shadow: 0 2px 10px rgba(0, 0, 0, .14);
  --glass-shadow-hover: 0 6px 18px rgba(255, 138, 46, .25);
  --glass-accent1: rgba(255, 138, 46, .6);
  --glass-accent2: rgba(255, 106, 61, .55);
  --glass-danger1: rgba(248, 113, 113, .6);
  --glass-danger2: rgba(239, 68, 68, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; height: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
  transition: background .25s, color .25s;
  -webkit-tap-highlight-color: transparent;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(91, 108, 255, .13), transparent 60%),
    radial-gradient(760px 480px at 96% 6%, rgba(124, 92, 252, .10), transparent 62%),
    radial-gradient(720px 520px at 50% 116%, rgba(91, 108, 255, .07), transparent 60%);
}

html[data-theme="light"] body::before { opacity: .45; }

html[data-theme="dark"] body {
  background: linear-gradient(180deg, #04050b 0%, #0a0c14 52%, #111530 100%);
  background-attachment: fixed;
}

html[data-theme="light"] body {
  background: linear-gradient(180deg, #f3f5fa 0%, #eaeff7 52%, #e0e7f4 100%);
  background-attachment: fixed;
}

html[data-theme="gold"] body {
  background: linear-gradient(180deg, #0b0903 0%, #131007 52%, #1e170a 100%);
  background-attachment: fixed;
}

html[data-theme="gold"] body::before {
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(212, 175, 55, .12), transparent 60%),
    radial-gradient(760px 480px at 96% 6%, rgba(240, 212, 122, .09), transparent 62%),
    radial-gradient(720px 520px at 50% 116%, rgba(212, 175, 55, .07), transparent 60%);
}

html[data-theme="orange"] body {
  background: linear-gradient(180deg, #0c1226 0%, #141d36 52%, #1c2a55 100%);
  background-attachment: fixed;
}

html[data-theme="orange"] body::before {
  background:
    radial-gradient(900px 520px at 12% -8%, rgba(255, 138, 46, .13), transparent 60%),
    radial-gradient(760px 480px at 96% 6%, rgba(255, 106, 61, .10), transparent 62%),
    radial-gradient(720px 520px at 50% 116%, rgba(255, 138, 46, .07), transparent 60%);
}

#sky {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
  display: block;
  background: linear-gradient(114deg, transparent 28%, rgba(148, 164, 220, .09) 42%, rgba(190, 200, 240, .12) 50%, rgba(148, 164, 220, .09) 58%, transparent 72%);
}

html[data-theme="light"] #sky { filter: invert(1) hue-rotate(180deg); }

#sky i, #sky b { position: absolute; pointer-events: none; }

.sky-far {
  top: -337px;
  left: -337px;
  width: calc(100% + 337px);
  height: calc(100% + 337px);
  background-image:
    radial-gradient(1.1px 1.1px at 14px 31px, rgba(255, 255, 255, .75), transparent),
    radial-gradient(1px 1px at 67px 8px, rgba(205, 218, 255, .6), transparent),
    radial-gradient(.9px .9px at 98px 44px, rgba(255, 255, 255, .5), transparent),
    radial-gradient(1.2px 1.2px at 131px 19px, rgba(232, 238, 255, .8), transparent),
    radial-gradient(1px 1px at 166px 72px, rgba(196, 210, 255, .55), transparent),
    radial-gradient(.9px .9px at 22px 89px, rgba(255, 255, 255, .45), transparent),
    radial-gradient(1.1px 1.1px at 53px 117px, rgba(255, 255, 255, .7), transparent),
    radial-gradient(.9px .9px at 214px 33px, rgba(214, 224, 255, .5), transparent),
    radial-gradient(1.3px 1.3px at 245px 86px, rgba(255, 255, 255, .8), transparent),
    radial-gradient(1px 1px at 289px 11px, rgba(200, 214, 255, .55), transparent),
    radial-gradient(.9px .9px at 311px 57px, rgba(255, 255, 255, .45), transparent),
    radial-gradient(1.1px 1.1px at 187px 128px, rgba(220, 230, 255, .65), transparent),
    radial-gradient(1px 1px at 96px 151px, rgba(255, 255, 255, .5), transparent),
    radial-gradient(.9px .9px at 141px 173px, rgba(235, 240, 255, .4), transparent),
    radial-gradient(1.2px 1.2px at 24px 168px, rgba(255, 255, 255, .75), transparent),
    radial-gradient(1px 1px at 71px 196px, rgba(196, 210, 255, .55), transparent),
    radial-gradient(1.3px 1.3px at 204px 158px, rgba(255, 255, 255, .8), transparent),
    radial-gradient(1px 1px at 262px 142px, rgba(214, 224, 255, .5), transparent),
    radial-gradient(1.1px 1.1px at 299px 187px, rgba(255, 255, 255, .6), transparent),
    radial-gradient(.9px .9px at 9px 214px, rgba(205, 218, 255, .45), transparent),
    radial-gradient(1.2px 1.2px at 117px 232px, rgba(255, 255, 255, .7), transparent),
    radial-gradient(1px 1px at 172px 209px, rgba(220, 230, 255, .5), transparent),
    radial-gradient(1.1px 1.1px at 236px 251px, rgba(232, 238, 255, .6), transparent),
    radial-gradient(.9px .9px at 307px 226px, rgba(255, 255, 255, .5), transparent),
    radial-gradient(1px 1px at 37px 53px, rgba(255, 255, 255, .55), transparent),
    radial-gradient(.9px .9px at 89px 117px, rgba(214, 224, 255, .45), transparent),
    radial-gradient(1.1px 1.1px at 149px 29px, rgba(255, 255, 255, .6), transparent),
    radial-gradient(1px 1px at 212px 87px, rgba(205, 218, 255, .5), transparent),
    radial-gradient(.9px .9px at 267px 41px, rgba(255, 255, 255, .4), transparent),
    radial-gradient(1.2px 1.2px at 322px 133px, rgba(232, 238, 255, .65), transparent),
    radial-gradient(1px 1px at 389px 74px, rgba(255, 255, 255, .5), transparent),
    radial-gradient(.9px .9px at 117px 191px, rgba(220, 230, 255, .45), transparent),
    radial-gradient(1px 1px at 243px 227px, rgba(255, 255, 255, .55), transparent),
    radial-gradient(1.1px 1.1px at 357px 187px, rgba(196, 210, 255, .5), transparent),
    radial-gradient(.9px .9px at 53px 263px, rgba(255, 255, 255, .4), transparent),
    radial-gradient(1px 1px at 191px 307px, rgba(214, 224, 255, .5), transparent),
    radial-gradient(1.2px 1.2px at 311px 341px, rgba(255, 255, 255, .6), transparent),
    radial-gradient(.9px .9px at 401px 289px, rgba(205, 218, 255, .45), transparent);
  background-size: 313px 313px, 431px 431px;
  animation: sky-twinkle-a 6.5s ease-in-out infinite alternate;
}

.sky-mid {
  inset: 0;
  background-image:
    radial-gradient(1.6px 1.6px at 28px 44px, rgba(255, 255, 255, .9), transparent),
    radial-gradient(1.2px 1.2px at 84px 12px, rgba(214, 226, 255, .7), transparent),
    radial-gradient(1.8px 1.8px at 139px 51px, rgba(255, 255, 255, .95), transparent),
    radial-gradient(1px 1px at 197px 9px, rgba(255, 255, 255, .6), transparent),
    radial-gradient(1.5px 1.5px at 251px 38px, rgba(196, 212, 255, .85), transparent),
    radial-gradient(1.1px 1.1px at 318px 17px, rgba(255, 255, 255, .65), transparent),
    radial-gradient(1.7px 1.7px at 372px 66px, rgba(224, 233, 255, .9), transparent),
    radial-gradient(1px 1px at 47px 93px, rgba(255, 255, 255, .55), transparent),
    radial-gradient(1.4px 1.4px at 112px 88px, rgba(210, 222, 255, .8), transparent),
    radial-gradient(1.9px 1.9px at 178px 71px, rgba(255, 255, 255, 1), transparent),
    radial-gradient(1.2px 1.2px at 233px 108px, rgba(255, 255, 255, .7), transparent),
    radial-gradient(1.6px 1.6px at 296px 96px, rgba(206, 220, 255, .9), transparent),
    radial-gradient(1px 1px at 356px 131px, rgba(255, 255, 255, .6), transparent),
    radial-gradient(1.5px 1.5px at 16px 141px, rgba(220, 230, 255, .8), transparent),
    radial-gradient(1.1px 1.1px at 76px 172px, rgba(255, 255, 255, .6), transparent),
    radial-gradient(1.8px 1.8px at 147px 158px, rgba(255, 255, 255, .95), transparent),
    radial-gradient(1.3px 1.3px at 215px 186px, rgba(214, 226, 255, .75), transparent),
    radial-gradient(1px 1px at 281px 163px, rgba(255, 255, 255, .55), transparent),
    radial-gradient(1.6px 1.6px at 343px 201px, rgba(196, 212, 255, .85), transparent),
    radial-gradient(1.2px 1.2px at 394px 243px, rgba(255, 255, 255, .7), transparent),
    radial-gradient(1.4px 1.4px at 37px 224px, rgba(220, 230, 255, .8), transparent),
    radial-gradient(1px 1px at 103px 251px, rgba(255, 255, 255, .6), transparent),
    radial-gradient(1.7px 1.7px at 169px 236px, rgba(228, 236, 255, .9), transparent),
    radial-gradient(1.1px 1.1px at 247px 271px, rgba(255, 255, 255, .65), transparent),
    radial-gradient(1.5px 1.5px at 311px 289px, rgba(206, 220, 255, .8), transparent),
    radial-gradient(1.3px 1.3px at 367px 322px, rgba(255, 255, 255, .7), transparent),
    radial-gradient(1.5px 1.5px at 47px 67px, rgba(255, 255, 255, .85), transparent),
    radial-gradient(1.1px 1.1px at 121px 29px, rgba(214, 226, 255, .6), transparent),
    radial-gradient(1.7px 1.7px at 197px 83px, rgba(255, 255, 255, .95), transparent),
    radial-gradient(1px 1px at 263px 37px, rgba(255, 255, 255, .55), transparent),
    radial-gradient(1.4px 1.4px at 331px 109px, rgba(196, 212, 255, .8), transparent),
    radial-gradient(1.2px 1.2px at 419px 57px, rgba(255, 255, 255, .7), transparent),
    radial-gradient(1.6px 1.6px at 487px 131px, rgba(224, 233, 255, .9), transparent),
    radial-gradient(1px 1px at 89px 167px, rgba(255, 255, 255, .6), transparent),
    radial-gradient(1.3px 1.3px at 211px 149px, rgba(210, 222, 255, .75), transparent),
    radial-gradient(1.5px 1.5px at 293px 213px, rgba(255, 255, 255, .9), transparent),
    radial-gradient(1.1px 1.1px at 377px 191px, rgba(206, 220, 255, .65), transparent),
    radial-gradient(1px 1px at 461px 253px, rgba(255, 255, 255, .55), transparent),
    radial-gradient(1.4px 1.4px at 149px 317px, rgba(220, 230, 255, .75), transparent),
    radial-gradient(1.2px 1.2px at 343px 297px, rgba(255, 255, 255, .7), transparent),
    radial-gradient(1px 1px at 437px 359px, rgba(228, 236, 255, .6), transparent),
    radial-gradient(1.1px 1.1px at 71px 431px, rgba(214, 226, 255, .6), transparent),
    radial-gradient(1.5px 1.5px at 257px 401px, rgba(255, 255, 255, .85), transparent),
    radial-gradient(1.2px 1.2px at 517px 467px, rgba(196, 212, 255, .7), transparent);
  background-size: 401px 401px, 563px 563px;
  animation: sky-twinkle-b 9s ease-in-out -3.5s infinite alternate;
}

.sky-near {
  inset: 0;
  background-image:
    radial-gradient(8px 8px at 71px 97px, rgba(210, 224, 255, .34), transparent),
    radial-gradient(2.6px 2.6px at 71px 97px, rgba(255, 255, 255, 1), transparent),
    radial-gradient(10px 10px at 302px 63px, rgba(255, 232, 180, .28), transparent),
    radial-gradient(2.8px 2.8px at 302px 63px, rgba(255, 246, 220, 1), transparent),
    radial-gradient(6px 6px at 188px 213px, rgba(170, 198, 255, .3), transparent),
    radial-gradient(2.2px 2.2px at 188px 213px, rgba(205, 222, 255, 1), transparent),
    radial-gradient(1.8px 1.8px at 429px 158px, rgba(255, 255, 255, .8), transparent),
    radial-gradient(9px 9px at 515px 243px, rgba(214, 226, 255, .3), transparent),
    radial-gradient(2.5px 2.5px at 515px 243px, rgba(255, 255, 255, 1), transparent),
    radial-gradient(2px 2px at 96px 341px, rgba(255, 255, 255, .9), transparent),
    radial-gradient(7px 7px at 262px 389px, rgba(255, 255, 255, .2), transparent),
    radial-gradient(2.3px 2.3px at 262px 389px, rgba(240, 246, 255, .95), transparent),
    radial-gradient(1.7px 1.7px at 401px 458px, rgba(255, 236, 200, .75), transparent),
    radial-gradient(6px 6px at 508px 517px, rgba(190, 210, 255, .28), transparent),
    radial-gradient(2.1px 2.1px at 508px 517px, rgba(255, 255, 255, 1), transparent),
    radial-gradient(1.9px 1.9px at 341px 71px, rgba(255, 255, 255, .9), transparent),
    radial-gradient(1.6px 1.6px at 483px 352px, rgba(200, 218, 255, .8), transparent),
    radial-gradient(2px 2px at 154px 447px, rgba(255, 255, 255, .9), transparent),
    radial-gradient(1.7px 1.7px at 224px 517px, rgba(228, 236, 255, .8), transparent),
    radial-gradient(1.8px 1.8px at 34px 481px, rgba(255, 255, 255, .85), transparent),
    radial-gradient(9px 9px at 97px 131px, rgba(210, 224, 255, .3), transparent),
    radial-gradient(2.4px 2.4px at 97px 131px, rgba(255, 255, 255, .95), transparent),
    radial-gradient(7px 7px at 283px 61px, rgba(255, 232, 180, .24), transparent),
    radial-gradient(2.2px 2.2px at 283px 61px, rgba(255, 246, 220, .9), transparent),
    radial-gradient(10px 10px at 431px 217px, rgba(170, 198, 255, .26), transparent),
    radial-gradient(2.6px 2.6px at 431px 217px, rgba(205, 222, 255, 1), transparent),
    radial-gradient(1.8px 1.8px at 593px 149px, rgba(255, 255, 255, .8), transparent),
    radial-gradient(8px 8px at 173px 379px, rgba(214, 226, 255, .26), transparent),
    radial-gradient(2.3px 2.3px at 173px 379px, rgba(255, 255, 255, .95), transparent),
    radial-gradient(2px 2px at 511px 317px, rgba(255, 236, 200, .7), transparent),
    radial-gradient(1.7px 1.7px at 647px 451px, rgba(200, 218, 255, .75), transparent),
    radial-gradient(6px 6px at 337px 521px, rgba(190, 210, 255, .24), transparent),
    radial-gradient(2.1px 2.1px at 337px 521px, rgba(255, 255, 255, .9), transparent),
    radial-gradient(1.9px 1.9px at 563px 601px, rgba(255, 255, 255, .85), transparent),
    radial-gradient(2px 2px at 227px 667px, rgba(228, 236, 255, .8), transparent);
  background-size: 557px 557px, 727px 727px;
  animation: sky-twinkle-c 13s ease-in-out -7s infinite alternate;
}

.sky-meteor {
  top: 6%;
  left: 30%;
  width: 190px;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, rgba(228, 240, 255, 1));
  filter: drop-shadow(0 0 6px rgba(190, 210, 255, .9));
  opacity: 0;
  animation: sky-meteor 9s ease-in 4s infinite;
}

.sky-meteor-b {
  top: 14%;
  left: 14%;
  width: 160px;
  animation: sky-meteor-b 13s ease-in 8s infinite;
}

.sky-meteor-c {
  top: 4%;
  left: 62%;
  width: 220px;
  animation: sky-meteor-c 11s ease-in 1s infinite;
}

@keyframes sky-twinkle-a {
  from { opacity: .45; }
  to { opacity: .78; }
}

@keyframes sky-twinkle-b {
  from { opacity: .6; }
  to { opacity: 1; }
}

@keyframes sky-twinkle-c {
  from { opacity: .65; }
  to { opacity: 1; }
}

@keyframes sky-meteor {
  0% { transform: translate3d(0, 0, 0) rotate(80deg); opacity: 0; }
  2% { opacity: 1; }
  9% { transform: translate3d(9vh, 54vh, 0) rotate(80deg); opacity: 0; }
  100% { transform: translate3d(9vh, 54vh, 0) rotate(80deg); opacity: 0; }
}

@keyframes sky-meteor-b {
  0% { transform: translate3d(0, 0, 0) rotate(75deg); opacity: 0; }
  2% { opacity: 1; }
  8% { transform: translate3d(12vh, 45vh, 0) rotate(75deg); opacity: 0; }
  100% { transform: translate3d(12vh, 45vh, 0) rotate(75deg); opacity: 0; }
}

@keyframes sky-meteor-c {
  0% { transform: translate3d(0, 0, 0) rotate(84deg); opacity: 0; }
  2% { opacity: 1; }
  10% { transform: translate3d(6vh, 60vh, 0) rotate(84deg); opacity: 0; }
  100% { transform: translate3d(6vh, 60vh, 0) rotate(84deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  #sky i, #sky b { animation: none !important; }
}

button, .client-card, .trow, .cal-cell, .prod-card { touch-action: manipulation; }

button { font-family: inherit; color: inherit; }
input, textarea, select { font-family: inherit; }

:focus-visible { outline: 2px solid var(--accent1); outline-offset: 2px; }

body.locked #app,
body.locked #quickbar { display: none; }

#app { display: flex; min-height: 100vh; animation: app-in .45s var(--ease); }

@keyframes app-in {
  from { opacity: 0; transform: translateY(16px) scale(.985); }
  to { opacity: 1; transform: none; }
}

/* ---------- Auth ---------- */

html[data-theme="dark"] {
  --auth-card-bg: rgba(19, 23, 34, .62);
  --auth-input-bg: rgba(255, 255, 255, .05);
  --auth-border-hi: rgba(255, 255, 255, .16);
}

html[data-theme="light"] {
  --auth-card-bg: rgba(255, 255, 255, .74);
  --auth-input-bg: rgba(23, 27, 38, .04);
  --auth-border-hi: rgba(255, 255, 255, .95);
}

#auth-root {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
  background: radial-gradient(1200px 700px at 70% -10%, rgba(124, 92, 252, .12), transparent 60%);
}

#auth-root::before,
#auth-root::after {
  content: '';
  position: absolute;
  width: 640px;
  height: 640px;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(110px);
  opacity: .5;
}
#auth-root::before {
  top: -220px;
  left: -160px;
  background: radial-gradient(circle at 35% 35%, rgba(91, 108, 255, .5), transparent 65%);
  animation: auth-drift 16s var(--ease) infinite alternate;
}
#auth-root::after {
  bottom: -260px;
  right: -180px;
  background: radial-gradient(circle at 60% 60%, rgba(124, 92, 252, .45), transparent 65%);
  animation: auth-drift 16s var(--ease) infinite alternate-reverse;
}
html[data-theme="light"] #auth-root::before,
html[data-theme="light"] #auth-root::after { opacity: .38; }

@keyframes auth-drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(60px, 40px, 0) scale(1.12); }
}

body:not(.locked) #auth-root { display: none; }

.auth-card {
  width: 100%;
  max-width: 410px;
  background:
    linear-gradient(var(--auth-card-bg), var(--auth-card-bg)) padding-box,
    linear-gradient(160deg, var(--auth-border-hi), rgba(91, 108, 255, .25) 45%, rgba(124, 92, 252, .2)) border-box;
  border: 1px solid transparent;
  border-radius: 26px;
  padding: 38px 32px 30px;
  backdrop-filter: blur(22px) saturate(1.35);
  -webkit-backdrop-filter: blur(22px) saturate(1.35);
  box-shadow:
    0 24px 70px rgba(3, 6, 18, .5),
    0 2px 8px rgba(3, 6, 18, .3),
    inset 0 1px 0 rgba(255, 255, 255, .06);
  animation: auth-in .55s var(--ease) both;
}
html[data-theme="light"] .auth-card {
  box-shadow:
    0 24px 60px rgba(35, 48, 95, .16),
    inset 0 1px 0 rgba(255, 255, 255, .9);
}

@keyframes auth-in {
  from { opacity: 0; transform: translateY(22px) scale(.96); }
  to { opacity: 1; transform: none; }
}

.auth-logo {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  margin: 0 auto 18px;
  background: url('icon.svg') center / cover no-repeat;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, .08),
    0 10px 30px rgba(91, 108, 255, .45),
    0 2px 8px rgba(91, 108, 255, .3);
  animation: logo-float 6s ease-in-out infinite alternate;
}

@keyframes logo-float {
  from { transform: translateY(0); }
  to { transform: translateY(-5px); }
}

.auth-title {
  text-align: center;
  font-size: 23px;
  font-weight: 800;
  letter-spacing: -.4px;
  margin: 0 0 7px;
  background: linear-gradient(135deg, var(--text) 45%, var(--accent2));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.auth-sub {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  margin: 0 auto 24px;
  max-width: 300px;
  line-height: 1.55;
}

.auth-error {
  background: rgba(248, 113, 113, .1);
  border: 1px solid rgba(248, 113, 113, .35);
  color: var(--danger);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 13.5px;
  margin-bottom: 16px;
  animation: auth-in .3s var(--ease);
}

.auth-error:empty { display: none; }

.auth-links { text-align: center; margin-top: 18px; }
.auth-link {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 9px;
  transition: color .15s, background .15s;
}
.auth-link:hover { color: var(--accent1); background: var(--accent-soft); }

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--auth-input-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 4px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  background: none;
  border: 0;
  border-radius: 10px;
  padding: 8px 4px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: color .18s var(--ease), background .18s var(--ease), box-shadow .18s var(--ease);
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(91, 108, 255, .4);
}

.auth-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
  cursor: pointer;
  margin: 4px 2px 16px;
  user-select: none;
}
.auth-check input {
  width: 16px;
  height: 16px;
  margin-top: 1px;
  accent-color: var(--accent1);
  cursor: pointer;
  flex: none;
}
.auth-check span { line-height: 1.45; }

.auth-card .field { margin-bottom: 14px; }
.auth-card .input {
  background: var(--auth-input-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 15px;
  font-size: 14.5px;
  transition: border-color .18s var(--ease), box-shadow .18s var(--ease);
}
.auth-card .input::placeholder { color: var(--muted); opacity: .7; }
.auth-card .input:focus {
  border-color: var(--accent1);
  box-shadow: 0 0 0 4px var(--ring);
}

.pin-input {
  font-size: 24px;
  letter-spacing: 12px;
  padding-left: 12px;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  caret-color: var(--accent1);
}

.perm-grid { display: flex; flex-direction: column; gap: 8px; margin: 10px 0 4px; }
.perm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 13.5px;
}
.perm-row .select { width: auto; min-width: 150px; }

.users-invites { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }


.rec-code {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 17px;
  letter-spacing: 1px;
  word-break: break-all;
  text-align: center;
  background: var(--auth-input-bg);
  border: 1px dashed rgba(91, 108, 255, .55);
  color: var(--text);
  border-radius: 16px;
  padding: 18px 14px;
  margin-bottom: 8px;
  user-select: all;
}

.rec-warn {
  color: var(--warn);
  font-size: 13px;
  text-align: center;
  margin: 0 0 16px;
  line-height: 1.5;
}

.auth-lock-note {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: .15px;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  opacity: .9;
}

.auth-card .btn-primary {
  position: relative;
  overflow: hidden;
  padding: 14px 20px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .2px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent1), var(--accent2) 60%, #9d7bff);
  background-size: 150% 150%;
  box-shadow:
    0 10px 28px rgba(91, 108, 255, .42),
    inset 0 1px 0 rgba(255, 255, 255, .22);
}
.auth-card .btn-primary::after {
  content: '';
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: -45%;
  width: 32%;
  background: linear-gradient(105deg, transparent, rgba(255, 255, 255, .4), transparent);
  transform: skewX(-20deg);
  transition: left .55s var(--ease);
  pointer-events: none;
}
.auth-card .btn-primary:hover::after { left: 125%; }
.auth-card .btn-primary:hover {
  background-position: 90% 50%;
  box-shadow:
    0 14px 34px rgba(91, 108, 255, .55),
    inset 0 1px 0 rgba(255, 255, 255, .25);
  transform: translateY(-1px);
}
.auth-card .btn-primary:disabled::after { display: none; }

@media (prefers-reduced-motion: reduce) {
  .auth-card,
  .auth-logo,
  #auth-root::before,
  #auth-root::after { animation: none; }
  .auth-card .btn-primary::after { transition: none; }
}

/* ---------- Sidebar ---------- */

#sidebar {
  width: 246px;
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: url('icon.svg') center / cover no-repeat;
  box-shadow: 0 4px 14px rgba(91, 108, 255, .35);
}

.brand-name { font-weight: 700; font-size: 17px; letter-spacing: .2px; }

.nav-group {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 12px 12px 6px;
  opacity: .85;
}

#nav { display: flex; flex-direction: column; gap: 4px; }

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background .15s, color .15s, box-shadow .2s var(--ease), transform .15s var(--ease);
  position: relative;
  text-align: left;
}

.nav-btn:hover { background: var(--accent-soft); color: var(--text); }
.nav-btn:not(.active):hover { transform: translateX(3px); }
.nav-btn.active {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(91, 108, 255, .42);
}

.nav-ic { display: inline-flex; width: 20px; height: 20px; }
.nav-ic svg { width: 100%; height: 100%; }

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.conn {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  flex: 1;
  min-width: 0;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
  transition: background .2s;
}
.conn.off .conn-dot { background: var(--danger); }

.icon-btn {
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: 10px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent1); }
.icon-btn svg { width: 18px; height: 18px; }

/* ---------- Main ---------- */

#main {
  flex: 1;
  min-width: 0;
  max-width: none;
  margin: 0 auto;
  padding: 20px 26px 90px;
  width: 100%;
}

#topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--topbar-bg);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

#quickbar {
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 7px 8px;
  box-shadow: var(--shadow);
  margin: 8px 0 4px;
}

#quick-input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 15px;
  padding: 10px 4px;
  outline: none;
}
#quick-input::placeholder { color: var(--muted); }

.mic-btn {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.mic-btn:hover { color: var(--text); border-color: var(--accent1); }

.mic-btn.listening {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  border-color: transparent;
  color: #fff;
  animation: pulse 1.2s infinite;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(91, 108, 255, .5); }
  50% { box-shadow: 0 0 0 10px rgba(91, 108, 255, 0); }
}

/* ---------- Buttons / inputs ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.2;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s var(--ease);
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--accent1);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(91, 108, 255, .18);
}
.btn:active { transform: translateY(0) scale(.97); box-shadow: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn:disabled:hover { transform: none; box-shadow: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  border: 0;
  color: #fff;
  box-shadow: 0 8px 24px rgba(91, 108, 255, .45);
}
.btn-primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 10px 30px rgba(91, 108, 255, .55);
  transform: translateY(-1px);
}
.btn-primary:active { filter: brightness(.96); transform: translateY(0) scale(.97); }

.btn-danger {
  background: rgba(248, 113, 113, .12);
  border-color: rgba(248, 113, 113, .55);
  color: var(--danger);
}
.btn-danger:hover {
  background: linear-gradient(135deg, #f87171, #ef4444);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--glow-danger);
  transform: translateY(-1px);
}
.btn-danger:active { transform: translateY(0) scale(.97); }

.modal-actions .btn-danger,
.btn-danger.btn-block {
  background: linear-gradient(135deg, #f87171, #ef4444);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--glow-danger);
}
.modal-actions .btn-danger:hover,
.btn-danger.btn-block:hover {
  filter: brightness(1.08);
  box-shadow: 0 8px 24px rgba(248, 113, 113, .4);
}

.btn-danger-soft {
  background: transparent;
  border-color: rgba(248, 113, 113, .4);
  color: var(--danger);
  box-shadow: none;
}
.btn-danger-soft:hover {
  background: rgba(248, 113, 113, .12);
  border-color: var(--danger);
  color: var(--danger);
  box-shadow: none;
  transform: none;
}

.btn-lg { padding: 13px 22px; font-size: 15px; border-radius: 14px; }
.btn-xl { padding: 15px 28px; font-size: 16px; font-weight: 700; border-radius: 16px; }

.view-head .btn-primary { padding: 11px 20px; font-size: 14.5px; }
.modal-actions .btn-primary { padding: 12px 20px; font-size: 14.5px; }

.btn-block { width: 100%; }

.input, .textarea, .select {
  width: 100%;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent1);
  box-shadow: 0 0 0 3px var(--ring);
}
.textarea { resize: vertical; min-height: 70px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; min-width: 0; }

/* ---------- View header ---------- */

.view-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 26px 2px 14px;
  flex-wrap: wrap;
}

.view-title { font-size: 24px; font-weight: 800; letter-spacing: -.4px; margin: 0; }
.view-sub { color: var(--muted); font-size: 13.5px; }
.spacer { flex: 1; }

/* ---------- Cards / lists ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .1);
}

.trow {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
  margin-bottom: 8px;
}
.trow:hover {
  border-color: var(--accent1);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(0, 0, 0, .08);
}

/* ---------- Tasks table (Б24-стиль) ---------- */

.ttable {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  margin-bottom: 14px;
}
.ttable-head {
  display: grid;
  grid-template-columns: 58px minmax(180px, 1fr) 80px 140px 110px 110px 140px;
  gap: 10px;
  align-items: center;
  min-width: 860px;
  padding: 9px 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: var(--card2);
}
.ttable-row {
  display: grid;
  grid-template-columns: 58px minmax(180px, 1fr) 80px 140px 110px 110px 140px;
  gap: 10px;
  align-items: start;
  min-width: 860px;
  padding: 11px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .12s;
  font-size: 13.5px;
}
.ttable-row:last-child { border-bottom: none; }
.ttable-row:hover { background: var(--card2); }
.ttable-row.done .tt-name { text-decoration: line-through; color: var(--muted); }
.tt-check { display: flex; align-items: flex-start; gap: 6px; padding-top: 1px; }
.tt-title { min-width: 0; }
.tt-name { font-weight: 600; word-break: break-word; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.tt-name .flag { display: inline-flex; align-items: center; }
.tt-notes { font-size: 12.5px; color: var(--muted); margin-top: 3px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tt-links { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.tt-cell { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.tt-muted { color: var(--muted); }
.tfoot-count { color: var(--muted); font-size: 11.5px; letter-spacing: .5px; text-transform: uppercase; padding: 4px 2px 20px; }

.dl-chip {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.dl-blue { background: #3ea8ff22; color: #3ea8ff; }
.dl-green { background: #2ecc7122; color: #2ecc71; }
.dl-red { background: #f8717122; color: #f87171; }
.dl-gray { background: var(--card2); color: var(--muted); }

.proj-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  white-space: nowrap;
}
.proj-chip svg { width: 12px; height: 12px; }

@media (max-width: 900px) {
  .ttable-head { display: none; }
  .ttable { border: none; background: none; }
  .ttable-row { grid-template-columns: 54px 1fr; min-width: 0; }
  .tt-check { grid-row: 1 / span 2; }
  .tt-cell { grid-column: 2; white-space: normal; }
}

.tt-clip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.tt-clip svg { width: 12px; height: 12px; }

.tf-empty { font-size: 13px; color: var(--muted); padding: 4px 0; }
.tf-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.tf-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--card2);
}
.tf-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tf-thumb:hover img { opacity: .85; }
.tf-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, .65);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.tf-del:hover { background: var(--danger); }
.tf-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  max-width: 220px;
}
.tf-file:hover { border-color: var(--accent1); }
.tf-file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Projects ---------- */

.proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.proj-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.proj-card:hover { border-color: var(--accent1); transform: translateY(-1px); box-shadow: 0 5px 16px rgba(0, 0, 0, .08); }
.proj-card-head { display: flex; align-items: center; gap: 10px; }
.proj-ic {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  flex: 0 0 auto;
}
.proj-ic svg { width: 17px; height: 17px; }
.proj-name { font-weight: 700; font-size: 15px; word-break: break-word; }
.proj-note { font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.proj-meta { font-size: 12px; color: var(--muted); margin-top: 10px; }
.proj-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.proj-card:hover .proj-actions { opacity: 1; }
.proj-del:hover { color: var(--danger); }

.proj-colors { display: flex; gap: 8px; }
.proj-color {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}
.proj-color.sel { border-color: var(--text); }

/* ---------- Mail ---------- */

.mail-btns { display: flex; gap: 8px; flex: 0 0 auto; }
.mail-account { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 8px; letter-spacing: 0; }
.mail-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  font-size: 13px;
  cursor: pointer;
}
.mail-dot { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--border); flex: 0 0 auto; }
.mail-row.unread { border-color: var(--accent1); }
.mail-row.unread .mail-dot { background: var(--accent1); border-color: var(--accent1); }
.mail-from { width: 240px; flex: 0 0 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.mail-row.unread .mail-from { color: var(--text); font-weight: 600; }
.mail-subject { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-row.unread .mail-subject { font-weight: 600; }
.mail-when { flex: 0 0 auto; color: var(--muted); font-size: 12px; }
@media (max-width: 720px) {
  .mail-from { width: 130px; }
}

.mail-search { margin: 0 2px 10px; }
.mail-msg-title { font-size: 15px; }
.mail-msg-head { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; margin-bottom: 12px; }
.mail-msg-from { font-size: 13.5px; font-weight: 600; }
.mail-msg-addr { color: var(--muted); font-weight: 400; }
.mail-msg-meta { font-size: 12.5px; color: var(--muted); }
.mail-msg-body { margin: 0 0 12px; }
.mail-text {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 13px;
  line-height: 1.55;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  max-height: min(560px, 56vh);
  overflow: auto;
  margin: 0;
  font-family: inherit;
}
.mail-frame {
  width: 100%;
  height: min(560px, 56vh);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  display: block;
}
.mail-atts { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.mail-atts-title { font-size: 12.5px; color: var(--muted); }
.mail-att {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
}
.mail-att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-att-size { color: var(--muted); }
#mail-card .crm-title { font-size: 20px; }
#mail-card .card-pane { overflow: visible; }


.checkbox {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  margin-top: 1px;
  border: 2px solid var(--muted);
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all .15s;
  padding: 0;
}
.checkbox:hover { border-color: var(--ok); }
.checkbox.checked { background: var(--ok); border-color: var(--ok); color: #06281c; }
input[type="checkbox"] { accent-color: #2ea6ff; }

.trow-body { flex: 1; min-width: 0; }
.trow-title { font-weight: 600; word-break: break-word; }
.trow.done .trow-title { text-decoration: line-through; color: var(--muted); }

.trow-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--muted);
  align-items: center;
}

.trow-notes { font-size: 13px; color: var(--muted); margin-top: 3px; }

.flag { font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.flag.p1 { color: var(--warn); }
.flag.p2 { color: var(--danger); }

.overdue { color: var(--danger); font-weight: 600; }

.client-badge {
  background: var(--accent-soft);
  color: var(--accent1);
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
}

.section-label {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--muted);
  margin: 20px 4px 10px;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 46px 20px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 14px;
}

/* ---------- Chips / tabs ---------- */

.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 14px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }

.chip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}
.chip:hover { color: var(--text); }
.chip.active {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  border-color: transparent;
  color: #fff;
}
.chip .count {
  background: rgba(0, 0, 0, .14);
  border-radius: 999px;
  padding: 1px 7px;
  font-size: 11.5px;
}
html[data-theme="dark"] .chip .count { background: rgba(255, 255, 255, .14); }
html[data-theme="gold"] .chip .count { background: rgba(212, 175, 55, .18); }
html[data-theme="orange"] .chip .count { background: rgba(255, 255, 255, .14); }

.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ---------- Calendar ---------- */

.cal-head { display: flex; align-items: center; gap: 10px; margin: 26px 2px 14px; flex-wrap: wrap; }
.cal-month { font-size: 20px; font-weight: 700; margin: 0; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }

.cal-dow {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  padding: 6px 0;
}

.cal-cell {
  min-height: 74px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 7px 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cal-cell:hover { border-color: var(--accent1); }
.cal-cell.out { opacity: .35; }
.cal-cell.today .cal-num {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #fff;
}
.cal-cell.sel { border-color: var(--accent1); background: var(--accent-soft); }

.cal-num {
  font-size: 13px;
  font-weight: 600;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
}

.cal-dots { display: flex; gap: 3px; flex-wrap: wrap; }
.cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent1); }
.cal-dot.done { background: var(--ok); }

.day-panel { margin-top: 20px; }
.day-panel-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.day-panel-title { font-size: 17px; font-weight: 700; margin: 0; }

/* ---------- Clients ---------- */

.client-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.client-card:hover {
  border-color: var(--accent1);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(0, 0, 0, .08);
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
}

.client-body { flex: 1; min-width: 0; }
.client-name { font-weight: 700; }
.client-contact {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 4px 11px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Kanban (Сделки) ---------- */

.kanban {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(250px, 1fr);
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 12px;
  align-items: start;
}

.kcol {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px;
  min-height: 160px;
  transition: border-color .15s, background .15s;
}

.kcol.dragover { border-color: var(--accent1); background: var(--accent-soft); }

.kcol-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px 10px;
}

.kcol-name { font-weight: 700; font-size: 13.5px; }
.kcol-count {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--card);
  border-radius: 999px;
  padding: 1px 8px;
}

.kcol-sum { margin-left: auto; font-size: 12px; font-weight: 800; color: var(--accent1); }

.kcard {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--stage, var(--accent1));
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: grab;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.kcard:hover {
  border-color: var(--stage, var(--accent1));
  box-shadow: 0 4px 14px rgba(91, 108, 255, .14);
  transform: translateY(-1px);
}
.kcard.dragging { opacity: .5; }

.kcard-title { font-weight: 600; font-size: 14px; word-break: break-word; }

.kcard-amount { margin-top: 5px; font-size: 15px; font-weight: 800; color: var(--accent1); }

.kcard-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent1);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 9px;
  white-space: nowrap;
}
.kcard-chip svg { width: 12px; height: 12px; flex-shrink: 0; }

/* ---------- Переключатель вида сделок (Канбан / Список) ---------- */

.view-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 9px;
  overflow: hidden;
}
.vs-btn {
  border: 0; background: var(--card); color: var(--muted);
  font: inherit; font-size: 13px; padding: 8px 14px; cursor: pointer;
}
.vs-btn + .vs-btn { border-left: 1px solid var(--border); }
.vs-btn.active { background: var(--accent-soft); color: var(--accent1); font-weight: 700; }

/* ---------- Список сделок ---------- */

.dlist-wrap { overflow-x: auto; padding: 0; }
.dlist { width: 100%; border-collapse: collapse; font-size: 13px; }
.dlist th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.dlist td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.drow { cursor: pointer; }
.drow:hover { background: var(--glass-bg-hover); }
.drow-check { width: 34px; }
.drow-check input { width: 15px; height: 15px; accent-color: #2ea6ff; cursor: pointer; }
.drow-stage { white-space: nowrap; color: var(--muted); font-weight: 600; }
.drow-stage .stage-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.drow-title { font-weight: 700; }
.drow-num { font-weight: 700; white-space: nowrap; }

/* ---------- Панель массовых действий ---------- */

.bulkbar {
  position: sticky; bottom: 12px; z-index: 20;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--accent1);
  border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18);
}
.bulkbar-count { font-size: 13px; }
.bulkbar[hidden] { display: none; }

/* ---------- Настройка вида карточек ---------- */

.kcard-opt { display: flex; align-items: center; gap: 10px; padding: 7px 2px; font-size: 14px; cursor: pointer; }
.kcard-opt input { width: 15px; height: 15px; accent-color: var(--accent1); }

.kcard.flash { animation: kflash 1.6s ease-out; }
@keyframes kflash {
  0%, 40% { box-shadow: 0 0 0 3px rgba(91, 108, 255, .55); }
  100% { box-shadow: 0 0 0 0 rgba(91, 108, 255, 0); }
}
.kcard-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.kstage-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.kstage-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

/* ---------- Products ---------- */

.prod-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 16px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color .15s, transform .15s, box-shadow .15s;
}
.prod-card:hover {
  border-color: var(--accent1);
  transform: translateY(-1px);
  box-shadow: 0 5px 16px rgba(0, 0, 0, .08);
}

.prod-body { flex: 1; min-width: 0; }
.prod-name { font-weight: 700; word-break: break-word; }
.prod-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.prod-price { font-weight: 800; font-size: 15px; white-space: nowrap; }

.btn-xs { padding: 4px 9px; font-size: 12px; border-radius: 8px; flex-shrink: 0; }

.prodrow {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.prodrow .select { flex: 2; min-width: 0; }
.prodrow .input { width: 70px; padding: 9px 8px; text-align: center; }
.prodrow .input.price { width: 110px; text-align: left; }
.prodrow .input.row-disc { width: 64px; text-align: left; }
.prodrow .select.row-period { flex: 0 0 auto; width: 88px; }
.prodrow .row-del {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 6px;
}
.prodrow .row-del:hover { color: var(--danger); }

.deal-total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-weight: 800;
  font-size: 15px;
  margin: 14px 0;
}

/* ---------- Modal ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(6, 8, 14, .62);
  backdrop-filter: blur(9px);
  -webkit-backdrop-filter: blur(9px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 18px;
  animation: fade-in .18s ease-out;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%;
  max-width: 540px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 22px;
  box-shadow: var(--shadow);
  animation: modal-in .24s cubic-bezier(.2, .8, .3, 1.08);
}

@keyframes modal-in {
  from { transform: translateY(18px) scale(.97); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.backdrop { transition: opacity .18s ease-in; }
.backdrop.closing { opacity: 0; }
.backdrop.closing .modal { animation: modal-out .18s var(--ease) both; }
@keyframes modal-out {
  to { transform: translateY(16px) scale(.97); opacity: 0; }
}

.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.modal-title { font-size: 18px; font-weight: 700; margin: 0; flex: 1; }

.modal-close {
  border: 0;
  background: var(--card2);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  flex-shrink: 0;
}
.modal-close:hover { color: var(--text); }

.modal-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.link-list { margin: 6px 0 2px; }
.link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 14px;
}
.link-row:hover .link-title { color: var(--accent1); }
.link-row:last-child { border-bottom: 0; }
.link-title { flex: 1; min-width: 0; word-break: break-word; }
.link-date { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* ---------- Toast ---------- */

#toast-root {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 26px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--card2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: toast-in .2s ease-out;
  max-width: min(90vw, 480px);
  text-align: center;
}
.toast.err { border-color: var(--danger); }

@keyframes toast-in {
  from { transform: translateY(10px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ---------- Install banner (mobile) ---------- */

#install-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  z-index: 60;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 600;
  animation: toast-in .25s ease-out;
}

#install-banner[hidden] { display: none; }
#install-banner .btn { padding: 8px 14px; }

.banner-close {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

/* ---------- Bottom nav (mobile) ---------- */

#bottomnav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
  z-index: 50;
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}

.bnav-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 7px 0;
  cursor: pointer;
  position: relative;
  border-radius: 10px;
}
.bnav-btn.active { color: var(--accent1); }
.bnav-btn .nav-ic { width: 22px; height: 22px; }

.bnav-badge {
  position: absolute;
  top: 2px;
  right: calc(50% - 22px);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  #sidebar { display: none; }
  #bottomnav { display: flex; }
  #main { padding: 12px 12px 96px; }
  #quickbar { top: 8px; padding: 8px; }
  #quick-add span { display: none; }
  .cal-cell { min-height: 52px; padding: 4px 5px; border-radius: 9px; }
  .cal-num { width: 20px; height: 20px; font-size: 12px; }
  .backdrop { align-items: flex-end; padding: 0; }
  .modal {
    max-width: none;
    border-radius: 20px 20px 0 0;
    max-height: 88vh;
    border-bottom: 0;
  }
  .view-title { font-size: 19px; }
  .kanban { grid-auto-columns: 232px; }
  .input, .select, .textarea { font-size: 16px; }
  .btn { padding: 12px 16px; }
}

/* ---------- Stats / dashboard / money ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.stat-card.stat-accent { border-color: var(--accent1); box-shadow: 0 4px 18px rgba(91, 108, 255, .1); }
.stat-label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.stat-value { font-size: 22px; font-weight: 800; margin-top: 4px; }
.stat-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; }
.bar-label { width: 140px; font-size: 13px; color: var(--muted); flex-shrink: 0; }
.bar-track { flex: 1; height: 10px; background: var(--card2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width .45s cubic-bezier(.2, .7, .3, 1); }
.bar-val { max-width: 150px; text-align: right; font-size: 12.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.money-nav { display: flex; align-items: center; gap: 10px; margin: 0 2px 14px; }
.money-month { font-weight: 700; font-size: 16px; min-width: 150px; text-align: center; }
.pay-date { width: 54px; flex-shrink: 0; text-align: center; font-weight: 800; font-size: 13px; color: var(--muted); line-height: 1.25; }
.price-per { font-size: 11px; font-weight: 600; color: var(--muted); }

/* ---------- View transitions ---------- */

#view.anim { animation: view-in .32s var(--ease); }
@keyframes view-in {
  from { opacity: 0; transform: translateY(14px) scale(.99); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

#view.anim > .enter { animation: enter-up .34s var(--ease) both; }
#view.anim > .enter:nth-child(2) { animation-delay: .05s; }
#view.anim > .enter:nth-child(3) { animation-delay: .1s; }
#view.anim > .enter:nth-child(4) { animation-delay: .15s; }
#view.anim > .enter:nth-child(5) { animation-delay: .2s; }
#view.anim > .enter:nth-child(n + 6) { animation-delay: .24s; }
@keyframes enter-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

#loadbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 300;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s;
}
#loadbar.active { opacity: 1; }
#loadbar::before {
  content: '';
  display: block;
  height: 100%;
  width: 40%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent1), var(--accent2));
  box-shadow: 0 0 12px rgba(91, 108, 255, .7);
  animation: loadbar-slide 1.1s var(--ease) infinite;
}
@keyframes loadbar-slide {
  from { transform: translateX(-110%); }
  to { transform: translateX(360%); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- Ultrawide (3440×1440) ---------- */

@media (min-width: 1920px) {
  #main { padding: 24px 34px 90px; }
  .cal-cell { min-height: 86px; }
}

@media (min-width: 2800px) {
  body { font-size: 16px; }
  #main { padding: 30px 44px 110px; }
  #sidebar { width: 264px; }
  .cal-cell { min-height: 104px; }
  .view-title, .cal-month { font-size: 26px; }
}

/* ---------- Custom fields & settings ---------- */

.cf-block {
  border-top: 1px dashed var(--border);
  margin-top: 14px;
  padding-top: 12px;
}

.cf-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  margin-bottom: 10px;
}

.cf-check { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.cf-check label { margin: 0; }

.cf-chips { margin-top: 4px; gap: 6px; flex-wrap: wrap; }

.cf-chip {
  background: var(--card2);
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 8px;
  padding: 1px 8px;
  font-size: 12px;
  white-space: nowrap;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.settings-colors {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.color-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 13px;
}

.color-input {
  width: 40px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  flex: none;
}

.cf-hint {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 10px;
}

.auto-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--card2);
  cursor: pointer;
}
.auto-row input[type="checkbox"] { margin-top: 3px; width: 16px; height: 16px; flex: none; }
.auto-row b { display: block; font-size: 13.5px; }
.auto-row .cf-hint { margin-top: 2px; }

.bd-when { flex-shrink: 0; text-align: right; }
.bd-date { font-weight: 700; font-size: 13.5px; white-space: nowrap; }
.bd-age { font-size: 12px; color: var(--muted); margin-top: 2px; white-space: nowrap; }
.bd-today { border-color: #f472b6; box-shadow: 0 0 0 1px #f472b6 inset; }
.bd-today .bd-date { color: #f472b6; }

.dup-group { margin-bottom: 10px; }
.dup-head { display: flex; align-items: baseline; gap: 8px; font-weight: 700; margin-bottom: 10px; }
.dup-reason { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: auto; white-space: nowrap; }
.dup-cand {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  background: var(--card2);
}
.dup-cand input { margin-top: 4px; flex: none; width: 16px; height: 16px; }
.dup-cand-body { min-width: 0; }
.dup-name { display: block; font-weight: 700; }
.dup-meta { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; word-break: break-word; }
.dup-keep { border-color: var(--accent1); }

.call-dir { flex: none; font-size: 10.5px; font-weight: 800; letter-spacing: .03em; padding: 3px 7px; border-radius: 7px; }
.call-dir.dir-in { background: rgba(59, 130, 246, .15); color: #60a5fa; }
.call-dir.dir-out { background: rgba(16, 185, 129, .15); color: #34d399; }
.call-row.call-missed .link-title { color: #ef4444; }

.cf-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  background: var(--card2);
}

.cf-row-main { flex: 1; min-width: 0; }
.cf-row-name { font-weight: 600; font-size: 14px; }

.cf-row-type {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cf-add {
  border-top: 1px dashed var(--border);
  margin-top: 12px;
  padding-top: 12px;
}

.cf-add-actions { display: flex; justify-content: flex-end; }

/* ---------- New shell: topbar / search / user chip ---------- */

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
}

.search-ic {
  position: absolute;
  left: 13px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  display: inline-flex;
  pointer-events: none;
}
.search-ic svg { width: 100%; height: 100%; }

#global-search {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  padding: 10px 16px 10px 38px;
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#global-search:focus { border-color: var(--accent1); box-shadow: 0 0 0 3px var(--ring); }
#global-search::placeholder { color: var(--muted); }

#search-results {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  z-index: 40;
  max-height: 400px;
  overflow-y: auto;
  padding: 6px;
}
#search-results[hidden] { display: none; }

.search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 11px;
  cursor: pointer;
  font-size: 13.5px;
}
.search-row:hover { background: var(--card2); }

.search-ic2 {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--card2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex: none;
}
.search-ic2 svg { width: 15px; height: 15px; }

.search-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.search-sub {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

.search-kind {
  font-size: 10.5px;
  color: var(--accent1);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 2px 8px;
  font-weight: 700;
  white-space: nowrap;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 12px 5px 5px;
  cursor: pointer;
  color: var(--text);
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  transition: border-color .15s;
}
.user-chip:hover { border-color: var(--accent1); }

.chip-ava {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: url('icon.svg') center / cover no-repeat;
  display: inline-block;
  flex-shrink: 0;
}

.chip-ava.has-photo { background: none; overflow: hidden; }
.chip-ava.has-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.chip-ava.with-initials {
  background: var(--accent1);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.user-chip svg { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }

/* ---------- Иконка модуля в настройках ---------- */

.mod-ic {
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  vertical-align: -4px;
  margin-right: 4px;
  color: var(--muted);
  flex-shrink: 0;
}
.mod-ic svg { width: 14px; height: 14px; display: block; }

/* ---------- Clock widget ---------- */

.clock-widget {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px 12px;
  cursor: pointer;
  color: var(--text);
  max-width: 320px;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.clock-widget:hover { border-color: var(--accent1); box-shadow: 0 4px 16px var(--accent-soft); }

.clock-ic {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.clock-ic svg { width: 17px; height: 17px; }

.clock-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
}

.clock-time {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .5px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.clock-next {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
  line-height: 1.3;
}
.clock-next.soon { color: var(--danger); font-weight: 600; }

/* ---------- Nav edit mode ---------- */

.nav-cfg-btn {
  margin: 10px 4px 0;
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.nav-cfg-btn:hover { color: var(--accent1); border-color: var(--accent1); }

.nav-edit-bar {
  background: var(--card);
  border: 1px solid var(--accent1);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 2px 2px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nav-edit-hint { font-size: 11.5px; color: var(--muted); line-height: 1.4; }

.nav-edit-btns { display: flex; gap: 6px; flex-wrap: wrap; }

.nav-tool {
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.nav-tool:hover { border-color: var(--accent1); }
.nav-tool-done { background: linear-gradient(135deg, var(--accent1), var(--accent2)); border: 0; color: #fff; }

.nav-btn[draggable="true"] { cursor: grab; }
.nav-btn.nav-dragging { opacity: .45; }
.nav-btn.nav-drag-over { box-shadow: 0 -2px 0 0 var(--accent1) inset, 0 2px 0 0 var(--accent1); }

.nav-drag {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: -2px;
  opacity: .7;
}
.nav-btn .nav-badge + .nav-drag { margin-left: 6px; }

.nav-pin {
  width: 22px;
  height: 22px;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.nav-pin:hover { color: var(--accent1); background: var(--accent-soft); }
.nav-pin.on { color: var(--accent1); }
.nav-pin::before { content: '\1F4CC'; font-size: 12px; opacity: .45; }
.nav-pin.on::before { opacity: 1; }
.nav-btn .nav-badge + .nav-drag + .nav-pin { margin-left: 6px; }

.nav-group-del {
  margin-left: 6px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  opacity: .7;
}
.nav-group-del:hover { color: var(--danger); opacity: 1; }

.nav-empty-hint {
  border: 1px dashed var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 11.5px;
  text-align: center;
  padding: 10px 8px;
  margin: 2px 0;
}

@media (max-width: 760px) {
  .clock-widget { display: none; }
}

/* ---------- New dashboard ---------- */

.stat-grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 12px;
}

.stat-card2 {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stat-head { display: flex; align-items: center; gap: 9px; }

.stat-ic {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.stat-ic svg { width: 17px; height: 17px; }

.stat-name {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}

.stat-trend { margin-left: auto; font-size: 12px; font-weight: 800; }

.stat-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}
.stat-main-text { min-width: 0; }

.stat-num { font-size: 23px; font-weight: 800; letter-spacing: -.4px; }

.stat-card2 .stat-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }

.spark { width: 120px; height: 40px; flex: none; opacity: .95; }

.sec-label {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  margin: 20px 2px 10px;
}

.dash-cols {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}

.dash-row3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.card-title { font-weight: 700; font-size: 14px; }

.card-count {
  font-size: 11.5px;
  color: var(--muted);
  background: var(--card2);
  border-radius: 999px;
  padding: 1px 8px;
  font-weight: 700;
  white-space: nowrap;
}
.card-count.overdue { color: var(--danger); background: rgba(248, 113, 113, .12); }

.dash-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.dchip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12.5px;
  color: var(--text);
}
.dchip b { font-weight: 800; }
.dchip-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }

.pay-mini, .task-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 2px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13.5px;
}
.pay-mini:last-child, .task-mini:last-child { border-bottom: 0; }
.pay-mini:hover .pay-name, .task-mini:hover .task-name { color: var(--accent1); }

.pay-ago { color: var(--muted); font-size: 12px; min-width: 74px; flex-shrink: 0; }

.pay-name, .task-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}

.pay-sum { color: var(--ok); font-weight: 800; white-space: nowrap; }

.task-when { color: var(--muted); font-size: 12px; min-width: 80px; white-space: nowrap; flex-shrink: 0; }

/* ---------- Mini calendar ---------- */

.mc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: -16px -16px 12px;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  border-radius: var(--radius) var(--radius) 0 0;
}

.mc-title { font-weight: 700; font-size: 14px; }
.mc-head .mc-title { color: #fff; letter-spacing: .4px; }

.mc-head .btn {
  background: rgba(255, 255, 255, .18);
  border-color: transparent;
  color: #fff;
}
.mc-head .btn:hover { background: rgba(255, 255, 255, .3); border-color: transparent; }

.mc-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.mc-dow {
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  padding: 4px 0;
}

.mc-cell {
  position: relative;
  border: 0;
  background: transparent;
  color: var(--text);
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .15s;
}
.mc-cell:hover { background: var(--card2); }
.mc-cell.empty-cell { cursor: default; }
.mc-today {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #fff;
}
.mc-today:hover { filter: brightness(1.08); }

.mc-dot {
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent1);
}
.mc-today .mc-dot { background: #fff; }

/* ---------- New dashboard responsive ---------- */

@media (max-width: 1080px) {
  .dash-row3 { grid-template-columns: 1fr 1fr; }
  .dash-row3 > .mc-card { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .chip-name { display: none; }
  .user-chip { padding: 5px; }
  .dash-cols, .dash-row3 { grid-template-columns: 1fr; }
  .search-wrap { max-width: none; }
  .pay-ago { min-width: 60px; }
}

/* ---------- Stage editor ---------- */

.se-note { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.se-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.se-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
}
.se-color {
  width: 40px;
  height: 34px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card2);
  cursor: pointer;
  flex-shrink: 0;
}
.se-label { flex: 1; min-width: 0; }

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.btn-icon:disabled { opacity: .4; cursor: default; }
.se-del { color: #f87171; }

/* ---------- CRM card (lead / deal) ---------- */

.modal-wide { max-width: 1000px; width: 94vw; }

/* ---------- Правая выдвижная панель (Bitrix-стиль) ---------- */

.backdrop.drawer {
  padding: 0;
  justify-content: flex-end;
  align-items: stretch;
}

.modal.drawer {
  max-width: min(1080px, 96vw);
  width: min(1080px, 96vw);
  height: 100%;
  max-height: none;
  border-radius: 20px 0 0 20px;
  border-right: 0;
  animation: drawer-in .28s cubic-bezier(.2, .8, .3, 1);
}

@keyframes drawer-in {
  from { transform: translateX(72px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.crm-head { align-items: flex-start; margin-bottom: 12px; }
.crm-head-main { flex: 1; min-width: 0; }
.crm-kind {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--accent1);
}
.crm-title { font-size: 20px; font-weight: 700; margin: 4px 0 0; word-break: break-word; }
.crm-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

.stage-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 2px 0 12px;
}
.spill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 999px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color .15s, color .15s, background .15s;
}
.spill-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--stage, var(--muted)); }
.spill:hover { color: var(--text); border-color: var(--stage, var(--border)); }
.spill.active {
  color: var(--text);
  border-color: var(--stage);
  background: var(--accent-soft);
  background: color-mix(in srgb, var(--stage) 14%, transparent);
}

.funnel-pills {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding: 0 0 12px;
}
.fpill-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  margin-right: 2px;
}

.call-ops { display: flex; flex-direction: column; overflow-x: auto; }
.call-ops-row {
  display: grid;
  grid-template-columns: minmax(120px, 1.7fr) repeat(6, minmax(56px, 1fr));
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
  min-width: 520px;
}
.call-ops-row:last-child { border-bottom: 0; }
.call-ops-head {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.call-ops-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.call-ops-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.call-ops-row:not(.call-ops-head) .call-ops-num { color: var(--text); }
.call-ops-num.bad { color: #ef4444; font-weight: 700; }

.dash-period { display: flex; gap: 6px; margin: 0 0 14px; }
.pchip {
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  padding: 5px 14px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.pchip:hover { color: var(--text); border-color: var(--accent1); }
.pchip.active {
  color: var(--text);
  border-color: var(--accent1);
  background: var(--accent-soft);
}

.dash-stack { display: grid; grid-template-columns: 1fr; gap: 14px; }

.dash-call2 { padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer; transition: background .15s; }
.dash-call2:last-child { border-bottom: 0; }
.dash-call2:hover { background: var(--card2); }
.dash-call2-top { display: flex; align-items: center; gap: 8px; }
.dash-call2-num { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-call2-when { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; }
.dash-call2-sub { display: flex; align-items: center; gap: 10px; margin-top: 3px; padding-left: 2px; }
.dash-call2-meta { margin-left: auto; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-call2-meta b { color: #ef4444; }
.dash-call-target {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dash-call-target svg { flex: none; opacity: .7; }

.card-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.ctab {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  flex-shrink: 0;
}
.ctab:hover { color: var(--text); }
.ctab.active { color: var(--accent1); border-bottom-color: var(--accent1); }

.card-pane[hidden] { display: none !important; }
.card-task-list { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }

/* ---------- Timeline / feed ---------- */

.feed-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.feed-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.timeline { display: flex; flex-direction: column; }
.tl-item {
  display: flex;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
}
.tl-item:last-child { border-bottom: 0; }
.tl-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--card);
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
}
.tl-icon[data-ft="call"] { color: #38bdf8; }
.tl-icon[data-ft="meeting"] { color: #a78bfa; }
.tl-icon[data-ft="stage"] { color: #fbbf24; }
.tl-icon[data-ft="created"] { color: #34d399; }
.tl-icon[data-ft="file"] { color: #38bdf8; }
.tl-icon svg { width: 15px; height: 15px; }
.tl-body { flex: 1; min-width: 0; }
.tl-text { font-size: 13.5px; word-break: break-word; }
.tl-date { font-size: 12px; color: var(--muted); margin-top: 2px; }

@media (max-width: 760px) {
  .modal-wide {
    max-width: none;
    width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 88vh;
    border-bottom: 0;
  }
  .backdrop.drawer { align-items: flex-end; }
  .modal.drawer {
    width: 100%;
    max-width: none;
    height: 94vh;
    border-radius: 20px 20px 0 0;
    animation: modal-in .24s ease-out;
  }
}

/* ---------- Bitrix-style card layout ---------- */

.crm-grid {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: 18px;
  align-items: start;
}
.crm-col-left, .crm-col-right { min-width: 0; display: flex; flex-direction: column; gap: 14px; }

.crm-fields {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--card);
}
.crm-fields-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.crm-block-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
}
.crm-edit-btn {
  border: 0;
  background: none;
  color: var(--accent1);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.crm-edit-btn:hover { text-decoration: underline; }

.crm-row {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  align-items: baseline;
}
.crm-row:last-child { border-bottom: 0; }
.crm-row-label { flex: 0 0 120px; font-size: 12.5px; color: var(--muted); }
.crm-row-value { flex: 1; min-width: 0; font-size: 13.5px; word-break: break-word; white-space: pre-line; }
.crm-row-value a { color: var(--accent1); text-decoration: none; }
.crm-row-value a:hover { text-decoration: underline; }
.crm-row[data-field] .crm-row-value { cursor: pointer; border-bottom: 1px dashed transparent; transition: border-color .15s ease; }
.crm-row[data-field] .crm-row-value:hover { border-bottom-color: var(--accent1); }
.crm-inline-box { display: flex; flex-direction: column; gap: 4px; }
.crm-inline-box .crm-inline-ctl { width: 100%; font-size: 13.5px; }
.crm-inline-hint { font-size: 11px; color: var(--muted); white-space: normal; }
.crm-title[data-action] { cursor: pointer; border-bottom: 1px dashed transparent; transition: border-color .15s ease; }
.crm-title[data-action]:hover { border-bottom-color: var(--accent1); }
.crm-inline-title { font-size: 16px; font-weight: 600; padding: 4px 8px; margin: 0; width: 100%; }

/* ---------- Обновлялка ---------- */

.upd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.upd-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  margin: 10px 0;
}
.upd-card-title { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.upd-grid .upd-card { margin: 0; }
.upd-status-row { display: flex; align-items: center; gap: 12px; }
.upd-status-main { flex: 1; min-width: 0; }
.upd-status-title { font-size: 15px; font-weight: 600; }
.upd-status-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.upd-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); flex-shrink: 0; }
.upd-dot-on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.upd-dot-found { background: #fbbf24; box-shadow: 0 0 0 3px rgba(251, 191, 36, .25); animation: upd-pulse 1s infinite; }
@keyframes upd-pulse { 50% { opacity: .4; } }
.upd-error { margin-top: 10px; font-size: 13px; color: #f87171; background: rgba(248, 113, 113, .1); border: 1px solid rgba(248, 113, 113, .3); border-radius: 10px; padding: 8px 12px; }
.upd-banner { margin-top: 10px; font-size: 13.5px; font-weight: 600; color: var(--ok); background: rgba(52, 211, 153, .1); border: 1px solid rgba(52, 211, 153, .35); border-radius: 10px; padding: 10px 12px; }
.upd-inline { display: flex; gap: 8px; align-items: center; }
.upd-inline .input { flex: 1; min-width: 0; }
.upd-chats { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--card2); border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 6px 3px 12px; font-size: 13px; font-weight: 600;
}
.chat-chip-x, .chat-chip-t {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 14px; line-height: 1; padding: 3px 5px; border-radius: 50%;
}
.chat-chip-x:hover { color: #f87171; }
.chat-chip-t:hover { color: var(--accent1); }
.upd-prof { padding: 12px 14px; }
.upd-prof-active { border-color: var(--ok); }
.upd-prof-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.upd-prof-name { font-size: 14.5px; font-weight: 700; flex: 1; min-width: 0; word-break: break-word; }
.upd-prof-iv { font-size: 12px; color: var(--muted); }
.upd-prof-body { font-size: 12.5px; color: var(--muted); margin-top: 6px; word-break: break-word; }
.upd-prof-tpl { margin-top: 2px; color: var(--text); }
.upd-prof-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.upd-prof-list { display: flex; flex-direction: column; gap: 8px; }
.upd-mode {
  font-size: 11px; font-weight: 700; letter-spacing: .03em;
  padding: 2px 8px; border-radius: 6px; flex-shrink: 0;
}
.upd-mode-cdp { background: rgba(91, 108, 255, .15); color: var(--accent1); }
.upd-mode-f5 { background: rgba(251, 191, 36, .15); color: #fbbf24; }
.upd-live { font-size: 11.5px; font-weight: 600; color: var(--ok); }
.upd-log-row { display: flex; gap: 10px; font-size: 12.5px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.upd-log-row:last-child { border-bottom: 0; }
.upd-log-time { color: var(--muted); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 9px; }
.note { font-size: 12px; color: var(--muted); margin: -4px 0 10px; }
@media (max-width: 900px) { .upd-grid { grid-template-columns: 1fr; } .upd-grid .upd-card { margin: 10px 0 0; } }

/* ---------- Чаты (мессенджер: всегда тёмная тема, отличается от CRM) ---------- */

/* Роут «Чаты» вписан в экран без ползунка страницы: колонка-флекс, внутренние скроллы */
#view.view-chats { display: flex; flex-direction: column; height: calc(100dvh - 254px); min-height: 340px; overflow: hidden; }
#view.view-chats .view-head { margin: 12px 2px 8px; }
#view.view-chats .view-sub { margin: 0 2px 8px; }
#main:has(#view.view-chats) { padding-bottom: 14px; }

.chats-wrap { display: grid; grid-template-columns: 320px 1fr; gap: 10px; height: calc(100vh - 175px); min-height: 420px; }
.view-chats .chats-wrap { flex: 1; min-height: 0; height: auto; }
.chats-side { background: #0d1220; border: 1px solid #262e45; border-radius: 14px; overflow-y: auto; padding: 4px; display: flex; flex-direction: column; gap: 3px; }
.chat-tabs { position: sticky; top: 0; z-index: 2; display: flex; gap: 4px; padding: 5px; background: #0d1220; border-bottom: 1px solid #262e45; }
.chat-tab { flex: 1; border: 0; background: #161d33; color: #8d97ad; font-size: 12px; font-weight: 700; padding: 7px 8px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.chat-tab-n { font-size: 10.5px; opacity: .75; }
.chat-tab:hover { color: #c9d2e6; }
.chat-tab.active { background: #1e2a4a; color: #e7ebf5; }
.chat-tab[data-tab="tg"].active { color: #7dd3fc; }
.chat-tab[data-tab="max"].active { color: #c4b5fd; }
.chat-item { display: flex; align-items: center; gap: 9px; padding: 8px; border-radius: 10px; border: 1px solid transparent; background: transparent; cursor: pointer; text-align: left; }
.chat-item-ava { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.chat-item-ava-letter { display: inline-flex; align-items: center; justify-content: center; background: #1a2237; border: 1px solid #2a3450; color: #8d97ad; font-size: 13px; font-weight: 700; }
.chat-item:hover { background: #1a2237; }
.chat-item.active { background: #1a2237; border-color: #38bdf8; }
.chat-chan { font-size: 10.5px; font-weight: 800; letter-spacing: .03em; padding: 3px 7px; border-radius: 7px; flex-shrink: 0; }
.chan-tg { background: rgba(56, 189, 248, .16); color: #38bdf8; }
.chan-max { background: rgba(167, 139, 250, .16); color: #a78bfa; }
.chat-item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chat-item-name { font-size: 13px; font-weight: 600; color: #e7ebf5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-kind { font-size: 9.5px; color: #7dd3fc; border: 1px solid rgba(56, 189, 248, .4); padding: 1px 5px; border-radius: 6px; font-weight: 700; white-space: nowrap; }
.chat-new { font-size: 10.5px; color: #fbbf24; font-weight: 700; }
.chat-item-prev { font-size: 11.5px; color: #8d97ad; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.chat-item-time { font-size: 10.5px; color: #8d97ad; }
.chat-unread { background: #2f6cb5; color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 999px; padding: 1px 7px; }
.chats-side .empty { color: #8d97ad; }
.chat-main { background: #0a0e1a; border: 1px solid #262e45; border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; }
.chat-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #262e45; flex-wrap: wrap; background: #0d1220; }
.chat-head-info { display: flex; align-items: center; gap: 10px; }
.chat-head-ava { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.chat-head-name { font-size: 14px; font-weight: 700; color: #e7ebf5; }
.chat-head-sub { font-size: 11.5px; color: #8d97ad; }
.chat-head-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 7px; }
.chat-day { align-self: center; margin: 8px 0 2px; padding: 2px 10px; border-radius: 10px; background: rgba(255,255,255,.06); font-size: 11px; color: rgba(231,235,245,.6); }
.chat-msg { max-width: 74%; padding: 7px 11px; border-radius: 12px; font-size: 13px; color: #e7ebf5; }
.chat-msg.has-media { padding: 4px; }
.chat-msg.has-media .chat-msg-meta { padding: 2px 7px 4px; }
.chat-msg.in { align-self: flex-start; background: #1c2438; border: 1px solid #2a3450; }
.chat-msg.out { align-self: flex-end; background: #2f6cb5; border: 1px solid #3d82c4; }
.chat-msg-who { font-size: 11px; font-weight: 700; color: #7dd3fc; margin-bottom: 2px; }
.chat-msg-text { white-space: pre-line; word-break: break-word; }
.chat-msg-media { display: block; max-width: 100%; max-height: 280px; border-radius: 10px; }
.chat-msg-meta { display: flex; align-items: center; justify-content: flex-end; gap: 5px; margin-top: 3px; }
.chat-msg-time { font-size: 10px; color: rgba(231, 235, 245, .55); }
.chat-msg-ticks { font-size: 10.5px; font-weight: 700; color: #9ecbff; }
.chat-send { display: flex; gap: 8px; padding: 9px 11px; border-top: 1px solid #262e45; align-items: flex-end; background: #0d1220; }
.chat-attach-btn { flex-shrink: 0; width: 38px; height: 38px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border-radius: 10px; }
.chat-send .textarea { flex: 1; min-height: 38px; max-height: 120px; resize: none; background: #141b30; border-color: #2a3450; color: #e7ebf5; }
.chat-send .textarea::placeholder { color: #6f7a94; }
.chat-send .textarea:focus { border-color: #38bdf8; }
.chat-main .empty { color: #8d97ad; }
.conn-block { background: var(--card2); border: 1px solid var(--border); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.conn-title { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 10px; }
.conn-step { font-size: 12.5px; color: var(--muted); margin: 8px 0; line-height: 1.45; }
.conn-ok { font-size: 13px; color: var(--ok); font-weight: 600; margin-bottom: 8px; }
.conn-or { text-align: center; color: var(--muted); font-size: 12px; margin: 12px 0 8px; }
.conn-qr { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 10px 0; }
.conn-qr img { border-radius: 12px; background: #fff; padding: 6px; }
.conn-qr-hint { font-size: 12px; color: var(--muted); }
.conn-dump { margin-top: 10px; font-size: 11px; color: var(--muted); border: 1px solid var(--border); border-radius: 8px; padding: 8px; max-height: 200px; overflow: auto; white-space: pre-wrap; }
@media (max-width: 900px) {
  .chats-wrap { grid-template-columns: 1fr; height: auto; }
  .chat-main { min-height: 420px; }
  #view.view-chats { height: auto; min-height: 0; overflow: visible; }
  #view.view-chats .view-head { margin-top: 20px; }
  #main:has(#view.view-chats) { padding-bottom: 96px; }
}
.crm-empty { color: var(--muted); opacity: .75; }
.crm-quick { display: inline-flex; gap: 4px; margin-left: 8px; vertical-align: middle; }
.crm-quick .btn-icon { width: 24px; height: 24px; padding: 3px; }

.crm-links { display: flex; flex-direction: column; gap: 2px; }
.crm-link-ok { color: var(--ok); }
.link-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  color: var(--accent1);
  font-size: 13px;
  font-weight: 600;
  padding: 7px 2px;
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
}
.link-btn:hover { background: var(--accent-soft); }
.link-btn svg { width: 14px; height: 14px; flex-shrink: 0; }

.crm-files #card-file-input { display: none; }
.crm-files .empty { padding: 8px 0 4px; }
.file-row { align-items: center; }
.file-row .link-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-ico { color: var(--accent1); display: inline-flex; flex-shrink: 0; }
.file-ico svg { width: 14px; height: 14px; }
.file-btns { display: inline-flex; gap: 6px; flex-shrink: 0; }

/* ---------- Мини-карточка контакта в сделке/лиде ---------- */

.client-mini {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.client-mini-name { font-weight: 600; word-break: break-word; }
.client-mini-mail { color: var(--muted); font-weight: 400; font-size: 12.5px; margin-left: 6px; }
.client-mini-phone {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text);
  font-size: 13px;
  width: fit-content;
}
.client-mini-phone svg { width: 13px; height: 13px; color: var(--ok); }
.client-mini-chats { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }

/* ---------- Переписка в карточках ---------- */

.crm-chatlog .crm-fields-head { margin-bottom: 8px; }
.chatlog-btns { display: inline-flex; gap: 6px; }
.chatlog-list { display: flex; flex-direction: column; }
.chatlog-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
}
.chatlog-row:last-child { border-bottom: 0; }
.chatlog-row .chat-chan { flex-shrink: 0; font-size: 10px; padding: 2px 6px; }
.chatlog-dir { color: var(--muted); flex-shrink: 0; width: 14px; text-align: center; }
.chatlog-row[data-dir="in"] .chatlog-dir { color: var(--ok); }
.chatlog-text { flex: 1; min-width: 0; word-break: break-word; }
.chatlog-time { color: var(--muted); flex-shrink: 0; font-size: 11px; white-space: nowrap; }

/* ---------- Чаты с потенциалом ---------- */

.chat-pot {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: #fbbf24;
  border: 1px solid color-mix(in srgb, #fbbf24 45%, transparent);
  background: color-mix(in srgb, #fbbf24 12%, transparent);
  border-radius: 999px;
  padding: 1px 7px;
  vertical-align: middle;
  margin-left: 4px;
}
.chat-item:has(.chat-pot) .chat-item-ava-letter { color: #fbbf24; }

/* ---------- Редактор сервисных полей ---------- */

.svc-block { margin-bottom: 14px; }
.svc-title { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.svc-count { color: var(--muted); font-weight: 400; }
.svc-rows { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.svc-row { display: flex; gap: 6px; align-items: center; }
.svc-row .input { flex: 1; min-width: 0; }

.composer {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  padding: 10px 12px 12px;
}
.composer-tabs { display: flex; gap: 2px; margin: -4px -4px 8px; }
.cptab {
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.cptab:hover { color: var(--text); }
.cptab.active { color: var(--accent1); background: var(--accent-soft); }
.composer-pane[hidden] { display: none !important; }
.composer-line { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; }
.composer-line .input { flex: 1; min-width: 150px; }
.composer-line .select { flex: 0 0 auto; width: auto; }
.composer-line .textarea { flex: 1 1 100%; min-height: 54px; }
.composer-send { flex: 0 0 auto; }

.tl-sep {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .4px;
  margin: 12px 0 2px;
}
.tl-sep::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.timeline .tl-sep:first-child { margin-top: 2px; }

@media (max-width: 760px) {
  .crm-grid { grid-template-columns: 1fr; }
  .crm-row-label { flex-basis: 100px; }
}

/* ---------- Фильтры разделов (Битрикс-стиль) ---------- */

.cfilter {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.cfilter[hidden] { display: none; }
.cfilter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.cfilter-grid .field { margin: 0; }
.cfilter-grid .field label { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: block; }
.cfilter-actions { display: flex; justify-content: flex-end; }

/* ---------- Модульный фильтр ---------- */

.modfilter { flex-direction: row; gap: 14px; align-items: stretch; }
.mf-presets {
  flex: 0 0 190px;
  border-right: 1px solid var(--border);
  padding-right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}
.mf-side-title { font-size: 12px; color: var(--muted); font-weight: 600; }
.mf-preset-list { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; max-height: 260px; }
.mf-preset { display: flex; align-items: center; border-radius: 8px; }
.mf-preset:hover { background: var(--glass-bg-hover); }
.mf-preset.active { background: var(--accent-soft); }
.mf-preset-name {
  flex: 1; min-width: 0; text-align: left; background: none; border: 0; color: var(--text);
  font: inherit; font-size: 13px; padding: 6px 8px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.mf-preset-del {
  background: none; border: 0; color: var(--muted); font-size: 14px; line-height: 1;
  padding: 4px 8px; cursor: pointer; border-radius: 6px;
}
.mf-preset-del:hover { color: var(--danger); }
.mf-empty { font-size: 12px; color: var(--muted); padding: 6px 8px; }
.mf-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.mf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.mf-field { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; }
.mf-field-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.mf-field-label { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mf-field-del { background: none; border: 0; color: var(--muted); font-size: 14px; line-height: 1; padding: 2px 6px; cursor: pointer; border-radius: 6px; }
.mf-field-del:hover { color: var(--danger); background: var(--glass-bg-hover); }
.mf-field-body { display: grid; gap: 6px; }
.mf-field-body .select, .mf-field-body .input { width: 100%; min-width: 0; }
.mf-toolbar { display: flex; align-items: center; gap: 10px; }
.mf-add { position: relative; }
.mf-add summary { list-style: none; display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.mf-add summary::-webkit-details-marker { display: none; }
.mf-add[open] summary { background: var(--glass-bg-hover); }
.mf-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 30;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  display: flex; flex-direction: column; min-width: 240px; max-height: 320px; overflow-y: auto; padding: 4px;
}
.mf-menu button {
  background: none; border: 0; text-align: left; font: inherit; font-size: 13px; color: var(--text);
  padding: 7px 10px; cursor: pointer; border-radius: 6px; white-space: nowrap;
}
.mf-menu button:hover { background: var(--accent-soft); }

/* ---------- Пагинация списка клиентов ---------- */

.pager { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 14px 0; flex-wrap: wrap; }
.pg-btn {
  min-width: 34px; height: 34px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--card); color: var(--text); font: inherit; font-size: 13px; cursor: pointer;
}
.pg-btn:hover:not(:disabled) { background: var(--glass-bg-hover); }
.pg-btn.active {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  border-color: var(--accent1); color: #fff;
}
.pg-btn:disabled { opacity: .45; cursor: default; }
.pager-info { font-size: 12px; color: var(--muted); margin-left: 10px; }

@media (max-width: 720px) {
  .modfilter { flex-direction: column; }
  .mf-presets { flex: none; border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 10px; }
  .mf-preset-list { flex-direction: row; flex-wrap: wrap; max-height: none; overflow: visible; }
}

/* ---------- Тип клиента ---------- */

.type-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent1);
  vertical-align: 2px;
  margin-left: 6px;
}

.imp-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .3px;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--accent-soft, #ede9fe);
  color: var(--accent1, #7c3aed);
  vertical-align: 2px;
  margin-left: 6px;
  white-space: nowrap;
}
.imp-badge.dup {
  background: rgba(239, 68, 68, .12);
  color: #ef4444;
}


/* ---------- Реквизиты ---------- */

.req-details {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-top: 10px;
  background: var(--card2);
  overflow: hidden;
}
.req-details summary {
  cursor: pointer;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 13px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.req-details summary::before { content: '▸'; color: var(--muted); font-size: 11px; transition: transform .15s; }
.req-details[open] summary::before { transform: rotate(90deg); }
.req-details[open] summary { border-bottom: 1px solid var(--border); }
.req-details .field { margin-top: 8px; }
.req-details > div { padding: 4px 12px 12px; }
.req-view { padding: 4px 0; }
.req-row { display: flex; gap: 10px; padding: 6px 12px; font-size: 13px; border-bottom: 1px solid var(--border); }
.req-row:last-child { border-bottom: 0; }
.req-label { color: var(--muted); min-width: 180px; flex-shrink: 0; }
.req-val { word-break: break-word; white-space: pre-wrap; }
.req-empty { padding: 8px 12px 12px; color: var(--muted); font-size: 12.5px; }

/* ---------- Город / часовой пояс ---------- */

.tz-row { display: flex; gap: 6px; }
.tz-row .input { flex: 1; min-width: 0; }
.tz-row .btn { flex-shrink: 0; }

/* ---------- Привязка чатов в карточке ---------- */

.chat-bind-btns { display: flex; gap: 8px; flex-wrap: wrap; padding: 6px 0 2px; }

/* ---------- UI-полировка (тёмный премиум) ---------- */

*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(128, 136, 160, .35);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(128, 136, 160, .55); background-clip: padding-box; }

html[data-theme="dark"] .card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, 0) 46%),
    var(--card);
}

html[data-theme="dark"] .modal {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, 0) 46%),
    var(--bg2);
}

html[data-theme="dark"] .trow {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .04), rgba(255, 255, 255, 0) 46%),
    var(--card);
}

html[data-theme="gold"] .card {
  background:
    linear-gradient(180deg, rgba(212, 175, 55, .05), rgba(212, 175, 55, 0) 46%),
    var(--card);
}

html[data-theme="gold"] .modal {
  background:
    linear-gradient(180deg, rgba(212, 175, 55, .05), rgba(212, 175, 55, 0) 46%),
    var(--bg2);
}

html[data-theme="gold"] .trow {
  background:
    linear-gradient(180deg, rgba(212, 175, 55, .05), rgba(212, 175, 55, 0) 46%),
    var(--card);
}

html[data-theme="orange"] .card {
  background:
    linear-gradient(180deg, rgba(255, 138, 46, .05), rgba(255, 138, 46, 0) 46%),
    var(--card);
}

html[data-theme="orange"] .modal {
  background:
    linear-gradient(180deg, rgba(255, 138, 46, .05), rgba(255, 138, 46, 0) 46%),
    var(--bg2);
}

html[data-theme="orange"] .trow {
  background:
    linear-gradient(180deg, rgba(255, 138, 46, .05), rgba(255, 138, 46, 0) 46%),
    var(--card);
}

.stat-card2 {
  transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s var(--ease);
}
.stat-card2:hover {
  transform: translateY(-2px);
  border-color: rgba(91, 108, 255, .45);
  box-shadow: 0 10px 26px rgba(0, 0, 0, .18);
}

.side-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  margin: 0 2px 12px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(91, 108, 255, .16), rgba(124, 92, 252, .09));
  border: 1px solid rgba(91, 108, 255, .22);
}

.su-ava {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  box-shadow: 0 6px 16px rgba(91, 108, 255, .4);
}

.su-name { font-size: 14px; font-weight: 700; }
.su-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

.promo-card {
  margin: 0 2px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(91, 108, 255, .28);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(91, 108, 255, .85), rgba(124, 92, 252, .75));
  color: #fff;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 10px 24px rgba(91, 108, 255, .35);
  transition: transform .15s var(--ease), box-shadow .2s var(--ease);
}
.promo-card:hover { transform: translateY(-1px); box-shadow: 0 14px 30px rgba(91, 108, 255, .45); }

.promo-title { font-size: 13.5px; font-weight: 700; }
.promo-sub { font-size: 11.5px; opacity: .82; margin-top: 2px; }

.promo-go {
  margin-left: auto;
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .18);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin: 4px 2px 14px;
}

.kpi-card {
  position: relative;
  overflow: hidden;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--border);
  transition: transform .18s var(--ease), border-color .18s var(--ease);
}
.kpi-card:hover { transform: translateY(-2px); border-color: rgba(91, 108, 255, .45); }

.kpi-top { display: flex; align-items: center; gap: 9px; }

.kpi-ic {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--kc, var(--accent1));
  background: color-mix(in srgb, var(--kc, var(--accent1)) 15%, transparent);
}
.kpi-ic svg { width: 17px; height: 17px; }

.kpi-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kpi-num { font-size: 26px; font-weight: 800; letter-spacing: -.5px; margin-top: 8px; }
.kpi-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.kpi-spark {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 64px;
  height: 24px;
  opacity: .9;
}

.sec-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 6px 4px 8px;
}

.stage-pills { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 2px 12px; }

.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.stage-pill b { font-weight: 800; color: var(--muted); }
.stage-pill .stage-dot { width: 8px; height: 8px; border-radius: 999px; flex: none; }
.stage-pill:hover { border-color: rgba(91, 108, 255, .45); }
.stage-pill.active { background: var(--accent-soft); border-color: rgba(91, 108, 255, .55); }
.stage-pill.active b { color: var(--text); }

@media (max-width: 900px) {
  .kpi-spark { display: none; }
  .side-user { margin-bottom: 8px; }
}

/* ---------- Профиль пользователя ---------- */
.side-user { cursor: pointer; }
.side-user:hover { background: rgba(255, 255, 255, 0.05); border-radius: 10px; }
.su-ava { overflow: hidden; }
.su-ava .su-ava-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; display: block; }
.profile-panel {
  position: fixed; top: 60px; right: 14px; z-index: 4000;
  width: 320px; background: #1c1f26; color: #e8eaf0;
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 14px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  animation: pp-in 0.14s ease-out;
}
@keyframes pp-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.pp-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 0; }
.pp-title { font-weight: 600; font-size: 13px; color: #9aa2b1; text-transform: uppercase; letter-spacing: 0.04em; }
.pp-x { background: none; border: none; color: #9aa2b1; font-size: 14px; cursor: pointer; padding: 4px 6px; }
.pp-x:hover { color: #fff; }
.pp-body { display: flex; gap: 14px; padding: 12px 14px; align-items: center; }
.pp-ava { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: none; }
.pp-ava-empty { display: flex; align-items: center; justify-content: center; background: #2c3242; font-size: 26px; color: #aab3c5; }
.pp-fields { min-width: 0; }
.pp-name { font-weight: 600; font-size: 15px; margin-bottom: 6px; word-break: break-word; }
.pp-row { font-size: 12.5px; color: #b8bfcc; display: flex; gap: 6px; margin-top: 2px; }
.pp-label { color: #8a93a5; flex: none; }
.pp-form { padding: 0 14px; display: flex; flex-direction: column; gap: 8px; }
.pp-f { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: #8a93a5; }
.pp-f input {
  background: #14171d; border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 8px;
  color: #e8eaf0; padding: 7px 9px; font-size: 13px; outline: none;
}
.pp-f input:focus { border-color: #6c5ce7; }
.pp-actions { display: flex; gap: 8px; padding: 12px 14px 14px; }
.pp-file input { display: none; }

/* ---------- Glass-кнопки ---------- */

.btn {
  background: var(--glass-bg);
  border-color: var(--glass-border);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--glass-shadow);
}
.btn:hover {
  background: var(--glass-bg-hover);
  border-color: var(--accent1);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--glass-shadow-hover);
}
.btn:active { box-shadow: inset 0 1px 0 var(--glass-hi); }
.btn:disabled {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--glass-accent1), var(--glass-accent2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 8px 24px rgba(91, 108, 255, .4);
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--glass-accent1), var(--glass-accent2));
  filter: brightness(1.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .3), 0 10px 30px rgba(91, 108, 255, .5);
}
.btn-primary:active { filter: brightness(.97); }

.btn-danger {
  background: rgba(248, 113, 113, .16);
  border-color: rgba(248, 113, 113, .45);
  backdrop-filter: blur(14px) saturate(1.4);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .1), 0 2px 10px rgba(248, 113, 113, .14);
}
.btn-danger:hover {
  background: linear-gradient(135deg, var(--glass-danger1), var(--glass-danger2));
  border-color: transparent;
  color: #fff;
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), var(--glow-danger);
}

.modal-actions .btn-danger,
.btn-danger.btn-block {
  background: linear-gradient(135deg, var(--glass-danger1), var(--glass-danger2));
  backdrop-filter: blur(14px) saturate(1.5);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .22), var(--glow-danger);
}
.modal-actions .btn-danger:hover,
.btn-danger.btn-block:hover {
  filter: brightness(1.1);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .28), 0 10px 26px rgba(248, 113, 113, .45);
}

.btn-danger-soft {
  background: rgba(248, 113, 113, .1);
  backdrop-filter: blur(12px) saturate(1.3);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 2px 8px rgba(248, 113, 113, .1);
}
.btn-danger-soft:hover {
  background: rgba(248, 113, 113, .18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .12), 0 4px 12px rgba(248, 113, 113, .18);
}

.icon-btn,
.mic-btn,
.modal-close {
  background: var(--glass-bg);
  border-color: var(--glass-border);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--glass-shadow);
}
.icon-btn:hover,
.mic-btn:hover {
  background: var(--glass-bg-hover);
  border-color: var(--accent1);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--glass-shadow-hover);
}
.modal-close:hover { background: var(--glass-bg-hover); }

.chip {
  background: var(--glass-bg);
  border-color: var(--glass-border);
  backdrop-filter: blur(12px) saturate(1.4);
  -webkit-backdrop-filter: blur(12px) saturate(1.4);
  box-shadow: inset 0 1px 0 var(--glass-hi), var(--glass-shadow);
}
.chip:hover { background: var(--glass-bg-hover); }
.chip.active {
  background: linear-gradient(135deg, var(--glass-accent1), var(--glass-accent2));
  backdrop-filter: blur(12px) saturate(1.5);
  -webkit-backdrop-filter: blur(12px) saturate(1.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 6px 18px rgba(91, 108, 255, .35);
}

@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .btn, .btn-danger, .btn-danger-soft, .icon-btn, .mic-btn, .modal-close, .chip {
    background: var(--card2);
    border-color: var(--border);
    box-shadow: inset 0 1px 0 var(--glass-hi), var(--glass-shadow);
  }
  .chip { background: var(--card); }
  .btn-primary, .chip.active, .modal-actions .btn-danger, .btn-danger.btn-block {
    background: linear-gradient(135deg, var(--accent1), var(--accent2));
  }
  .btn-danger:hover { background: linear-gradient(135deg, #f87171, #ef4444); }
}

.staff-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
  margin-right: 2px;
}
.staff-dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent);
}
.staff-meta {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 3px;
}

/* ---------- Пикер сущностей ---------- */

#picker-root .picker-layer { z-index: 500; }

.picker-modal { max-width: 560px; display: flex; flex-direction: column; padding: 18px; }
.picker-panel { display: flex; flex-direction: column; min-height: 0; }
.picker-panel .modal-head { margin-bottom: 12px; }
.pk-search { margin-bottom: 10px; }
.pk-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  min-height: 120px;
  max-height: min(46vh, 420px);
  padding-right: 2px;
}
.pk-row {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--border);
  background: var(--card2);
  border-radius: 12px;
  padding: 9px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  color: inherit;
  text-align: left;
  width: 100%;
}
.pk-row:hover { border-color: var(--accent1, #7c3aed); }
.pk-row.active { border-color: var(--accent1, #7c3aed); background: rgba(124, 58, 237, .08); }
.pk-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-sub { color: var(--muted); font-size: 12px; white-space: nowrap; flex-shrink: 0; }
.pk-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 26px 0; }
.pk-more { display: flex; justify-content: center; padding: 8px 0 2px; }
.picker-panel .modal-actions { margin-top: 12px; display: flex; gap: 8px; }

.picker-field { display: flex; gap: 6px; align-items: stretch; }
.picker-value {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--text);
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}
.picker-value.empty { color: var(--muted); }
.picker-value:hover { border-color: var(--accent1, #7c3aed); }
.pk-placeholder { color: var(--muted); }
.picker-clear {
  border: 1px solid var(--border);
  background: var(--card2);
  color: var(--muted);
  border-radius: 10px;
  width: 34px;
  flex: 0 0 34px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.picker-clear:hover { color: #ef4444; border-color: #ef4444; }
.picker-clear.hidden { display: none; }
.mf-clientpick .picker-value { min-height: 38px; }

.num-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .2px;
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(91, 108, 255, .12);
  color: #5b6cff;
  vertical-align: 2px;
  white-space: nowrap;
}
.num-badge.num-empty { visibility: hidden; }

/* ---------- Полоса чата сотрудников ---------- */

#chatbar {
  flex: none;
  width: 56px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 6px;
  background: var(--nav-bg);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  z-index: 40;
}
#chatbar[hidden] { display: none; }

.chatbar-item {
  position: relative;
  width: 42px;
  height: 42px;
  border: 1px solid var(--border);
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  flex: none;
  transition: border-color .15s;
}
.chatbar-item:hover { border-color: var(--accent1); }
.chatbar-item.active { border-color: var(--accent1); box-shadow: 0 0 0 2px var(--accent-soft); }
.chatbar-item.chatbar-new { border-style: dashed; }
.chatbar-ava {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  pointer-events: none;
}
.chatbar-item[data-chatbar-group] .chatbar-ava { border-radius: 12px; }
.chatbar-ava-plus { background: var(--card2) !important; color: var(--muted); }
.chatbar-ava-plus svg { width: 16px; height: 16px; }
.chatbar-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 17px;
  height: 17px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  pointer-events: none;
}

/* ---------- Окно чата сотрудников (мессенджер) ---------- */

html[data-theme="light"] { --chat-grad1: #dcefe2; --chat-grad2: #d7e6f6; }
html[data-theme="dark"] { --chat-grad1: #132019; --chat-grad2: #121a2a; }
html[data-theme="gold"] { --chat-grad1: #1e180c; --chat-grad2: #171205; }
html[data-theme="orange"] { --chat-grad1: #22281a; --chat-grad2: #171f38; }

#chat-panel-root .scp-window {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(920px, 100vw);
  display: flex;
  background: var(--card);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 90;
  animation: scp-in .22s var(--ease);
}
@keyframes scp-in {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.scp-list {
  flex: none;
  width: 300px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}
.scp-list-head {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 12px 8px 16px;
}
.scp-list-head .scp-title { flex: 1; font-size: 16px; font-weight: 800; }
.scp-search { position: relative; margin: 0 12px 8px; }
.scp-search svg {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}
.scp-search .input { padding-left: 33px; height: 36px; font-size: 13.5px; }
.scp-rows {
  flex: 1;
  overflow-y: auto;
  padding: 4px 6px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.sp-row:hover { background: var(--card2); }
.sp-row.active { background: var(--accent-soft); }
.sp-row-ava { width: 40px; height: 40px; flex: none; }
.sp-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sp-row-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.sp-row-name { font-size: 13.5px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-row-time { font-size: 10.5px; color: var(--muted); flex: none; }
.sp-row-prev { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-row .chatbar-badge { position: static; flex: none; }
.sp-row .chatbar-badge svg { display: none; }

.scp-chat {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: linear-gradient(160deg, var(--chat-grad1), var(--chat-grad2));
}
.scp-chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.scp-head-ava { width: 38px; height: 38px; flex: none; }
.scp-back { display: none; flex: none; }
.scp-head-main { min-width: 0; }
.scp-title { font-size: 15px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scp-sub { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scp-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px clamp(14px, 4%, 40px) 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.scp-day {
  align-self: center;
  margin: 8px 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(125, 135, 155, .18);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 700;
}
.scp-mrow { display: flex; align-items: flex-end; gap: 8px; max-width: 72%; }
.scp-mrow.in { align-self: flex-start; }
.scp-mrow.out { align-self: flex-end; flex-direction: row-reverse; }
.scp-m-ava { width: 32px; height: 32px; font-size: 11px; flex: none; }
.scp-msg {
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  box-shadow: 0 1px 2px rgba(15, 20, 30, .07);
}
.scp-msg.in { background: var(--card); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.scp-msg.out {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #fff;
  border-bottom-right-radius: 5px;
}
.scp-msg-who { font-size: 11px; font-weight: 800; color: var(--accent1); margin-bottom: 2px; }
.scp-msg-text { white-space: pre-line; word-break: break-word; }
.scp-msg-meta { display: flex; justify-content: flex-end; align-items: center; gap: 5px; margin-top: 3px; }
.scp-msg-time { font-size: 10px; color: var(--muted); }
.scp-msg.out .scp-msg-time, .scp-msg.out .scp-ticks { color: rgba(255, 255, 255, .8); }
.scp-ticks { font-size: 10px; font-weight: 700; letter-spacing: -2px; }
.scp-empty { margin: auto; padding: 20px; text-align: center; color: var(--muted); font-size: 13px; }
.scp-placeholder {
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13.5px;
}
.scp-ph-ic {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
}
.scp-ph-ic svg { width: 24px; height: 24px; }
.scp-send {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
}
.scp-send .textarea {
  flex: 1;
  min-height: 44px;
  max-height: 132px;
  resize: none;
  border-radius: 22px;
  padding: 11px 16px;
}
.scp-send-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow);
}
.scp-send-btn svg { width: 18px; height: 18px; }
.scp-send-btn:hover { filter: brightness(1.08); }

/* ---------- Попап уведомлений ---------- */

#notif-btn { position: relative; }
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
#notif-popover {
  position: fixed;
  width: 348px;
  max-width: calc(100vw - 16px);
  max-height: min(64vh, 520px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  z-index: 105;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#notif-popover[hidden] { display: none; }
.np-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-weight: 800;
  font-size: 13px;
}
.np-list {
  overflow-y: auto;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.np-row {
  display: flex;
  gap: 9px;
  padding: 8px 9px;
  border-radius: 10px;
  cursor: pointer;
  align-items: flex-start;
}
.np-row:hover { background: var(--card2); }
.np-dot { width: 8px; height: 8px; border-radius: 999px; background: var(--border); flex: none; margin-top: 6px; }
.np-row.np-unread .np-dot { background: var(--accent1); }
.np-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.np-text { font-size: 13px; line-height: 1.4; word-break: break-word; }
.np-time { font-size: 11px; color: var(--muted); }

/* ---------- Чекбоксы воронок и участников ---------- */

.funnel-ck-grid { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 4px; }
.ck-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13.5px;
  cursor: pointer;
}
.ck-row input { width: 16px; height: 16px; accent-color: var(--accent1); flex: none; }
.ck-dot { width: 9px; height: 9px; border-radius: 999px; flex: none; }

/* ---------- Полоса чата: мобильная адаптация ---------- */

@media (max-width: 760px) {
  #chatbar {
    position: fixed;
    left: 0;
    right: 0;
    top: auto;
    bottom: calc(64px + env(safe-area-inset-bottom));
    width: auto;
    height: 54px;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 6px 8px;
    border-left: 0;
    border-top: 1px solid var(--border);
    z-index: 45;
  }
  #app #main { padding-bottom: 152px; }
  #chat-panel-root .scp-window { width: 100vw; }
  .scp-list { width: 100%; border-right: 0; }
  .scp-chat { display: none; }
  .scp-window.has-chat .scp-list { display: none; }
  .scp-window.has-chat .scp-chat { display: flex; }
  .scp-back { display: inline-flex; }
}

/* ---------- Settings tree + server monitor ---------- */

.settings-wrap {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.settings-nav {
  width: 232px;
  flex: none;
  position: sticky;
  top: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-nav-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
  margin: 10px 8px 4px;
}

.settings-nav-label:first-child { margin-top: 2px; }

.settings-nav-item {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 8px;
  padding: 7px 10px;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
}

.settings-nav-item:hover { background: var(--card2); }

.settings-nav-item.active {
  background: linear-gradient(135deg, var(--accent1), var(--accent2));
  color: #fff;
  font-weight: 600;
}

.settings-content { flex: 1; min-width: 0; }

.monitor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}

.mon-card {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.mon-title {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}

.mon-value {
  font-size: 15.5px;
  font-weight: 700;
  margin-top: 4px;
  word-break: break-word;
}

.mon-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

.mon-bar {
  height: 6px;
  border-radius: 4px;
  background: var(--border);
  margin-top: 8px;
  overflow: hidden;
}

.mon-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--accent1), var(--accent2));
  transition: width 0.4s ease;
}

.mon-bar-fill.hot { background: #ef4444; }

@media (max-width: 760px) {
  .settings-wrap { flex-direction: column; }
  .settings-nav {
    position: static;
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 8px;
  }
  .settings-nav-label { width: 100%; margin: 6px 4px 2px; }
  .settings-nav-label:first-child { margin-top: 0; }
  .settings-nav-item { width: auto; }
}

.mpick { position: relative; }
.mpick-drop { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 60; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); max-height: 224px; overflow: auto; }
.mpick-item { display: block; width: 100%; text-align: left; padding: 8px 12px; background: none; border: 0; color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.mpick-item:hover, .mpick-item.hi { background: var(--accent-soft); }
.mpick-add { color: var(--muted); }
.pv-grid { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .pv-grid { grid-template-columns: 1fr; } }
.pv-card { padding: 20px; }
.pv-ava { width: 96px; height: 96px; border-radius: var(--radius-sm); object-fit: cover; display: block; }
.pv-ava-empty { display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--accent1), var(--accent2)); color: #fff; font-size: 34px; font-weight: 700; }
.pv-name { font-size: 20px; font-weight: 700; margin-top: 14px; }
.pv-badge { display: inline-block; margin-top: 8px; padding: 3px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.pv-badge-admin { background: rgba(99, 102, 241, .18); color: #818cf8; }
.pv-meta { margin-top: 10px; color: var(--muted); font-size: 13px; }
.pv-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.pv-row { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.pv-label { flex: 0 0 190px; color: var(--muted); }
.pv-empty { color: var(--muted); font-style: italic; }
.pv-block-title { margin: 16px 0 4px; font-weight: 700; }
.pv-hint { margin-top: 10px; color: var(--muted); font-size: 12.5px; }
.pv-file { display: inline-flex; align-items: center; cursor: pointer; }

/* ---------- Проекты: участники, чат, файлы, статусы ---------- */

.proj-status-chip {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
}
.proj-status-chip.proj-hidden { background: rgba(248, 113, 113, .15); color: var(--danger); }
.proj-unread {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.proj-invite-banner { margin: 0 0 14px; display: flex; flex-direction: column; gap: 8px; }
.proj-invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card);
  font-size: 14px;
}
.proj-invite-btns { display: inline-flex; gap: 8px; }
.pp-members { display: flex; flex-direction: column; gap: 6px; }
.pp-member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
}
.pp-member-ava { width: 28px; height: 28px; font-size: 12px; position: static; }
.pp-member-name { font-size: 14px; font-weight: 500; }
.pp-kick { margin-left: auto; color: var(--muted); }
.pp-kick:hover { color: var(--danger); }
.proj-role-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.pp-invited { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.proj-invited-chip {
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px dashed var(--border);
  color: var(--muted);
  font-size: 12.5px;
}
.pp-invite-row { display: flex; gap: 8px; margin-top: 10px; max-width: 480px; }
.pp-invite-row .select { flex: 1; }

/* ---------- Чат проекта и обсуждение задачи ---------- */

.tchat {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding: 4px 2px;
}
.tchat-empty { color: var(--muted); font-size: 13.5px; font-style: italic; padding: 6px 0; }
.tchat-msg {
  align-self: flex-start;
  max-width: 82%;
  padding: 7px 12px;
  border-radius: 12px 12px 12px 4px;
  background: var(--card2);
  border: 1px solid var(--border);
}
.tchat-msg.own {
  align-self: flex-end;
  border-radius: 12px 12px 4px 12px;
  background: var(--accent-soft);
}
.tchat-head { display: flex; gap: 10px; align-items: baseline; margin-bottom: 2px; }
.tchat-author { font-size: 12px; font-weight: 700; color: var(--muted); }
.tchat-msg.own .tchat-author { color: var(--accent1); }
.tchat-time { font-size: 11px; color: var(--muted); }
.tchat-text { font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.tchat-mention { color: var(--accent1); font-weight: 600; }
.tchat-ac {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 4px;
  min-width: 240px;
  max-height: 210px;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 30;
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.tchat-ac-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
}
.tchat-ac-item:hover { background: var(--accent-soft); }
.tchat-ac-item b { color: var(--accent1); }

/* ---------- Массовое закрытие задач ---------- */

.tt-sel { width: 18px; height: 18px; margin-top: 3px; border-radius: 4px; border-color: var(--border); color: transparent; opacity: 1; }
.tt-sel:hover { border-color: #2ea6ff; }
.tt-sel.checked { background: #2ea6ff; border-color: #2ea6ff; color: #fff; opacity: 1; }
.sel-bar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  font-size: 13.5px;
  font-weight: 600;
}
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* ---------- Права: флаг удаления ---------- */

.perm-del {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 8px;
  font-size: 11.5px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.perm-del input { accent-color: var(--accent1); margin: 0; }

/* ---------- Lite-режим: отключение анимаций и эффектов ---------- */

html.lite *,
html.lite *::before,
html.lite *::after {
  animation: none !important;
  transition: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  filter: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

html.lite #sky,
html.lite #auth-root::before,
html.lite #auth-root::after {
  display: none !important;
}

/* ---------- Водяной знак пользователя ---------- */

#crm-wm {
  position: fixed;
  right: 10px;
  bottom: 8px;
  z-index: 99999;
  pointer-events: none;
  user-select: none;
  font-size: 11px;
  font-weight: 600;
  color: currentColor;
  opacity: .14;
}

/* ---------- Выбор темы в нижнем меню ---------- */

.theme-panel {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  margin: 8px 0 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
}

.theme-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.theme-item:hover { background: var(--glass-bg-hover); }
.theme-item.active {
  border-color: var(--accent1);
  background: var(--accent-soft);
}

.theme-swatch {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .2);
}

.theme-item.active .theme-name::after {
  content: ' — выбрана';
  color: var(--muted);
  font-size: 12px;
}
