/* ---------- Базовые переменные и сброс ---------- */
:root {
  --bg: #12161c;
  --card: #1b2129;
  --line: #2c3542;
  --text: #e6edf3;
  --muted: #9aa7b4;
  --accent: #2ecc71;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 24px;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, "Segoe UI", Roboto, sans-serif;
}

header h1 { margin: 0 0 4px; font-size: 22px; }
.muted { color: var(--muted); margin: 0 0 20px; font-size: 13px; }
main { max-width: 1200px; margin: 0 auto; }

/* ---------- Панель управления ---------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: end;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 20px;
}

.controls > label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

select, input[type="date"], button {
  background: #0f141a;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
}

button { cursor: pointer; transition: border-color 0.2s; }
button:hover { border-color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Список ID ---------- */
.ids {
  flex: 1 1 320px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 0;
}

.ids legend {
  font-size: 13px;
  color: var(--muted);
  padding: 0 4px;
}

.hint { color: #5d6b7a; font-weight: normal; font-size: 11px; }
.ids-actions { display: flex; gap: 8px; margin-bottom: 8px; }

.id-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  max-height: 132px;
  overflow-y: auto;
}

.id-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  transition: opacity .15s;
  padding: 2px 4px;
  border-radius: 4px;
}

.id-item:hover { background: #0f141a; }

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.id-name {
  cursor: pointer;
  border-radius: 4px;
  padding: 1px 4px;
  border: 1px dashed transparent;
}

.id-name:hover { border-color: var(--line); background: rgba(255,255,255,0.05); }



/* ---------- Статус и График ---------- */
.status { min-height: 22px; color: var(--muted); font-size: 13px; margin-bottom: 10px; }

.chart-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  height: 440px;
  margin-bottom: 30px;
  position: relative;
}

.chart-copy {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 5;
  font-size: 12px;
  padding: 5px 12px;
  background: #0f141a;
  color: var(--muted);
}

.chart-copy:hover { color: var(--text); }
.chart-copy:disabled { cursor: default; border-color: var(--accent); color: var(--accent); }

/* ---------- Таблица сводки ---------- */
h2 { font-size: 17px; margin: 28px 0 10px; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
}

th, td {
  padding: 9px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

thead th {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  background: #161b22;
}

tbody tr { transition: background .15s; }
tbody tr:hover { background: #222b36; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }

.summary-row { cursor: pointer; }

.player-cell { vertical-align: middle; }
.player-cell .id-sub {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: normal;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}



/* ---------- Модальное окно редактирования ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  width: 380px;
  max-width: 92vw;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.modal h3 { margin: 0 0 14px; font-size: 16px; color: var(--text); }
.modal h3 small { color: var(--muted); font-weight: normal; font-size: 12px; }

.modal label {
  display: block;
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--muted);
}

.modal input[type=text], .modal textarea {
  width: 100%;
  background: #0f141a;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  font: inherit;
  margin-top: 4px;
}

.modal textarea { resize: vertical; font-family: monospace; }

.leave-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text) !important;
  margin-top: 10px;
}

.leave-row input { width: auto; margin: 0; }

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
}

.modal-actions button {
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 13px;
}

.modal-actions .ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}
.modal-actions .ghost:hover { color: var(--text); background: rgba(255,255,255,0.05); }

/* ---------- Окно редактирования дня ---------- */
.edit-modal { width: 440px; max-height: 90vh; overflow-y: auto; }

.edit-modal select, .edit-modal input[type="date"] {
  width: 100%;
  margin-top: 4px;
}

.edit-error {
  color: #ff8a8a;
  font-size: 13px;
  margin: 8px 0 0;
  min-height: 18px;
}

.detail-table tbody tr { cursor: default; }

/* ---------- Детальный отчёт по игроку ---------- */
.detail-modal {
  width: 860px;
  max-width: 94vw;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}

.detail-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  padding: 0;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
}

.detail-chart {
  height: 300px;
  margin-bottom: 16px;
}

.detail-table { max-height: 320px; overflow-y: auto; }
.detail-table thead th { position: sticky; top: 0; z-index: 1; }
.detail-table td, .detail-table th { padding: 6px 10px; font-size: 13px; }

.day-missing td { color: #6b7684; font-style: italic; }
.day-future td { color: #4a5563; }
.day-leave td:last-child { color: var(--leave, #f39c12); }


/* ---------- Адаптив ---------- */
@media (max-width: 640px) {
  .chart-card { height: 340px; }
  body { padding: 16px; }
  .controls { flex-direction: column; align-items: stretch; }
  .detail-chart { height: 220px; }
}