/* OpenPrim admin styles */
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Segoe UI, system-ui, sans-serif;
  color: #0F2F4A;
  background: #F5FBFF;
}
a { color: inherit; }

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #074A8C, #0B5FA8 50%, #1A7ABF);
}
.login-card {
  width: min(400px, calc(100% - 2rem));
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  display: grid;
  gap: 0.8rem;
}
.login-card h1 {
  margin: 0;
  font-size: 1.4rem;
  color: #0B4F8C;
}
.login-lead { margin: 0; color: #4A6F8A; font-size: 0.95rem; }
.login-error { margin: 0; color: #b42318; font-weight: 700; }
.login-card label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #4A6F8A;
}
.login-card input {
  border: 1.5px solid #d0e8f5;
  border-radius: 10px;
  padding: 0.7rem 0.8rem;
  font: inherit;
}
.login-card button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  padding: 0.65rem 1.1rem;
  background: #0B4F8C;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn-ghost {
  background: #fff;
  color: #0B4F8C;
  border: 1.5px solid #d0e8f5;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 1.2rem 1.4rem;
  background: linear-gradient(120deg, #074A8C, #1A7ABF);
  color: #fff;
}
.admin-header h1 { margin: 0; font-size: 1.25rem; }
.admin-header p { margin: 0.2rem 0 0; opacity: 0.85; font-size: 0.9rem; }
.admin-header-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }
.admin-header .btn { background: #B8E8FF; color: #0B4F8C; }
.admin-header .btn-ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,0.35); }

.banner-error {
  margin: 1rem 1.4rem 0;
  padding: 0.9rem 1rem;
  background: #fee4e2;
  color: #b42318;
  border-radius: 10px;
  font-weight: 700;
}
.banner-ok {
  margin: 1rem 1.4rem 0;
  padding: 0.9rem 1rem;
  background: #e8f8ef;
  color: #1a8a5a;
  border-radius: 10px;
  font-weight: 700;
}
.btn-danger {
  background: #fff;
  color: #b42318;
  border: 1.5px solid rgba(180, 35, 24, 0.35);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-weight: 700;
  cursor: pointer;
}
.inst-panel {
  margin: 1rem 1.4rem;
  padding: 1.1rem 1.2rem;
  background: #fff;
  border: 1px solid #d0e8f5;
  border-radius: 14px;
}
.inst-panel h2 { margin: 0 0 0.9rem; font-size: 1.1rem; color: #0B4F8C; }
.inst-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}
.inst-add-form label {
  flex: 1 1 280px;
  display: grid;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #4A6F8A;
}
.inst-add-form input {
  border: 1.5px solid #d0e8f5;
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
  font: inherit;
}
.inst-table {
  width: 100%;
  border-collapse: collapse;
}
.inst-table th, .inst-table td {
  text-align: left;
  padding: 0.65rem 0.4rem;
  border-bottom: 1px solid #e5eef3;
  vertical-align: middle;
}
.inst-table tr.is-off td { opacity: 0.55; }
.inst-actions { white-space: nowrap; }

