:root {
  --primary: #1e3a5f;
  --primary-light: #2c5282;
  --accent: #d69e2e;
  --accent-hover: #b7791f;
  --success: #38a169;
  --warning: #d69e2e;
  --danger: #e53e3e;
  --info: #3182ce;
  --bg: #f7fafc;
  --card: #ffffff;
  --text: #2d3748;
  --text-light: #718096;
  --border: #e2e8f0;
  --sidebar-width: 260px;
  --header-height: 64px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(30,58,95,0.9) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(44,82,130,0.8) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(20,40,70,0.95) 0%, rgba(10,25,50,1) 100%),
    linear-gradient(135deg, #1e3a5f 0%, #0d1b2a 100%);
  z-index: 0;
}

.login-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, transparent, transparent 48px, rgba(255,255,255,0.03) 48px, rgba(255,255,255,0.03) 49px),
    repeating-linear-gradient(0deg, transparent, transparent 48px, rgba(255,255,255,0.03) 48px, rgba(255,255,255,0.03) 49px);
}

.login-box {
  position: relative;
  z-index: 1;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 2.5rem;
  border-radius: 16px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.35);
  width: 100%;
  max-width: 420px;
  border: 1px solid rgba(255,255,255,0.2);
}

.login-logo {
  text-align: center;
  font-size: 3rem;
  margin-bottom: 0.5rem;
}

.login-box h1 {
  color: var(--primary);
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
  text-align: center;
}

.login-box .subtitle {
  color: var(--text-light);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
  text-align: center;
}

.login-footer {
  margin-top: 1.25rem;
  text-align: center;
}

.login-footer a {
  color: var(--primary);
  font-size: 0.85rem;
  text-decoration: none;
}

.login-footer a:hover {
  text-decoration: underline;
}

.login-footer .demo-accounts {
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--text-light);
  text-align: left;
  background: var(--bg);
  padding: 0.75rem;
  border-radius: 8px;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
  color: var(--text);
}

.form-control {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(30, 58, 95, 0.1);
}

select.form-control {
  appearance: auto;
}

textarea.form-control {
  min-height: 80px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}

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

.btn-primary:hover { background: var(--primary-light); }

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

.btn-accent:hover { background: var(--accent-hover); }

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

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

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

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

/* Layout */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--primary);
  color: white;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.2s;
}

