@font-face {
  font-family: 'YearHandicrafts';
  src: url('/fonts/TheYearofHandicrafts-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'YearHandicrafts';
  src: url('/fonts/TheYearofHandicrafts-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'YearHandicrafts';
  src: url('/fonts/TheYearofHandicrafts-SemiBold.otf') format('opentype');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'YearHandicrafts';
  src: url('/fonts/TheYearofHandicrafts-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'YearHandicrafts';
  src: url('/fonts/TheYearofHandicrafts-Black.otf') format('opentype');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

/* =========================================================
   Design tokens — "Mobbin" system: gallery-white monochrome,
   shadow-free tint-ladder elevation, stadium-pill controls.
   One accent color (electric blue) reserved for rare emphasis.
   Auto-switches to a polarity-inverted dark companion via
   prefers-color-scheme — the doc itself only specifies light,
   the dark tokens here extend it with the same "ink fill +
   on-ink text" inversion the doc uses for its footer.
   ========================================================= */
:root {
  color-scheme: light dark;

  --canvas: #ffffff;
  --canvas-soft: #f3f3f3;
  --field: #f0f0f0;
  --hairline-soft: #f0f0f0;
  --hairline: #e0e0e0;

  --ink: #141414;
  --ink-soft: #262626;
  --on-ink: #ffffff;
  --muted: #707070;
  --faint: #adadad;

  --accent: #0066ff;

  --success: #2f8f5b;
  --warning: #b3760a;
  --danger: #c1362c;

  --radius-sm: 16px;
  --radius: 24px;
  --radius-full: 9999px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --canvas: #121212;
    --canvas-soft: #1e1e1e;
    --field: #242424;
    --hairline-soft: #242424;
    --hairline: #333333;

    --ink: #f2f2f2;
    --ink-soft: #cfcfcf;
    --on-ink: #141414;
    --muted: #9a9a9a;
    --faint: #6b6b6b;

    --accent: #3d8bff;

    --success: #4ade80;
    --warning: #fbbf24;
    --danger: #f87171;
  }
}

* { box-sizing: border-box; }

html { background: var(--canvas); }

body {
  margin: 0;
  font-family: 'YearHandicrafts', "Segoe UI", Tahoma, Arial, sans-serif;
  background: var(--canvas);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden { display: none !important; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--hairline); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ---- Gate (admin-key.html) ---- */
.gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--canvas);
}
.gate-box {
  background: var(--canvas);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius);
  padding: 40px 36px;
  max-width: 380px;
  width: 100%;
  text-align: center;
}
.gate-box h1 { font-size: 1.3rem; margin: 0 0 6px; font-weight: 700; }
.gate-box p { color: var(--muted); margin: 0 0 20px; font-size: .9rem; }
.gate-box input {
  width: 100%;
  padding: 13px 14px;
  margin-bottom: 14px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--ink);
  font-size: .95rem;
  font-family: inherit;
  transition: border-color .15s;
}
.gate-box input:focus {
  outline: none;
  border-color: var(--ink);
}
.gate-box button { width: 100%; padding: 14px; font-size: .95rem; }
.error { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; margin: 10px 0 0; }

.link-btn {
  display: block;
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  padding: 12px 0 0;
  width: 100%;
  text-align: center;
  text-decoration: none;
  transition: color .15s;
}
.link-btn:hover { color: var(--ink); }
.admin-link {
  display: block;
  color: var(--muted);
  font-size: .75rem;
  font-weight: 500;
  text-align: center;
  margin-top: 10px;
}
.admin-link:hover { color: var(--ink); text-decoration: underline; }

/* ---- Photo placeholder — swap for a real image later ---- */
.photo-placeholder {
  position: relative;
  border-radius: var(--radius-sm);
  border: 1.5px dashed var(--hairline);
  background: repeating-linear-gradient(135deg, var(--canvas-soft) 0 12px, transparent 12px 24px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: border-color .2s;
}
.photo-placeholder-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  color: var(--faint);
  font-size: .78rem;
  font-weight: 600;
}
.photo-placeholder-label .icon { font-size: 1.6rem; opacity: .7; }
.photo-placeholder:hover { border-color: var(--muted); }

