:root {
  --green: #087f5b;
  --green2: #0ca678;
  --green-dark: #065f46;
  --green-soft: #e6f5ed;
  --ink: #17231f;
  --muted: #6c7974;
  --bg: #f3f6f4;
  --surface: #f8faf9;
  --line: #e3e9e5;
  --white: #ffffff;
  --orange: #f4a340;
  --orange-soft: #fff0dc;
  --orange-ink: #9c5700;
  --red: #e03131;
  --red-soft: #fff5f5;
  --blue: #1971c2;
  --blue-soft: #e7f5ff;
  --radius-lg: 20px;
  --radius-md: 15px;
  --radius-sm: 10px;
  --shadow-sm: 0 2px 8px rgba(22, 59, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(22, 59, 42, 0.10);
  --shadow-lg: 0 18px 44px rgba(15, 38, 28, 0.18);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

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

button {
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

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

/* App Shell */
.app {
  max-width: 1380px;
  margin: 0 auto;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 256px 1fr;
  background: var(--surface);
  box-shadow: 0 0 40px rgba(15, 38, 28, 0.04);
}

/* Sidebar */
.sidebar {
  background: var(--white);
  border-right: 1px solid var(--line);
  padding: 20px 15px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  padding: 2px 4px;
}

.brand-logo-img {
  height: 44px;
  width: auto;
  display: block;
}

/* Mode Switcher (Parent / Player / Admin) */
.mode {
  padding: 4px;
  background: #edf2ef;
  border-radius: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.mode button {
  border: 0;
  background: transparent;
  padding: 8px 4px;
  border-radius: 9px;
  color: #52615a;
  font-size: 11.5px;
  font-weight: 750;
  text-align: center;
}

.mode button.active {
  background: var(--white);
  color: var(--green);
  box-shadow: var(--shadow-sm);
}

/* Navigation */
.nav-group-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--muted);
  padding: 8px 10px 2px;
}

.nav {
  display: grid;
  gap: 3px;
}

.nav button {
  border: 0;
  background: transparent;
  text-align: left;
  padding: 10px 11px;
  border-radius: 10px;
  color: #56645e;
  display: flex;
  gap: 10px;
  align-items: center;
  font-weight: 650;
  font-size: 12.5px;
  width: 100%;
}

.nav button.active,
.nav button:hover {
  background: #e8f5ef;
  color: var(--green);
}

.nav .ico {
  width: 19px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--green);
  color: var(--white);
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 99px;
}

.nav-badge.orange {
  background: var(--orange);
  color: #211504;
}

.side-note {
  margin-top: auto;
  padding: 13px;
  border-radius: 14px;
  background: #f1f7f3;
  border: 1px solid #dfece4;
  color: #4f6157;
  font-size: 11.5px;
  line-height: 1.48;
}

.side-note-links {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  font-size: 11px;
  font-weight: 700;
}

.side-note-links a {
  color: var(--green);
  cursor: pointer;
  text-decoration: underline;
}

/* Main Content Area */
.main {
  min-width: 0;
  padding: 22px 30px 44px;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.crumb {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.7px;
  color: var(--muted);
  margin-bottom: 4px;
  text-transform: uppercase;
}

.top h1 {
  font-size: 26px;
  letter-spacing: -0.7px;
  margin: 0;
}

.top-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pill {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 11px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 650;
  color: #44524c;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.pill select {
  border: 0;
  background: transparent;
  font-weight: 750;
  color: var(--green);
  cursor: pointer;
  outline: none;
  padding-right: 4px;
}

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

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

.icon-btn {
  position: relative;
  border: 1px solid var(--line);
  background: var(--white);
  width: 38px;
  height: 38px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 16px;
}

.icon-btn:hover {
  border-color: var(--green);
  background: #f3faf6;
}

.notif-count {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--orange);
  color: #1f1400;
  font-size: 10px;
  font-weight: 850;
  min-width: 18px;
  height: 18px;
  border-radius: 99px;
  display: grid;
  place-items: center;
  padding: 0 4px;
  border: 2px solid var(--surface);
}

.avatar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 99px;
  padding: 4px 12px 4px 4px;
  font-size: 12px;
  font-weight: 700;
}

.avatar-btn:hover {
  border-color: var(--green);
}

.avatar {
  height: 30px;
  width: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #d7ebe1;
  color: #087f5b;
  font-weight: 850;
  font-size: 11.5px;
}

