/* ═══════════════════════════════════════════
   Ethos — Dashboard   style.css
   Brand: #C46D5E  Canvas: #F2F2F5
═══════════════════════════════════════════ */

:root {
  --brand: #C46D5E;
  --brand-h: #b05e50;
  --brand-lt: #fde8e1;
  --canvas: #F2F2F5;
  --surface: #ffffff;
  --border: #e8e8ec;
  --text: #1e1e2e;
  --muted: #9ca3af;
  --radius: 18px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 6px 24px rgba(0, 0, 0, .06);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, .12);
}

/* ── Reset & Base ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--canvas);
  color: var(--text);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.55;
}

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}

::-webkit-scrollbar-thumb {
  background: #d4c4c1;
  border-radius: 99px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* ── Surfaces ── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.overflow-hidden {
  overflow: hidden;
}

/* ══════════════════════════════════
   BUTTONS
══════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 8px 18px;
  font-size: .83rem;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  cursor: pointer;
  transition: background .15s, transform .12s, box-shadow .15s;
  white-space: nowrap;
}

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

.btn:active {
  transform: translateY(0);
}

.btn-brand {
  background: var(--brand);
  color: #fff;
  box-shadow: 0 2px 10px rgba(196, 109, 94, .3);
}

.btn-brand:hover {
  background: var(--brand-h);
  box-shadow: 0 4px 16px rgba(196, 109, 94, .4);
}

.btn-ghost {
  background: #f0f0f3;
  color: #555;
  border: 1.5px solid #e0e0e6;
}

.btn-ghost:hover {
  background: #e6e6ea;
}

.btn-danger {
  background: var(--brand-lt);
  color: var(--brand);
  border: 1px solid #f0c4bc;
  padding: 5px 11px;
  font-size: .75rem;
  border-radius: 8px;
}

.btn-danger:hover {
  background: #f9cec5;
}

.btn-sm {
  padding: 5px 12px;
  font-size: .75rem;
  border-radius: 8px;
}

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 8px;
  transition: background .15s;
  font-size: 1rem;
}

.btn-icon:hover {
  background: #f0f0f0;
}

/* ══════════════════════════════════
   INPUTS
══════════════════════════════════ */
.inp {
  border: 1.5px solid #e0e0e8;
  border-radius: 10px;
  padding: 9px 13px;
  background: #fafafa;
  outline: none;
  width: 100%;
  font-size: .875rem;
  font-family: 'Inter', sans-serif;
  transition: border-color .18s, box-shadow .18s;
  color: var(--text);
}

.inp:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(196, 109, 94, .1);
}

textarea.inp {
  resize: none;
}

input[type="date"].inp {
  color: var(--text);
}

/* ══════════════════════════════════
   HEADER
══════════════════════════════════ */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: 0 1px 8px rgba(0, 0, 0, .04);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-logo {
  height: 52px;
  object-fit: contain;
}

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

.admin-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: .73rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fde8e1, #fcd5cb);
  color: var(--brand);
  border: 1px solid #f0c4bc;
}

/* ══════════════════════════════════
   MAIN LAYOUT
══════════════════════════════════ */
.main-content {
  max-width: 1280px;
  margin: 0 auto;
  padding: 36px 20px 80px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.section-title {
  font-size: 1.0rem;
  font-weight: 800;
  color: var(--text);
}

.section-sub {
  font-size: .73rem;
  color: var(--muted);
  margin-top: 3px;
}

.db-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ══════════════════════════════════
   EVENTS GRID
══════════════════════════════════ */
.events-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

/* ══════════════════════════════════
   PROJECTS GRID
══════════════════════════════════ */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

/* ══════════════════════════════════
   SHARED CARD STYLES (Events + Projects)
══════════════════════════════════ */
.event-card,
.project-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: box-shadow .2s, transform .18s;
  border: 1px solid var(--border);
}

.event-card:hover,
.project-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
}

.card-img-wrap {
  width: 100%;
  height: 180px;
  overflow: hidden;
  background: #f5f3f2;
  flex-shrink: 0;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s ease;
}

.event-card:hover .card-img,
.project-card:hover .card-img {
  transform: scale(1.03);
}