/* ---- Logo marks ---- */
.brand-logo { height: 34px; width: auto; display: block; }
.gate-logo { height: 72px; width: auto; margin: 0 auto 8px; display: block; }
.hero-logo {
  height: 300px;
  width: auto;
  max-width: 88%;
  animation: float-logo 5s ease-in-out infinite;
}
@keyframes float-logo {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@media (prefers-reduced-motion: reduce) {
  .hero-logo { animation: none; }
}

/* ---- Login page (login-page.html) ---- */
.screen {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Step 1: phone entry */
.screen-dark {
  background: var(--canvas);
  color: var(--ink);
}
.hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  padding: 20px 20px 0;
}
.hero-title {
  margin: 0;
  font-size: clamp(1.5rem, 6vw, 2.2rem);
  font-weight: 700;
  color: var(--ink);
  min-height: 1.3em;
  max-width: 100%;
}
.hero-title::after {
  content: '';
  display: inline-block;
  width: 3px;
  height: .9em;
  margin-inline-start: 4px;
  background: var(--ink);
  vertical-align: -.15em;
  animation: caret-blink 1s step-end infinite;
}
.hero-title.done::after { animation: caret-blink 1s step-end 4; }
@keyframes caret-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
@media (max-width: 420px) {
  .hero-logo { height: 190px; }
}
.sheet {
  color: var(--ink);
  padding: 0 28px 40px;
  text-align: center;
}
.sheet h1 { font-size: 1.3rem; margin: 0 0 6px; font-weight: 700; }
.sheet p { color: var(--muted); margin: 0 0 20px; font-size: .88rem; font-weight: 400; }
.sheet input {
  width: 50%;
  padding: 14px;
  margin-bottom: 14px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--ink);
  font-size: .95rem;
  font-family: inherit;
  text-align: center;
  transition: border-color .15s;
}
.sheet input:focus {
  outline: none;
  border-color: var(--ink);
}
.sheet button[type="submit"] {
  width: 50%;
  padding: 14px;
  font-size: .95rem;
  border-radius: var(--radius-full);
}
.tg-hint { color: var(--muted); font-size: .85rem; margin: 4px 0 14px; }
.tg-link-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin-bottom: 10px;
  border-radius: var(--radius-full);
  background: #229ED9;
  color: #fff;
  font-weight: 600;
  font-size: .95rem;
  text-decoration: none;
  text-align: center;
  transition: filter .15s;
}
.tg-link-btn:hover { filter: brightness(.92); }

/* Step 2: OTP entry */
.screen-light {
  background: var(--canvas);
  color: var(--ink);
  position: relative;
}
.back-btn {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  right: 20px;
  background: var(--canvas);
  border: 1px solid var(--hairline);
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  transition: background .15s;
}
.back-btn:hover { background: var(--canvas-soft); }
.otp-content {
  flex: 1;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 90px 24px 24px;
  text-align: center;
}
.otp-content h1 { font-size: 1.3rem; margin: 0 0 8px; font-weight: 700; }
.otp-content p { color: var(--muted); margin: 0; font-size: .88rem; }
.phone-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 22px 0;
  font-size: .88rem;
}
.phone-row-label { color: var(--muted); }
.phone-row-value { font-weight: 700; }
.change-link {
  background: none;
  border: none;
  color: var(--ink);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.change-link:hover { color: var(--muted); }
.otp-boxes {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 24px 0;
}
.otp-box {
  width: 44px;
  height: 54px;
  text-align: center;
  font-size: 1.4rem;
  font-family: inherit;
  border: 2px solid var(--hairline-soft);
  border-radius: var(--radius-sm);
  background: var(--canvas);
  color: var(--ink);
  transition: border-color .15s;
}
.otp-box:focus {
  outline: none;
  border-color: var(--ink);
}
.resend-row { margin-top: 20px; font-size: .85rem; color: var(--muted); }
.link-inline {
  background: none;
  border: none;
  color: var(--ink);
  font-family: inherit;
  font-size: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-inline:hover:not(:disabled) { color: var(--muted); }
.link-inline:disabled { color: var(--faint); text-decoration: none; cursor: default; }
.submit-fixed {
  width: calc(100% - 48px);
  max-width: 372px;
  margin: 0 auto max(28px, env(safe-area-inset-bottom));
  display: block;
  padding: 15px;
  font-size: .95rem;
  border-radius: var(--radius-full);
}
.submit-fixed:disabled {
  background: var(--field);
  color: var(--faint);
  cursor: default;
}

/* ---- Shell / sidebar layout ---- */
.shell {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--canvas);
  border-left: 1px solid var(--hairline-soft);
  color: var(--muted);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 22px;
}
.brand-name { font-weight: 700; font-size: 1.1rem; color: var(--ink); }

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}
.tab-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  color: var(--muted);
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .9rem;
  font-family: inherit;
  text-align: right;
  transition: background .15s, color .15s;
}
.tab-btn:hover { background: var(--canvas-soft); color: var(--ink); }
.tab-btn.active {
  background: var(--canvas-soft);
  color: var(--ink);
  font-weight: 700;
}
.tab-btn.active::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: var(--radius-full);
  background: var(--ink);
}
.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-icon svg { width: 18px; height: 18px; }

