:root {
  color-scheme: dark;
  --bg: #090d14;
  --panel: rgba(18, 27, 42, 0.86);
  --panel-strong: #121b2a;
  --line: #26364d;
  --text: #eef5ff;
  --muted: #94a3b8;
  --green: #34e0a1;
  --blue: #4d8dff;
  --red: #ff5570;
  --yellow: #f2c94c;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background: radial-gradient(circle at 50% 0%, rgba(52, 224, 161, 0.11), transparent 30%), var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(920px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 10px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  background: linear-gradient(180deg, rgba(9, 13, 20, 0.96), rgba(9, 13, 20, 0.72));
  backdrop-filter: blur(14px);
}

.icon-button,
.primary-button,
.secondary-button,
.chip-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--panel-strong);
  min-height: 42px;
}

.icon-button {
  width: 44px;
  font-weight: 800;
}

.title-block {
  min-width: 0;
}

.eyebrow,
.subline,
.stat-label,
.player-meta,
.action-meta {
  color: var(--muted);
  font-size: 12px;
}

h1 {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 18px;
  letter-spacing: 0;
}

.section-title {
  margin: 14px 0 10px;
  color: var(--green);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.compact-title {
  margin: 4px 0 6px;
}

.notice,
.auth-card,
.empty,
.picker,
.dashboard,
.card,
.stat,
dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.notice {
  padding: 12px;
  color: var(--yellow);
}

.empty,
.auth-card,
.picker,
.dashboard {
  padding: 12px;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.login-form input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #080d14;
  color: var(--text);
}

.candidate-list,
.list,
.table-list,
.actions-list {
  display: grid;
  gap: 8px;
}

.candidate,
.card,
.action-row {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 12px;
  text-align: left;
}

.candidate {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1420;
  color: var(--text);
}

.candidate-title,
.player-name {
  font-weight: 800;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.stat {
  padding: 10px;
}

.stat-value {
  margin-top: 4px;
  font-size: 20px;
  font-weight: 900;
}

.director-actions {
  display: grid;
  margin-top: 10px;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 12px 0;
}

.tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d1420;
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  border-color: rgba(52, 224, 161, 0.75);
  color: var(--text);
  background: rgba(52, 224, 161, 0.14);
}

.move-bar {
  position: sticky;
  top: 70px;
  z-index: 4;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  margin: 0 0 10px;
  padding: 10px;
  border: 1px solid rgba(52, 224, 161, 0.7);
  border-radius: 8px;
  background: rgba(10, 32, 26, 0.96);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.move-bar strong,
.move-bar span {
  display: block;
}

.move-bar span {
  color: var(--muted);
  font-size: 12px;
}

.search-box {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.search-input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #080d14;
  color: var(--text);
}

.mobile-search-results {
  display: grid;
  gap: 8px;
  max-height: 260px;
  overflow: auto;
  padding-right: 2px;
}

.seat-picker-results {
  max-height: 360px;
}

.table-card {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    radial-gradient(circle at 50% 20%, rgba(52, 224, 161, 0.12), transparent 36%),
    var(--panel);
}

.table-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}

.seat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.seat {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  align-content: center;
  min-height: 66px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  color: var(--text);
  text-align: left;
  touch-action: manipulation;
}

.seat span {
  grid-row: span 2;
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.seat strong,
.seat em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seat strong {
  font-size: 13px;
}

.seat em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.occupied {
  background: rgba(77, 141, 255, 0.08);
}

.occupied::after {
  content: "удерж.";
  grid-column: 2;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  opacity: 0.72;
}

.empty-seat {
  background: rgba(255, 255, 255, 0.025);
}

.drop-ready {
  border-color: rgba(52, 224, 161, 0.85);
  background: rgba(52, 224, 161, 0.16);
}

.selected {
  outline: 2px solid rgba(52, 224, 161, 0.8);
  outline-offset: 2px;
}

.player-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: start;
}

.player-card {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 62px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 27, 42, 0.78);
}

