:root {
  --bg: #111318;
  --bg-raised: #181b22;
  --bg-column: #0d0f14;
  --text: #ececec;
  --text-muted: #9aa0ab;
  --line: #2a2e38;
  --line-strong: #3d4350;
  --accent: #6ea8ff;
  --accent-soft: rgba(110, 168, 255, 0.16);
  --danger: #ef6b6b;
  --team-border: #4d8fb5;
  --team-bg: #0a1524;
  --party-title: #7ec8e3;
  --radius: 12px;
  --shadow: 0 0 0 1px var(--line);
  font-family: "Segoe UI", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  padding: 20px 32px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

body.is-login {
  padding: 0;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at top, rgba(110, 168, 255, 0.12), transparent 50%),
    var(--bg);
}

.login-screen[hidden] {
  display: none;
}

.login-card {
  width: min(360px, calc(100% - 32px));
  padding: 28px 24px 24px;
  border-radius: var(--radius);
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.login-card h1 {
  font-size: 28px;
}

.login-lede {
  margin: 0 0 8px;
  color: var(--text-muted);
  line-height: 1.5;
}

.login-card input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

.login-card input:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.login-card button {
  height: 40px;
  margin-top: 4px;
  border: 0;
  border-radius: 8px;
  background: #2a3140;
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
}

.login-card button:hover {
  background: #364056;
}

.login-error {
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.login-error[hidden] {
  display: none;
}

.hero-title {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.hero-heading {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sync-status {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
}

.sync-status.is-server {
  color: var(--party-title);
}

.sync-status.is-local {
  color: #e3c07e;
}

.sync-status.is-error {
  color: var(--danger);
}

.logout-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: #11141b;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.logout-btn:hover {
  color: var(--text);
  background: #2a3140;
}

.app {
  max-width: none;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}


.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-end;
  margin-bottom: 16px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 650;
}

.lede {
  margin: 8px 0 0;
  color: var(--text-muted);
  max-width: 520px;
  line-height: 1.5;
}

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

.stats div {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}

.stats dt {
  color: var(--text-muted);
  font-size: 12px;
}

.stats dd {
  margin: 4px 0 0;
  font-size: 22px;
  font-weight: 650;
}

.class-stats-bar {
  display: grid;
  grid-template-columns: 4fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
  align-items: stretch;
  flex-shrink: 0;
}

.class-stats {
  min-width: 0;
  padding: 10px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  align-items: center;
}

.class-stats-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 0;
}

.class-stat {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  margin: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.class-stat:hover {
  background: var(--accent-soft);
}

.class-stat.is-active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.class-stat img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.class-stat strong {
  font-size: 14px;
  font-weight: 650;
}

.class-stat-sep {
  color: var(--text-muted);
  padding: 0 2px;
  font-weight: 500;
}

.member-search {
  min-width: 0;
  padding: 10px 12px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  align-items: center;
}

.member-search input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 13px;
}

.member-name.blink {
  border-radius: 4px;
  padding: 0 4px;
  animation: member-blink 0.5s ease-in-out 8;
}

@keyframes member-blink {
  0%,
  100% {
    background: transparent;
    color: inherit;
  }
  50% {
    background: var(--accent);
    color: #111318;
  }
}

.board {
  display: flex;
  align-items: stretch;
  gap: 14px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding-bottom: 4px;
}

.column {
  width: 240px;
  min-width: 240px;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
}

.column.source {
  background: transparent;
  border: 2px solid var(--line-strong);
  flex-shrink: 0;
}

.column.source .member-list {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.groups-wrap {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.groups {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding-right: 4px;
}

.column.group {
  width: 100%;
  min-width: 0;
  height: auto;
  max-height: none;
  flex-direction: row;
  align-items: stretch;
  background: var(--team-bg);
  border: 1px solid var(--team-border);
  border-radius: 14px;
  overflow: hidden;
  padding: 10px 10px 10px 14px;
  gap: 10px;
}

.column.drag-over,
.subgroup.drag-over {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--accent-soft);
}

.subgroup.drop-full {
  outline: 2px solid var(--danger);
  outline-offset: -2px;
}

.column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.column.source .column-head {
  flex-shrink: 0;
}

.column.group .column-head {
  width: 176px;
  min-width: 160px;
  max-width: 200px;
  padding: 4px 6px 4px 0;
  border-bottom: 0;
  align-items: center;
  flex-shrink: 0;
}

.column-head h2,
.group-title {
  flex: 1;
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  color: var(--text);
  background: transparent;
  border: 0;
  min-width: 0;
}

.group-info {
  min-width: 0;
  width: 100%;
}

.group-title-row {
  display: flex;
  align-items: flex-start;
  gap: 4px;
}

.group-title {
  padding: 2px 4px;
  border-radius: 6px;
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  width: 100%;
  resize: none;
  overflow: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.15;
  min-height: calc(1.15em + 4px);
  field-sizing: content;
}

.group-title:focus {
  outline: 1px solid var(--accent);
  background: var(--bg-raised);
}

.group-meta {
  margin: 4px 0 0;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.count {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.icon-btn {
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.icon-btn:hover {
  color: var(--danger);
  background: rgba(239, 107, 107, 0.12);
}

.subgroups {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  padding: 0;
  flex: 1;
  overflow-x: auto;
  overflow-y: hidden;
  min-width: 0;
  min-height: 0;
  align-items: stretch;
}

.subgroup {
  width: 148px;
  min-width: 148px;
  max-width: 148px;
  min-height: 148px;
  border: 1px solid var(--team-border);
  border-radius: 10px;
  background: rgba(8, 16, 28, 0.65);
  display: flex;
  flex-direction: column;
}

.subgroup-head {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 6px 0;
}

.subgroup-title {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 2px 4px;
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--party-title);
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.subgroup-title:focus {
  outline: 1px solid var(--accent);
  background: var(--bg-raised);
}

.subgroup-head .icon-btn {
  width: 18px;
  height: 18px;
  font-size: 14px;
}

.subgroup-head .count {
  display: none;
}

.column.group .member:hover {
  background: var(--accent-soft);
}

.subgroup .member-list {
  counter-reset: slot;
  min-height: 72px;
  flex: 1;
  padding: 4px 6px 8px;
  gap: 1px;
}

.subgroup .member-list:empty::after {
  content: "Lepas di sini";
  min-height: 64px;
  font-size: 11px;
  border-color: var(--team-border);
}

.add-subgroup {
  margin: 0;
  width: 34px;
  min-width: 34px;
  height: auto;
  align-self: stretch;
  border: 1px dashed var(--team-border);
  border-radius: 10px;
  background: transparent;
  color: var(--party-title);
  cursor: pointer;
  font: inherit;
  font-size: 22px;
  font-weight: 600;
  line-height: 1;
}

.add-subgroup:hover:not(:disabled) {
  background: var(--accent-soft);
}

.add-subgroup:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.member-list {
  list-style: none;
  margin: 0;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 120px;
}

.member-list:empty::after {
  content: "Lepas member di sini";
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 88px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13px;
}

.member {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px 8px 12px;
  border-radius: 8px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  cursor: grab;
  user-select: none;
}

.column.group .member {
  background: transparent;
  border: 0;
  border-radius: 4px;
  padding: 2px 4px;
  gap: 6px;
}

.column.group .member::before {
  counter-increment: slot;
  content: counter(slot);
  width: 12px;
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-align: right;
}

.column.group .member-name {
  font-size: 12px;
  font-weight: 500;
}

.column.group .member-class {
  width: 18px;
  height: 18px;
}

.member:active {
  cursor: grabbing;
}

.member.dragging {
  opacity: 0.4;
}

.member-name {
  font-size: 14px;
  font-weight: 600;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-class {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
  pointer-events: none;
}

.add-member {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.add-member input,
.add-member select,
.add-member button {
  font: inherit;
}

.add-member input,
.add-member select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line-strong);
  background: var(--bg-raised);
  color: var(--text);
}

.add-member button,
.add-group {
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: #2a3140;
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}

.add-member button:hover,
.add-group:hover {
  background: #364056;
}

.add-group {
  width: 40px;
  min-width: 40px;
  height: 40px;
  border-radius: 999px;
  align-self: flex-start;
  margin-top: 10px;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #11141b;
  border: 1px solid var(--line-strong);
  flex-shrink: 0;
}

.dialog-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.dialog-backdrop[hidden] {
  display: none;
}

.dialog {
  width: min(320px, calc(100% - 32px));
  padding: 20px 18px 16px;
  border-radius: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--line-strong);
  color: var(--text);
}

.dialog p {
  margin: 0 0 16px;
  font-size: 16px;
  font-weight: 650;
  text-align: center;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.dialog-actions button {
  min-width: 88px;
  height: 36px;
  border-radius: 8px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}

.dialog-yes {
  border: 0;
  background: var(--danger);
  color: #fff;
}

.dialog-no {
  border: 1px solid var(--line-strong);
  background: #2a3140;
  color: var(--text);
}

@media (max-width: 800px) {
  body {
    padding: 16px;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }

  .class-stats-bar {
    grid-template-columns: 1fr;
  }
}