.sidebar-brand {
  padding: 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h2 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.sidebar-brand small {
  opacity: 0.7;
  font-size: 0.75rem;
}

.sidebar-user {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  font-size: 0.85rem;
}

.sidebar-user .grade {
  display: inline-block;
  background: var(--accent);
  color: var(--primary);
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  margin-top: 0.25rem;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  color: rgba(255,255,255,0.85);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: rgba(255,255,255,0.08);
  color: white;
  border-left-color: var(--accent);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer a {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.85rem;
}

.sidebar-footer a:hover { color: white; }

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.topbar {
  height: var(--header-height);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--primary);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.page-content {
  padding: 1.5rem;
  flex: 1;
}

/* Cards */
.card {
  background: var(--card);
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}

.card-body {
  padding: 1.25rem;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--card);
  border-radius: 10px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: 700;
}

.stat-icon.blue { background: #ebf8ff; color: var(--info); }
.stat-icon.green { background: #f0fff4; color: var(--success); }
.stat-icon.amber { background: #fffaf0; color: var(--warning); }
.stat-icon.red { background: #fff5f5; color: var(--danger); }
.stat-icon.purple { background: #faf5ff; color: #805ad5; }
.stat-icon.teal { background: #e6fffa; color: #319795; }

.stat-info .label {
  font-size: 0.8rem;
  color: var(--text-light);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.stat-info .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

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

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--bg);
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-light);
}

.data-table tr:hover td {
  background: #f7fafc;
}

.data-table .actions {
  display: flex;
  gap: 0.4rem;
}

/* Badges */
.badge {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-green { background: #c6f6d5; color: #22543d; }
.badge-yellow { background: #fefcbf; color: #744210; }
.badge-red { background: #fed7d7; color: #742a2a; }
.badge-blue { background: #bee3f8; color: #2a4365; }
.badge-gray { background: #e2e8f0; color: #2d3748; }

/* Alerts */
.alert {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-success { background: #f0fff4; color: #22543d; border: 1px solid #9ae6b4; }
.alert-danger { background: #fff5f5; color: #742a2a; border: 1px solid #fc8181; }
.alert-warning { background: #fffaf0; color: #744210; border: 1px solid #fbd38d; }

/* Grid layouts */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.col { flex: 1; min-width: 280px; }
.col-6 { flex: 1 1 calc(50% - 0.625rem); min-width: 300px; }
.col-4 { flex: 1 1 calc(33.333% - 0.833rem); min-width: 260px; }
.col-8 { flex: 1 1 calc(66.666% - 0.417rem); min-width: 260px; }
.col-3 { flex: 1 1 calc(25% - 0.9375rem); min-width: 200px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
}

.tab-btn {
  padding: 0.6rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Mobile menu toggle */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--primary);
}

/* Charts placeholder */
.chart-container {
  position: relative;
  height: 280px;
  width: 100%;
}

/* Search & Filters */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  align-items: end;
}

.filter-bar .form-group {
  margin-bottom: 0;
  flex: 1;
  min-width: 180px;
}

/* Print / Export */
@media print {
  .sidebar, .topbar, .btn, .actions { display: none !important; }
  .main-content { margin-left: 0; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* Responsive */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar {
    transform: translateX(-100%);
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .col-6, .col-4, .col-8, .col-3 { flex: 1 1 100%; }
}

/* Scoring Module */
.scoring-grid { display: flex; flex-direction: column; gap: 0.5rem; }
.end-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: nowrap; padding: 0.75rem; min-height: 70px; background: var(--bg); border-radius: 6px; border: 1px solid var(--border); }
.end-label { font-weight: 600; font-size: 1rem; min-width: 80px; white-space: nowrap; color: var(--primary); }
.arrow-cell { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; }
.arrow-cell select { width: 56px; padding: 0.25rem; font-size: 0.85rem; border-radius: 4px; border: 1px solid var(--border); }
.arrow-cell input[type="text"] { width: 56px; padding: 0.2rem; font-size: 0.75rem; border-radius: 4px; border: 1px solid var(--border); }
.arrow-cell .plot-btn { width: 56px; padding: 0.2rem; font-size: 0.7rem; background: var(--info); color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.arrow-cell .plot-btn.plotted { background: var(--success); }
.end-subtotal { font-weight: 700; font-size: 0.9rem; margin-left: auto; color: var(--primary); min-width: 40px; text-align: right; }
.target-canvas-wrap { position: relative; display: inline-block; }
.target-canvas { border-radius: 50%; background: #fff; border: 2px solid var(--border); cursor: crosshair; }
.stat-box { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; text-align: center; flex: 1; min-width: 120px; }
.stat-box .stat-value { font-size: 1.5rem; font-weight: 700; color: var(--primary); }
.stat-box .stat-label { font-size: 0.8rem; color: var(--text-light); margin-top: 0.25rem; }
.zone-bar { display: flex; height: 24px; border-radius: 4px; overflow: hidden; font-size: 0.7rem; }
.zone-bar span { display: flex; align-items: center; justify-content: center; color: #fff; }
.zone-gold { background: #ffd700; color: #333 !important; }
.zone-red { background: #e53e3e; }
.zone-blue { background: #3182ce; }
.zone-black { background: #2d3748; }
.zone-white { background: #e2e8f0; color: #333 !important; }
.zone-miss { background: #a0aec0; }
.tendency-arrow { font-size: 1.2rem; }
.arrow-score-cell { flex: 1 1 0; min-width: 50px; min-height: 50px; max-width: 70px; width: auto; height: auto; aspect-ratio: 1 / 1; display: flex; align-items: center; justify-content: center; border-radius: 8px; border: 2px solid var(--border); font-weight: 700; font-size: 1rem; cursor: pointer; background: var(--bg); color: var(--text); transition: all 0.15s; box-sizing: border-box; position: relative; }
.arrow-score-cell.line-breaker::after { content: '*'; position: absolute; top: 1px; right: 4px; font-size: 0.75rem; font-weight: 700; color: #000; line-height: 1; }
.line-breaker-cell { position: relative; }
.line-breaker-cell::after { content: '*'; position: absolute; top: 0; right: 3px; font-size: 0.65rem; font-weight: 700; color: #000; line-height: 1; }
.arrow-score-cell:hover { transform: scale(1.1); border-color: var(--primary); }
.arrow-score-cell.active-cell { box-shadow: 0 0 0 3px var(--accent); border-color: var(--accent); }
.score-gold { background: #fbbf24 !important; color: #744210 !important; border-color: #d69e2e; }
.score-red { background: #ef4444 !important; color: #fff !important; border-color: #c53030; }
.score-blue { background: #3b82f6 !important; color: #fff !important; border-color: #2563eb; }
.score-black { background: #2d3748 !important; color: #fff !important; border-color: #1a202c; }
.score-white { background: #e2e8f0 !important; color: #2d3748 !important; border-color: #cbd5e0; }
.score-miss { background: #a0aec0 !important; color: #fff !important; border-color: #718096; font-style: italic; }
#targetWrap { position: relative; display: inline-block; }
.target-canvas-wrap { position: relative; display: inline-block; max-width: 100%; }
.target-canvas-wrap > img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; border-radius: 50%; z-index: 0; object-fit: cover; }
.target-canvas-wrap > canvas { position: relative; z-index: 1; max-width: 100%; }
.analysis-panel { background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; }
.analysis-panel h5 { margin-bottom: 0.75rem; color: var(--primary); }
.score-ring-X { color: #d69e2e; font-weight: 700; }
.score-ring-10 { color: #d69e2e; font-weight: 700; }
.score-ring-9, .score-ring-8 { color: #e53e3e; font-weight: 600; }
.score-ring-7, .score-ring-6 { color: #3182ce; font-weight: 600; }
.score-ring-M { color: #a0aec0; font-style: italic; }

/* Scoring predictions & analysis */
.prediction-banner { background: linear-gradient(90deg, #1e3a5f 0%, #2c5282 100%); color: #fff; border-radius: 8px; padding: 0.75rem 1rem; margin-bottom: 1rem; display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: center; }
.prediction-banner .pred-item { display: flex; flex-direction: column; align-items: center; min-width: 80px; }
.prediction-banner .pred-value { font-size: 1.3rem; font-weight: 700; }
.prediction-banner .pred-label { font-size: 0.75rem; opacity: 0.85; }

.analysis-card { background: var(--bg); border-radius: 6px; padding: 0.75rem; margin-bottom: 0.5rem; border-left: 4px solid var(--accent); }
.analysis-card h6 { margin: 0 0 0.25rem 0; font-size: 0.85rem; color: var(--primary); }
.analysis-card p { margin: 0; font-size: 0.9rem; }

.analysis-hints { background: #f0fff4; border: 1px solid #c6f6d5; border-radius: 6px; padding: 0.75rem; }
.analysis-hints ul { margin: 0.3rem 0 0 1.2rem; padding: 0; }
.analysis-hints li { font-size: 0.9rem; margin-bottom: 0.3rem; }

/* In-progress session card */
.session-card { background: var(--card); border: 2px dashed var(--accent); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.75rem; }
.session-card .session-info { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.session-card .session-meta { font-size: 0.85rem; color: var(--text-light); }

/* End row score sorting highlight */
.end-row.sort-gold { border-color: #d69e2e; background: #fffbeb; }
.end-row.sort-red { border-color: #e53e3e; background: #fef2f2; }

/* Mobile wizard steps */
.wizard-step { display: block; }
@media (max-width: 768px) {
  .wizard-step { display: none; }
  .wizard-step.active { display: block; }
}
.wizard-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; gap: 0.5rem; }
.wizard-progress { display: flex; gap: 0.5rem; justify-content: center; margin-bottom: 1rem; }
.wizard-progress .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.wizard-progress .dot.active { background: var(--primary); }

/* Round tabs */
.round-tabs { display: flex; gap: 0.5rem; margin-bottom: 0.75rem; border-bottom: 2px solid var(--border); }
.round-tab { padding: 0.5rem 1rem; background: none; border: none; border-bottom: 2px solid transparent; cursor: pointer; font-weight: 600; color: var(--text-light); }
.round-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Manual total section */
.manual-total-section { background: var(--bg); border: 2px dashed var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.manual-total-section .total-mismatch { color: var(--danger); font-size: 0.9rem; margin-top: 0.5rem; }
.scoring-mode-badge { display: inline-block; padding: 0.25rem 0.5rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600; }
.scoring-mode-badge.arrow { background: #dbeafe; color: #1e40af; }
.scoring-mode-badge.manual { background: #fef3c7; color: #92400e; }
.scoring-mode-badge.mixed { background: #fee2e2; color: #991b1b; }

/* Graph filters */
.graph-filters { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 0.75rem; align-items: center; }
.graph-filters select { font-size: 0.85rem; padding: 0.25rem 0.5rem; }

/* End summary stats */
.end-wrapper { background: var(--bg); border-radius: 6px; border: 1px solid var(--border); margin-bottom: 0.5rem; overflow: visible; }
.end-wrapper .end-row { border: none; background: none; margin-bottom: 0; }
.end-summary { display: flex; gap: 0.75rem; flex-wrap: wrap; font-size: 0.85rem; padding: 0 0.5rem 0.5rem; }
.end-summary .es-item { display: flex; align-items: center; gap: 0.25rem; }
.end-summary .es-value { font-weight: 700; color: var(--primary); }

/* Mobile-only / mobile-flex utilities */
.mobile-only, .mobile-flex { display: none !important; }
@media (max-width: 768px) {
  .mobile-only { display: block !important; }
  .mobile-flex { display: flex !important; }
}
@media (min-width: 769px) {
  #roundTabs { display: none !important; }
}

/* Required field indicator */
.required-label::after { content: ' *'; color: var(--danger); font-weight: 700; }

/* Validation banner */
.validation-banner { background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; border-radius: 6px; padding: 0.75rem 1rem; margin-bottom: 1rem; font-size: 0.9rem; }

/* ===== Arrow Entry Layout ===== */
.scoring-entry-layout { display: flex; gap: 1.5rem; align-items: flex-start; }
.scoring-entry-grid { flex: 1 1 60%; min-width: 0; overflow-x: auto; padding: 0.25rem; }
.scoring-entry-target { flex: 1 1 40%; min-width: 360px; text-align: center; }
.scoring-entry-target .target-canvas-wrap canvas { width: 100%; max-width: 600px; height: auto; aspect-ratio: 1 / 1; display: block; margin: 0 auto; }
.scoring-entry-grid .scoring-grid { max-height: none; }
.active-arrow-display { font-size: 1.1rem; font-weight: 600; margin-bottom: 0.75rem; color: var(--primary); }
.end-subtotal::before { content: 'T:'; font-size: 0.85rem; margin-right: 3px; opacity: 0.8; }

/* Desktop ≥1024px */
@media (min-width: 1024px) {
  .arrow-score-cell { min-width: 50px; min-height: 50px; max-width: 70px; font-size: 1.05rem; }
  .end-label { font-size: 1rem; min-width: 90px; white-space: nowrap; }
  .end-row { gap: 0.75rem; padding: 0.75rem; min-height: 70px; }
}

/* Large desktop ≥1280px */
@media (min-width: 1280px) {
  .scoring-entry-target { min-width: 450px; }
  .arrow-score-cell { min-width: 55px; min-height: 55px; max-width: 70px; font-size: 1.1rem; }
  .end-label { font-size: 1.05rem; min-width: 100px; white-space: nowrap; }
  .end-row { min-height: 75px; }
}

/* Extra-large desktop ≥1440px */
@media (min-width: 1440px) {
  .scoring-entry-target { min-width: 500px; }
  .arrow-score-cell { min-width: 60px; min-height: 60px; max-width: 75px; font-size: 1.15rem; }
  .end-row { min-height: 80px; }
}

/* Tablet (768px–1023px) */
@media (max-width: 1023px) and (min-width: 768px) {
  .scoring-entry-grid { flex: 1 1 55%; }
  .scoring-entry-target { flex: 1 1 45%; min-width: 300px; }
  .scoring-entry-target .target-canvas-wrap canvas { max-width: 400px; }
  .arrow-score-cell { min-width: 40px; min-height: 40px; max-width: 55px; font-size: 0.95rem; }
  .end-label { font-size: 0.9rem; min-width: 70px; }
  .end-row { gap: 0.5rem; padding: 0.5rem; min-height: 55px; }
}

/* Mobile (≤767px) */
@media (max-width: 767px) {
  .scoring-entry-layout { flex-direction: column; gap: 0.75rem; }
  .scoring-entry-grid { flex: 1 1 auto; order: 2; }
  .scoring-entry-target { flex: 1 1 auto; order: 1; position: sticky; top: 0; z-index: 10; background: var(--card); padding: 0.5rem 0; min-width: auto; }
  .scoring-entry-target .target-canvas-wrap canvas { max-width: 320px; }
  .active-arrow-display { font-size: 0.9rem; margin-bottom: 0.5rem; }
  .arrow-score-cell { flex: 0 0 28px !important; min-width: 28px !important; max-width: 28px !important; width: 28px !important; height: 28px !important; font-size: 0.75rem !important; border-width: 1px !important; }
  .arrow-score-cell.line-breaker::after { font-size: 0.55rem !important; top: 0 !important; right: 2px !important; }
  .end-row { flex-wrap: wrap !important; gap: 0.25rem !important; padding: 0.3rem !important; min-height: auto !important; }
  .end-label { font-size: 0.72rem !important; min-width: auto !important; }
  .end-label-full { display: none !important; }
  .end-label-compact { display: inline !important; }
  .end-subtotal { font-size: 0.72rem !important; min-width: auto !important; margin-left: auto; white-space: nowrap; }
  .end-subtotal::before { font-size: 0.65rem; }
  .end-summary { display: none !important; }
  .end-wrapper { margin-bottom: 0.35rem !important; }
}
@media (min-width: 768px) {
  .end-label-compact { display: none !important; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .page-content { padding: 1rem; }
  .login-box { padding: 1.5rem; margin: 1rem; }
}

/* ========== NUTRITION DASHBOARD ========== */
.nutrition-dashboard {
  background: #050B14;
  color: #E8EDF5;
  padding: 1.5rem;
  border-radius: 12px;
  min-height: calc(100vh - var(--header-height, 64px) - 2rem);
}
.nutrition-dashboard h1,
.nutrition-dashboard h2,
.nutrition-dashboard h3,
.nutrition-dashboard h4 {
  color: #E8EDF5;
  margin-bottom: 0.75rem;
}
.nutrition-dashboard .nd-muted { color: #8B9CB5; }
.nutrition-dashboard .nd-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}
.nutrition-dashboard .nd-card {
  background: #111D32;
  border: 1px solid #1A2A44;
  border-radius: 12px;
  padding: 1.25rem;
}
.nutrition-dashboard .nd-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  border-bottom: 1px solid #1A2A44;
  padding-bottom: 0.75rem;
}
.nutrition-dashboard .nd-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #E8EDF5;
  margin: 0;
}
.nutrition-dashboard .nd-input,
.nutrition-dashboard .nd-select,
.nutrition-dashboard .nd-textarea {
  background: #0B1628;
  border: 1px solid #1A2A44;
  color: #E8EDF5;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  width: 100%;
}
.nutrition-dashboard .nd-input:focus,
.nutrition-dashboard .nd-select:focus,
.nutrition-dashboard .nd-textarea:focus {
  outline: none;
  border-color: #00D4FF;
}
.nutrition-dashboard .nd-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: opacity 0.15s;
}
.nutrition-dashboard .nd-btn:hover { opacity: 0.9; }
.nutrition-dashboard .nd-btn-primary { background: #00D4FF; color: #050B14; font-weight: 600; }
.nutrition-dashboard .nd-btn-success { background: #00E676; color: #050B14; font-weight: 600; }
.nutrition-dashboard .nd-btn-danger { background: #FF5252; color: #fff; }
.nutrition-dashboard .nd-btn-sm { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
.nutrition-dashboard .nd-ring-wrap {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto;
}
.nutrition-dashboard .nd-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.nutrition-dashboard .nd-ring-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #00E676;
}
.nutrition-dashboard .nd-ring-label {
  font-size: 0.75rem;
  color: #8B9CB5;
  text-transform: uppercase;
}
.nutrition-dashboard .nd-gauge {
  height: 12px;
  background: #0B1628;
  border-radius: 6px;
  overflow: hidden;
  margin-top: 0.5rem;
}
.nutrition-dashboard .nd-gauge-fill {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, #00D4FF, #00E676);
  transition: width 0.5s ease;
}
.nutrition-dashboard .nd-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}
.nutrition-dashboard .nd-metric-label { color: #8B9CB5; font-size: 0.9rem; }
.nutrition-dashboard .nd-metric-value { font-weight: 700; color: #E8EDF5; }
.nutrition-dashboard .nd-progress {
  height: 8px;
  background: #0B1628;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.nutrition-dashboard .nd-progress-fill {
  height: 100%;
  border-radius: 4px;
  background: #00E676;
}
.nutrition-dashboard .nd-progress-fill.carbs { background: #FFC107; }
.nutrition-dashboard .nd-progress-fill.protein { background: #00D4FF; }
.nutrition-dashboard .nd-progress-fill.fat { background: #FF5252; }
.nutrition-dashboard .nd-micro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.75rem;
}
.nutrition-dashboard .nd-micro {
  background: #0B1628;
  border: 1px solid #1A2A44;
  border-radius: 10px;
  padding: 0.9rem 0.5rem;
  text-align: center;
}
.nutrition-dashboard .nd-micro-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: #E8EDF5;
}
.nutrition-dashboard .nd-micro-unit {
  font-size: 0.7rem;
  color: #8B9CB5;
}
.nutrition-dashboard .nd-micro-status {
  display: inline-block;
  margin-top: 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 12px;
  text-transform: uppercase;
}
.nutrition-dashboard .nd-micro-status.ok { background: rgba(0,230,118,0.15); color: #00E676; }
.nutrition-dashboard .nd-micro-status.low { background: rgba(255,193,7,0.15); color: #FFC107; }
.nutrition-dashboard .nd-micro-status.high { background: rgba(255,82,82,0.15); color: #FF5252; }
.nutrition-dashboard .nd-micro-status.missing { background: rgba(139,156,181,0.15); color: #8B9CB5; }
.nutrition-dashboard .nd-check {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0;
  color: #E8EDF5;
  font-size: 0.92rem;
}
.nutrition-dashboard .nd-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: #00E676;
}
.nutrition-dashboard .nd-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}
.nutrition-dashboard .nd-form-group label {
  display: block;
  font-size: 0.8rem;
  color: #8B9CB5;
  margin-bottom: 0.3rem;
}
.nutrition-dashboard .nd-supplement {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0;
  border-bottom: 1px solid #1A2A44;
}
.nutrition-dashboard .nd-supplement:last-child { border-bottom: none; }
.nutrition-dashboard .nd-supplement-name { font-weight: 600; }
.nutrition-dashboard .nd-supplement-meta { font-size: 0.8rem; color: #8B9CB5; }
.nutrition-dashboard .nd-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.nutrition-dashboard .nd-table th,
.nutrition-dashboard .nd-table td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid #1A2A44;
  color: #E8EDF5;
}
.nutrition-dashboard .nd-table th { color: #8B9CB5; font-weight: 500; }
.nutrition-dashboard .nd-chart-wrap {
  position: relative;
  height: 260px;
}
.nutrition-dashboard .nd-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.nutrition-dashboard .nd-date-picker {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.nutrition-dashboard .nd-date-picker input {
  background: #111D32;
  border: 1px solid #1A2A44;
  color: #E8EDF5;
  border-radius: 8px;
  padding: 0.45rem 0.7rem;
}
@media (max-width: 767px) {
  .nutrition-dashboard { padding: 1rem; }
  .nutrition-dashboard .nd-topbar { flex-direction: column; align-items: flex-start; }
  .nutrition-dashboard .nd-grid { grid-template-columns: 1fr; }
  .nutrition-dashboard .nd-form-grid { grid-template-columns: 1fr 1fr; }
  .nutrition-dashboard .nd-chart-wrap { height: 220px; }
}
@media (max-width: 480px) {
  .nutrition-dashboard .nd-form-grid { grid-template-columns: 1fr; }
}

/* ========== COACH ID CARD ========== */
.coach-id-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1.5rem;
  align-items: start;
}
.coach-id-preview-panel {
  position: sticky;
  top: 80px;
}
.coach-id-card {
  width: 85.6mm;
  height: 53.98mm;
  background: linear-gradient(135deg, #1e3a5f 0%, #0d1b2a 100%);
  border-radius: 3.18mm;
  color: #fff;
  padding: 4mm;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.coach-id-card::before {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}
.coach-id-card::after {
  content: '';
  position: absolute;
  bottom: -20px;
  left: -20px;
  width: 90px;
  height: 90px;
  background: rgba(214,158,46,0.12);
  border-radius: 50%;
}
.coach-id-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1;
}
.coach-id-title {
  font-size: 3.2mm;
  font-weight: 800;
  letter-spacing: 0.5mm;
  color: #d69e2e;
}
.coach-id-body {
  display: flex;
  gap: 3mm;
  align-items: center;
  z-index: 1;
  flex: 1;
  min-height: 0;
}
.coach-id-photo {
  width: 18mm;
  height: 22mm;
  object-fit: cover;
  border-radius: 1.5mm;
  border: 1px solid rgba(255,255,255,0.3);
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
}
.coach-id-photo-placeholder {
  width: 18mm;
  height: 22mm;
  border-radius: 1.5mm;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 8mm;
  flex-shrink: 0;
}
.coach-id-details {
  flex: 1;
  min-width: 0;
}
.coach-id-name {
  font-size: 3.6mm;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 1mm;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.coach-id-role {
  font-size: 2.6mm;
  color: #e2e8f0;
  margin-bottom: 1.5mm;
}
.coach-id-groups {
  display: flex;
  gap: 1mm;
  flex-wrap: wrap;
  margin-bottom: 1.5mm;
}
.coach-id-group {
  font-size: 2mm;
  padding: 0.6mm 1.2mm;
  border-radius: 1mm;
  background: rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.7);
}
.coach-id-group.active {
  background: #d69e2e;
  color: #050B14;
  font-weight: 700;
}
.coach-id-footer {
  display: flex;
  justify-content: space-between;
  font-size: 1.8mm;
  color: rgba(255,255,255,0.75);
  z-index: 1;
  padding-right: 20mm;
}
.coach-id-validity {
  color: #00E676;
  font-weight: 700;
}
.coach-id-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
}
.coach-id-qr {
  position: absolute;
  bottom: 3mm;
  right: 3mm;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.coach-id-logo {
  max-width: 14mm;
  max-height: 8mm;
  object-fit: contain;
  margin-bottom: 0.5mm;
}
.coach-id-qr img:last-child {
  width: 16mm;
  height: 16mm;
}
@media (max-width: 991px) {
  .coach-id-layout { grid-template-columns: 1fr; }
  .coach-id-preview-panel { position: static; }
}
.coach-id-print-only { display: none; }
@media print {
  body * { visibility: hidden; }
  .coach-id-print-only,
  .coach-id-print-only * { visibility: visible; }
  .coach-id-print-only {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    padding: 0;
  }
  .coach-id-print-only .coach-id-card {
    box-shadow: none;
    border: 1px solid #ccc;
    page-break-inside: avoid;
  }
}
@page {
  margin: 0;
  size: auto;
}

/* ========== ATHLETE LICENSE ID CARD ========== */
.license-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, auto);
  gap: 1.5rem;
  align-items: start;
}
.license-form-col .form-group {
  margin-bottom: 1rem;
}
.license-preview-panel {
  position: sticky;
  top: 80px;
}
.license-card {
  width: 85.6mm;
  height: 53.98mm;
  background: linear-gradient(135deg, #ffffff 0%, #f7fafc 100%);
  border: 1px solid #1e3a5f;
  border-radius: 3.18mm;
  color: #1e3a5f;
  padding: 3mm;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.license-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 55mm;
  height: 55mm;
  background: radial-gradient(circle at top right, rgba(30,58,95,0.08) 0%, transparent 60%);
}
.license-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1;
  border-bottom: 0.5mm solid #1e3a5f;
  padding-bottom: 1mm;
  margin-bottom: 1mm;
}
.license-card-title {
  font-size: 3mm;
  font-weight: 800;
  letter-spacing: 0.3mm;
  color: #1e3a5f;
}
.license-card-maf {
  font-size: 2.2mm;
  font-weight: 700;
  color: #d69e2e;
}
.license-card-body {
  display: flex;
  gap: 2mm;
  align-items: flex-start;
  z-index: 1;
  flex: 1;
  min-height: 0;
}
.license-card-photo {
  width: 16mm;
  height: 20mm;
  object-fit: cover;
  border-radius: 1.5mm;
  border: 0.5mm solid #1e3a5f;
  background: #e2e8f0;
  flex-shrink: 0;
}
.license-card-photo-placeholder {
  width: 16mm;
  height: 20mm;
  border-radius: 1.5mm;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7mm;
  flex-shrink: 0;
}
.license-card-details {
  flex: 1;
  min-width: 0;
  font-size: 2mm;
  line-height: 1.35;
}
.license-card-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  padding-left: 2mm;
  flex-shrink: 0;
}
.license-card-logo {
  max-width: 16mm;
  max-height: 9mm;
  object-fit: contain;
  margin-bottom: 1mm;
}
.license-card-qr img:last-child {
  width: 18mm;
  height: 18mm;
}
.license-card-name {
  font-size: 3mm;
  font-weight: 700;
  color: #1e3a5f;
  line-height: 1.2;
  margin-bottom: 0.5mm;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.license-card-row {
  display: flex;
  gap: 1mm;
}
.license-card-label {
  font-weight: 700;
  color: #1e3a5f;
  white-space: nowrap;
}
.license-card-value {
  color: #2d3748;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.license-card-badge {
  display: inline-block;
  font-size: 1.6mm;
  font-weight: 700;
  padding: 0.4mm 1mm;
  border-radius: 1mm;
  background: #d69e2e;
  color: #fff;
  margin-top: 0.5mm;
}
.license-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.6mm;
  color: #4a5568;
  z-index: 1;
  border-top: 0.5mm solid #e2e8f0;
  padding-top: 1mm;
}
.license-card-valid {
  color: #38a169;
  font-weight: 700;
}
.license-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.license-sheet-page {
  width: 210mm;
  min-height: 297mm;
  padding: 5mm 6mm;
  box-sizing: border-box;
  background: #fff;
  display: grid;
  grid-template-columns: 85.6mm 85.6mm;
  grid-template-rows: repeat(5, 53.98mm);
  gap: 3mm 6mm;
  justify-content: center;
  align-content: start;
  page-break-after: always;
}
.license-sheet-page:last-child {
  page-break-after: auto;
}
.license-print-controls {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.license-print-sheet {
  display: none;
}
@media (max-width: 991px) {
  .license-layout { grid-template-columns: 1fr; }
  .license-preview-panel { position: static; }
}
@media print {
  body * { visibility: hidden; }
  .license-print-sheet,
  .license-print-sheet * { visibility: visible; }
  .license-print-sheet {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    padding: 0;
  }
  .license-sheet-page {
    page-break-after: always;
    box-shadow: none;
    padding: 8mm 6mm;
  }
  .license-print-controls,
  .license-actions,
  .app-layout,
  .sidebar,
  .topbar { display: none !important; }
}
@page {
  size: A4 portrait;
  margin: 0;
}