.drag-handle,
.player-main {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.035);
}

.drag-handle {
  width: 42px;
  min-height: 42px;
  font-weight: 900;
  touch-action: none;
}

.player-main {
  display: grid;
  gap: 2px;
  min-width: 0;
  min-height: 42px;
  padding: 6px 8px;
  text-align: left;
}

.search-player {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
}

.search-player .player-main {
  min-width: 0;
  min-height: 38px;
  width: 100%;
  padding: 5px 8px;
}

.search-player .player-main:disabled {
  opacity: 0.55;
}

.search-player .player-name,
.search-player .player-meta {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-player .player-name {
  font-size: 15px;
  line-height: 1.15;
}

.search-player .player-meta {
  font-size: 11px;
  line-height: 1.1;
}

.search-player .status {
  grid-column: auto;
  align-self: center;
  justify-self: end;
  max-width: 72px;
  min-height: 22px;
  padding: 0 6px;
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.ghost {
  grid-column: 2 / -1;
  color: #cfe7ff;
  background: rgba(77, 141, 255, 0.12);
}

.bonus-action {
  border-color: rgba(242, 201, 76, 0.68);
  color: #ffe9a6;
  background: rgba(242, 201, 76, 0.12);
}

.selected-action {
  border-color: rgba(52, 224, 161, 0.9) !important;
  background: rgba(52, 224, 161, 0.18) !important;
  color: var(--text) !important;
  box-shadow: 0 0 0 2px rgba(52, 224, 161, 0.22);
}

.empty-line {
  padding: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(77, 141, 255, 0.18);
  color: #bcd3ff;
  font-size: 12px;
  font-weight: 800;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-button {
  min-height: 36px;
  padding: 0 10px;
  font-size: 13px;
  font-weight: 800;
}

.danger {
  border-color: rgba(255, 85, 112, 0.7);
  color: #ffd6de;
}

.primary-button {
  padding: 0 14px;
  background: var(--green);
  color: #04120d;
  font-weight: 900;
}

.secondary-button {
  padding: 0 14px;
}

dialog {
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  color: var(--text);
  padding: 0;
  overflow: hidden;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.dialog-body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  padding: 14px;
  max-height: calc(100dvh - 24px);
}

.dialog-body h2 {
  margin: 0;
  font-size: 18px;
}

.dialog-text,
.entry-sheet {
  margin: 0;
  color: var(--muted);
}

.entry-sheet {
  display: grid;
  gap: 8px;
}

#dialogFields {
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 8px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
}

.field input,
.field select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #080d14;
  color: var(--text);
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  position: sticky;
  bottom: 0;
  padding-top: 8px;
  background: linear-gradient(180deg, rgba(18, 27, 42, 0), rgba(18, 27, 42, 0.96) 22%);
}

.hidden {
  display: none !important;
}

@media (max-width: 360px) {
  .app-shell {
    padding: 8px;
  }

  h1 {
    font-size: 16px;
  }

  .tabs {
    gap: 4px;
  }

  .tab {
    font-size: 12px;
  }

  .seat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .player-card {
    grid-template-columns: 40px 1fr;
  }

  .player-card .status {
    grid-column: 2;
    justify-self: start;
  }

  .search-player {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .search-player .status {
    grid-column: auto;
    justify-self: end;
  }
}

@media (max-width: 640px) {
  dialog {
    width: calc(100vw - 16px);
    max-width: none;
    max-height: calc(100dvh - 16px);
    margin: auto 8px 8px;
  }

  .dialog-body {
    padding: 10px;
    gap: 8px;
    max-height: calc(100dvh - 16px);
  }

  .dialog-body h2 {
    font-size: 16px;
  }

  .mobile-search-results {
    max-height: 170px;
  }

  .seat-picker-results {
    max-height: 240px;
  }

  .field input,
  .field select,
  .search-input {
    font-size: 16px;
    min-height: 40px;
  }
}
