:root {
      --red: #ff4548;
      --blue: #3869ee;
      --amber: #ffb715;
      --ink: #080808;
      --muted: #5f6368;
      --line: #111;
      --soft: #f6f6f6;
      --card: #fff;
      --shadow: 0 10px 24px rgba(0, 0, 0, .16);
      --radius: 18px;
    }
    * { box-sizing: border-box; }
    body {
      margin: 0;
      min-height: 100vh;
      color: var(--ink);
      background: #fff;
      font-family: Inter, Manrope, "Segoe UI", Arial, sans-serif;
      letter-spacing: 0;
    }
    body.locked { overflow: hidden; }
    button, input { font: inherit; }
    .shell {
      width: min(1242px, calc(100vw - 48px));
      margin: 0 auto;
    }
    .topbar {
      height: 70px;
      display: flex;
      align-items: center;
      background: #fff;
      box-shadow: 0 9px 22px rgba(0, 0, 0, .16);
    }
    .topbar .shell {
      display: grid;
      grid-template-columns: 260px 1fr 90px;
      align-items: center;
    }
    .logo-img {
      display: block;
      width: 130px;
      height: auto;
    }
    .nav {
      justify-self: center;
      display: flex;
      gap: 48px;
      align-items: center;
      font-size: 17px;
    }
    .nav button, .nav a {
      border: 0;
      background: transparent;
      cursor: pointer;
      padding: 7px 0;
      color: #151515;
      border-bottom: 3px solid transparent;
      text-decoration: none;
    }
    .nav button.active, .nav a.active { border-bottom-color: var(--red); }
    .user-icon {
      width: 28px;
      height: 28px;
      color: #000;
    }
    .user-menu { position: relative; justify-self: end; }
    .user-menu-button {
      border: 0;
      background: transparent;
      padding: 4px;
      cursor: pointer;
      display: grid;
      place-items: center;
    }
    .user-dropdown {
      position: absolute;
      right: 0;
      top: 42px;
      z-index: 30;
      width: 260px;
      display: none;
      padding: 14px;
      border: 1px solid #111;
      border-radius: 10px;
      background: #fff;
      box-shadow: var(--shadow);
    }
    .user-dropdown.open { display: grid; gap: 8px; }
    .user-card-name { font-weight: 900; font-size: 15px; }
    .user-card-meta { color: var(--muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
    .user-dropdown button, .user-dropdown a {
      border: 0;
      background: var(--soft);
      border-radius: 8px;
      padding: 9px 10px;
      text-align: left;
      cursor: pointer;
      color: #111;
      text-decoration: none;
    }
    main { min-height: calc(100vh - 132px); }
    .page { display: none; padding: 64px 0 42px; }
    .page.active { display: block; }
    .dashboard-grid {
      display: grid;
      grid-template-columns: minmax(0, 1fr) 376px;
      gap: 20px;
      align-items: stretch;
    }
    .card {
      background: var(--card);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
    }
    .chart-card {
      min-width: 0;
      min-height: 565px;
      padding: 20px 34px 24px;
      overflow: hidden;
    }
    .chart-title {
      margin: 0 0 20px;
      font-size: 18px;
      font-weight: 800;
    }
    .bar-chart {
      width: 100%;
      max-width: 100%;
      height: 406px;
      display: grid;
      grid-template-columns: repeat(var(--count), 144px);
      gap: 6px;
      align-items: end;
      padding: 0 18px 48px;
      margin-bottom: 10px;
      border-bottom: 1px solid var(--line);
      overflow-x: auto;
      overflow-y: hidden;
      scrollbar-gutter: stable;
    }
    .bar-group {
      display: grid;
      grid-template-columns: repeat(3, 42px);
      justify-content: center;
      gap: 0;
      align-items: end;
      height: 100%;
      position: relative;
    }
    .bar-wrap {
      height: 100%;
      display: flex;
      flex-direction: column;
      justify-content: flex-end;
      align-items: center;
      min-width: 42px;
    }
    .bar-val {
      font-size: 11px;
      white-space: nowrap;
      margin-bottom: 8px;
      color: #171717;
    }
    .bar {
      width: 34px;
      min-height: 2px;
    }
    .bar.plan { background: var(--red); }
    .bar.done { background: var(--blue); }
    .bar.err { background: var(--amber); }
    .bar-label {
      position: absolute;
      left: 0;
      right: 0;
      bottom: -38px;
      text-align: center;
      font-size: 12px;
      min-height: 30px;
      font-weight: 800;
      overflow-wrap: anywhere;
    }
    .legend {
      display: flex;
      gap: 72px;
      align-items: center;
      padding: 10px 18px 0;
      font-size: 12px;
    }
    .legend-item { display: flex; align-items: center; gap: 10px; }
    .legend-pill {
      width: 63px;
      height: 19px;
      border-radius: 10px;
      display: inline-block;
    }
    .side-stack { display: grid; gap: 18px; }
    .plan-card { padding: 28px 22px; align-self: stretch; }
    .donut-wrap {
      position: relative;
      width: 100%;
      min-height: 360px;
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: visible;
    }
    .donut {
      width: 256px;
      height: 256px;
      flex-shrink: 0;
      border-radius: 50%;
      background: conic-gradient(var(--blue) 0 var(--done-deg), var(--red) var(--done-deg) 360deg);
      position: relative;
    }
    .donut::after {
      content: "";
      position: absolute;
      inset: 50px;
      border-radius: 50%;
      background: #fff;
      z-index: 1;
    }
    .donut-center {
      position: absolute;
      text-align: center;
      z-index: 2;
      line-height: 1.08;
      pointer-events: none;
    }
    .donut-center strong { display: block; font-size: 38px; font-weight: 900; }
    .donut-center span { display: block; margin-top: 6px; font-size: 18px; }

    /* Labels positioned relative to .donut via absolute on .donut itself */
    .donut-note {
      position: absolute;
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 18px;
      font-weight: 700;
      white-space: nowrap;
      color: var(--ink);
      z-index: 3;
    }
    .donut-note::before {
      content: "";
      width: 46px;
      height: 2px;
      background: #111;
      display: block;
      flex-shrink: 0;
    }
    /* Labels positioned within the card — above/below ring, aligned to edges */
    .donut-note {
      position: absolute;
      display: flex;
      align-items: center;
      gap: 10px;
      font-size: 17px;
      font-weight: 700;
      white-space: nowrap;
      color: var(--ink);
      z-index: 3;
    }
    .donut-note::before {
      content: "";
      width: 46px;
      height: 2px;
      background: #111;
      display: block;
      flex-shrink: 0;
    }
    /* Выполнено (синий) — у верхнего края кольца справа.
       50% = центр wrap = центр доната. -128px = верхний край доната (радиус). +16px = небольшой отступ вниз. */
    .donut-note.done {
      top: calc(50% - 112px);
      right: 0;
      left: auto;
    }
    /* Невыполнено (красный) — у нижнего края кольца слева. */
    .donut-note.rest {
      flex-direction: row-reverse;
      bottom: calc(50% - 112px);
      left: 0;
      right: auto;
    }
    .donut-legend {
      display: flex;
      justify-content: center;
      gap: 14px;
      margin-top: 0;
      font-size: 12px;
    }
    .dot { width: 15px; height: 15px; border-radius: 50%; display: inline-block; }
    .divider { border-top: 1px solid #111; margin: 38px 0 42px; }
    .city-block { text-align: center; }
    .city-block h3 { margin: 0 0 5px; font-size: 38px; line-height: 1; }
    .city-block p { margin: 0 0 10px; font-size: 17px; }
    .city-block strong { font-size: 20px; }
    .total-mini { margin-top: 0; align-self: end; }
    .total-mini h3 { margin: 0 0 12px; font-size: 16px; text-align: left; }
    .total-number {
      display: grid;
      place-items: center;
      height: 151px;
      font-size: 52px;
      font-weight: 900;
    }
    .below-grid {
      display: grid;
      grid-template-columns: 1fr 376px;
      gap: 20px;
      margin-top: 22px;
      align-items: start;
    }
    .plain-panel h3 {
      margin: 0 0 12px;
      font-size: 16px;
    }
    table {
      width: 100%;
      border-collapse: collapse;
      font-size: 12px;
    }
    th, td {
      border: 1px solid #111;
      padding: 7px 8px;
      vertical-align: middle;
    }
    .simple-table th, .simple-table td { border-left: 0; border-right: 0; }
    .simple-table th.num, .simple-table td.num { text-align: center; }
    th { font-weight: 800; text-align: center; }
    td.num, th.num { text-align: right; white-space: nowrap; }
    .register-wrap {
      display: grid;
      grid-template-columns: 1fr 260px;
      gap: 20px;
      align-items: stretch;
    }
    .period-toolbar {
      display: flex;
      align-items: end;
      gap: 16px;
      margin: 0 0 18px;
      flex-wrap: wrap;
    }
    .period-toolbar label {
      display: grid;
      gap: 6px;
      font-size: 13px;
      font-weight: 800;
    }
    .period-toolbar select {
      min-width: 210px;
      height: 36px;
      border: 1px solid #111;
      border-radius: 8px;
      background: #fff;
      padding: 0 10px;
      font: inherit;
    }
    .compare-summary {
      min-height: 36px;
      display: flex;
      align-items: center;
      padding: 8px 12px;
      border-radius: 8px;
      background: var(--soft);
      font-size: 13px;
      color: var(--muted);
    }
    .registry-heading {
      margin: 0 0 18px;
      font-size: clamp(18px, 2vw, 24px);
      line-height: 1.15;
      font-weight: 900;
      max-width: 100%;
    }
    .export-actions {
      display: flex;
      justify-content: flex-end;
      gap: 10px;
      margin: 0 0 12px;
    }
    .registry-export-area {
      background: #fff;
      padding: 0;
      overflow: visible;
    }
    .registry-table-card {
      border-radius: 16px;
      overflow-x: auto;
    }
    .registry-table {
      background: #fff;
      font-size: 14px;
      table-layout: fixed;
    }
    .registry-table th {
      background: #d6d6d6;
      font-size: 15px;
      line-height: 1.05;
    }
    .registry-table td { padding: 4px 6px; }
    .registry-table .group td {
      background: #aaa;
      font-weight: 900;
      text-align: left;
      font-size: 16px;
    }
    .registry-table .total td {
      background: #777;
      color: #fff;
      font-weight: 900;
    }
    .registry-table .sum-cell,
    .registry-table .fail-cell,
    .registry-table .plan-result-cell {
      background: #d90000;
      color: #fff;
      font-weight: 900;
    }
    .registry-table .status-ok,
    .registry-table .plan-cell.status-ok,
    .registry-table .sum-cell.status-ok,
    .registry-table .fail-cell.status-ok { background: #34a853; color: #fff; }
    .registry-table .status-fail,
    .registry-table .plan-cell.status-fail,
    .registry-table .sum-cell.status-fail,
    .registry-table .fail-cell.status-fail { background: #cc0000; color: #fff; }
    .registry-table .err-cell { background: #e89598; font-weight: 700; text-align: center; }
    .registry-table .plan-cell { background: #6da0e7; font-weight: 900; text-align: center; }
    .register-side {
      padding: 26px 22px;
      align-self: stretch;
      box-sizing: border-box;
    }
    .compact-donut {
      width: 192px;
      height: 192px;
    }
    .compact-donut::after { inset: 38px; }
    .compact-donut + .donut-center strong { font-size: 27px; }
    .compact-donut + .donut-center span { font-size: 14px; }
    .register-side .donut-wrap { min-height: 260px; overflow: visible; }
    .register-side .donut-note { font-size: 13px; }
    .register-side .donut-note::before { width: 32px; }
    .register-side .donut-note.done { top: calc(50% - 84px); right: 0; left: auto; bottom: auto; }
    .register-side .donut-note.rest { bottom: calc(50% - 84px); left: 0; right: auto; top: auto; }
    .admin-title {
      font-size: 39px;
      margin: 0 0 54px;
      font-weight: 900;
    }
    .admin-subtitle {
      margin: 28px 0 12px;
      font-size: 20px;
    }
    .admin-auth {
      display: grid;
      grid-template-columns: repeat(2, minmax(260px, 360px));
      gap: 18px;
      align-items: start;
      margin-bottom: 24px;
    }
    .auth-card {
      display: grid;
      gap: 12px;
      padding: 18px;
      border: 1px solid #111;
      border-radius: 10px;
      background: #fff;
    }
    .auth-card h2 {
      margin: 0 0 6px;
      font-size: 20px;
    }
    .auth-card input, .auth-card select {
      height: 38px;
      border: 1px solid #111;
      border-radius: 8px;
      padding: 0 10px;
    }
    .admin-user-row {
      display: flex;
      align-items: center;
      gap: 14px;
      margin-bottom: 24px;
    }
    .auth-overlay, .profile-modal {
      position: fixed;
      inset: 0;
      z-index: 100;
      display: none;
      place-items: center;
      padding: 20px;
      background: rgba(255, 255, 255, .94);
    }
    .auth-overlay.active, .profile-modal.active { display: grid; }
    .auth-dialog, .profile-card {
      width: min(480px, 100%);
      display: grid;
      gap: 14px;
      padding: 26px;
      border: 1px solid #111;
      border-radius: 14px;
      background: #fff;
      box-shadow: var(--shadow);
    }
    .auth-logo { width: 132px; height: auto; }
    .auth-tabs { display: flex; gap: 10px; }
    .auth-tabs button {
      flex: 1;
      height: 38px;
      border: 1px solid #111;
      border-radius: 8px;
      background: #fff;
      cursor: pointer;
      font-weight: 800;
    }
    .auth-tabs button.active { background: #111; color: #fff; }
    .auth-panel { display: none; gap: 10px; }
    .auth-panel.active { display: grid; }
    .auth-panel input, .auth-panel select, .profile-card input {
      height: 40px;
      border: 1px solid #111;
      border-radius: 8px;
      padding: 0 10px;
    }
    .captcha-label { display: grid; gap: 6px; font-size: 13px; font-weight: 800; }
    .profile-card label { display: grid; gap: 6px; font-size: 13px; font-weight: 800; }
    .profile-actions { display: flex; gap: 12px; flex-wrap: wrap; }
    .auth-message { min-height: 18px; color: #cc0000; font-size: 13px; }
    .period-picker-row {
      width: min(760px, 100%);
      display: grid;
      grid-template-columns: 250px 230px 1fr;
      gap: 22px;
      align-items: center;
      font-size: 17px;
      margin-bottom: 26px;
    }
    .period-picker-row input[type="month"] {
      height: 38px;
      border: 1px solid #111;
      border-radius: 8px;
      padding: 0 10px;
      font-family: inherit;
      font-size: 14px;
      background: #fff;
      cursor: pointer;
    }
    .upload-grid {
      width: min(760px, 100%);
      display: grid;
      gap: 26px;
    }
    .upload-row {
      display: grid;
      grid-template-columns: 250px 230px 1fr;
      gap: 22px;
      align-items: center;
      font-size: 17px;
    }
    .file-control {
      position: relative;
      height: 22px;
      border: 1px solid #111;
      border-radius: 12px;
      cursor: pointer;
      background: #fff;
      overflow: hidden;
    }
    .file-control input {
      position: absolute;
      inset: 0;
      opacity: 0;
      cursor: pointer;
    }
    .file-control::after {
      content: "";
      position: absolute;
      right: 6px;
      top: 50%;
      width: 13px;
      height: 13px;
      transform: translateY(-50%);
      border-radius: 50%;
      background: #000;
    }
    .file-control::before {
      content: "";
      position: absolute;
      right: 10px;
      top: 50%;
      z-index: 1;
      width: 5px;
      height: 5px;
      border-left: 1px solid #fff;
      border-bottom: 1px solid #fff;
      transform: translateY(-62%) rotate(-45deg);
    }
    .file-name {
      font-size: 12px;
      color: var(--muted);
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
    .admin-actions {
      display: flex;
      gap: 14px;
      margin-top: 36px;
      flex-wrap: wrap;
    }
    .primary-btn, .ghost-btn {
      height: 40px;
      border-radius: 10px;
      padding: 0 18px;
      cursor: pointer;
      border: 1px solid #111;
      font-weight: 800;
      background: #fff;
    }
    .primary-btn { background: #111; color: #fff; }
    .mini-btn {
      height: 30px;
      padding: 0 10px;
      margin-left: 12px;
    }
    .status-panel {
      margin-top: 26px;
      width: min(760px, 100%);
      display: grid;
      gap: 8px;
      font-size: 13px;
      color: var(--muted);
    }
    .status-line {
      background: var(--soft);
      border-radius: 8px;
      padding: 9px 12px;
    }
    .slice-grid {
      display: grid;
      grid-template-columns: 1fr 340px;
      gap: 18px;
      align-items: start;
    }
    .tabs {
      display: flex;
      gap: 0;
      margin-bottom: 18px;
      border-bottom: 1px solid #111;
    }
    .tab {
      border: 0;
      background: transparent;
      padding: 10px 20px;
      border-bottom: 4px solid transparent;
      cursor: pointer;
      font-weight: 800;
    }
    .tab.active { border-bottom-color: var(--red); }
    .stat-cards {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 12px;
      margin-bottom: 18px;
    }
    .stat-card {
      border-radius: 12px;
      background: var(--soft);
      padding: 15px;
      min-height: 88px;
    }
    .stat-card span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
    .stat-card strong { font-size: 25px; }
    .error-bars { display: grid; gap: 12px; }
    .error-row {
      display: grid;
      grid-template-columns: minmax(170px, 270px) 1fr 54px;
      align-items: center;
      gap: 12px;
      font-size: 13px;
    }
    .error-track { height: 20px; background: #eee; border-radius: 5px; overflow: hidden; }
    .error-fill { height: 100%; background: var(--red); }
    .footer {
      border-top: 1px solid #111;
      padding: 18px 0 20px;
      display: flex;
      justify-content: space-between;
      gap: 20px;
      font-size: 12px;
    }
    .empty {
      padding: 34px;
      background: var(--soft);
      border-radius: 14px;
      color: var(--muted);
      text-align: center;
    }

    /* ── Таблица пользователей (панель администратора) ── */
    .users-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 13px;
    }
    .users-table th {
      text-align: left;
      padding: 10px 12px;
      background: var(--soft);
      font-weight: 700;
      white-space: nowrap;
      border-bottom: 2px solid #e0e0e0;
    }
    .users-table td {
      padding: 10px 12px;
      border-bottom: 1px solid #f0f0f0;
      vertical-align: middle;
    }
    .users-table tr:last-child td { border-bottom: none; }
    .users-table tr:hover td { background: #fafafa; }
    .user-actions-cell {
      white-space: nowrap;
      display: flex;
      gap: 6px;
      align-items: center;
    }
    .user-status {
      display: inline-block;
      padding: 3px 10px;
      border-radius: 20px;
      font-size: 11px;
      font-weight: 700;
      letter-spacing: .3px;
    }
    .user-status.approved { background: #e6f4ea; color: #1e7e34; }
    .user-status.pending  { background: #fff3cd; color: #856404; }
    .danger-btn { border-color: #ff4548 !important; color: #ff4548 !important; }
    .danger-btn:hover { background: #ff4548 !important; color: #fff !important; }
    #pendingUsers { width: 100%; overflow-x: auto; }


    /* ── Общий свод ── */
    .svod-toolbar {
      display: flex;
      align-items: end;
      justify-content: space-between;
      gap: 16px;
      margin: 0 0 18px;
      flex-wrap: wrap;
    }
    .svod-toolbar label {
      display: grid;
      gap: 6px;
      font-size: 13px;
      font-weight: 700;
      color: var(--muted);
    }
    .svod-toolbar select {
      padding: 10px 14px;
      border-radius: 10px;
      border: 1.5px solid #e0e0e0;
      font-size: 14px;
      font-family: inherit;
      background: #fff;
      min-width: 140px;
    }
    .svod-export-actions {
      display: flex;
      gap: 10px;
    }
    .svod-table-card { overflow-x: auto; }
    .svod-table {
      table-layout: auto;
      font-size: 13px;
      white-space: nowrap;
    }
    .svod-table th, .svod-table td {
      padding: 8px 12px;
      text-align: center;
    }
    .svod-table td.svod-dept-name {
      text-align: left;
      white-space: normal;
      min-width: 220px;
    }
    .svod-month-header {
      color: #fff;
      font-weight: 800;
      font-size: 14px;
      padding: 10px 12px;
    }
    .svod-sub-header {
      background: var(--soft);
      font-weight: 700;
      font-size: 12px;
    }
    .svod-group-row td {
      background: #8e8e8e;
      color: #fff;
      font-weight: 800;
      text-align: left;
      padding: 8px 12px;
    }
    .svod-total-row td {
      background: #6e6e6e;
      color: #fff;
      font-weight: 800;
    }
    .svod-grand-total-row td {
      background: #444;
      color: #fff;
      font-weight: 900;
      font-size: 14px;
    }
    .svod-plan-cell {
      background: #4285f4;
      color: #fff;
      font-weight: 800;
      vertical-align: middle;
    }
    .svod-empty-cell { color: #bbb; }
    .svod-no-data {
      padding: 40px;
      text-align: center;
      color: var(--muted);
      font-size: 15px;
    }
    .svod-summary-card {
      margin-top: 28px;
      max-width: 460px;
      background: var(--card);
      border-radius: var(--radius);
      box-shadow: var(--shadow);
      padding: 22px 26px;
    }
    .svod-summary-card h3 {
      margin: 0 0 14px;
      font-size: 18px;
      font-weight: 800;
    }
    .svod-summary-table {
      width: 100%;
      border-collapse: collapse;
      font-size: 14px;
    }
    .svod-summary-table th {
      text-align: left;
      padding: 8px 10px;
      background: var(--soft);
      font-weight: 700;
    }
    .svod-summary-table td {
      padding: 10px 10px;
      border-top: 1px solid #f0f0f0;
      font-weight: 800;
    }

    @media (max-width: 980px) {
      .shell { width: min(100% - 24px, 760px); }
      .topbar { height: auto; padding: 12px 0; }
      .topbar .shell { grid-template-columns: 1fr auto; gap: 12px; }
      .nav { grid-column: 1 / -1; justify-self: start; gap: 20px; overflow-x: auto; max-width: 100%; }
      .dashboard-grid, .below-grid, .register-wrap, .slice-grid { grid-template-columns: 1fr; }
      .chart-card { padding: 18px; }
      .bar-chart { overflow-x: auto; grid-template-columns: repeat(var(--count), 136px); gap: 6px; }
      .legend { gap: 16px; flex-wrap: wrap; }
      .stat-cards { grid-template-columns: repeat(2, 1fr); }
      .admin-auth { grid-template-columns: 1fr; }
      .upload-row { grid-template-columns: 1fr; gap: 8px; }
      .period-picker-row { grid-template-columns: 1fr; gap: 8px; }
      .registry-table-card { overflow-x: auto; }
      .registry-table { min-width: 880px; }
      .footer { flex-direction: column; }
    }
