@font-face { font-family: "IRANSans"; src: url("../fonts/IRANSans_UltraLight.ttf") format("truetype"); font-weight: 200; font-display: swap; }
@font-face { font-family: "IRANSans"; src: url("../fonts/IRANSans_Light.ttf") format("truetype"); font-weight: 300; font-display: swap; }
@font-face { font-family: "IRANSans"; src: url("../fonts/IRANSans.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "IRANSans"; src: url("../fonts/IRANSans_Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "IRANSans"; src: url("../fonts/IRANSans_Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "IRANSans"; src: url("../fonts/IRANSans_Black.ttf") format("truetype"); font-weight: 900; font-display: swap; }

:root {
  --backdrop: #ece6f1;
  --bg: #efeff3;
  --surface: #ffffff;
  --surface-2: #f7f7fa;
  --text: #1d1d2c;
  --text-2: #4b4b63;
  --muted: #9191a8;
  --border: #e6e6ee;
  --primary: #7b7ff6;
  --primary-2: #9a9df9;
  --primary-soft: #ededfe;
  --primary-ink: #5a5ee8;
  --teal: #86c2c7;
  --coral: #f2a09c;
  --green: #86deb0;
  --amber: #f5c26b;
  --danger: #ea5b6c;
  --danger-soft: #fdecef;
  --success: #2fb877;
  --success-soft: #e5f7ee;
  --warning: #e3a13a;
  --warning-soft: #fdf3e2;
  --telegram: #2aa3de;
  --bale: #1cb58c;
  --rubika: #e0457b;
  --shadow: 0 10px 30px rgba(84, 84, 140, 0.08);
  --shadow-lg: 0 24px 60px rgba(60, 60, 110, 0.18);
  --tip-bg: #2b2b3d;
  --tip-fg: #f3f3fb;
  --s1: #6a6ef4;
  --s2: #2f93a8;
  --s3: #e0665f;
  --s4: #1fa06d;
  --radius: 22px;
  --radius-sm: 14px;
  --sidebar: 264px;
  --sidebar-collapsed: 88px;
  color-scheme: light;
}

[data-theme="dark"] {
  --backdrop: #0d0d14;
  --bg: #13131c;
  --surface: #1c1c28;
  --surface-2: #232332;
  --text: #ececf6;
  --text-2: #c2c2d6;
  --muted: #8b8ba5;
  --border: #2c2c3d;
  --primary: #8b8ef9;
  --primary-2: #a3a6fb;
  --primary-soft: #26263f;
  --primary-ink: #a9acff;
  --danger-soft: #3a1f27;
  --success-soft: #16332a;
  --warning-soft: #3a2e17;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.5);
  --tip-bg: #33334a;
  --tip-fg: #f3f3fb;
  --s1: #8b8ef9;
  --s2: #4fc3cf;
  --s3: #ff8a7d;
  --s4: #45d39a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "IRANSans", Tahoma, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary-ink); text-decoration: none; }
svg { flex-shrink: 0; }
.hidden { display: none !important; }
/* Also hide the legacy shortcut when an older app shell is still present. */
.skip-link { display: none !important; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: plaintext; }
.nowrap { white-space: nowrap; }
.ellipsis { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
::selection { background: var(--primary-soft); }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0;
  gap: 0;
  transition: grid-template-columns 0.25s ease;
}
.frame {
  display: contents;
}
.sidebar {
  background: var(--surface);
  border-radius: 0;
  padding: 26px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  box-shadow: none;
  overflow: hidden;
  z-index: 5;
}
[dir="rtl"] .sidebar { border-radius: 0; }
.scrim {
  position: fixed; inset: 0; z-index: 4; background: rgba(20, 20, 35, 0.45); backdrop-filter: blur(2px);
  opacity: 0; visibility: hidden; transition: opacity 0.25s ease, visibility 0.25s ease;
}
body.no-scroll { overflow: hidden; }
.main {
  background: var(--bg);
  border-radius: 0;
  padding: 28px 30px 40px;
  min-width: 0;
  box-shadow: none;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px 10px; }
.brand-mark {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #b5a3f7);
  color: #fff; font-weight: 800; font-size: 19px;
  box-shadow: 0 0 0 4px var(--primary-soft);
}
.brand-name { font-weight: 700; font-size: 18px; color: var(--primary-ink); white-space: nowrap; }
.brand-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.nav { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; overflow-x: hidden; flex: 1; padding-inline-end: 2px; scrollbar-width: none; -ms-overflow-style: none; }
.nav::-webkit-scrollbar { width: 0; height: 0; display: none; }
.nav-title { font-weight: 700; color: var(--text-2); margin: 14px 12px 4px; font-size: 13px; white-space: nowrap; }
.nav a {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 14px; border-radius: 14px;
  color: var(--muted); font-size: 15px; font-weight: 500;
  transition: background 0.2s, color 0.2s;
  white-space: nowrap;
}
.nav a svg { width: 22px; height: 22px; }
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--primary-ink); background: var(--primary-soft); }
.nav a .count { margin-inline-start: auto; background: var(--danger); color: #fff; font-size: 11px; border-radius: 10px; padding: 0 7px; line-height: 18px; }
.cta {
  margin-top: 10px; border: 0; border-radius: 20px; cursor: pointer;
  background: linear-gradient(160deg, var(--primary), var(--primary-2));
  color: #fff; padding: 20px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; box-shadow: 0 14px 30px rgba(123, 127, 246, 0.35);
  transition: transform 0.2s;
}
.cta:hover { transform: translateY(-2px); }
.cta svg { width: 36px; height: 36px; }
.me-card {
  margin-top: 12px; display: flex; align-items: center; gap: 10px;
  border: 1.5px solid var(--primary-soft); border-radius: 16px; padding: 8px 10px; cursor: pointer; background: var(--surface);
  position: relative;
}
.avatar {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #f3b4a5, #e98a9d); color: #fff; font-weight: 700; flex-shrink: 0;
  position: relative; overflow: hidden;
}
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar.avatar-sm { width: 34px; height: 34px; font-size: 13px; }
.me-name { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: 11px; color: var(--muted); white-space: nowrap; }
.collapse-btn {
  position: absolute; top: 30px; left: 10px; border: 0; background: var(--surface-2); color: var(--muted);
  width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center; cursor: pointer;
}
@media (min-width: 901px) {
  .shell.collapsed { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }
  .shell.collapsed .brand-text, .shell.collapsed .nav a span, .shell.collapsed .nav-title,
  .shell.collapsed .cta span, .shell.collapsed .me-card .me-text, .shell.collapsed .me-card .chev, .shell.collapsed .nav a .count { display: none; }
  .shell.collapsed .nav a { justify-content: center; padding: 12px; }
  .shell.collapsed .collapse-btn { position: static; margin: 0 auto 8px; transform: scaleX(-1); }
  .shell.collapsed .brand { justify-content: center; padding: 0 0 8px; }
  .shell.collapsed .cta { padding: 14px 8px; }
  .shell.collapsed .me-card { justify-content: center; padding: 6px; }
  .scrim { display: none; }
}

.topbar { display: flex; align-items: center; gap: 18px; margin-bottom: 26px; flex-wrap: wrap; }
.page-title h1 { margin: 0; font-size: 28px; font-weight: 800; line-height: 1.3; }
.page-title .sub { color: var(--text-2); font-size: 13px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--surface); color: var(--text-2);
  display: grid; place-items: center; cursor: pointer; position: relative; transition: background .2s;
}
.icon-btn:hover { background: var(--primary-soft); color: var(--primary-ink); }
.icon-btn .dot { position: absolute; top: 6px; left: 6px; min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 10px; display: grid; place-items: center; padding: 0 4px; }
.nav-toggle { display: none; }

.tip {
  display: inline-grid; place-items: center; width: 17px; height: 17px; margin-inline-start: 6px;
  flex-shrink: 0; border: 0; padding: 0; background: transparent; border-radius: 50%;
  color: var(--muted); cursor: pointer; position: relative; vertical-align: -4px; line-height: 1;
  transition: color .15s, background .15s;
}
.tip:hover, .tip:focus-visible, .tip[aria-expanded="true"] { color: var(--primary-ink); background: var(--primary-soft); }
.tip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.field-help {
  position: fixed; z-index: 10000; width: max-content; max-width: min(280px, calc(100vw - 24px));
  max-height: min(300px, calc(100dvh - 24px)); overflow: auto; overflow-wrap: anywhere;
  white-space: normal; text-align: start; direction: rtl; background: var(--tip-bg); color: var(--tip-fg);
  font-size: 12px; font-weight: 400; line-height: 1.75; padding: 8px 12px;
  border-radius: 10px; box-shadow: var(--shadow-lg);
}

.boot { position: fixed; inset: 0; display: grid; grid-auto-flow: column; gap: 8px; place-content: center; background: var(--backdrop); }
.boot-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); animation: boot-pulse 1s infinite ease-in-out; }
.boot-dot:nth-child(2) { animation-delay: .15s; }
.boot-dot:nth-child(3) { animation-delay: .3s; }
@keyframes boot-pulse { 0%, 80%, 100% { opacity: .25; transform: scale(.75); } 40% { opacity: 1; transform: scale(1); } }