.card-img-placeholder {
  width: 100%;
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fde8e1 0%, #f5e8f8 100%);
  font-size: 3rem;
  flex-shrink: 0;
}

.card-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

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

.card-title {
  font-size: .95rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}

.card-details {
  font-size: .78rem;
  color: #6b7280;
  line-height: 1.65;
}

.card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid #f5f5f7;
}

/* ── Capacity badge ── */
.capacity-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
  border: 1px solid #fcd34d;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Deadline badge ── */
.deadline-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .7rem;
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

.d-urgent {
  background: var(--brand-lt);
  color: var(--brand);
  border: 1px solid #f0c4bc;
}

.d-medium {
  background: #fef9ec;
  color: #b38a1a;
  border: 1px solid #fde68a;
}

.d-ok {
  background: #ecf5f0;
  color: #3a7d5a;
  border: 1px solid #a7f3d0;
}

.deadline-info {
  font-size: .74rem;
  color: var(--muted);
}

.deadline-info strong {
  color: var(--text);
  font-weight: 600;
}

/* ══════════════════════════════════
   EMPTY CARD
══════════════════════════════════ */
.empty-card {
  grid-column: 1 / -1;
  background: var(--surface);
  border-radius: var(--radius);
  border: 2px dashed var(--border);
  padding: 56px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  color: var(--muted);
  font-size: .82rem;
}

.empty-icon {
  font-size: 2.4rem;
  opacity: .45;
}

/* ══════════════════════════════════
   LEADERBOARD
══════════════════════════════════ */
.lb-header {
  padding: 20px 24px 12px;
  border-bottom: 1px solid #f0f0f0;
}

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

/* Workflow steps */
.wf-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wf-step {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: .72rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 99px;
}

.wf-done {
  background: #ecf5f0;
  color: #3a7d5a;
}

.wf-active {
  background: var(--brand);
  color: #fff;
}

.wf-idle {
  background: #f0f0f0;
  color: #aaa;
}

.wf-arrow {
  color: #ccc;
  font-size: .75rem;
}

.lb-table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
  font-size: .83rem;
}

thead tr {
  background: #fafafa;
}

thead th {
  padding: 10px 16px;
  text-align: center;
  font-size: .68rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

thead th:nth-child(2) {
  text-align: left;
}

.th-score {
  color: var(--brand) !important;
}

.lb-row {
  transition: background .15s;
  border-bottom: 1px solid #f8f8f8;
}

.lb-row:hover {
  background: #faf7f6;
}

td {
  padding: 10px 16px;
  text-align: center;
  vertical-align: middle;
}

td:nth-child(2) {
  text-align: left;
}

/* Medals */
.med {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: .72rem;
  font-weight: 700;
}

.med-1 {
  background: #fef3c7;
  color: #92400e;
}

.med-2 {
  background: #f1f5f9;
  color: #475569;
}

.med-3 {
  background: #fde8e1;
  color: #9a3b2a;
}

.med-n {
  background: #f0f0f0;
  color: #6b6b6b;
}

/* Name cell */
.name-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.name-cell:hover .name-text {
  text-decoration: underline;
  text-decoration-color: var(--brand);
}

.name-text {
  font-weight: 600;
  color: var(--text);
}

.name-sub {
  font-size: .68rem;
  color: var(--muted);
  line-height: 1.2;
}

/* Score pill */
.score-pill {
  background: var(--brand);
  color: #fff;
  border-radius: 999px;
  padding: 3px 14px;
  font-size: .8rem;
  font-weight: 700;
  display: inline-block;
}

/* Status badges */
.st-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .7rem;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 99px;
  white-space: nowrap;
}

.st-added {
  background: #f0f0f0;
  color: #888;
}

.st-scored {
  background: #ecf5f0;
  color: #3a7d5a;
}

/* Slash for missing */
.slash {
  color: #d1d1d1;
}

/* Empty table state */
.empty-cell {
  padding: 48px 0 !important;
  color: var(--muted);
}

.empty-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-inner svg {
  opacity: .3;
}

/* ══════════════════════════════════
   PARTICIPANTS GRID
══════════════════════════════════ */
.users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.u-card {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow .18s, transform .15s;
}

.u-card:hover {
  box-shadow: 0 6px 24px rgba(196, 109, 94, .13);
  transform: translateY(-2px);
}