/* Content Layout & Hero Banner */
.content {
  display: grid;
  gap: 18px;
}

.welcome {
  background: linear-gradient(118deg, #065540 0%, #087f5b 58%, #0ca678 100%);
  color: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px 26px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 10px 28px rgba(8, 127, 91, 0.16);
}

.welcome > :not(.welcome-art) {
  position: relative;
  z-index: 1;
}

.welcome .welcome-art {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  height: 130%;
  max-height: 210px;
  width: auto;
  max-width: 46%;
  opacity: 0.42;
  pointer-events: none;
  z-index: 0;
}

.welcome h2 {
  font-size: 22px;
  letter-spacing: -0.5px;
  margin: 0 0 7px;
}

.welcome p {
  margin: 0;
  color: #d7f2e7;
  font-size: 13px;
  max-width: 580px;
  line-height: 1.55;
}

.welcome-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Buttons */
.btn {
  border: 1px solid transparent;
  background: var(--green);
  color: var(--white);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 750;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover:not(:disabled) {
  background: var(--green-dark);
}

.btn.white {
  background: var(--white);
  color: var(--green);
}

.btn.white:hover:not(:disabled) {
  background: #f1fbf6;
}

.btn.ghost {
  background: #eaf6f0;
  color: var(--green);
}

.btn.ghost:hover:not(:disabled) {
  background: #d7efe3;
}

.btn.outline {
  background: var(--white);
  border: 1px solid var(--line);
  color: #3e4d46;
}

.btn.outline:hover:not(:disabled) {
  border-color: var(--green);
  color: var(--green);
}

.btn.orange {
  background: var(--orange);
  color: #231602;
}

.btn.danger {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid #ffc9c9;
}

.btn.danger:hover:not(:disabled) {
  background: var(--red);
  color: var(--white);
}

.btn.sm {
  padding: 6px 10px;
  font-size: 11px;
  border-radius: 8px;
}

/* Section Headers, Cards & Grids */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.section-head h2 {
  font-size: 16px;
  letter-spacing: -0.3px;
  margin: 0;
}

.section-head a {
  font-size: 12px;
  color: var(--green);
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
}

.section-head a:hover {
  text-decoration: underline;
}

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

.stat,
.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 18px;
}

.stat {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.stat:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #c5ded1;
}

.stat label {
  display: block;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 650;
  margin-bottom: 8px;
  cursor: pointer;
}

.stat strong {
  font-size: 25px;
  letter-spacing: -0.6px;
  display: block;
}

.stat small {
  display: block;
  color: var(--green);
  font-size: 11px;
  font-weight: 650;
  margin-top: 6px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 16px;
}

.grid2-equal {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.cards3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}

.cards2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.feature {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.feature .symbol {
  height: 38px;
  width: 38px;
  border-radius: 11px;
  background: #e5f4ec;
  display: grid;
  place-items: center;
  font-size: 18px;
  margin-bottom: 11px;
}

.feature b {
  display: block;
  font-size: 13.5px;
  margin-bottom: 5px;
}

.feature p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 12px;
}

/* Lists & Items */
.list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 4px;
  border-bottom: 1px solid #edf1ee;
}

.item:last-child {
  border-bottom: 0;
}

.thumb {
  height: 42px;
  width: 46px;
  border-radius: 11px;
  background: #dfefe7;
  color: var(--green-dark);
  display: grid;
  place-items: center;
  font-size: 19px;
  font-weight: 800;
  flex-shrink: 0;
}

.item-main {
  min-width: 0;
  flex: 1;
}

.item-main b {
  display: block;
  font-size: 13px;
  margin-bottom: 3px;
}

.item-main small {
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.4;
}