.logout {
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: 1px solid var(--hairline);
  color: var(--muted);
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: .85rem;
  font-family: inherit;
  transition: background .15s, color .15s, border-color .15s;
}
.logout:hover { background: var(--canvas-soft); color: var(--danger); border-color: var(--danger); }

.main-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(22px, env(safe-area-inset-top)) 32px 22px;
  background: var(--canvas);
  border-bottom: 1px solid var(--hairline-soft);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 1.25rem; margin: 0; font-weight: 700; }
.logout-topbar {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-full);
  background: var(--canvas-soft);
  color: var(--ink);
  border: none;
  flex-shrink: 0;
}
.logout-topbar svg { width: 18px; height: 18px; }
.logout-topbar:hover { color: var(--danger); }

main {
  max-width: 1100px;
  width: 100%;
  padding: 28px 32px;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }
.tab-panel.active > * {
  animation: rise-in .4s cubic-bezier(.16,1,.3,1) backwards;
}
.tab-panel.active > *:nth-child(1) { animation-delay: .02s; }
.tab-panel.active > *:nth-child(2) { animation-delay: .07s; }
.tab-panel.active > *:nth-child(3) { animation-delay: .12s; }
.tab-panel.active > *:nth-child(4) { animation-delay: .17s; }
.tab-panel.active > *:nth-child(n+5) { animation-delay: .22s; }
@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .tab-panel.active > * { animation: none !important; }
}

h2 { font-size: 1rem; margin: 24px 0 10px; font-weight: 600; color: var(--muted); }
h2:first-child { margin-top: 0; }
h3 { font-size: .95rem; margin: 20px 0 10px; color: var(--muted); font-weight: 600; }

/* ---- Home / overview tab ---- */
.home-greeting { margin-bottom: 22px; }
.home-greeting h2 {
  font-size: 1.5rem;
  margin: 0 0 4px;
  font-weight: 700;
  color: var(--ink);
}
.home-subtitle { color: var(--muted); font-size: .9rem; margin: 0; font-weight: 400; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 8px;
}
.stat-card { padding: 20px; }
.stat-card-label { color: var(--muted); font-size: .8rem; font-weight: 600; margin-bottom: 8px; }
.stat-card-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stat-card-value.small-text { font-size: 1rem; font-weight: 600; line-height: 1.4; }
.stat-card-unit { font-size: .95rem; font-weight: 600; color: var(--muted); }

/* ---- Cards ---- */
.card {
  background: var(--canvas);
  border: 1px solid var(--hairline-soft);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 18px;
}
.table-card { padding: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }

.hero-stat {
  position: relative;
  border-radius: var(--radius);
  padding: 30px 30px 34px;
  margin-bottom: 18px;
  background: var(--ink);
}
.hero-stat-label {
  font-size: .85rem;
  color: rgba(255,255,255,.62);
  margin-bottom: 10px;
  font-weight: 600;
}
.hero-stat-value {
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--on-ink);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.hero-stat-unit {
  font-size: 1.1rem;
  font-weight: 600;
  color: rgba(255,255,255,.62);
  margin-right: 6px;
}