.card { background: var(--surface); border-radius: var(--radius); padding: 22px; box-shadow: 0 2px 10px rgba(80, 80, 120, 0.03); min-width: 0; }
.card h3, .section-title { margin: 0 0 14px; font-size: 19px; font-weight: 700; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 26px 4px 14px; }
.section-head h2 { margin: 0; font-size: 24px; font-weight: 800; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h3 { margin: 0; font-size: 17px; }

.dash { display: grid; grid-template-columns: minmax(0, 1fr); gap: 26px; max-width: 1600px; margin-inline: auto; }
@media (min-width: 1800px) {
  .dash .stat .val { font-size: 40px; }
}
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.stat {
  --c: var(--primary);
  position: relative; overflow: hidden; isolation: isolate;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  padding: 15px 18px 16px; display: flex; flex-direction: column; gap: 3px;
  transition: transform .25s ease, border-color .25s ease, box-shadow .25s ease;
}
.stat::before {
  content: ""; position: absolute; inset: 0; z-index: -2;
  background: radial-gradient(85% 130% at 100% 0%, color-mix(in srgb, var(--c) 20%, transparent), transparent 64%);
  transition: opacity .25s ease; opacity: .85;
}
.stat::after {
  content: ""; position: absolute; inset-block: 12px; inset-inline-start: 0; width: 3px; border-radius: 0 3px 3px 0;
  background: linear-gradient(to bottom, var(--c), color-mix(in srgb, var(--c) 10%, transparent));
}
.stat:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--c) 35%, var(--border)); box-shadow: var(--shadow); }
.stat:hover::before { opacity: 1; }
.stat-top { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); }
.stat-top svg { color: var(--c); }
.stat .val { font-size: 34px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; letter-spacing: -.5px; }
.stat .note { font-size: 12px; color: var(--muted); }
.stat.s1 { --c: var(--s1); }
.stat.s2 { --c: var(--s2); }
.stat.s3 { --c: var(--s3); }
.stat.s4 { --c: var(--s4); }
.two-col { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 22px; align-items: stretch; }
.two-col > .col { display: flex; flex-direction: column; min-width: 0; }
.two-col > .col > .fill { flex: 1; }
.two-col > .col > .card.empty.fill { display: grid; place-items: center; }
.two-col > .col > .progress-cards.fill { grid-auto-rows: 1fr; align-content: stretch; }
.chart-wrap { position: relative; }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.chart-tip {
  position: absolute; pointer-events: none; background: var(--surface); box-shadow: var(--shadow-lg); border-radius: 10px;
  padding: 6px 12px; font-size: 12px; white-space: nowrap; transform: translate(50%, -120%); color: var(--text); z-index: 3;
}
.legend { display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--text-2); }
.legend .it { display: flex; align-items: center; gap: 8px; }
.legend .sw { width: 9px; height: 9px; border-radius: 50%; }
.platform-card { display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.platform-card > .barchart { flex: 1; min-height: 0; }
.platform-card .barchart .plot { flex: 1; height: auto; min-height: 180px; }
.barchart { display: flex; flex-direction: column; gap: 12px; }
.barchart .plot { position: relative; height: var(--plot); }
.barchart .gl { position: absolute; inset-inline: 0; height: 0; border-top: 1px dashed var(--border); }
.barchart .cols { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 16px; }
.barchart .col { flex: 1; min-width: 0; height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.barchart .pillar {
  position: relative; width: 100%; max-width: 62px; height: var(--h); min-height: 4px; border-radius: 14px 14px 5px 5px;
  background: linear-gradient(to top, var(--c), color-mix(in srgb, var(--c) 52%, transparent));
  box-shadow: 0 10px 24px -14px var(--c); transform-origin: bottom;
  animation: pillar-in .65s cubic-bezier(.2, .85, .25, 1) var(--d) both;
  transition: filter .2s ease;
}
.barchart .pillar > b {
  position: absolute; bottom: 100%; inset-inline: 0; margin-bottom: 7px; text-align: center;
  font-size: 13px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums;
}
.barchart .col:hover .pillar { filter: brightness(1.06) saturate(1.08); }
@keyframes pillar-in { from { transform: scaleY(0); } }
.barchart .axis { display: flex; gap: 16px; }
.barchart .tick { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 3px; }
.barchart .tick .nm { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); }
.barchart .tick .sw { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.barchart .tick > b { font-size: 12.5px; color: var(--text); font-variant-numeric: tabular-nums; }
.chart-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border-top: 1px solid var(--border); padding-top: 12px; font-size: 12.5px; color: var(--text-2);
}
.chart-foot > b { font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
.progress-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.pcard { background: var(--surface); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.progress-cards > .pcard:last-child:nth-child(odd) { grid-column: 1 / -1; }
.pcard .over { font-size: 11px; color: var(--muted); }
.pcard .title { font-weight: 800; font-size: 17px; margin: 2px 0 12px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 8px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }
.pcard .meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
.pcard .meta b { color: var(--text); }
.heat-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.heat { display: grid; grid-template-columns: 70px repeat(24, minmax(0, 1fr)); gap: 3px; font-size: 10px; color: var(--muted); }
.heat .cell { aspect-ratio: 1; border-radius: 4px; background: var(--primary-soft); }
.heat .lab { display: flex; align-items: center; font-size: 11px; }
.heat .hr { text-align: center; }

.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head .title { font-size: 22px; font-weight: 800; }
.cal-nav { display: flex; gap: 6px; }
.cal-nav button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--border); background: transparent; cursor: pointer; display: grid; place-items: center; color: var(--muted); }
.calendar { background: var(--surface); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.calendar .wd, .calendar .days { display: grid; grid-template-columns: repeat(7, 1fr); text-align: center; gap: 6px; }
.calendar .wd { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.calendar .days span { padding: 7px 0; border-radius: 8px; font-weight: 500; font-size: 14px; position: relative; }
.calendar .days span.out { color: var(--border); }
.calendar .days span.today { background: var(--primary); color: #fff; }
.calendar .days span.has::after { content: ""; position: absolute; bottom: 3px; left: 50%; width: 4px; height: 4px; margin-left: -2px; border-radius: 50%; background: var(--coral); }
.timeline { position: relative; display: flex; flex-direction: column; gap: 14px; }
.tl-item { background: var(--surface); border-radius: 14px; padding: 12px 16px; border-inline-start: 4px solid var(--primary); box-shadow: 0 2px 8px rgba(0,0,0,0.03); }
.tl-item.c2 { border-color: var(--coral); }
.tl-item.c3 { border-color: var(--teal); }
.tl-item.c4 { border-color: var(--green); }
.tl-item .t { font-weight: 700; font-size: 13px; }
.tl-item .d { font-size: 11px; color: var(--muted); }

.btn {
  border: 0; border-radius: 12px; padding: 10px 18px; cursor: pointer; font-weight: 600; font-size: 13.5px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--surface-2); color: var(--text);
  transition: filter .2s, background .2s, transform .1s; white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn svg { width: 18px; height: 18px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 8px 18px rgba(123,127,246,0.3); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-soft { background: var(--primary-soft); color: var(--primary-ink); }
.btn-ghost { background: transparent; border: 1.5px solid var(--border); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; border-radius: 10px; }
.btn-icon { width: 38px; height: 38px; padding: 0; justify-content: center; flex-shrink: 0; }
.btn-icon.loading svg { display: none; }
.btn-pill { border-radius: 999px; padding: 8px 22px; }
.btn.loading { pointer-events: none; opacity: .75; }
.btn.loading::before { content: ""; width: 14px; height: 14px; border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-weight: 600; font-size: 13px; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; min-width: 0; border: 1.5px solid var(--border); background: var(--surface); border-radius: 12px; padding: 10px 14px; outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.8; }
.input[readonly], .textarea[readonly] { background: var(--surface-2); color: var(--text-2); cursor: default; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-soft); }
.input.invalid, .textarea.invalid { border-color: var(--danger); }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; position: relative; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; margin: 0; }
.switch .track { width: 44px; height: 24px; background: var(--border); border-radius: 12px; position: relative; transition: background .2s; flex-shrink: 0; }
.switch .track::after { content: ""; position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(-20px); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--text-2); white-space: nowrap; }
.chip .d { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.telegram { background: rgba(42,163,222,.12); color: var(--telegram); }
.chip.bale { background: rgba(28,181,140,.12); color: var(--bale); }
.chip.rubika { background: rgba(224,69,123,.12); color: var(--rubika); }
.chip.ok { background: var(--success-soft); color: var(--success); }
.chip.warn { background: var(--warning-soft); color: var(--warning); }
.chip.err { background: var(--danger-soft); color: var(--danger); }
.chip.info { background: var(--primary-soft); color: var(--primary-ink); }

.toolbar { display: flex; align-items: flex-end; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .field { min-width: 150px; }
.toolbar .field.wide { min-width: 240px; flex: 1; }
.toolbar.one-row { flex-wrap: nowrap; }
.toolbar.one-row .field { flex: 1 1 0; min-width: 0; }
.toolbar.one-row .field.wide { flex: 2 1 0; }
.toolbar.one-row .field > label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.table-card { background: var(--surface); border-radius: var(--radius); overflow: hidden; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: right; font-size: 12px; color: var(--muted); font-weight: 600; padding: 14px 16px; background: var(--surface-2); white-space: nowrap; }
.table td { padding: 13px 16px; border-top: 1px solid var(--border); vertical-align: middle; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table .excerpt { max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pager { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }
.empty { padding: 50px 20px; text-align: center; color: var(--muted); }
.empty svg { width: 54px; height: 54px; opacity: .45; margin-bottom: 8px; }

.bot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr)); gap: 18px; align-items: start; }
.bot-card { background: var(--surface); border-radius: var(--radius); padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; position: relative; }
.bot-card .top { display: flex; align-items: center; gap: 12px; }
.bot-card .name { font-weight: 700; font-size: 16px; }
.bot-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 20px; color: var(--muted); font-size: 12px; }
.bot-summary > span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.bot-summary > span > svg { flex-shrink: 0; }
.bot-summary b { font-variant-numeric: tabular-nums; }
.bot-card .accounts { display: flex; flex-direction: column; gap: 8px; }
.acc { display: flex; align-items: center; gap: 10px; font-size: 13px; background: var(--surface-2); border-radius: 12px; padding: 8px 12px; min-width: 0; }
.bot-card .actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.bot-card .details { border-top: 1px solid var(--border); padding-top: 14px; }
.bot-kv { gap: 10px 18px; align-items: start; }
.bot-kv dt { padding-top: 3px; white-space: nowrap; }

.overlay { position: fixed; inset: 0; background: rgba(20, 20, 35, 0.45); backdrop-filter: blur(3px); z-index: 50; display: grid; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 20px; animation: fade .15s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: 26px; width: min(640px, 100%); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
.modal.lg { width: min(900px, 100%); }
.modal.sm { width: min(440px, 100%); }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 22px 26px 8px; }
.modal-head h3 { margin: 0; font-size: 19px; }
.modal-body { padding: 12px 26px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-start; padding: 16px 26px 22px; border-top: 1px solid var(--border); }

.steps { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.steps .step { min-width: 0; flex: 1 1 120px; }
.step { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); padding: 8px 10px; border-radius: 12px; background: var(--surface-2); }
.step .n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: var(--border); color: var(--text-2); font-weight: 700; font-size: 12px; flex-shrink: 0; }
.step.clickable { cursor: pointer; }
.step.clickable:hover { background: var(--primary-soft); }
.step.active { background: var(--primary-soft); color: var(--primary-ink); }
.step.active .n { background: var(--primary); color: #fff; }
.step.done .n { background: var(--success); color: #fff; }
.platform-box { border: 1.5px solid var(--border); border-radius: 18px; padding: 16px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.platform-box.required { border-color: var(--primary-2); }
.platform-box .ph { display: flex; align-items: center; gap: 10px; font-weight: 700; }
.result { border-radius: 12px; padding: 10px 14px; font-size: 13px; display: flex; gap: 8px; align-items: flex-start; }
.result.ok { background: var(--success-soft); color: var(--success); }
.result.err { background: var(--danger-soft); color: var(--danger); }
.result.warn { background: var(--warning-soft); color: var(--warning); }
.result.info { background: var(--primary-soft); color: var(--primary-ink); }
.result svg { width: 18px; height: 18px; margin-top: 2px; }
.group-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }
.group-opt { display: flex; align-items: center; gap: 10px; min-width: 0; border: 1.5px solid var(--border); border-radius: 14px; padding: 10px 14px; cursor: pointer; }
.group-opt.sel { border-color: var(--primary); background: var(--primary-soft); }
.tabs { display: inline-flex; background: var(--surface); border-radius: 14px; padding: 4px; gap: 4px; }
.tabs button { border: 0; background: transparent; padding: 7px 16px; border-radius: 10px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tabs button.on { background: var(--primary-soft); color: var(--primary-ink); }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.segmented button { border: 0; background: var(--surface); padding: 5px 12px; font-size: 12px; cursor: pointer; color: var(--muted); }
.segmented button.on { background: var(--primary-soft); color: var(--primary-ink); }
.preview-bubble { background: var(--surface-2); border-radius: 16px 16px 4px 16px; padding: 12px 14px; white-space: pre-wrap; font-size: 13px; min-height: 44px; word-break: break-word; }

.thread { display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; border-radius: 16px; padding: 10px 14px; font-size: 13px; white-space: normal; word-break: break-word; position: relative; }
.msg .tx { white-space: pre-wrap; }
.msg.in { align-self: flex-start; background: var(--surface-2); border-top-right-radius: 4px; }
.msg.out { align-self: flex-end; background: var(--primary-soft); border-top-left-radius: 4px; }
.msg .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 11px; color: var(--muted); margin-top: 6px; min-height: 28px; white-space: normal; }
.reply-box { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.reply-to { font-size: 12px; color: var(--muted); }
.reply-to:empty { display: none; }
.reply-to .link { border: 0; background: none; padding: 0; color: var(--primary-ink); font: inherit; cursor: pointer; }
.reply-row { display: flex; align-items: flex-end; gap: 10px; }
.reply-row .textarea { flex: 1; min-height: 44px; max-height: 160px; resize: vertical; }
.msg .auto { margin-top: 8px; font-size: 12px; color: var(--text-2); }
.msg .auto span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg-media { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; min-width: 0; }
.msg-file { display: block; width: min(320px, 100%); margin-bottom: 8px; border-radius: 12px; overflow: hidden; }
.msg-file img, .msg-file video { display: block; width: 100%; height: auto; max-height: 360px; object-fit: cover; background: var(--surface-2); }
audio.msg-file { width: min(280px, 100%); height: 40px; }
.msg-act { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.msg-act:hover { background: var(--border); color: var(--text); }
.msg-act.on { color: var(--primary-ink); background: var(--primary-soft); }
.msg-act.loading svg { display: none; }
.chat-page { display: flex; flex-direction: column; gap: 14px; height: calc(100vh - 190px); height: calc(100dvh - 190px); min-height: 440px; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; flex-shrink: 0; }
.chat-head .avatar { width: 44px; height: 44px; font-size: 17px; }
.chat-head .icon-btn { background: var(--surface-2); flex-shrink: 0; }
.chat-body { flex: 1; overflow-y: auto; }
.chat-body .msg { max-width: min(88%, 760px); }
.chat-foot { padding: 14px 18px; flex-shrink: 0; }
.profile-name { font-weight: 800; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; font-size: 12px; color: var(--muted); }
.profile-link { color: inherit; text-decoration: none; }
.profile-link:hover, .profile-link:focus-visible { color: var(--primary); text-decoration: underline; }
.profile-sub .profile-link { display: inline-flex; align-items: center; gap: 4px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.dp { position: absolute; z-index: 60; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 14px; width: 290px; }
.dp .cal-head .title { font-size: 15px; }
.dp .days span { cursor: pointer; padding: 5px 0; font-size: 13px; }
.dp .days span:hover:not(.out) { background: var(--primary-soft); }
.dp .days span.sel { background: var(--primary); color: #fff; }
.dp .days span.inrange { background: var(--primary-soft); color: var(--primary-ink); border-radius: 0; }
.dp .days span.out { visibility: hidden; }
.dp .foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 10px; }
.dp .time { display: flex; gap: 6px; align-items: center; margin-top: 10px; justify-content: center; }
.dp .time input { width: 60px; text-align: center; }
.date-input { position: relative; }
.date-input .input { cursor: pointer; padding-inline-start: 38px; }
.date-input svg { position: absolute; top: 50%; right: 12px; transform: translateY(-50%); width: 18px; height: 18px; color: var(--muted); pointer-events: none; }

.toasts { position: fixed; bottom: 22px; left: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 90; }
.toast { background: var(--surface); box-shadow: var(--shadow-lg); border-radius: 14px; padding: 12px 16px; min-width: 260px; max-width: 420px; display: flex; gap: 10px; align-items: flex-start; border-inline-start: 4px solid var(--primary); animation: pop .2s; font-size: 13px; }
.toast.ok { border-color: var(--success); }
.toast.err { border-color: var(--danger); }
.toast.warn { border-color: var(--warning); }
.popover { position: absolute; z-index: 40; background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); width: 360px; max-height: 460px; overflow: hidden; display: flex; flex-direction: column; }
.popover .list { overflow-y: auto; }
.notif { padding: 12px 16px; border-top: 1px solid var(--border); font-size: 13px; }
.notif.unread { background: var(--primary-soft); }
.notif .t { font-weight: 700; }
.notif .b { color: var(--text-2); font-size: 12px; }
.notif .d { color: var(--muted); font-size: 11px; }
.menu { position: absolute; bottom: 60px; right: 0; left: 0; background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 30; }
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 9px 12px; border-radius: 10px; cursor: pointer; text-align: right; font-size: 13px; }
.menu button:hover { background: var(--surface-2); }
.menu button svg { width: 18px; height: 18px; }
.perm-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.perm-group { border: 1.5px solid var(--border); border-radius: 16px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.perm-group .gt { font-weight: 700; font-size: 13px; }
.qr { background: #fff; border-radius: 16px; padding: 10px; width: 200px; margin: 0 auto; }
.qr svg { width: 100%; height: auto; display: block; }
.secret { font-family: monospace; direction: ltr; text-align: center; background: var(--surface-2); padding: 8px; border-radius: 10px; letter-spacing: 1px; }
.progress-big { height: 12px; background: var(--surface-2); border-radius: 12px; overflow: hidden; }
.progress-big > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--green)); transition: width .4s; }
.bc-text { font-size: 13px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.bot-card > .progress-big { height: 5px; }
.count-box { display: flex; gap: 12px; flex-wrap: wrap; }
.count-box .cb { flex: 1; min-width: 110px; background: var(--surface-2); border-radius: 16px; padding: 12px 14px; }
.count-box .cb b { display: block; font-size: 22px; font-weight: 800; }
.count-box .cb span { font-size: 12px; color: var(--muted); }
.phrase-list { display: flex; flex-wrap: wrap; gap: 10px; }
.phrase { display: inline-flex; align-items: center; gap: 10px; background: var(--surface); border: 1.5px solid var(--border); border-radius: 999px; padding: 6px 8px 6px 14px; }
.phrase .hits { font-size: 11px; color: var(--muted); }
.phrase button { border: 0; background: var(--surface-2); width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
.phrase button svg { width: 14px; height: 14px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 12px; min-height: 16px; }
@keyframes sk { to { background-position: -200% 0; } }

.code-input { letter-spacing: 12px; text-align: center; font-size: 22px; direction: ltr; }

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .progress-cards { grid-template-columns: minmax(0, 1fr); }
  .platform-card .barchart .plot { min-height: var(--plot); }
}
@media (max-width: 900px) {
  .shell, .shell.collapsed { grid-template-columns: minmax(0, 1fr); padding: 0; }
  .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; width: min(284px, 86vw); height: 100%;
    border-radius: 0; padding: 20px 16px 16px; transform: translateX(-100%); transition: transform 0.25s ease;
  }
  [dir="rtl"] .sidebar { border-radius: 0; transform: translateX(100%); }
  .shell.nav-open .sidebar, [dir="rtl"] .shell.nav-open .sidebar { transform: none; }
  .shell.nav-open .scrim { opacity: 1; visibility: visible; }
  .collapse-btn { display: none; }
  .nav-toggle { display: grid; }
  .main { padding: 18px; border-radius: 0; }
  .grid-2, .grid-3, .perm-groups { grid-template-columns: minmax(0, 1fr); }
  .topbar { gap: 12px; margin-bottom: 20px; }
  .page-title h1 { font-size: 22px; }
  .chat-page { height: calc(100vh - 150px); height: calc(100dvh - 150px); }
  .toolbar.one-row { flex-wrap: wrap; }
  .toolbar.one-row .field { flex: 1 1 180px; }
  .msg { max-width: 100%; }
  .heat { min-width: 560px; }
}
@media (max-width: 640px) {
  .shell, .shell.collapsed { padding: 0; }
  .main { padding: 14px 14px 26px; border-radius: 0; }
  .topbar { gap: 10px; margin-bottom: 16px; }
  .topbar > .grow { display: none; }
  .page-title { flex: 1 1 auto; min-width: 0; }
  .page-title h1 { font-size: 19px; }
  .page-title .sub { font-size: 12px; }
  .page-actions { order: 5; flex: 1 1 100%; flex-wrap: wrap; }
  .page-actions .btn { flex: 1 1 auto; }
  .icon-btn { width: 38px; height: 38px; }
  .card, .calendar { padding: 16px; border-radius: 18px; }
  .section-head { margin: 20px 2px 12px; }
  .section-head h2 { font-size: 19px; }
  .card h3, .section-title { font-size: 16px; }
  .stats { gap: 12px; }
  .stat { padding: 12px 13px 13px; }
  .stat-top { font-size: 11.5px; gap: 5px; }
  .stat .val { font-size: 24px; }
  .stat .note { font-size: 11px; }
  .toolbar .field, .toolbar.one-row .field { flex: 1 1 140px; min-width: 0; }
  .toolbar .field.wide, .toolbar.one-row .field.wide { flex: 1 1 100%; }
  .toolbar .btn { flex: 1 1 auto; }
  .table-scroll > .table { min-width: 560px; }
  .table th { padding: 11px 12px; }
  .table td { padding: 11px 12px; font-size: 12.5px; }
  .table .excerpt { max-width: 200px; }
  .pager { flex-wrap: wrap; gap: 8px; padding: 12px; }
  .bot-card { padding: 16px; }
  .overlay { padding: 0; place-items: end stretch; }
  .modal, .modal.lg, .modal.sm { width: 100%; max-height: 92dvh; border-radius: 24px 24px 0 0; animation: sheet 0.22s ease; }
  .modal-head { padding: 18px 18px 6px; }
  .modal-body { padding: 10px 18px; }
  .modal-foot { padding: 14px 18px 20px; flex-wrap: wrap; }
  .modal-foot .btn { flex: 1 1 auto; }
  .steps { gap: 6px; flex-wrap: nowrap; }
  .steps .step { flex: 1 1 0; }
  .step { flex-direction: column; text-align: center; gap: 4px; padding: 8px 6px; font-size: 11px; }
  .popover, .dp {
    position: fixed; width: auto; max-height: 72dvh;
    inset-inline: 12px !important; inset-block-start: auto !important; inset-block-end: 12px;
  }
  .toasts { inset-inline: 12px; bottom: 12px; }
  .toast { min-width: 0; max-width: none; }
  .chat-page { height: calc(100vh - 128px); height: calc(100dvh - 128px); min-height: 320px; }
  .chat-head, .chat-foot { padding: 12px 14px; }
  .chat-head .avatar { width: 38px; height: 38px; font-size: 15px; }
  .count-box .cb { min-width: 0; }
  .qr { width: 170px; }
}
@media (max-width: 420px) {
  .count-box { flex-direction: column; }
  .tabs, .segmented { display: flex; width: 100%; }
  .tabs button, .segmented button { flex: 1; }
  .phrase { flex: 1 1 100%; justify-content: space-between; }
}
@media (max-width: 360px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
}
@keyframes sheet { from { transform: translateY(100%); } }

:where(a, button, [role="button"], summary, .step.clickable):focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

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