:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-soft: #f0f5f6;
  --ink: #1d252c;
  --muted: #62727d;
  --line: #dce3e7;
  --orange: #ec7a2d;
  --orange-soft: #fff1e8;
  --teal: #2b9b91;
  --blue: #2686c9;
  --green: #2f8f55;
  --deep-green: #1f6d45;
  --deep-blue: #1f4f89;
  --red: #a83c39;
  --purple: #8056b4;
  --danger: #c54242;
  --success: #2c8a51;
  --shadow: 0 18px 50px rgba(29, 37, 44, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(43, 155, 145, 0.12), transparent 28rem),
    linear-gradient(180deg, #f8fafb 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden],
.is-hidden {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(100%, 520px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand-row,
.topbar,
.session-tools,
.user-pill,
.section-header,
.section-actions,
.card-title-row,
.inline-actions,
.form-grid,
.admin-strip,
.reward-layout,
.score-row,
.setting-row {
  display: flex;
  align-items: center;
}

.brand-row {
  gap: 16px;
  margin-bottom: 24px;
}

.home-mark {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  overflow: hidden;
}

.home-mark::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 13px;
  width: 30px;
  height: 26px;
  background: #fff;
  clip-path: polygon(50% 0, 100% 42%, 100% 100%, 0 100%, 0 42%);
}

.home-mark span {
  position: absolute;
  bottom: 12px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  z-index: 1;
}

.home-mark span:nth-child(1) {
  left: 18px;
}

.home-mark span:nth-child(2) {
  left: 28px;
  background: var(--teal);
}

.home-mark span:nth-child(3) {
  left: 38px;
  background: var(--blue);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 4vw, 2.25rem);
  line-height: 1.05;
}

h2 {
  margin-bottom: 8px;
  font-size: 1.38rem;
}

h3 {
  margin-bottom: 8px;
  font-size: 1rem;
}

.access-form,
.stack {
  display: grid;
  gap: 16px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 700;
}

.field input,
.field textarea,
.field select,
.compact-input,
.compact-select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

.field textarea {
  min-height: 112px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus,
.field select:focus,
.compact-input:focus,
.compact-select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(43, 155, 145, 0.14);
}

.activation-card {
  border: 1px solid rgba(236, 122, 45, 0.38);
  background: var(--orange-soft);
  border-radius: 8px;
  padding: 16px;
}

.activation-card p {
  margin: 6px 0 14px;
  color: #6b4a31;
}

.primary-button,
.secondary-button,
.danger-button,
.ghost-button,
.icon-button {
  border: 1px solid transparent;
  border-radius: 8px;
  min-height: 42px;
  font-weight: 800;
}

.primary-button {
  background: var(--teal);
  color: #fff;
  padding: 0 18px;
}

.primary-button:hover {
  background: #227e77;
}

.secondary-button {
  background: var(--ink);
  color: #fff;
  padding: 0 16px;
}

.ghost-button {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
  padding: 0 14px;
}

.danger-button {
  background: var(--danger);
  color: #fff;
  padding: 0 16px;
}

.compact-danger-button {
  min-height: 36px;
  padding: 0 12px;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.icon-button:hover,
.ghost-button:hover {
  border-color: var(--teal);
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-weight: 700;
}

.form-message.is-ok {
  color: var(--success);
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  padding: 22px clamp(16px, 4vw, 42px);
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.session-tools {
  justify-content: flex-end;
  gap: 12px;
}

.user-pill {
  min-width: 0;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px 7px 7px;
  background: var(--panel-soft);
}

.sync-status {
  display: grid;
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  min-width: 158px;
}

.sync-status strong {
  font-size: 0.88rem;
}

.sync-status small {
  color: var(--muted);
  font-weight: 750;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-status.is-online {
  border-color: rgba(44, 138, 81, 0.3);
  background: rgba(44, 138, 81, 0.08);
}

.sync-status.is-online strong {
  color: var(--success);
}

.sync-status.is-offline {
  border-color: rgba(197, 66, 66, 0.32);
  background: rgba(197, 66, 66, 0.08);
}

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

.user-pill small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.user-initial {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--orange);
  color: #fff;
  font-weight: 900;
}

.tab-nav {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px clamp(16px, 4vw, 42px);
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.tab-nav button {
  flex: 0 0 auto;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  padding: 0 13px;
  font-weight: 850;
}

.tab-nav button[aria-selected="true"] {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.content-area {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

.section-header {
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 18px;
}

.section-header p {
  margin-bottom: 0;
  max-width: 760px;
  color: var(--muted);
  line-height: 1.55;
}

.panel,
.tool-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.panel {
  padding: 22px;
}

.tool-panel {
  padding: 18px;
}

.notice-text {
  margin: 0;
  white-space: pre-wrap;
  color: var(--ink);
  line-height: 1.65;
  font-size: 1.03rem;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 420px);
  gap: 18px;
  align-items: start;
}

.form-grid {
  align-items: stretch;
  gap: 12px;
  flex-wrap: wrap;
}

.form-grid .field {
  flex: 1 1 180px;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}

.check-label,
.switch-label {
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--ink);
  font-weight: 750;
}

.poll-list {
  display: grid;
  gap: 12px;
}

.poll-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.poll-card.is-voted {
  border-color: rgba(236, 122, 45, 0.72);
  background: var(--orange-soft);
}

.poll-main {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 92px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 18px;
  text-align: left;
}

.poll-main:hover {
  background: rgba(43, 155, 145, 0.07);
}

.card-title-row {
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
}

.time-chip {
  color: var(--orange);
  font-weight: 900;
}

.poll-detail,
.vote-meta,
.muted {
  color: var(--muted);
}

.poll-detail {
  margin: 0;
  line-height: 1.45;
}

.vote-meta {
  margin: 8px 0 0;
  font-weight: 750;
}

.vote-check {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  color: transparent;
  font-weight: 900;
}

.is-voted .vote-check {
  border-color: var(--orange);
  background: var(--orange);
  color: #fff;
}

.poll-admin {
  border-top: 1px solid var(--line);
  background: rgba(246, 247, 249, 0.72);
  padding: 12px 18px;
}

.admin-strip {
  gap: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
}

.poll-tools-row {
  align-items: flex-start;
}

.compact-check-grid {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}

.edit-panel {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.edit-panel summary {
  cursor: pointer;
  color: var(--ink);
  font-weight: 900;
}

.poll-edit-form {
  margin-top: 12px;
}

.section-actions,
.table-actions,
.mini-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.sync-panel {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid rgba(44, 138, 81, 0.24);
  border-radius: 8px;
  background: rgba(44, 138, 81, 0.08);
  color: var(--ink);
  padding: 12px 14px;
  margin-bottom: 14px;
}

.sync-panel.is-warning {
  border-color: rgba(236, 122, 45, 0.38);
  background: var(--orange-soft);
}

.assigned-label {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(44, 138, 81, 0.12);
  color: var(--success);
  font-weight: 850;
}

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

.agenda-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 14px;
}

.agenda-toolbar .field {
  min-width: min(100%, 260px);
}

.schedule-people-field {
  flex: 1 1 420px;
}

.agenda-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  max-height: 72vh;
}

.agenda-table {
  width: 100%;
  min-width: 1180px;
  border-collapse: collapse;
}

.agenda-table th,
.agenda-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 8px;
  vertical-align: top;
}

.agenda-table thead th,
.agenda-table tbody th {
  position: sticky;
  background: var(--panel-soft);
  z-index: 1;
}

.agenda-table thead th {
  top: 0;
  text-align: left;
}

.agenda-table tbody th {
  left: 0;
  width: 74px;
  color: var(--muted);
  font-size: 0.86rem;
}

.agenda-input {
  width: 100%;
  min-height: 54px;
  border: 1px solid transparent;
  border-radius: 8px;
  resize: vertical;
  padding: 8px;
  color: var(--ink);
  background: #fff;
}

.agenda-input:focus {
  border-color: var(--teal);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(43, 155, 145, 0.14);
}

.agenda-note {
  min-height: 28px;
  color: var(--ink);
  white-space: pre-wrap;
}

.agenda-matches {
  display: grid;
  gap: 5px;
  margin-top: 6px;
}

.agenda-match-chip {
  display: inline-flex;
  width: fit-content;
  border-radius: 8px;
  background: var(--orange-soft);
  color: #8c4516;
  padding: 4px 7px;
  font-size: 0.78rem;
  font-weight: 900;
}

.routine-card {
  min-height: 180px;
}

.routine-card p {
  margin-bottom: 0;
  white-space: pre-wrap;
  line-height: 1.65;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.logistics-table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

.logistics-table th,
.logistics-table td {
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  padding: 10px;
  vertical-align: middle;
}

.logistics-table th:last-child,
.logistics-table td:last-child {
  border-right: 0;
}

.logistics-table tr:last-child td {
  border-bottom: 0;
}

.logistics-table thead th {
  background: var(--panel-soft);
  text-align: left;
  font-size: 0.88rem;
}

.row-label {
  width: 170px;
  background: #fff;
  font-weight: 850;
}

.day-title {
  display: block;
  color: var(--ink);
}

.day-date {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 2px;
}

.cell-value {
  display: inline-block;
  min-height: 22px;
  font-weight: 900;
}

.cell-select {
  width: 100%;
  min-width: 128px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 9px;
  font-weight: 900;
}

.whole-day-select {
  width: 100%;
  min-width: 128px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 7px;
  font-size: 0.78rem;
  font-weight: 850;
}

.custom-cell-form {
  display: grid;
  gap: 7px;
  min-width: 170px;
}

.custom-cell-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px;
  color: var(--purple);
  font-weight: 900;
}

.mini-button {
  min-height: 30px;
  border: 1px solid var(--teal);
  border-radius: 8px;
  background: var(--teal);
  color: #fff;
  padding: 0 9px;
  font-weight: 850;
}

.ghost-mini {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}

.table-actions {
  margin-top: 14px;
}

.share-panel {
  margin-top: 14px;
  display: grid;
  gap: 12px;
  justify-items: start;
}

.share-panel img {
  width: min(100%, 760px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.permission-grid {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) 72px 72px;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}

.permission-grid input {
  justify-self: center;
}

.download-link {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.cell-albert {
  color: var(--green);
}

.cell-marc {
  color: var(--blue);
}

.cell-sandra {
  color: var(--deep-green);
}

.cell-conxita {
  color: var(--deep-blue);
}

.cell-dinar {
  color: var(--red);
}

.cell-festa,
.cell-custom {
  color: var(--purple);
}

.reward-layout {
  align-items: flex-start;
  gap: 18px;
}

.reward-layout > * {
  flex: 1 1 0;
}

.scoreboard,
.reward-catalog,
.match-list,
.print-list {
  display: grid;
  gap: 10px;
}

.score-row,
.catalog-row,
.match-card,
.print-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.match-card {
  grid-template-columns: minmax(96px, auto) 1fr auto;
}

.match-card.is-attending {
  border-color: rgba(43, 155, 145, 0.5);
  background: rgba(43, 155, 145, 0.08);
}

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

.print-card h3 {
  margin: 8px 0 4px;
}

.color-list {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.color-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.color-swatch {
  width: 22px;
  height: 22px;
  display: inline-block;
  flex: 0 0 22px;
  border: 1px solid var(--line);
  border-radius: 50%;
  vertical-align: middle;
}

.color-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 5px 0 0;
}

.color-form {
  align-items: end;
}

.fcbq-candidates {
  margin-bottom: 14px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 8px;
  padding: 0 9px;
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 900;
  font-size: 0.82rem;
}

.status-pending {
  background: var(--orange-soft);
  color: #8c4516;
}

.status-printing {
  background: rgba(38, 134, 201, 0.12);
  color: var(--blue);
}

.status-done {
  background: rgba(44, 138, 81, 0.12);
  color: var(--success);
}

.status-select {
  min-width: 132px;
}

.match-date {
  display: grid;
  gap: 4px;
  min-width: 96px;
  border-radius: 8px;
  background: var(--panel-soft);
  padding: 10px;
}

.match-date strong {
  color: var(--ink);
}

.match-date span {
  color: var(--orange);
  font-weight: 900;
}

.match-main h3 {
  margin-bottom: 4px;
}

.source-chip {
  display: inline-flex;
  width: fit-content;
  min-height: 26px;
  align-items: center;
  border-radius: 8px;
  background: rgba(38, 134, 201, 0.12);
  color: var(--blue);
  padding: 0 8px;
  font-size: 0.76rem;
  font-weight: 900;
  margin-bottom: 6px;
}

.match-main p {
  margin-bottom: 0;
}

.match-notes {
  margin-top: 8px;
  color: var(--ink);
  line-height: 1.45;
}

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

.score-badge,
.catalog-points {
  display: grid;
  place-items: center;
  min-width: 44px;
  min-height: 34px;
  border-radius: 8px;
  background: var(--panel-soft);
  color: var(--ink);
  font-weight: 900;
}

.person-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--teal);
}

.reward-toggle {
  margin-top: 14px;
}

.settings-extra-panel {
  margin-top: 18px;
}

.setting-row {
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.setting-row:last-child {
  border-bottom: 0;
}

@media (max-width: 860px) {
  .topbar,
  .section-header,
  .reward-layout,
  .agenda-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .session-tools {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .section-actions {
    justify-content: flex-start;
  }

  .split-grid,
  .schedule-grid {
    grid-template-columns: 1fr;
  }

  .tab-nav {
    position: sticky;
    top: 0;
    z-index: 5;
  }
}

@media (max-width: 560px) {
  body {
    background: var(--bg);
  }

  .login-view {
    padding: 14px;
  }

  .login-card,
  .panel,
  .tool-panel {
    padding: 16px;
  }

  .topbar {
    padding: 16px 12px;
  }

  .topbar h1 {
    font-size: 1.45rem;
  }

  .sync-status,
  .user-pill {
    flex: 1 1 170px;
  }

  .sync-status {
    min-width: 0;
  }

  .content-area {
    width: min(100% - 16px, 1180px);
    padding-top: 18px;
  }

  .tab-nav {
    gap: 6px;
    padding: 10px 8px;
  }

  .tab-nav button {
    min-height: 38px;
    padding: 0 11px;
  }

  .poll-main {
    grid-template-columns: 1fr;
  }

  .vote-check {
    justify-self: start;
  }

  .form-grid {
    display: grid;
  }

  .score-row,
  .catalog-row,
  .match-card,
  .print-card {
    grid-template-columns: 1fr;
  }

  .match-date {
    min-width: 0;
  }

  .section-actions > *,
  .table-actions > *,
  .primary-button,
  .secondary-button,
  .danger-button,
  .ghost-button {
    width: 100%;
  }

  .icon-button {
    width: 40px;
  }

  .permission-grid {
    grid-template-columns: minmax(92px, 1fr) 62px 62px;
  }

  .logistics-table {
    min-width: 760px;
  }

  .agenda-table {
    min-width: 980px;
  }
}
