* {
  box-sizing: border-box;
}

:root {
  --bg-0: #070b14;
  --bg-1: #0d1528;
  --bg-2: #111d34;
  --panel: rgba(13, 23, 42, 0.82);
  --panel-strong: rgba(10, 18, 34, 0.94);
  --line: rgba(148, 163, 184, 0.24);
  --line-soft: rgba(148, 163, 184, 0.14);
  --text: #e7eefb;
  --muted: #94a7c5;
  --brand: #22d3ee;
  --brand-2: #f97316;
  --good: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 16px;
  --radius-sm: 11px;
  --shadow: 0 20px 50px rgba(2, 8, 20, 0.45);
}

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

body {
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 80% 8%, #1c3258 0%, transparent 32%),
              radial-gradient(circle at 12% 20%, #11314f 0%, transparent 30%),
              linear-gradient(145deg, var(--bg-0), var(--bg-1) 42%, var(--bg-2));
  overflow-x: hidden;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-family: 'Sora', 'Space Grotesk', sans-serif;
}

p {
  margin: 0;
}

.hidden {
  display: none !important;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.52;
}

.app-root {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.view {
  min-height: 100vh;
}

.muted {
  color: var(--muted);
}

.eyebrow {
  display: inline-flex;
  padding: 0.28rem 0.68rem;
  border-radius: 999px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  color: #a5f3fc;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
}

/* Auth */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: min(1080px, 100%);
  border-radius: 26px;
  background: linear-gradient(125deg, rgba(15, 25, 44, 0.92), rgba(11, 18, 36, 0.92));
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  overflow: hidden;
  animation: rise 0.6s ease;
}

.auth-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
}

.auth-side {
  padding: 2.3rem 2.4rem 2.6rem;
  border-right: 1px solid var(--line-soft);
}

.auth-side h1 {
  margin-top: 0.9rem;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
}

.auth-side p {
  margin-top: 0.9rem;
  color: var(--muted);
  line-height: 1.6;
}

.auth-side ul {
  margin: 1.2rem 0 0;
  padding-left: 1.2rem;
  color: #c5d2ea;
  display: grid;
  gap: 0.5rem;
}

.auth-form {
  padding: 2.3rem 2.2rem;
  display: grid;
  align-content: start;
  gap: 0.95rem;
}

.auth-form h2 {
  font-size: 1.6rem;
}

.code-wrap {
  display: grid;
  gap: 0.75rem;
  padding-top: 0.3rem;
}

.field {
  display: grid;
  gap: 0.34rem;
}

.field span {
  color: var(--muted);
  font-size: 0.86rem;
}

.field input,
.field textarea {
  font: inherit;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.82);
  padding: 0.72rem 0.84rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

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

.field input:focus,
.field textarea:focus {
  border-color: rgba(34, 211, 238, 0.7);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.16);
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0.68rem 0.95rem;
  transition: transform 0.14s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  color: #09232a;
  background: linear-gradient(115deg, #22d3ee, #2dd4bf);
  box-shadow: 0 10px 20px rgba(45, 212, 191, 0.27);
}

.btn-primary:hover {
  box-shadow: 0 12px 26px rgba(45, 212, 191, 0.38);
}

.btn-ghost {
  color: var(--text);
  background: rgba(148, 163, 184, 0.08);
  border-color: var(--line);
}

.btn-ghost:hover {
  border-color: rgba(34, 211, 238, 0.5);
}

.btn-danger {
  color: #fee2e2;
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.45);
}

.file-btn {
  position: relative;
  overflow: hidden;
}

.mini-hint {
  color: var(--muted);
  font-size: 0.76rem;
}

/* Dashboard */
#dashboard-view {
  padding: 1rem 1rem 1.2rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-strong);
  padding: 0.82rem 1rem;
  backdrop-filter: blur(8px);
  animation: rise 0.45s ease;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  color: #04222b;
  background: linear-gradient(135deg, #22d3ee, #f97316);
}

.brand-title {
  font-family: 'Sora', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
}

