:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --surface-soft: #eef4f1;
  --ink: #16201f;
  --muted: #66736f;
  --line: #d9e3df;
  --green: #1f8a70;
  --green-dark: #156653;
  --blue: #2d6cdf;
  --amber: #b7791f;
  --red: #bd3d32;
  --shadow: 0 18px 55px rgba(22, 32, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto minmax(180px, 1fr) auto auto;
  gap: 18px;
  align-items: center;
  padding: 14px 24px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.topbar-user {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  max-width: 280px;
}

.topbar-user > span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.topbar-user select {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  font-weight: 650;
  color: var(--ink);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
}

.brand-title {
  font-size: 20px;
  font-weight: 820;
  color: #cf2727;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.mode-switch {
  display: grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.mode-button,
.ghost-button,
.primary-button,
.danger-button,
.icon-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 14px;
  font-weight: 650;
}

.mode-button {
  background: transparent;
  color: var(--muted);
}

.mode-button.is-active {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
  box-shadow: 0 6px 18px rgba(22, 32, 31, 0.08);
}

.primary-button {
  color: #fff;
  background: var(--green);
  border-color: var(--green);
}

.primary-button:hover {
  background: var(--green-dark);
}

.ghost-button {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.danger-button {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}

.icon-button {
  width: 38px;
  padding: 0;
  background: var(--surface);
  border-color: var(--line);
  font-size: 22px;
  line-height: 1;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.main-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 22px;
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 22px 24px 32px;
}

.sidebar,
.workspace {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 86px;
  align-self: start;
  display: grid;
  gap: 16px;
}

.area-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.sidebar-heading {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 2px 10px;
}

.area-list {
  display: grid;
  gap: 6px;
}

.area-item {
  display: grid;
  gap: 2px;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.area-item:hover {
  background: var(--surface-soft);
}

.area-item.is-active {
  background: rgba(31, 138, 112, 0.12);
  border-color: var(--green);
  box-shadow: inset 3px 0 0 var(--green);
}

.area-item-name {
  font-weight: 650;
}

.area-item-sub {
  font-size: 12px;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.field input,
.field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  color: var(--ink);
}

.quick-stats,
.notification-list,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.quick-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  overflow: hidden;
  background: var(--line);
}

.stat {
  display: grid;
  gap: 3px;
  padding: 14px;
  background: var(--surface);
}

.stat strong {
  font-size: 22px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.notification-list {
  max-height: calc(100vh - 320px);
  overflow: auto;
  padding: 8px;
}

.notification {
  padding: 10px;
  border-bottom: 1px solid var(--line);
}

.notification:last-child {
  border-bottom: 0;
}

.notification p {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
}

.notification time {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.workspace {
  display: grid;
  gap: 12px;
}

.section-heading {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-heading h1,
.section-heading h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}

.section-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.panel {
  padding: 16px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.three-grid {
  display: grid;
  grid-template-columns: minmax(620px, 1fr) minmax(280px, 360px);
  gap: 18px;
  align-items: start;
}

.manager-side {
  position: sticky;
  top: 86px;
  align-self: start;
  display: grid;
  gap: 18px;
  max-height: calc(100vh - 100px);
  overflow: auto;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
}

.toolbar .field {
  min-width: 180px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 12px;
  font-weight: 720;
  white-space: nowrap;
}

.pill.green {
  background: #dff3ec;
  color: #12634f;
}

.pill.amber {
  background: #fff1d6;
  color: #81520f;
}

.pill.red {
  background: #ffe2df;
  color: #9c2c23;
}

.stack {
  display: grid;
  gap: 12px;
}

.checkin-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.checkin-qr {
  display: grid;
  justify-items: center;
  gap: 8px;
}

.checkin-qr-canvas {
  /* Всегда виден сам QR; при нехватке места просто уменьшается. */
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1;
  height: auto;
  border: 10px solid #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: #fff;
  image-rendering: pixelated;
}

.scanner {
  display: grid;
  gap: 10px;
}

.scanner video {
  display: none;
  width: 100%;
  max-height: 260px;
  border-radius: 8px;
  background: #0d1514;
}

.scanner.is-running video {
  display: block;
}

.manager-controls {
  display: grid;
  gap: 12px;
}

.workplace-creator {
  display: grid;
  grid-template-columns: minmax(130px, 1fr) minmax(130px, 1fr) minmax(110px, 0.8fr) auto;
  gap: 10px;
  align-items: end;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.schedule-rule-editor {
  display: grid;
  grid-template-columns: repeat(4, minmax(140px, 1fr));
  gap: 10px;
  align-items: end;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.schedule-rule-editor [data-rule-field][hidden] {
  display: none;
}

.schedule-rule-editor .weekday-field {
  grid-column: 1 / -1;
}

.weekday-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.weekday-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.weekday-option input {
  width: auto;
  min-height: 0;
  margin: 0;
}

.rules-table-wrap,
.preview-table-wrap {
  margin-top: 12px;
}

.rules-table,
.preview-table {
  min-width: 760px;
}

.rule-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.rule-num {
  width: 54px;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 6px;
  text-align: center;
  font: inherit;
}

.rule-actions .icon-button {
  width: 34px;
  min-height: 34px;
  font-size: 16px;
}

.rules-reorder {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 10px;
}

.rules-reorder-hint {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin-right: 2px;
}

.rules-reorder .icon-button {
  width: 38px;
  min-height: 38px;
  font-size: 18px;
}

.rules-reorder .icon-button[disabled] {
  opacity: 0.3;
  cursor: default;
}

.rules-table tbody tr.rule-row {
  cursor: pointer;
}

.rules-table tbody tr.rule-row:hover {
  background: var(--surface-soft);
}

.rules-table tbody tr.is-selected {
  background: rgba(31, 138, 112, 0.12);
  box-shadow: inset 3px 0 0 var(--green);
}

.preview-table tbody tr.preview-row {
  cursor: pointer;
}

.preview-table tbody tr.preview-row:hover {
  background: var(--surface-soft);
}

.preview-table tbody tr.preview-row.is-selected {
  background: rgba(31, 138, 112, 0.12);
  box-shadow: inset 3px 0 0 var(--green);
}

.date-employees {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.date-employee {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.date-employee-name {
  font-weight: 600;
}

.admin-note {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}

.admin-add {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  align-items: end;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.admin-add .primary-button {
  grid-column: 1 / -1;
}

.admin-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}

.admin-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-item-name {
  display: block;
  font-weight: 650;
}

.admin-item-sub {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.admin-edit-item {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-edit-actions {
  display: flex;
  gap: 8px;
  align-items: end;
}

.admin-emp-item {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-areas-field {
  grid-column: 1 / -1;
}

.area-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.area-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.area-check input {
  width: auto;
  min-height: 0;
  margin: 0;
}

@media (max-width: 1080px) {
  .admin-grid {
    grid-template-columns: 1fr;
  }
}

.admin-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.emp-card {
  display: grid;
  gap: 4px;
  justify-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.emp-card-name {
  font-size: 16px;
  font-weight: 700;
}

.emp-card-sub {
  font-size: 12px;
  color: var(--muted);
}

.schedule-preview {
  margin-top: 18px;
}

/* Компактная шапка календаря укомплектованности */
.mgr-calendar-section {
  margin-top: 8px;
}

.mgr-cal-head {
  align-items: flex-start;
  margin-bottom: 6px;
}

.mgr-cal-head h2 {
  font-size: 16px;
}

.mgr-cal-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
}

.mgr-cal-sub {
  font-size: 11px;
  color: var(--muted);
}

.mgr-cal-head .calendar-legend {
  margin: 0;
  font-size: 11px;
}

.schedule-preview .section-heading {
  gap: 12px;
}

.preview-table .is-muted-row {
  color: #7c8884;
  background: #f7faf9;
}

.capacity-control {
  display: grid;
  grid-template-columns: 82px auto;
  gap: 8px;
  align-items: center;
}

.capacity-control input {
  min-height: 36px;
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 64px;
  gap: 12px;
  align-items: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--green);
}

.monitor {
  min-height: calc(100vh - 150px);
  display: grid;
  grid-template-columns: minmax(280px, 420px) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}

.qr-stage {
  display: grid;
  justify-items: center;
  gap: 16px;
}

#qrCanvas {
  width: min(76vw, 360px);
  aspect-ratio: 1;
  border: 14px solid #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  background: #fff;
}

.qr-code {
  font-size: 34px;
  font-weight: 780;
  letter-spacing: 0;
}

.monitor-board {
  display: grid;
  gap: 12px;
}

.shift-strip {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.muted {
  color: var(--muted);
}

.calendar-heading {
  align-items: flex-start;
}

.calendar-nav {
  display: grid;
  grid-template-columns: 38px minmax(150px, auto) 38px;
  gap: 8px;
  align-items: center;
}

.calendar-nav strong {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  text-transform: capitalize;
  white-space: nowrap;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.calendar-legend span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-dot.available {
  background: #cdeede;
  border: 1px solid var(--green);
}

.legend-dot.mine {
  background: var(--green);
}

.legend-dot.unavailable {
  background: #d2d9d6;
}

.calendar-scroll {
  overflow-x: auto;
  padding-bottom: 2px;
}

.calendar-board {
  min-width: 760px;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(104px, 1fr));
}

.calendar-weekdays {
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  overflow: hidden;
  background: var(--surface-soft);
}

.calendar-weekdays div {
  padding: 3px 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 760;
  text-align: center;
  border-right: 1px solid var(--line);
}

.calendar-weekdays div:last-child {
  border-right: 0;
}

.calendar-grid {
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
}

.calendar-day {
  min-height: 46px;
  display: grid;
  grid-template-rows: auto minmax(34px, 1fr);
  align-content: start;
  gap: 1px;
  padding: 2px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.calendar-day.is-outside {
  background: #f8faf9;
  color: #9aa6a2;
}

.calendar-day.is-today {
  box-shadow: inset 0 0 0 2px rgba(31, 138, 112, 0.28);
}

.calendar-date {
  min-height: 22px;
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
}

.calendar-date strong {
  font-size: 12px;
}

.calendar-date span {
  color: var(--green-dark);
  font-size: 11px;
  font-weight: 760;
}

.calendar-shifts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-content: start;
  min-height: 26px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 140ms ease, box-shadow 140ms ease;
}

.calendar-shifts:hover {
  background: rgba(31, 138, 112, 0.05);
  box-shadow: inset 0 0 0 1px rgba(31, 138, 112, 0.16);
}

.calendar-shifts.is-empty {
  align-items: center;
}

.calendar-shifts .calendar-shift {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
}

.calendar-slot-add {
  flex: 1 1 0;
  min-width: 0;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.calendar-slot-add:hover {
  border-color: var(--green);
  color: var(--green);
}

.calendar-add {
  font-weight: 700;
  font-size: 15px;
}

.calendar-slot-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.calendar-slot-empty {
  flex: 1 1 0;
  min-width: 0;
}

.mgr-shift {
  flex: 1 1 0;
  min-width: 0;
  min-height: 34px;
  display: grid;
  gap: 1px;
  align-content: center;
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: default;
  font: inherit;
  text-align: left;
}

.mgr-shift.is-editable {
  cursor: pointer;
}

.mgr-shift.is-editable:hover {
  box-shadow: 0 0 0 2px rgba(31, 138, 112, 0.45);
}

.mgr-shift-top {
  display: flex;
  justify-content: space-between;
  gap: 4px;
  font-size: 10px;
}

.mgr-shift-top em {
  font-style: normal;
  font-weight: 800;
}

.mgr-shift-name {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.85;
}

.mgr-shift.mgr-ok {
  background: #bdeed4;
  border-color: var(--green);
  color: var(--green-dark);
}

.mgr-shift.mgr-low {
  background: #ffe08a;
  border-color: #d99a00;
  color: #7a5600;
}

.mgr-shift.mgr-none {
  background: #ffb4ab;
  border-color: var(--red);
  color: #8f231a;
}

.legend-dot.mgr-ok {
  background: var(--green);
}

.legend-dot.mgr-low {
  background: #f0b429;
}

.legend-dot.mgr-none {
  background: var(--red);
}

/* Кнопки управления в левой колонке руководителя */
.mgr-actions {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.mgr-actions .ghost-button,
.mgr-actions .primary-button {
  width: 100%;
}

/* Компактные строки таблицы правил и формы */
.rules-table th,
.rules-table td {
  padding: 6px 12px;
}

.schedule-rule-editor {
  padding: 8px;
  gap: 8px;
}

.schedule-rule-editor .field input,
.schedule-rule-editor .field select {
  min-height: 32px;
}

.schedule-rule-editor .primary-button {
  min-height: 32px;
}

/* Форма правил слева, таблица справа, оба компактные */
.rules-split {
  display: grid;
  grid-template-columns: minmax(240px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 12px;
}

.rules-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.mgr-emp-head {
  gap: 16px;
}

.mgr-emp-picker {
  min-width: 220px;
  flex: 0 0 auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.admin-table th {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.admin-table input,
.admin-table select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
}

.admin-table-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  white-space: nowrap;
}

.manager-pill {
  background: #fdf0d5;
  color: #8a5a00;
  border: 1px solid #f0d28a;
  align-self: flex-start;
}

.subject-field {
  padding: 10px;
  border: 1px solid var(--green);
  border-radius: 10px;
  background: #eef7f0;
}

.subject-pill {
  background: var(--green);
  color: #fff;
  align-self: flex-start;
}

.admin-emp-head {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  width: 100%;
  text-align: left;
}

button.admin-emp-head {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 8px;
  margin: -8px -8px 0;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

button.admin-emp-head:hover {
  background: var(--surface-soft);
  border-color: var(--line);
}

button.admin-emp-head.is-active {
  background: #eef7f0;
  border-color: var(--green);
}

/* Пояснение под заголовком — всплывает поверх при наведении, не раздвигая разметку. */
.heading-text {
  position: relative;
}

.heading-hint {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 30;
  margin-top: 6px;
  width: max-content;
  max-width: min(420px, 80vw);
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--muted);
}

.heading-text:hover .heading-hint {
  display: block;
}

.admin-card-hint {
  font-size: 12px;
  font-weight: 650;
  color: var(--green);
  display: none; /* подсказка появляется только при наведении на карточку */
}

button.admin-emp-head:hover .admin-card-hint,
button.admin-emp-head:focus-visible .admin-card-hint {
  display: block;
}

.section-heading-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-heading-tools .ghost-button {
  min-height: 32px;
  padding: 0 12px;
  font-size: 13px;
}

.admin-filter-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  padding: 10px 14px;
  border: 1px solid var(--green);
  border-radius: 10px;
  background: #eef7f0;
  font-weight: 600;
}

.rules-split .schedule-rule-editor {
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  padding: 6px;
  margin: 0;
}

.rules-split .schedule-rule-editor .field {
  gap: 3px;
  font-size: 11px;
}

.rules-split .schedule-rule-editor .field input,
.rules-split .schedule-rule-editor .field select {
  min-height: 26px;
}

.rules-split .schedule-rule-editor .primary-button {
  grid-column: 1 / -1;
  min-height: 28px;
}

.rules-split .rules-reorder {
  margin: 0 0 6px;
}

.rules-split .rules-reorder .icon-button {
  width: 30px;
  min-height: 30px;
}

.rules-split .rules-table-wrap {
  margin-top: 0;
  max-height: 132px;
  overflow: auto;
}

.rules-split .rules-table {
  min-width: 0;
}

.rules-split .rules-table th,
.rules-split .rules-table td {
  padding: 3px 8px;
  font-size: 12px;
}

.rules-split .rules-table .icon-button {
  width: 26px;
  min-height: 26px;
}

.rules-split .rules-table .ghost-button,
.rules-split .rules-table .primary-button {
  min-height: 26px;
  padding: 0 8px;
}

.rules-split .rule-num {
  width: 46px;
  min-height: 24px;
}

@media (max-width: 1080px) {
  .rules-split {
    grid-template-columns: 1fr;
  }
}

.calendar-slot-blocked {
  flex: 1 1 0;
  min-width: 0;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e7eae9;
  border-radius: 8px;
  background: #f3f5f4;
  color: #b3bbb8;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.calendar-shift.is-cancellable {
  cursor: pointer;
}

.calendar-shift.is-cancellable:hover {
  border-color: var(--red);
  box-shadow: 0 6px 14px rgba(189, 61, 50, 0.15);
}

.calendar-cancel {
  color: var(--red);
  font-weight: 700;
}

.calendar-empty {
  color: #a5afac;
  font-size: 12px;
}

.calendar-shift {
  width: 100%;
  min-height: 20px;
  display: grid;
  gap: 1px;
  align-content: start;
  padding: 2px 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.calendar-shift:hover:not(:disabled) {
  border-color: var(--green);
  box-shadow: 0 8px 18px rgba(31, 138, 112, 0.12);
}

.calendar-shift.is-available {
  border-color: rgba(31, 138, 112, 0.38);
  background: #f2fbf7;
}

.calendar-shift.is-mine {
  background: var(--green);
  border-color: var(--green-dark);
  color: #fff;
}

.calendar-shift.is-mine .calendar-shift-area,
.calendar-shift.is-mine .calendar-shift-state,
.calendar-shift.is-mine .calendar-shift-top strong,
.calendar-shift.is-mine .calendar-shift-top em,
.calendar-shift.is-mine .calendar-cancel {
  color: #fff;
}

.calendar-shift.is-unavailable {
  background: #f3f5f4;
  border-color: #e7eae9;
  color: #b3bbb8;
  cursor: not-allowed;
}

.calendar-shift.is-unavailable .calendar-shift-area,
.calendar-shift.is-unavailable .calendar-shift-state,
.calendar-shift.is-unavailable .calendar-shift-top strong,
.calendar-shift.is-unavailable .calendar-shift-top em {
  color: #b3bbb8;
}

.calendar-shift:disabled {
  pointer-events: none;
}

.calendar-shift-top {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: space-between;
  font-size: 10px;
}

.calendar-shift-top em {
  font-style: normal;
  color: var(--muted);
  font-weight: 720;
}

.calendar-shift-area {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 760;
}

.calendar-shift-state {
  color: var(--muted);
  font-size: 9px;
  font-weight: 720;
}

.compact-head {
  padding: 8px 14px;
}

.compact-head .section-heading {
  margin-bottom: 6px;
}

.compact-head h1 {
  font-size: 17px;
  margin: 0;
}

.compact-head .section-heading p {
  font-size: 12px;
  margin-top: 2px;
}

.compact-head .toolbar {
  margin-top: 8px;
}

.calendar-heading h2 {
  font-size: 16px;
}

.calendar-heading {
  margin-bottom: 4px;
}

.calendar-legend {
  margin: 2px 0 4px;
  font-size: 11px;
}

.empty {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.55);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 30;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateY(120%);
  opacity: 0;
  transition: transform 160ms ease, opacity 160ms ease;
}

.toast.is-visible {
  transform: translateY(0);
  opacity: 1;
}

dialog {
  width: min(900px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(11, 23, 21, 0.45);
}

.dialog-shell {
  padding: 16px;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.dialog-header h2 {
  margin: 0;
}

.dialog-header p {
  margin: 4px 0 0;
}

.shift-picker {
  margin-top: 14px;
}

.picker-table-wrap {
  max-height: 62vh;
}

.picker-table .is-muted-row {
  color: #7c8884;
  background: #f7faf9;
}

.picker-table .is-muted-row td {
  opacity: 0.72;
}

pre {
  max-height: 65vh;
  overflow: auto;
  padding: 14px;
  border-radius: 8px;
  background: #101918;
  color: #e5f0ec;
  font-size: 12px;
}

@media (max-width: 1320px) {
  .three-grid {
    grid-template-columns: 1fr;
  }

  .manager-side {
    position: static;
    max-height: none;
    overflow: visible;
  }
}

@media (max-width: 1080px) {
  .main-layout,
  .split-grid,
  .monitor {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

  .notification-list {
    max-height: 240px;
  }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  .mode-switch {
    grid-auto-flow: row;
    grid-template-columns: 1fr 1fr;
  }

  .mode-button {
    padding: 0 8px;
    font-size: 13px;
  }

  .main-layout {
    padding: 14px 12px 24px;
  }

  .quick-stats {
    grid-template-columns: 1fr 1fr;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .checkin-grid {
    grid-template-columns: 1fr;
  }

  .workplace-creator {
    grid-template-columns: 1fr;
  }

  .schedule-rule-editor {
    grid-template-columns: 1fr;
  }

  .shift-strip {
    grid-template-columns: 1fr;
  }
}

/* ===== Вход и аккаунты ===== */
.topbar-user {
  max-width: none;
}

.topbar-user-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-userpick {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.topbar-userpick > span {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.topbar-userpick select {
  min-height: 38px;
  max-width: 280px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--surface);
  font-weight: 650;
  color: var(--ink);
}

.topbar-who {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.topbar-who > span {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.topbar-who > strong {
  font-size: 15px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.topbar-btn {
  min-height: 34px;
  padding: 0 12px;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--bg);
  padding: 20px;
}

/* Важно: атрибут hidden должен прятать экран входа, несмотря на display:grid выше. */
.login-screen[hidden] {
  display: none;
}

.login-card {
  width: min(380px, 100%);
  display: grid;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login-card h2 {
  margin: 6px 0 2px;
}

.login-error {
  color: #fff;
  background: var(--red);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
}

.login-showpwd {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.login-showpwd input {
  width: 18px;
  height: 18px;
}

.login-version {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

.topbar-version {
  align-self: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  padding: 0 4px;
}

.login-card .muted {
  margin: 0 0 4px;
  font-size: 13px;
  color: var(--muted);
}

.history-grid {
  grid-template-columns: 1fr 1fr;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
}

.history-list li {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.history-when {
  font-size: 12px;
  color: var(--muted);
  font-weight: 650;
}

.history-dev,
.history-act {
  font-weight: 650;
}

.history-by {
  font-size: 12px;
  color: var(--muted);
}

@media (max-width: 900px) {
  .history-grid {
    grid-template-columns: 1fr;
  }
}

/* ===== Отпуск ===== */
.vacation-panel {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.vacation-panel.is-active {
  border-color: #6c5ce7;
  background: #f1f0fe;
}

.vacation-field {
  gap: 6px;
}

.vacation-toggle {
  width: 100%;
}

.vacation-hint {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.calendar-vacation,
.calendar-vacation-add {
  flex: 1 1 0;
  min-width: 0;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.calendar-vacation {
  background: #6c5ce7;
  color: #fff;
  border: 1px solid #5a4bd1;
  cursor: default;
}

.calendar-vacation.is-editable {
  cursor: pointer;
}

.calendar-vacation-add {
  background: transparent;
  border: 1px dashed #b3aef0;
  color: #6c5ce7;
  cursor: pointer;
}

.calendar-vacation-add:hover {
  background: #f1f0fe;
}

.calendar-vacation-add em {
  font-style: normal;
  opacity: 0.85;
}

.accounts-table .pill {
  font-size: 11px;
}

.account-temp {
  color: var(--red);
  font-weight: 700;
}

.pill.device-ok {
  background: #dff3ec;
  color: #12634f;
  align-self: flex-start;
}

.pill.device-warn {
  background: #fdecea;
  color: var(--red);
  border: 1px solid #f3b4ad;
  align-self: flex-start;
  white-space: normal;
  line-height: 1.3;
}

/* Киоск-сканер прихода */
.kiosk-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  flex-direction: column;
  background: #0d1514;
  color: #fff;
}

.kiosk-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  font-size: 18px;
  font-weight: 700;
}

.kiosk-video-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
}

#kioskVideo {
  max-width: 100%;
  max-height: 100%;
}

.kiosk-result {
  padding: 20px;
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  background: #16201f;
}

.kiosk-result.is-ok {
  background: #1f8a70;
}

.kiosk-result.is-err {
  background: #cf2727;
}
