:root {
  --ink: #152038;
  --ink-soft: #3d4a63;
  --paper: #f4f1ea;
  --paper-2: #ebe6db;
  --panel: rgba(255, 252, 247, 0.88);
  --line: rgba(21, 32, 56, 0.12);
  --gold: #b08d57;
  --gold-deep: #8a6a3a;
  --navy: #1a2744;
  --navy-2: #243556;
  --ok: #2f6b4f;
  --warn: #9a5b1f;
  --danger: #8f2f2f;
  --shadow: 0 18px 50px rgba(16, 24, 40, 0.14);
  --radius: 18px;
  --font-display: "Fraunces", "Times New Roman", serif;
  --font-body: "Manrope", "Segoe UI", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(176, 141, 87, 0.22), transparent 55%),
    radial-gradient(900px 600px at 100% 0%, rgba(36, 53, 86, 0.18), transparent 50%),
    linear-gradient(165deg, #f7f4ee 0%, #e9e4d8 48%, #dde3ec 100%);
  background-attachment: fixed;
  touch-action: manipulation;
  -ms-touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
}

button,
input,
select,
a {
  touch-action: manipulation;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
  mix-blend-mode: soft-light;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 18px 48px;
}

.hidden { display: none !important; }

/* —— Login —— */
.login-shell {
  min-height: calc(100dvh - 40px);
  display: grid;
  place-items: center;
  animation: rise 0.7s var(--ease) both;
}

.login-card {
  width: min(440px, 100%);
  padding: 36px 32px 30px;
  border-radius: 28px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.65);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.brand {
  text-align: center;
  margin-bottom: 28px;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.2rem, 7vw, 2.8rem);
  letter-spacing: 0.02em;
  color: var(--navy);
  line-height: 1;
  margin: 0;
}

.brand-sub {
  margin: 10px 0 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--ink-soft);
}

.brand-rule {
  width: 56px;
  height: 2px;
  margin: 16px auto 0;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.lang-switch {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-bottom: 22px;
}

.lang-switch button,
.chip,
.btn,
.band-btn {
  font-family: var(--font-body);
  cursor: pointer;
}

.lang-switch button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  transition: 0.2s var(--ease);
}

.lang-switch button.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.field label {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.field input,
.field select,
.team-form input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input:focus,
.field select:focus,
.team-form input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(176, 141, 87, 0.2);
}

.btn {
  border: none;
  border-radius: 12px;
  padding: 13px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  transition: transform 0.2s var(--ease), box-shadow 0.2s, background 0.2s;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff;
  box-shadow: 0 10px 24px rgba(26, 39, 68, 0.28);
}

.btn-primary:hover { filter: brightness(1.05); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.btn-gold {
  background: linear-gradient(135deg, #c4a06a, var(--gold-deep));
  color: #fff;
}

.btn-danger {
  background: transparent;
  border: 1px solid rgba(143, 47, 47, 0.35);
  color: var(--danger);
}

.hint {
  margin-top: 14px;
  font-size: 0.82rem;
  color: var(--ink-soft);
  text-align: center;
  line-height: 1.4;
}

.demo-banner {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(176, 141, 87, 0.12);
  border: 1px dashed rgba(176, 141, 87, 0.45);
  font-size: 0.78rem;
  color: var(--gold-deep);
  text-align: center;
  line-height: 1.4;
}

.error-text {
  color: var(--danger);
  font-size: 0.85rem;
  margin: 8px 0 0;
  text-align: center;
  min-height: 1.2em;
}

/* —— App chrome —— */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
  animation: rise 0.55s var(--ease) both;
}

.topbar-brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 600;
  color: var(--navy);
}

.topbar-brand p {
  margin: 4px 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  font-size: 0.82rem;
}

.user-pill strong { font-weight: 700; }

.nav-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.nav-tabs button {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 0.85rem;
  font-weight: 650;
  transition: 0.2s var(--ease);
}

.nav-tabs button.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.panel {
  animation: rise 0.5s var(--ease) both;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
  margin-bottom: 16px;
}

.toolbar .field {
  margin: 0;
  min-width: min(260px, 100%);
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.status-chip.draft { background: rgba(154, 91, 31, 0.12); color: var(--warn); }
.status-chip.submitted { background: rgba(47, 107, 79, 0.12); color: var(--ok); }
.status-chip.empty { background: rgba(21, 32, 56, 0.06); color: var(--ink-soft); }

.score-section {
  margin-bottom: 18px;
  padding: 18px 18px 8px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.06);
  backdrop-filter: blur(10px);
}

.score-section h2 {
  margin: 0 0 14px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--navy);
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.score-section h2 span {
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gold-deep);
  letter-spacing: 0.04em;
}

.score-item {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.score-item-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.score-item-title {
  font-weight: 700;
  font-size: 0.95rem;
}

.score-item-max {
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.bands {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.band-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-soft);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 0.75rem;
  font-weight: 650;
  transition: 0.18s var(--ease);
}

.band-btn small {
  display: block;
  margin-top: 2px;
  font-weight: 500;
  opacity: 0.75;
}

.band-btn.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.score-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: #fff;
  user-select: none;
  -webkit-user-select: none;
}

.stepper-btn {
  width: 52px;
  height: 52px;
  border: none;
  background: transparent;
  color: var(--navy);
  font-size: 1.55rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.stepper-btn:active {
  background: rgba(26, 39, 68, 0.08);
}

.stepper-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.stepper-value {
  min-width: 64px;
  padding: 0 8px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
}

.band-hint {
  font-size: 0.75rem;
  color: var(--ink-soft);
  flex: 1;
  min-width: 140px;
}

.footer-bar {
  position: sticky;
  bottom: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(26, 39, 68, 0.92);
  color: #fff;
  box-shadow: 0 16px 40px rgba(16, 24, 40, 0.28);
  backdrop-filter: blur(12px);
}

.footer-bar .total-line {
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.footer-bar .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.footer-bar .btn-ghost {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.28);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: 0.3s var(--ease);
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* —— Chief overview —— */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.06);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

table.data th,
table.data td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

table.data th {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.55);
}

table.data tr:last-child td { border-bottom: none; }

table.data .num {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.rank-badge {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.rank-badge.gold { background: linear-gradient(135deg, #d4b278, #8a6a3a); }
.rank-badge.silver { background: #7b8494; }
.rank-badge.bronze { background: #8d6e54; }

.note {
  margin: 10px 0 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.team-form {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  padding: 16px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.team-form .full { grid-column: 1 / -1; }

.team-list {
  display: grid;
  gap: 10px;
}

.team-card {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.team-card h3 {
  margin: 0;
  font-size: 1rem;
}

.team-card p {
  margin: 4px 0 0;
  font-size: 0.8rem;
  color: var(--ink-soft);
}

.muted { color: var(--ink-soft); }

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  #app { padding: 14px 12px 40px; }
  .login-card { padding: 28px 20px 24px; }
  .footer-bar { bottom: 8px; }
  .band-btn { flex: 1 1 calc(50% - 6px); }
}