.brand-sub {
  color: var(--muted);
  font-size: 0.78rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.58rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quick-stats {
  display: flex;
  gap: 0.48rem;
  flex-wrap: wrap;
}

.quick-pill {
  padding: 0.32rem 0.55rem;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.3);
  color: #b8f7ff;
  font-size: 0.72rem;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  border: 1px solid var(--line);
  background: rgba(10, 19, 35, 0.75);
  border-radius: 999px;
  padding: 0.28rem 0.62rem 0.28rem 0.3rem;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #062630;
  background: linear-gradient(120deg, #22d3ee, #f97316);
}

.user-email {
  font-size: 0.82rem;
}

.user-roles {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.layout {
  margin-top: 0.9rem;
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 0.9rem;
}

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

.side-panel {
  padding: 1rem;
  display: grid;
  align-content: start;
  gap: 0.75rem;
  max-height: calc(100vh - 106px);
  overflow: auto;
}

.side-panel h3,
.content-panel h3.section-title {
  font-size: 1rem;
  margin-bottom: 0.3rem;
}

.search-field input {
  width: 100%;
}

.search-list,
.claim-list {
  display: grid;
  gap: 0.45rem;
}

.search-item,
.claim-item {
  width: 100%;
  color: var(--text);
  font: inherit;
  text-align: left;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(10, 18, 34, 0.75);
  padding: 0.6rem 0.72rem;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.2s ease, background 0.2s ease;
}

.search-item:hover,
.claim-item:hover {
  transform: translateY(-1px);
  border-color: rgba(34, 211, 238, 0.38);
  background: rgba(13, 28, 49, 0.82);
}

.search-name {
  font-weight: 600;
}

.search-meta,
.claim-meta {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.25rem;
}

.panel-divider {
  margin: 0.35rem 0;
  border-top: 1px dashed var(--line-soft);
}

.content-panel {
  padding: 1rem;
  overflow: hidden;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 1.4rem;
  color: var(--muted);
  text-align: center;
}

.empty-state h2 {
  color: var(--text);
  margin-bottom: 0.52rem;
}

.participant-shell {
  display: grid;
  gap: 0.85rem;
}

.participant-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
  flex-wrap: wrap;
}

.participant-head h2 {
  font-size: clamp(1.5rem, 3vw, 2.25rem);
}

.claim-box {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(8, 16, 31, 0.75);
  padding: 0.7rem;
  min-width: 260px;
  max-width: 100%;
}

.claim-box h4 {
  margin-bottom: 0.45rem;
  font-size: 0.92rem;
}

.claim-dogs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  margin-bottom: 0.55rem;
}

.claim-chip {
  display: inline-flex;
  gap: 0.3rem;
  align-items: center;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  padding: 0.26rem 0.5rem;
  font-size: 0.74rem;
  background: rgba(10, 20, 36, 0.86);
}

.claim-chip input {
  accent-color: var(--brand);
}

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

.stat-card {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 0.62rem 0.7rem;
  background: rgba(7, 14, 28, 0.8);
}

.stat-card .value {
  font-family: 'Sora', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: #b8f7ff;
}

.stat-card .label {
  color: var(--muted);
  font-size: 0.74rem;
  margin-top: 0.15rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.section-title {
  margin-top: 0.25rem;
}

.dogs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
  gap: 0.6rem;
}

.dog-card {
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  padding: 0.68rem;
  background: rgba(7, 14, 28, 0.8);
  display: grid;
  gap: 0.48rem;
}

.dog-header {
  display: flex;
  align-items: center;
  gap: 0.54rem;
}

.dog-photo {
  width: 58px;
  height: 58px;
  border-radius: 12px;
  object-fit: cover;
  background: rgba(148, 163, 184, 0.22);
  border: 1px solid var(--line-soft);
}

.dog-name {
  font-size: 1rem;
  font-weight: 700;
}

.dog-meta {
  color: var(--muted);
  font-size: 0.76rem;
}

.dog-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.34rem;
}

.badge {
  border-radius: 999px;
  padding: 0.16rem 0.48rem;
  border: 1px solid var(--line-soft);
  font-size: 0.72rem;
}

.badge.good {
  background: rgba(34, 197, 94, 0.16);
  color: #b6f8cb;
  border-color: rgba(34, 197, 94, 0.35);
}

.badge.warn {
  background: rgba(245, 158, 11, 0.16);
  color: #ffe4b0;
  border-color: rgba(245, 158, 11, 0.35);
}

.badge.neutral {
  background: rgba(148, 163, 184, 0.12);
  color: #c7d2e7;
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem;
}

.chart-card {
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  padding: 0.62rem;
  background: rgba(7, 14, 28, 0.8);
  height: 250px;
  display: flex;
  flex-direction: column;
}

