:root {
  color-scheme: light;
  --font-display: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SFMono-Regular", Menlo, Consolas, monospace;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-soft: #f8f8f8;
  --text: #1f1f1f;
  --muted: #666d78;
  --brand: #171717;
  --brand-strong: #0f0f0f;
  --accent: #171717;
  --danger: #b42318;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
}

.container {
  max-width: 1180px;
  margin: 24px auto 36px;
  padding: 0 16px;
}

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

.brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.brand-logo {
  display: block;
  width: clamp(150px, 18vw, 240px);
  max-width: 100%;
  height: auto;
}

.header h1 {
  font-family: Arial, Helvetica, sans-serif;
  text-transform: none;
  letter-spacing: 0;
  line-height: 1.2;
  font-size: clamp(0.88rem, 1.35vw, 1.05rem);
  font-weight: 500;
  color: #000;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h2,
h3,
h4 {
  font-family: var(--font-body);
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  font-weight: 600;
}

h2 {
  font-size: 1.4rem;
}

h3 {
  font-size: 1.15rem;
}

h4 {
  font-size: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid #e3e3e3;
  border-radius: var(--radius-lg);
  padding: 16px;
}

#login-card {
  max-width: 420px;
  margin-inline: auto;
}

.stack {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

label {
  display: grid;
  gap: 6px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
}

label.no-label {
  gap: 0;
}

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

input,
select,
textarea {
  padding: 10px 12px;
  border: 1px solid #d5d7dc;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
}

input::placeholder,
textarea::placeholder {
  color: #99a0ab;
}

input:focus,
select:focus,
textarea:focus,
button:focus {
  outline: 2px solid rgba(23, 23, 23, 0.2);
  outline-offset: 1px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

button {
  padding: 10px 14px;
  border: 1px solid var(--brand);
  border-radius: var(--radius-sm);
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}

button:hover:not(:disabled) {
  background: var(--brand-strong);
}

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

.secondary {
  background: #fff;
  border-color: #d2d5db;
  color: var(--text);
}

.secondary:hover:not(:disabled) {
  background: #f4f4f4;
}

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

.danger:hover:not(:disabled) {
  background: #83170f;
}

.hidden {
  display: none !important;
}

.error {
  margin-top: 10px;
  color: var(--danger);
  font-weight: 600;
}

.row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 10px;
}

.panel {
  margin-top: 6px;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: #fff;
  color: var(--text);
  border: 1px solid #d2d5db;
}

.icon-button:hover:not(:disabled) {
  background: #f4f4f4;
}

.icon-button svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

#matches-index-view,
#match-detail-view {
  display: grid;
  align-content: start;
  gap: 10px;
}

.detail-view-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}

#match-detail-view {
  gap: 6px;
}

#match-detail {
  margin-top: 0;
}

.match-top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.match-heading {
  min-width: 0;
  flex: 1 1 auto;
}

.nav-icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: #fff;
  border: 1px solid #d2d5db;
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-icon-button:hover:not(:disabled) {
  background: #f4f4f4;
}

.nav-icon-button svg,
.icon-only-button svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-only-button {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  border: 1px solid #d2d5db;
  color: #6c737d;
}

.icon-only-button:hover:not(:disabled) {
  background: #f4f4f4;
  color: var(--text);
}

.icon-only-button.danger-icon {
  border-color: #e4d5d5;
  color: #8c5b5b;
}

.icon-only-button.danger-icon:hover:not(:disabled) {
  background: #fff4f4;
  border-color: #dcb8b8;
  color: var(--danger);
}

.inline-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.timeline-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.timeline-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-icon-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #d2d5db;
  background: #fff;
  color: var(--text);
  font-weight: 500;
}

.inline-icon-button:hover:not(:disabled) {
  background: #f4f4f4;
}

.inline-icon-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.inline-danger-button {
  border-color: #e4d5d5;
  color: #8c5b5b;
}

.inline-danger-button:hover:not(:disabled) {
  background: #fff4f4;
  border-color: #dcb8b8;
  color: var(--danger);
}

.inline-link {
  border: 0;
  background: none;
  color: var(--text);
  padding: 0;
  font-weight: 500;
  text-decoration: underline;
}

.inline-link:hover:not(:disabled) {
  background: none;
  color: #000;
}

.match-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 8px;
}

.match-list-item {
  width: 100%;
  text-align: left;
  border: 1px solid #e2e4e8;
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text);
  padding: 10px 11px;
}

.match-list-item:hover:not(:disabled) {
  background: #f7f7f7;
}

.match-list-item.active {
  background: #f2f2f2;
  border-color: #d0d4da;
}

.match-list-main {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
}

.match-list-status {
  font-size: 0.82rem;
  color: var(--muted);
  margin-top: 4px;
}

#match-empty {
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  padding: 16px;
  color: var(--muted);
}

.match-title {
  font-family: var(--font-body);
  font-size: 1.25rem;
  letter-spacing: 0;
  color: var(--text);
  font-weight: 600;
}

.match-summary {
  margin-top: 8px;
}

