:root {
  --bg: #08111f;
  --bg-soft: #0d1b2f;
  --panel: #ffffff;
  --panel-border: rgba(15, 23, 42, 0.08);
  --text: #0f172a;
  --muted: #64748b;
  --brand: #1d4ed8;
  --brand-2: #0ea5e9;
  --sidebar-text: rgba(255,255,255,0.88);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, Roboto, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(14,165,233,.22), transparent 24%),
    linear-gradient(135deg, #08111f 0%, #10213a 48%, #17345d 100%);
  min-height: 100vh;
}

a { text-decoration: none; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 290px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, rgba(6,14,28,.95), rgba(13,27,47,.92));
  color: var(--sidebar-text);
  border-right: 1px solid rgba(255,255,255,.08);
  padding: 24px 18px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  backdrop-filter: blur(10px);
}

.brand, .login-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  color: white;
  margin-bottom: 22px;
}
.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid;
  place-items: center;
  color: white;
  font-weight: 800;
  letter-spacing: .04em;
  box-shadow: 0 12px 24px rgba(14, 165, 233, .28);
}
.brand-title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.1;
}
.brand-subtitle {
  font-size: .86rem;
  color: rgba(255,255,255,.72);
}
.sidebar-section-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: rgba(255,255,255,.45);
  margin: 22px 10px 8px;
}
.sidebar-nav {
  display: grid;
  gap: 8px;
}
.sidebar-link {
  color: var(--sidebar-text);
  padding: 11px 14px;
  border-radius: 14px;
  transition: .18s ease;
  font-weight: 500;
}
.sidebar-link:hover,
.sidebar-link.active {
  color: white;
  background: rgba(255,255,255,.1);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.sidebar-footer { display: grid; gap: 14px; }
.user-chip {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
}
.user-chip-title { color: white; font-weight: 700; }
.user-chip-subtitle { color: rgba(255,255,255,.65); font-size: .88rem; }

.main-panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 28px 32px 0;
  color: white;
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .72rem;
  color: rgba(255,255,255,.68);
  margin-bottom: 6px;
}
.page-title {
  margin: 0;
  font-size: clamp(1.5rem, 2vw, 2.2rem);
  font-weight: 800;
}
.topbar-badge {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.9);
  white-space: nowrap;
}
.content-area {
  margin: 22px 24px 0;
  padding: 22px;
  border-radius: 28px;
  background: rgba(255,255,255,.96);
  box-shadow: 0 20px 45px rgba(2, 8, 23, .18);
  min-height: calc(100vh - 150px);
}
.app-footer {
  color: rgba(255,255,255,.72);
  padding: 16px 30px 24px;
  font-size: .9rem;
}

.card, .list-group-item, .form-control, .form-select, .alert, .btn, .card-header {
  border-radius: 16px !important;
}
.card {
  border: 1px solid var(--panel-border);
  box-shadow: 0 10px 24px rgba(15, 23, 42, .06);
}
.card-header {
  background: #f8fafc;
  border-bottom: 1px solid rgba(15,23,42,.06);
  font-weight: 700;
}
.list-group-item { border-color: rgba(15,23,42,.06); }
.form-control, .form-select {
  min-height: 46px;
  border-color: rgba(15,23,42,.12);
}
.btn-primary, .btn-dark {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  border: none;
}
.btn-outline-dark, .btn-outline-primary, .btn-outline-secondary {
  border-width: 1px;
}
.table thead th {
  color: #475569;
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.metric-card {
  background: linear-gradient(135deg, #eff6ff, #f8fafc);
  border: 1px solid rgba(29, 78, 216, .1);
}
.metric-label { color: #64748b; font-size: .9rem; }
.metric-value { font-size: 2rem; font-weight: 800; color: #0f172a; }
.section-intro {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.section-intro p { margin: 0; color: var(--muted); }
.empty-state {
  padding: 24px;
  border: 1px dashed rgba(15,23,42,.14);
  border-radius: 18px;
  background: #f8fafc;
  color: var(--muted);
}
.day-nav, .week-nav { display: flex; gap: 10px; flex-wrap: wrap; }
.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-shell > * { width: min(100%, 480px); }
.login-messages { margin-bottom: 18px; }
.login-card {
  background: rgba(255,255,255,.97);
  border-radius: 28px;
  padding: 28px;
  box-shadow: 0 24px 60px rgba(2, 8, 23, .22);
}
.login-card .brand-subtitle { color: #64748b; }

@media (max-width: 991.98px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { padding-bottom: 18px; }
  .topbar { padding: 20px 20px 0; }
  .content-area { margin: 16px; padding: 16px; min-height: auto; }
  .app-footer { padding: 0 20px 20px; }
}

/* ===== Foreign Judge PDF improvements ===== */
.foreign-judge-pdf-card {
  border-radius: 24px;
}

.foreign-judge-pdf-header {
  display: grid;
  grid-template-columns: 140px 1fr 160px;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}

.foreign-judge-pdf-title {
  text-align: center;
}

.foreign-judge-watermark-logo {
  max-width: 110px;
  width: 100%;
  opacity: 0.08;
}

.foreign-judge-main-logo {
  max-width: 130px;
  width: 100%;
  justify-self: end;
}

.foreign-judge-summary-table th,
.foreign-judge-summary-table td {
  padding: 10px 12px;
  vertical-align: middle;
}

.foreign-judge-bottom-grid {
  margin-top: 16px;
}

@media print {
  @page {
    size: A4 portrait;
    margin: 10mm;
  }

  body {
    background: #fff !important;
  }

  .app-shell,
  .main-panel,
  .content-area {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
    min-height: auto !important;
  }

  .topbar,
  .app-footer,
  .sidebar,
  .no-print {
    display: none !important;
  }

  .foreign-judge-pdf-card {
    border: 1px solid rgba(15, 23, 42, 0.08) !important;
    box-shadow: none !important;
    border-radius: 18px !important;
    padding: 14px !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .foreign-judge-pdf-header {
    grid-template-columns: 110px 1fr 120px;
    gap: 12px;
    margin-bottom: 12px;
  }

  .foreign-judge-pdf-title h1,
  .foreign-judge-pdf-title h2,
  .foreign-judge-pdf-title h3 {
    margin: 0 0 6px 0 !important;
    line-height: 1.1 !important;
  }

  .foreign-judge-pdf-title {
    font-size: 0.95rem;
    line-height: 1.25;
  }

  .foreign-judge-watermark-logo {
    max-width: 90px !important;
    opacity: 0.04 !important;
  }

  .foreign-judge-main-logo {
    max-width: 110px !important;
  }

  .foreign-judge-summary-table {
    font-size: 0.92rem;
    margin-bottom: 12px !important;
  }

  .foreign-judge-summary-table th,
  .foreign-judge-summary-table td {
    padding: 7px 8px !important;
  }

  .foreign-judge-bottom-grid {
    margin-top: 10px !important;
    font-size: 0.95rem;
  }

  .foreign-judge-bottom-grid h3,
  .foreign-judge-bottom-grid h4,
  .foreign-judge-bottom-grid h5 {
    margin-top: 0 !important;
    margin-bottom: 8px !important;
  }

  .foreign-judge-pdf-card p,
  .foreign-judge-pdf-card li,
  .foreign-judge-pdf-card div,
  .foreign-judge-pdf-card span {
    line-height: 1.25;
  }
}