/* Tags & Portal Badges */
.tag {
  font-size: 10.5px;
  font-weight: 800;
  background: var(--green-soft);
  color: var(--green);
  padding: 4px 9px;
  border-radius: 99px;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.tag.orange {
  background: var(--orange-soft);
  color: var(--orange-ink);
}

.tag.grey {
  background: #edf0ee;
  color: #536059;
}

.tag.blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.tag.red {
  background: var(--red-soft);
  color: var(--red);
}

.portal-pill {
  font-size: 10px;
  font-weight: 850;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.portal-UTR { background: #e3f2fd; color: #0d47a1; }
.portal-WTN { background: #e8f5e9; color: #1b5e20; }
.portal-ITF { background: #e0f2f1; color: #004d40; }
.portal-TENNIS_EUROPE { background: #fff3e0; color: #e65100; }
.portal-QTF { background: #fce4ec; color: #880e4f; }
.portal-ATF { background: #f3e5f5; color: #4a148c; }

/* Filters & Forms */
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 13px 0;
}

.filters input,
.filters select,
.field input,
.field select,
.field textarea {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--white);
  padding: 9px 11px;
  font-size: 12.5px;
  min-width: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.filters input:focus,
.filters select:focus,
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(8, 127, 91, 0.12);
}

.filters input {
  flex: 1;
  min-width: 170px;
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 12px;
}

.field label {
  font-size: 11px;
  color: var(--muted);
  font-weight: 750;
}

.field input,
.field select,
.field textarea {
  width: 100%;
}

.formrow {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.formrow3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 99px;
  padding: 5px 11px;
  font-size: 11px;
  font-weight: 700;
  color: #4c5a53;
  cursor: pointer;
  user-select: none;
}

.chip.active {
  background: var(--green);
  border-color: var(--green);
  color: var(--white);
}

/* Tables */
.tablewrap {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.table th {
  text-align: left;
  color: var(--muted);
  font-weight: 750;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 11px 8px;
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 12px 8px;
  border-bottom: 1px solid #edf1ee;
  vertical-align: middle;
}

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

/* Player Avatars & Rankings */
.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.person {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #dcebe2;
  color: var(--green-dark);
  display: grid;
  place-items: center;
  font-size: 20px;
  font-weight: 800;
  flex-shrink: 0;
  overflow: hidden;
}

.person.blue {
  background: #e3e9fa;
  color: #1e40af;
}

.person.gold {
  background: #f8e8d1;
  color: #92400e;
}

.rank-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 12px;
}

.rank {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 15px;
  background: var(--white);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.rank small {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
}

.rank strong {
  display: block;
  font-size: 24px;
  letter-spacing: -0.5px;
  margin: 7px 0 4px;
  color: var(--ink);
}

.rank span {
  font-size: 11px;
  color: var(--muted);
}

/* Dropzone for File Ingestion */
.dropzone {
  border: 2px dashed #b9d8c8;
  background: #f5fbf8;
  border-radius: 14px;
  padding: 20px;
  text-align: center;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.dropzone:hover {
  border-color: var(--green);
  background: #ebf7f1;
}

/* Notices & Empty States */
.notice {
  background: #fff8e9;
  border: 1px solid #f5dfb6;
  padding: 12px 14px;
  border-radius: 11px;
  color: #79531d;
  font-size: 11.5px;
  line-height: 1.5;
}

.notice.info {
  background: #edf8f3;
  border-color: #c5e6d6;
  color: #12543d;
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

/* Modal Backdrop & Dialog */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 32, 25, 0.52);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 1000;
}

.modal {
  background: var(--white);
  border-radius: 18px;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 22px;
  animation: modalIn 0.16s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-size: 17px;
}

/* Toast Notification Stack */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1200;
  display: grid;
  gap: 8px;
  max-width: 360px;
}

.toast {
  background: var(--ink);
  color: var(--white);
  padding: 12px 15px;
  border-radius: 12px;
  font-size: 12.5px;
  font-weight: 650;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 4px solid var(--green2);
}

.toast.warn {
  border-left-color: var(--orange);
}

.toast.error {
  border-left-color: var(--red);
}

.hidden {
  display: none !important;
}

/* Responsive Breakpoints */
@media (max-width: 980px) {
  .app {
    display: block;
  }
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    z-index: 50;
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    gap: 10px;
  }
  .sidebar .side-note,
  .nav-group-label {
    display: none;
  }
  .nav {
    display: flex;
    overflow-x: auto;
    gap: 4px;
    padding-bottom: 2px;
  }
  .nav button {
    white-space: nowrap;
    width: auto;
    padding: 8px 10px;
    font-size: 11.5px;
  }
  .main {
    padding: 18px 15px 36px;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .grid2,
  .grid2-equal {
    grid-template-columns: 1fr;
  }
  .cards3 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .cards3,
  .cards2,
  .formrow,
  .formrow3 {
    grid-template-columns: 1fr;
  }
  .welcome {
    flex-direction: column;
    align-items: flex-start;
    padding: 20px;
  }
  .top h1 {
    font-size: 22px;
  }
}
