:root {
  --accent: #2A6FDB;
  --accent-fg: #ffffff;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fbfcfd;
  --surface-hover: #f3f5f8;
  --border: #e6e8ec;
  --border-strong: #d4d8de;
  --text: #1a1d23;
  --text-2: #5b6472;
  --text-3: #8a93a3;
  --danger: #d92d20;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 16px -4px rgba(16, 24, 40, .12), 0 2px 6px -2px rgba(16, 24, 40, .07);
  --shadow-lg: 0 18px 50px -12px rgba(16, 24, 40, .28);
}

[data-theme="dark"] {
  --bg: #0c0e12;
  --surface: #14171d;
  --surface-2: #181c23;
  --surface-hover: #1d222b;
  --border: #262b34;
  --border-strong: #333a45;
  --text: #eef1f6;
  --text-2: #9aa4b2;
  --text-3: #69727f;
  --danger: #ff6b5f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 22px -6px rgba(0, 0, 0, .55);
  --shadow-lg: 0 24px 60px -14px rgba(0, 0, 0, .7);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv05" 1, "ss01" 1, "tnum" 1;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

#app {
  margin: 0 auto;
  max-width: 1320px;
  padding: 28px 28px 80px;
}

.app-header {
  align-items: flex-end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 20px;
}

h1 {
  font-family: "Inter Tight", system-ui, sans-serif;
  font-size: 27px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.1;
  margin: 0;
}

.app-header p {
  color: var(--text-2);
  font-size: 13.5px;
  margin: 6px 0 0;
}

.app-header b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.header-actions,
.toolbar,
.dialog-actions {
  align-items: center;
  display: flex;
  gap: 10px;
}

.session-pill {
  background: var(--surface);
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 11px;
}

.toolbar {
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-box {
  flex: 1 1 230px;
  max-width: 340px;
  position: relative;
}

.search-box svg {
  color: var(--text-3);
  height: 16px;
  left: 11px;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
}

input,
select {
  background: var(--surface);
  border: 0;
  border-radius: 9px;
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text);
  outline: 0;
  padding: 9px 12px;
}

input:focus,
select:focus {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.search-box input {
  padding-left: 34px;
  width: 100%;
}

.select-wrap select {
  appearance: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  min-width: 132px;
  padding-right: 30px;
}

.compact-select select {
  min-width: 104px;
}

.segmented {
  background: var(--surface);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px var(--border);
  display: flex;
  gap: 5px;
  padding: 4px;
}

.segmented button {
  align-items: center;
  background: transparent;
  border: 0;
  border-radius: 7px;
  color: var(--text-2);
  display: inline-flex;
  font-size: 13px;
  font-weight: 600;
  gap: 7px;
  padding: 6px 12px;
}

.segmented button.is-active {
  background: var(--surface-2);
  color: var(--text);
}

.dot {
  border-radius: 99px;
  display: inline-block;
  height: 7px;
  width: 7px;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  align-items: center;
  border: 0;
  border-radius: 9px;
  display: inline-flex;
  font-size: 13px;
  font-weight: 700;
  gap: 7px;
  justify-content: center;
  min-height: 36px;
  padding: 0 13px;
}

.primary-button {
  background: var(--accent);
  color: var(--accent-fg);
}

.secondary-button {
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text-2);
}

.danger-button {
  background: transparent;
  color: var(--danger);
}

.icon-button {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text-2);
  height: 36px;
  padding: 0;
  width: 36px;
}

button svg {
  fill: none;
  height: 15px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.2;
  width: 15px;
}

.coverage {
  align-items: stretch;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.coverage-card {
  align-items: center;
  background: var(--surface);
  border-radius: 10px;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--border);
  display: flex;
  gap: 8px;
  min-width: 92px;
  padding: 8px 12px;
}

.coverage-card.is-empty {
  opacity: .62;
}

.coverage-card strong {
  display: block;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.coverage-card span:last-child {
  color: var(--text-2);
  display: block;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.15;
}

.coverage-dot {
  border-radius: 99px;
  flex: none;
  height: 9px;
  width: 9px;
}

.matrix-shell {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-md), inset 0 0 0 1px var(--border);
  overflow: auto;
}

.matrix {
  border-collapse: collapse;
  width: 100%;
}

.matrix th {
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 3;
}

.matrix .name-head,
.matrix .character-cell {
  left: 0;
  min-width: 240px;
  position: sticky;
}

.matrix .name-head {
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  height: 68px;
  letter-spacing: .06em;
  padding: 0 16px 12px;
  text-align: left;
  text-transform: uppercase;
  top: 28px;
  vertical-align: bottom;
  z-index: 4;
}

.band-head {
  border-left: 2px solid var(--border-strong);
  color: var(--text-3);
  font-size: 10.5px;
  font-weight: 700;
  height: 28px;
  letter-spacing: .09em;
  padding-top: 12px;
  text-align: center;
  text-transform: uppercase;
}