.u-card-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.u-card-name {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
}

.u-card-title {
  font-size: .7rem;
  color: var(--muted);
}

.u-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid #f5f5f5;
}

/* ══════════════════════════════════
   AVATAR
══════════════════════════════════ */
.av {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--brand-lt);
  color: var(--brand);
  font-weight: 700;
  overflow: hidden;
  flex-shrink: 0;
}

.av img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

/* ══════════════════════════════════
   PROFILE PAGE OVERLAY
══════════════════════════════════ */
#profile-page {
  position: fixed;
  inset: 0;
  background: var(--canvas);
  z-index: 200;
  overflow-y: auto;
  display: none;
}

.profile-inner {
  max-width: 520px;
  margin: 0 auto;
  padding: 40px 16px;
}

.profile-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}

.profile-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.profile-name {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
}

.profile-sub {
  font-size: .8rem;
  color: var(--muted);
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.info-block {
  background: #fafafa;
  border-radius: 12px;
  padding: 14px 16px;
}

.info-label {
  font-size: .7rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.info-value {
  font-size: .88rem;
  font-weight: 600;
  color: var(--text);
}

.info-value.accent {
  color: var(--brand);
  font-weight: 700;
}

/* Score bars */
.score-bars {
  margin-top: 4px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.bar-label {
  font-size: .75rem;
  color: #777;
  width: 110px;
  flex-shrink: 0;
}

.bar-track {
  flex: 1;
  background: #f0f0f0;
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
}

.bar-fill {
  height: 7px;
  background: var(--brand);
  border-radius: 999px;
  transition: width .4s ease;
}

.bar-val {
  font-size: .72rem;
  font-weight: 600;
  color: var(--brand);
  width: 24px;
  text-align: right;
}

/* ══════════════════════════════════
   HIDDEN ADMIN BUTTON
══════════════════════════════════ */
.admin-key-btn {
  position: fixed;
  bottom: 18px;
  right: 18px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(200, 200, 210, .2);
  color: rgba(0, 0, 0, .15);
  font-size: .85rem;
  cursor: pointer;
  z-index: 500;
  transition: background .2s, color .2s, transform .15s, box-shadow .2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-key-btn:hover {
  background: rgba(196, 109, 94, .18);
  color: var(--brand);
  transform: scale(1.15);
  box-shadow: 0 4px 16px rgba(196, 109, 94, .25);
}

/* ══════════════════════════════════
   MODALS
══════════════════════════════════ */
.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(15, 15, 25, .32);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-back.hidden {
  display: none;
}

.modal-box {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  margin: 16px;
  padding: 28px;
  animation: fi .22s ease both;
}

.modal-box.wide {
  max-width: 560px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 12px;
}

.modal-title {
  font-size: .95rem;
  font-weight: 800;
  color: var(--text);
}

.modal-sub {
  font-size: .73rem;
  color: var(--muted);
  margin-top: 3px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 24px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-label {
  font-size: .75rem;
  font-weight: 700;
  color: #444;
}

.form-hint {
  font-size: .7rem;
  color: var(--muted);
}

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

.av-upload-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.key-error {
  font-size: .73rem;
  color: var(--brand);
  font-weight: 600;
  margin-top: 4px;
}

/* ══════════════════════════════════
   TOAST
══════════════════════════════════ */
#toast {
  position: fixed;
  bottom: 28px;
  right: 64px;
  z-index: 600;
  display: none;
}

#toast.visible {
  display: block;
}

.toast-inner {
  background: var(--surface);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 3px solid var(--brand);
  animation: fi .2s ease both;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text);
}

/* ══════════════════════════════════
   ANIMATIONS & UTILITIES
══════════════════════════════════ */
.fi {
  animation: fi .25s ease both;
}

@keyframes fi {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hidden {
  display: none !important;
}

.text-muted {
  color: var(--muted);
  font-size: .75rem;
  font-style: italic;
}

@media (max-width: 640px) {
  .main-content {
    padding: 24px 14px 80px;
  }

  .events-grid,
  .projects-grid,
  .users-grid {
    grid-template-columns: 1fr;
  }

  .modal-box {
    padding: 20px;
  }

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