.match-summary-table {
  width: 70%;
  min-width: 0;
  max-width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #e2e5ea;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}

.match-summary-table td {
  width: 33.3333%;
  padding: 4px 5px;
  border-right: 1px solid #eceef2;
  background: transparent;
  font-size: inherit;
}

.match-summary-table td:last-child {
  border-right: 0;
}

.match-summary-table tbody tr:nth-child(odd) td,
.match-summary-table tbody tr:nth-child(even) td {
  background: transparent;
}

.sync-controls {
  margin-top: 10px;
}

.sync-summary-table {
  width: 100%;
  min-width: 0;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #e2e5ea;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #fff;
}

.sync-summary-table td {
  width: 28%;
  padding: 4px 5px;
  border-right: 1px solid #eceef2;
  background: transparent;
  font-size: inherit;
}

.sync-summary-table td.sync-action-cell {
  width: 44%;
}

.sync-summary-table td:last-child {
  border-right: 0;
}

.sync-summary-table tbody tr:nth-child(odd) td,
.sync-summary-table tbody tr:nth-child(even) td {
  background: transparent;
}

.sync-action-cell {
  vertical-align: middle;
}

.sync-action-cell button {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  font-size: 0.9rem;
  font-weight: 500;
}

.summary-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-icon {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  fill: none;
  stroke: #7a828e;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.summary-content {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.summary-label {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #7a828e;
}

.summary-value {
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.match-status {
  color: var(--muted);
  margin-top: 2px;
  font-weight: 600;
}

.match-status + .match-status {
  margin-top: 2px;
}

.live-timer-shell {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.match-timer {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 260px;
  max-width: 100%;
  padding: 12px 18px;
  font-family: var(--font-mono);
  font-size: clamp(2rem, 4.8vw, 2.7rem);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: #171717;
  background: #ffffff;
  border: 1px solid #d7dbe1;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px #f2f3f5;
}

.top-gap {
  margin-top: 12px;
}

.panel-block {
  margin-top: 12px;
  background: #fafafa;
  border: 1px solid #e6e6e6;
  border-radius: var(--radius-md);
  padding: 12px;
}

.mark-events-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.event-buttons {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.event-buttons-title {
  grid-column: 1 / -1;
  margin: 0 0 2px;
  text-align: center;
  font-size: 0.96rem;
  font-weight: 600;
}

.event-buttons button {
  min-height: 46px;
}

.event-buttons button[data-event-type="Falta"] {
  background: var(--brand);
  border-color: var(--brand);
}

.event-buttons button[data-event-type="Violación"] {
  background: var(--brand);
  border-color: var(--brand);
}

.event-buttons button[data-event-type="Trabajo Equipo"] {
  background: var(--brand);
  border-color: var(--brand);
}

.event-buttons button[data-event-type="Mecánica"] {
  background: var(--brand);
  border-color: var(--brand);
}

.event-buttons button[data-event-type="IRS"] {
  background: #e9510e;
  border-color: #e9510e;
}

#sync-video {
  width: 100%;
  margin-top: 10px;
  border-radius: var(--radius-sm);
  background: #0f131a;
}

.clip-link {
  display: inline-block;
  color: var(--text);
  text-decoration: underline;
  font-weight: 500;
}

.clip-link-button {
  border: 0;
  background: none;
  color: var(--text);
  padding: 0;
  text-decoration: underline;
  font-weight: 500;
}

.clip-link-button:hover:not(:disabled) {
  background: none;
  color: #000;
}

.clip-preview-card {
  width: min(920px, 100%);
}

.clip-preview-video {
  width: 100%;
  max-height: 70vh;
  background: #0f131a;
  border-radius: var(--radius-sm);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
}

.modal-card {
  position: relative;
  width: min(560px, 100%);
  max-height: min(84vh, 780px);
  overflow: auto;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid #e3e3e3;
  padding: 14px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.modal-description {
  margin-top: 8px;
  color: var(--muted);
}

.modal-form {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.modal-fields {
  display: grid;
  gap: 10px;
}

.modal-fields-two-cols {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.modal-fields-two-cols > label {
  grid-column: 1 / -1;
}

.modal-fields-two-cols > label.modal-field-half {
  grid-column: span 1;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
}

.inline-form {
  margin-top: 10px;
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(140px, 1fr) 160px 120px;
  gap: 8px;
}

.table-wrapper {
  overflow: auto;
  margin-top: 10px;
  border-radius: var(--radius-sm);
  background: #fff;
  border: 1px solid #e3e3e3;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}

thead th {
  position: sticky;
  top: 0;
  background: #f2f3f5;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0;
}

th,
td {
  text-align: left;
  padding: 10px 9px;
  font-size: 0.95rem;
  border: 0;
}

tbody tr:nth-child(odd) td {
  background: #ffffff;
}

tbody tr:nth-child(even) td {
  background: #fafafa;
}

td button {
  padding: 6px 10px;
  font-size: 0.86rem;
}

#admin-panel h3 {
  margin-bottom: 8px;
}

@media (max-width: 860px) {
  .container {
    margin-top: 18px;
    padding: 0 12px;
  }

  .brand-logo {
    width: clamp(130px, 42vw, 210px);
  }

  .header h1 {
    font-size: clamp(0.8rem, 3.3vw, 0.98rem);
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  table {
    min-width: 520px;
  }
}

@media (max-width: 620px) {
  .card {
    padding: 14px;
  }

  .match-summary-table,
  .match-summary-table tbody,
  .match-summary-table tr,
  .sync-summary-table,
  .sync-summary-table tbody,
  .sync-summary-table tr {
    display: block;
    width: 100%;
  }

  .match-summary-table td,
  .sync-summary-table td {
    display: block;
    width: 100%;
    border-right: 0;
    border-top: 1px solid #eceef2;
  }

  .match-summary-table td:first-child,
  .sync-summary-table td:first-child {
    border-top: 0;
  }

  .timeline-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .match-timer {
    min-width: 220px;
    font-size: clamp(1.75rem, 10vw, 2.25rem);
  }

  .match-top-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .row {
    align-items: stretch;
  }

  .row button {
    width: 100%;
  }

  .event-buttons {
    grid-template-columns: 1fr;
  }

  .mark-events-header {
    flex-wrap: wrap;
  }

  .modal-fields-two-cols {
    grid-template-columns: 1fr;
  }

  .modal-fields-two-cols > label.modal-field-half {
    grid-column: 1 / -1;
  }

  .modal-card {
    padding: 12px;
  }
}