.stats {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
  padding: 1rem 1.4rem;
}
.stat {
  background: #fff;
  border: 1px solid #d0e8f5;
  border-radius: 12px;
  padding: 0.9rem 1rem;
}
.stat strong {
  display: block;
  font-size: 1.5rem;
  color: #0B4F8C;
}
.stat span { color: #4A6F8A; font-size: 0.88rem; font-weight: 600; }

.table-wrap {
  padding: 0 1.4rem 2rem;
  overflow: auto;
}
.board {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid #d0e8f5;
  border-radius: 12px;
  overflow: hidden;
}
.board th,
.board td {
  border-bottom: 1px solid #e8f2f4;
  padding: 0.9rem;
  vertical-align: top;
  text-align: left;
}
.board th {
  background: #e8f6fb;
  color: #0B4F8C;
  font-size: 0.9rem;
}
.col-event { width: 28%; }
.event-name { font-weight: 700; color: #0B4F8C; margin-bottom: 0.25rem; }
.event-track { font-size: 0.85rem; color: #0077be; font-weight: 700; }
.event-dates {
  margin-top: 0.3rem;
  font-size: 0.8rem;
  font-weight: 700;
  color: #0F2F4A;
}
.event-meta { margin-top: 0.35rem; font-size: 0.82rem; color: #4A6F8A; }
.event-status-badge {
  display: inline-block;
  margin: 0.35rem 0.25rem 0 0;
  padding: 0.15rem 0.5rem;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.event-status-badge.badge-past {
  background: #fde8e8;
  color: #b42318;
}
.event-status-badge.badge-active {
  background: #dcfae6;
  color: #067647;
}
.event-status-badge.badge-upcoming {
  background: #e0f2fe;
  color: #0369a1;
}
.event-status-badge.badge-unknown {
  background: #eef2f6;
  color: #4A6F8A;
}
.event-status-badge.badge-manual {
  background: #fef0c7;
  color: #b54708;
}
.event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.55rem;
}
.event-hint {
  font-size: 0.75rem;
  font-weight: 700;
  color: #4A6F8A;
  align-self: center;
}
.btn-suggest-other {
  background: #0B4F8C;
  color: #fff;
  border-color: #0B4F8C;
}
.btn-suggest-other:hover {
  filter: brightness(1.06);
}
.board-section-title {
  margin: 0.4rem 0 0.65rem;
  font-size: 1.05rem;
  font-weight: 800;
  color: #0B4F8C;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.board-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.5rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: #e8f6fb;
  color: #0B4F8C;
  font-size: 0.8rem;
  font-weight: 800;
}
.board-past-section {
  margin: 1.4rem 0 0.5rem;
  border: 1px solid #f5c2c0;
  border-radius: 14px;
  background: #fff8f7;
  padding: 0.55rem 0.75rem 0.85rem;
}
.board-past-section > summary {
  cursor: pointer;
  list-style: none;
  font-size: 1.05rem;
  font-weight: 800;
  color: #b42318;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.15rem 0.55rem;
  user-select: none;
}
.board-past-section > summary::-webkit-details-marker { display: none; }
.board-past-section > summary::before {
  content: "▸";
  display: inline-block;
  transition: transform 0.2s ease;
}
.board-past-section[open] > summary::before {
  transform: rotate(90deg);
}
.board-past-section .board-count {
  background: #fde8e8;
  color: #b42318;
}
.board-row-past td {
  background: #fff9f8;
}
.board-row-past .col-event {
  border-left: 4px solid #f04438;
}
.event-quota {
  display: inline-block;
  margin-top: 0.45rem;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.event-quota.quota-low {
  background: #fee4e2;
  color: #b42318;
}
.event-quota.quota-mid {
  background: #fef0c7;
  color: #b54708;
}
.event-quota.quota-high {
  background: #dcfae6;
  color: #067647;
}
.event-quota.quota-unknown {
  background: #eef2f6;
  color: #4A6F8A;
  font-weight: 700;
}
.chip {
  background: #F5FBFF;
  border: 1px solid #d0e8f5;
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.45rem;
}
.chip-done { background: #eefaf3; border-color: #b7e4c7; }
.chip-in-work {
  background: #fff7e8;
  border-color: #f0c36a;
}
.chip-badge {
  display: inline-block;
  margin: 0.2rem 0 0.15rem;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  background: #f0c36a;
  color: #5a3d00;
  font-size: 0.72rem;
  font-weight: 700;
}
.chip-badge-rated {
  background: #dbeafe;
  color: #1e40af;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
a.chip-badge-rated:hover {
  background: #bfdbfe;
  color: #1e3a8a;
}
.board-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
  margin: 0 0 0.85rem;
}
.col-list { width: 20%; min-width: 170px; }
.chip-check {
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
  cursor: pointer;
}
.chip-check input {
  margin-top: 0.2rem;
  flex: 0 0 auto;
}
.directed-toolbar {
  margin-bottom: 0.45rem;
}
.chip-fio { font-weight: 700; color: #0F2F4A; }
.chip-inst-inline {
  font-weight: 600;
  color: #0a5a6e;
  font-size: 0.88em;
}
.chip-mail { font-size: 0.8rem; color: #4A6F8A; margin: 0.15rem 0 0.4rem; }
.chip-data {
  display: inline-block;
  margin: 0.15rem 0.25rem 0.25rem 0;
  padding: 0.28rem 0.65rem;
  border: 1px solid #9adbe8;
  border-radius: 8px;
  background: #e8f6fb;
  color: #0B4F8C;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}
.chip-data:hover {
  background: #d6eef8;
  border-color: #0077be;
}

.chip-contact-btn {
  display: inline-block;
  margin: 0.15rem 0.25rem 0.25rem 0;
  padding: 0.28rem 0.65rem;
  border: 1px solid #b8d4a8;
  border-radius: 8px;
  background: #eef8e8;
  color: #2d6a1f;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  vertical-align: top;
}
.chip-contact-btn:hover,
.chip-contact-btn.is-open {
  background: #dff0d4;
  border-color: #5a9a3a;
}
.chip-contact-menu {
  position: fixed;
  z-index: 4000;
  min-width: 220px;
  max-width: min(280px, calc(100vw - 16px));
  max-height: min(320px, calc(100vh - 16px));
  overflow: auto;
  padding: 0.3rem;
  background: #fff;
  border: 1px solid #d0e8f5;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(11, 79, 140, 0.22);
  display: none;
}
.chip-contact-menu[hidden] { display: none !important; }
.chip-contact-menu.is-open {
  display: block !important;
}
.chip-contact-item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #0F2F4A;
  font-size: 0.78rem;
  font-weight: 650;
  font-family: inherit;
  padding: 0.45rem 0.55rem;
  border-radius: 7px;
  cursor: pointer;
}
.chip-contact-item:hover {
  background: #f0f7fc;
  color: #0B4F8C;
}
.chip-contact-item:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* Person data modal */
.person-modal[hidden] { display: none !important; }
.person-modal {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 1rem;
}
.person-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(7, 40, 80, 0.5);
}
.person-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  max-height: min(90vh, 640px);
  overflow: auto;
  background: #fff;
  border-radius: 16px;
  padding: 1.35rem 1.4rem 1.25rem;
  box-shadow: 0 20px 50px rgba(11, 79, 140, 0.22);
}
.person-modal-close {
  position: absolute;
  top: 0.55rem;
  right: 0.7rem;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  color: #4A6F8A;
  cursor: pointer;
  padding: 0.2rem 0.45rem;
}
.person-modal-title {
  margin: 0 0 1rem;
  font-size: 1.15rem;
  font-weight: 800;
  color: #0B4F8C;
  padding-right: 1.5rem;
}
.person-modal-fields {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.person-modal-fields > div {
  padding: 0.55rem 0.7rem;
  background: #f5fbff;
  border: 1px solid #d0e8f5;
  border-radius: 10px;
}
.person-modal-fields dt {
  margin: 0 0 0.15rem;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4A6F8A;
}
.person-modal-fields dd {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0F2F4A;
  word-break: break-word;
}
.person-modal-extra {
  margin-top: 0.85rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e8f2f4;
  font-size: 0.85rem;
  color: #4A6F8A;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.person-modal-extra .label {
  font-weight: 800;
  color: #0B4F8C;
  margin-right: 0.35rem;
}
.person-modal-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
}
.chip-move {
  border: 0;
  background: #0B4F8C;
  color: #fff;
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
}
.chip-done .chip-move { background: #4A6F8A; }
.chip-delete {
  border: 1.5px solid rgba(180, 35, 24, 0.35);
  background: #fff;
  color: #b42318;
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  cursor: pointer;
  margin-left: 0.35rem;
}
.chip-delete:hover {
  background: #b42318;
  color: #fff;
  border-color: #b42318;
}
.chip-delete:disabled,
.chip-move:disabled {
  opacity: 0.6;
  cursor: wait;
}
.empty, .empty-col { color: #8aa0b0; text-align: center; padding: 1rem; }

.act-form {
  display: grid;
  gap: 0.75rem;
  max-width: 920px;
}
.act-form-grid {
  grid-template-columns: 1fr 1fr;
}
.act-form-grid .span-2 { grid-column: 1 / -1; }
.act-form label,
.inst-add-form label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #4A6F8A;
}
.act-form input,
.act-form select,
.act-form textarea,
.inst-add-form input,
.inst-add-form select {
  border: 1.5px solid #d0e8f5;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font: inherit;
  color: #0F2F4A;
  background: #fff;
}
.act-form textarea { resize: vertical; }
.check-label {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600 !important;
}
.check-label input { width: auto; }
.form-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.hint { color: #4A6F8A; font-size: 0.9rem; margin: 0 0 0.75rem; }
.hint code { background: #e8f4f8; padding: 0.1rem 0.35rem; border-radius: 4px; font-size: 0.85em; }
.json-ai-prompt-block {
  margin-top: 1.35rem;
  padding-top: 1.1rem;
  border-top: 1px solid #d0e8f5;
}
.json-ai-prompt-block h3 {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
  color: #0B4F8C;
}
.json-ai-prompt {
  margin: 0;
  padding: 0.85rem 1rem;
  max-height: 22rem;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #0F2F4A;
  background: #f4fafc;
  border: 1px solid #c5e4f0;
  border-radius: 12px;
}
.muted { color: #6a8494; font-size: 0.85rem; margin-top: 0.2rem; }
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}
.inline-form { display: inline-flex; gap: 0.35rem; align-items: center; margin: 0; }
.pass-form input[type="password"] {
  width: 8rem;
  border: 1.5px solid #d0e8f5;
  border-radius: 8px;
  padding: 0.35rem 0.5rem;
  font: inherit;
}
.btn-sm {
  padding: 0.35rem 0.7rem !important;
  font-size: 0.8rem !important;
  border-radius: 999px !important;
}
.btn-danger { color: #b42318 !important; border-color: #f3c4c0 !important; }
.admin-header .btn-active {
  background: #fff !important;
  color: #0B4F8C !important;
}
.act-table td { vertical-align: top; }
.act-table .act-num {
  width: 3.5rem;
  white-space: nowrap;
}
.act-id-chip {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 8px;
  background: #e8f2f8;
  color: #0B4F8C;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.btn-copy-link.is-copied {
  color: #067647 !important;
  border-color: #abefc6 !important;
}
.row-readonly { opacity: 0.72; }
.diff-list {
  margin: 0;
  padding-left: 1.1rem;
  font-size: 0.88rem;
  color: #2c4a5e;
}
.diff-list li { margin: 0.2rem 0; }

.settings-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0 0 1rem;
  padding: 0.15rem 0;
}
.settings-subtabs {
  margin: -0.35rem 0 1.15rem;
}
.settings-tab {
  display: inline-block;
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  color: #0B4F8C;
  background: #e8f4fb;
  border: 1px solid #d0e8f5;
}
.settings-tab.is-active {
  background: #0B4F8C;
  color: #fff;
  border-color: #0B4F8C;
}
.settings-tab:hover {
  background: #d6eef9;
}
.settings-tab.is-active:hover {
  background: #094070;
  color: #fff;
}
.settings-subh {
  margin: 1.1rem 0 0.55rem;
  font-size: 1rem;
  color: #0B4F8C;
}

@media (max-width: 900px) {
  .act-form-grid { grid-template-columns: 1fr; }
  .act-form-grid .span-2 { grid-column: auto; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .board, .board thead, .board tbody, .board tr, .board th, .board td {
    display: block;
  }
  .board thead { display: none; }
  .board tr {
    border-bottom: 2px solid #d0e8f5;
    margin-bottom: 0.8rem;
    padding-bottom: 0.8rem;
  }
  .col-event, .col-list { width: 100%; }
}