.vertical-head {
  border-bottom: 1px solid var(--border);
  height: 96px;
  padding: 0 0 8px;
  width: 44px;
}

.vertical-head.is-divider,
.matrix-cell.is-divider {
  border-left: 2px solid var(--border-strong);
}

.vertical-head > div {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.vertical-head span:first-child {
  color: var(--text-2);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  transform: rotate(180deg);
  white-space: nowrap;
  writing-mode: vertical-rl;
}

.vertical-head .dot {
  height: 9px;
  margin-bottom: 4px;
  width: 9px;
}

.vertical-head .dot.square {
  border-radius: 3px;
}

.section-row td {
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  color: var(--text-2);
  font-size: 12px;
  font-weight: 700;
  padding: 9px 16px;
}

.section-row .section-label {
  align-items: center;
  display: inline-flex;
  gap: 8px;
}

.section-row small {
  color: var(--text-3);
  font-size: 12px;
  font-weight: 600;
}

.character-row {
  border-bottom: 1px solid var(--border);
}

.character-cell {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 7px 16px;
  z-index: 2;
}

.character-button {
  align-items: center;
  background: transparent;
  border: 0;
  color: inherit;
  display: flex;
  gap: 10px;
  padding: 0;
  text-align: left;
  width: 100%;
}

.avatar {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  flex: none;
  font-size: 10px;
  font-weight: 700;
  height: 26px;
  justify-content: center;
  width: 26px;
}

.char-name {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.25;
}

.char-account {
  color: var(--text-3);
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  line-height: 1.25;
}

.matrix-cell {
  border-left: 1px solid var(--border);
  cursor: pointer;
  padding: 0;
  text-align: center;
}

.matrix-cell button {
  background: transparent;
  border: 0;
  display: grid;
  height: var(--cell-size, 36px);
  padding: 0;
  place-items: center;
  width: 100%;
}

.check {
  border-radius: 7px;
  box-shadow: inset 0 0 0 1.5px var(--border-strong);
  display: grid;
  height: calc(var(--cell-size, 36px) - 14px);
  place-items: center;
  transition: all .1s ease;
  width: calc(var(--cell-size, 36px) - 14px);
}

.check.group-check {
  border-radius: 6px;
}

.matrix-cell button:hover .check {
  box-shadow: inset 0 0 0 1.5px var(--accent);
}

.check.is-on {
  box-shadow: none;
}

.check svg {
  fill: none;
  height: 42%;
  stroke: #fff;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 3.4;
  width: 42%;
}

.loading,
.empty {
  color: var(--text-3);
  font-size: 14px;
  padding: 60px 0;
  text-align: center;
}

dialog {
  background: transparent;
  border: 0;
  color: var(--text);
  padding: 0;
}

dialog::backdrop {
  background: rgba(12, 14, 18, .42);
}

.dialog-card {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--border);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: min(520px, calc(100vw - 32px));
  padding: 16px;
}

.dialog-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.dialog-head h2 {
  font-family: "Inter Tight", system-ui, sans-serif;
  font-size: 19px;
  margin: 0;
}

.dialog-card label,
.field-group {
  color: var(--text-2);
  display: flex;
  flex-direction: column;
  font-size: 12px;
  font-weight: 700;
  gap: 7px;
}

.dialog-card input {
  width: 100%;
}

.check-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.chip-check {
  align-items: center;
  background: var(--surface-2);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--border);
  color: var(--text-2);
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 6px;
  padding: 6px 9px;
  user-select: none;
}

.chip-check input {
  display: none;
}

.chip-check:has(input:checked) {
  color: var(--chip-color);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--chip-color) 42%, transparent);
}

.spacer {
  flex: 1;
}

.toast {
  background: var(--surface);
  border-radius: 10px;
  bottom: 18px;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  padding: 10px 13px;
  pointer-events: none;
  position: fixed;
  right: 18px;
  transform: translateY(8px);
  transition: opacity .14s ease, transform .14s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.login-view {
  align-items: center;
  background: var(--bg);
  display: grid;
  inset: 0;
  padding: 24px;
  place-items: center;
  position: fixed;
  z-index: 20;
}

.login-panel {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--border);
  max-width: 420px;
  padding: 24px;
  text-align: center;
  width: 100%;
}

.login-panel p {
  color: var(--text-2);
  font-size: 14px;
  margin: 10px 0 18px;
}

.login-button {
  text-decoration: none;
  width: 100%;
}

*::-webkit-scrollbar {
  height: 11px;
  width: 11px;
}

*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border: 3px solid var(--surface);
  border-radius: 99px;
}

*::-webkit-scrollbar-track {
  background: transparent;
}

@media (max-width: 760px) {
  #app {
    padding: 18px 14px 64px;
  }

  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions {
    justify-content: space-between;
  }

  .segmented {
    overflow-x: auto;
    width: 100%;
  }
}
