:root {
  --bg: #f4f1e8;
  --surface: #fffdf7;
  --surface-strong: #ffffff;
  --ink: #1c2430;
  --muted: #667085;
  --line: #d9d2c3;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --warning: #b54708;
  --ok: #16763b;
  --shadow: 0 18px 40px rgba(28, 36, 48, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.12), transparent 36%),
    linear-gradient(315deg, rgba(180, 35, 24, 0.08), transparent 32%),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  min-height: 40px;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--accent-dark);
}

button.secondary {
  background: #263241;
}

button.secondary:hover {
  background: #111827;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.68;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 22px;
  background: rgba(255, 253, 247, 0.88);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #1c2430;
  color: #f8d05f;
  font-weight: 900;
  font-size: 24px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.05;
}

h2 {
  font-size: 16px;
  margin-bottom: 14px;
}

.brand p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.form-panel {
  display: grid;
  gap: 14px;
}

.meta-form {
  display: grid;
  gap: 12px;
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid #ded6c8;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.62);
}

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  min-height: 40px;
  width: 100%;
  border: 1px solid #c8c0af;
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--ink);
  padding: 0 10px;
}

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

fieldset {
  border: 1px solid #ded6c8;
  border-radius: 7px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0;
  padding: 10px 12px;
}

legend {
  color: #344054;
  font-size: 13px;
  font-weight: 800;
  padding: 0 4px;
}

.check-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.check-label input {
  width: 16px;
  min-height: 16px;
}

.job-status {
  border: 1px solid #ded6c8;
  border-radius: 7px;
  background: #fff;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.job-status strong {
  font-size: 13px;
}

.job-bar {
  height: 8px;
  border-radius: 999px;
  background: #e7dfd2;
  overflow: hidden;
}

.job-bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s ease;
}

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

.job-grid span {
  border: 1px solid #e3dbcf;
  border-radius: 6px;
  color: var(--muted);
  font-size: 11px;
  padding: 7px;
}

.job-grid strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
  margin-top: 2px;
}

.compact {
  margin-top: 14px;
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--warning);
  display: inline-block;
}

.status-dot.ok {
  background: var(--ok);
}

.status-dot.fail {
  background: var(--danger);
}

.workspace {
  padding: 22px;
  min-width: 0;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
  overflow-x: auto;
}

.tab {
  background: transparent;
  color: #394150;
  border-radius: 6px 6px 0 0;
  min-height: 38px;
  white-space: nowrap;
}

.tab:hover,
.tab.active {
  background: #1c2430;
  color: white;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

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

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 24px;
  line-height: 1;
}

.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.match-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.match-list,
.sync-log,
.comp-list {
  display: grid;
  gap: 10px;
}

.empty {
  color: var(--muted);
  font-size: 14px;
}

.player-card,
.match-row,
.comp-row,
.note,
.participant-row {
  border: 1px solid #ded6c8;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 7px;
  padding: 12px;
}

.player-card {
  display: grid;
  gap: 10px;
}

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

.stats-strip span {
  border: 1px solid #e6dfd2;
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  color: var(--muted);
}

.stats-strip strong {
  display: block;
  color: var(--ink);
  font-size: 17px;
  margin-top: 3px;
}

.match-row {
  text-align: left;
  color: var(--ink);
  display: grid;
  grid-template-columns: 54px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 70px;
  background: #fff;
  cursor: pointer;
}

.match-row:hover,
.match-row.active {
  border-color: var(--accent);
  background: #f0fdfa;
}

.placement {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-weight: 900;
  background: #e7f3f1;
  color: var(--accent-dark);
}

.placement.low {
  background: #fff1f0;
  color: var(--danger);
}

.muted {
  color: var(--muted);
  font-size: 13px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.board,
.traits,
.augments,
.notes,
.participants {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(98px, 1fr));
  gap: 10px;
}

.unit {
  border: 1px solid #e0d8c8;
  border-radius: 7px;
  background: #fff;
  min-height: 128px;
  padding: 8px;
}

.unit img,
.entity-chip img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  background: #d7d0c2;
}

.unit-name {
  font-size: 12px;
  font-weight: 800;
  margin-top: 6px;
  min-height: 30px;
}

.stars {
  color: #b7791f;
  font-size: 12px;
}

.items {
  display: flex;
  gap: 4px;
  margin-top: 6px;
  flex-wrap: wrap;
}

.items img {
  width: 22px;
  height: 22px;
}

.chip-list {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
}

.entity-chip {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  border: 1px solid #e0d8c8;
  border-radius: 999px;
  padding: 5px 9px 5px 5px;
  background: #fff;
  font-size: 12px;
  font-weight: 700;
}

.entity-chip img {
  width: 24px;
  height: 24px;
}

.note {
  border-left: 4px solid #98a2b3;
}

.note.alta {
  border-left-color: var(--danger);
}

.note.media {
  border-left-color: var(--warning);
}

.note.positiva {
  border-left-color: var(--ok);
}

.note h3,
.comp-row h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.note p,
.comp-row p {
  margin: 0;
  color: #475467;
  font-size: 13px;
  line-height: 1.45;
}

.comp-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

.comp-stats {
  display: grid;
  grid-template-columns: repeat(4, 76px);
  gap: 6px;
}

.comp-stats span {
  background: #f8f5ed;
  border: 1px solid #e3dbcf;
  border-radius: 6px;
  padding: 7px;
  font-size: 11px;
  color: var(--muted);
}

.comp-stats strong {
  display: block;
  color: var(--ink);
  font-size: 15px;
}

.participant-row {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  gap: 10px;
  align-items: center;
}

.limit-list {
  margin: 0;
  padding-left: 18px;
  color: #475467;
  line-height: 1.6;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  background: #111827;
  color: white;
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: 0.2s ease;
  font-size: 14px;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .app-shell,
  .match-layout,
  .two-column {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

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

  .comp-row {
    grid-template-columns: 1fr;
  }

  .comp-stats {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .workspace,
  .sidebar {
    padding: 14px;
  }

  .tabs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow-x: visible;
    gap: 6px;
    border-bottom: 0;
  }

  .tab {
    border-radius: 6px;
    width: 100%;
  }

  .metric-grid,
  .stats-strip,
  .split,
  .meta-grid,
  .job-grid,
  .comp-stats {
    grid-template-columns: 1fr;
  }

  .match-row,
  .participant-row {
    grid-template-columns: 44px 1fr;
  }
}