.chart-card h4 {
  margin-bottom: 0.42rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.chart-card canvas {
  display: block;
  width: 100% !important;
  flex: 1 1 auto;
  min-height: 0;
}

.chart-card-wide {
  grid-column: 1 / -1;
  height: 290px;
}

.runs-wrap {
  border: 1px solid var(--line-soft);
  border-radius: 13px;
  overflow: auto;
  background: rgba(7, 14, 28, 0.82);
}

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

thead th {
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  text-align: left;
  padding: 0.58rem 0.62rem;
  border-bottom: 1px solid var(--line-soft);
}

tbody td {
  padding: 0.52rem 0.62rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.11);
  vertical-align: top;
  font-size: 0.84rem;
}

tbody tr:hover {
  background: rgba(34, 211, 238, 0.06);
}

.rank-pill {
  width: 28px;
  height: 28px;
  border-radius: 9px;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  background: rgba(148, 163, 184, 0.17);
}

.rank-1 {
  background: rgba(245, 158, 11, 0.22);
  color: #ffd493;
}

.rank-2 {
  background: rgba(148, 163, 184, 0.3);
}

.rank-3 {
  background: rgba(249, 115, 22, 0.22);
  color: #ffd2b6;
}

.bew-pill {
  display: inline-flex;
  border-radius: 999px;
  padding: 0.16rem 0.44rem;
  border: 1px solid var(--line-soft);
  font-size: 0.74rem;
}

.bew-V {
  background: rgba(245, 158, 11, 0.14);
  color: #ffe7bd;
}

.bew-SG {
  background: rgba(34, 211, 238, 0.14);
  color: #b8f7ff;
}

.bew-G {
  background: rgba(34, 197, 94, 0.14);
  color: #b6f8cb;
}

.bew-B,
.bew-NA {
  background: rgba(239, 68, 68, 0.14);
  color: #ffd3d3;
}

.bew-DIS {
  background: rgba(148, 163, 184, 0.12);
  color: #d0d9eb;
}

.notes-btn {
  font-size: 0.75rem;
  padding: 0.3rem 0.52rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(15, 25, 42, 0.85);
  cursor: pointer;
}

.notes-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 1rem;
  background: rgba(4, 9, 20, 0.66);
  backdrop-filter: blur(4px);
  z-index: 20;
}

.modal.open {
  display: grid;
}

.modal-card {
  position: relative;
  width: min(880px, 100%);
  max-height: 92vh;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(8, 15, 30, 0.96);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.modal-close {
  position: absolute;
  top: 0.42rem;
  right: 0.42rem;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(15, 25, 42, 0.8);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}

.modal-header {
  padding-right: 2rem;
  margin-bottom: 0.65rem;
  color: #d6e5ff;
}

.notes-list {
  display: grid;
  gap: 0.56rem;
  margin-bottom: 0.8rem;
}

.note-item {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(13, 24, 42, 0.72);
  padding: 0.65rem;
}

.note-head {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  margin-bottom: 0.32rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.note-role {
  font-size: 0.68rem;
  border-radius: 999px;
  padding: 0.15rem 0.42rem;
  border: 1px solid rgba(34, 211, 238, 0.35);
  color: #b8f7ff;
}

.note-comment {
  white-space: pre-wrap;
  line-height: 1.5;
}

.note-media {
  margin-top: 0.42rem;
  display: grid;
  gap: 0.38rem;
}

.note-media iframe,
.note-media video {
  width: 100%;
  max-width: 520px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
}

.note-media video {
  max-height: 320px;
  background: #000;
}

.note-form {
  display: grid;
  gap: 0.6rem;
  border-top: 1px dashed var(--line-soft);
  padding-top: 0.75rem;
}

#toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 40;
  max-width: min(420px, calc(100% - 2rem));
}

.toast-item {
  margin-top: 0.45rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(7, 14, 28, 0.93);
  padding: 0.7rem 0.82rem;
  box-shadow: var(--shadow);
  animation: toastIn 0.22s ease;
}

.toast-item.error {
  border-color: rgba(239, 68, 68, 0.5);
}

.toast-item.ok {
  border-color: rgba(34, 197, 94, 0.5);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(10px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 1040px) {
  .auth-grid {
    grid-template-columns: 1fr;
  }

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

  .layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    max-height: none;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

  .chart-card-wide {
    grid-column: auto;
  }

  .topbar {
    align-items: start;
    flex-direction: column;
  }

  .topbar-right {
    width: 100%;
    justify-content: flex-start;
  }
}