/* ---- Forms ---- */
.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1 1 150px;
}
.field label {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 600;
}
.inline-form input, .inline-form select {
  padding: 10px 12px;
  border: 2px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--field);
  color: var(--ink);
  font-family: inherit;
  font-size: .88rem;
  transition: border-color .15s;
}
.inline-form input:focus, .inline-form select:focus {
  outline: none;
  border-color: var(--ink);
}

button {
  background: var(--ink);
  color: var(--on-ink);
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.87rem;
  font-family: inherit;
  font-weight: 600;
  transition: background .15s, transform .1s;
}
button:hover { background: var(--ink-soft); }
button:active { transform: scale(.97); }
button.small {
  padding: 7px 14px;
  font-size: 0.78rem;
  background: var(--canvas);
  color: var(--ink);
  border: 1px solid var(--hairline);
  font-weight: 600;
}
button.small:hover { background: var(--canvas-soft); }
button.small + button.small { margin-inline-start: 6px; }
button.small.danger { color: var(--danger); border-color: var(--danger); }
button.small.danger:hover { background: var(--canvas-soft); }

.dinner-admin-card { background: var(--canvas-soft); border-style: dashed; }
.dinner-import-result { color: var(--muted); font-size: .85rem; margin: 10px 0 0; }

.team-cell { display: flex; align-items: center; gap: 8px; }
.team-logo { width: 22px; height: 22px; object-fit: contain; flex-shrink: 0; }

/* Al-Hilal team blue — authentic club color, kept as the one place
   content/brand color is allowed to interrupt the monochrome system. */
.hilal-matches-card { border-color: #1c3f94; }
.home-hilal-card { background: #1c3f94; }
.home-hilal-card .stat-card-label { color: rgba(255,255,255,.7); }
.home-hilal-card .stat-card-value { color: #fff; }

.edit-input {
  width: 100%;
  padding: 7px 9px;
  border: 1.5px solid var(--hairline);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font-family: inherit;
  font-size: .85rem;
  transition: border-color .15s;
}
.edit-input:focus {
  outline: none;
  border-color: var(--ink);
}

/* ---- Tables ---- */
table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
}
th, td {
  text-align: right;
  padding: 13px 16px;
  border-bottom: 1px solid var(--hairline-soft);
  font-size: 0.87rem;
  white-space: nowrap;
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .02em;
  background: var(--canvas-soft);
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .15s; }
tbody tr:hover td { background: var(--canvas-soft); }
tr.clickable { cursor: pointer; }

/* ---- Badges ---- */
.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  background: var(--canvas-soft);
  font-size: .76rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-success { color: var(--success); }
.badge-warning {
  color: var(--warning);
  animation: pulse-badge 2.2s ease-in-out infinite;
}
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}
.badge-danger  { color: var(--danger); }
.badge-neutral { color: var(--muted); }

/* ---- Responsive: fixed bottom tab bar on mobile ---- */
@media (max-width: 860px) {
  .shell { display: block; }
  .sidebar {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    height: auto;
    width: 100%;
    max-width: 100%;
    flex-direction: row;
    align-items: stretch;
    gap: 0;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    border: none;
    border-top: 1px solid var(--hairline-soft);
    border-radius: 0;
    background: var(--canvas);
    overflow-x: auto;
    scrollbar-width: none;
    z-index: 50;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .brand { display: none; }
  .nav { flex-direction: row; flex: 1; gap: 2px; }
  .tab-btn {
    flex: 1 0 auto;
    min-width: 58px;
    flex-direction: column;
    gap: 3px;
    padding: 8px 6px 7px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
  }
  .tab-btn span:last-child {
    display: block;
    font-size: .6rem;
    font-weight: 600;
    white-space: nowrap;
  }
  .tab-btn.active::before { display: none; }
  .logout-sidebar { display: none; }
  .logout-topbar { display: inline-flex; }
  main { padding: 18px; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  .topbar { padding: 16px 18px; }
  .hero-stat-value { font-size: 2.4rem; }
  table { min-width: 480px; }
}
