:root {
  --bg: #f6faff;
  --panel: #ffffff;
  --panel-soft: #f9fcff;
  --line: #dbe7f2;
  --line-strong: #bfd2e4;
  --text: #17324a;
  --muted: #6e8298;
  --primary: #2d7ef7;
  --primary-strong: #1f67d3;
  --accent: #ebf4ff;
  --success: #19925f;
  --warning: #ce8a17;
  --danger: #d94c4c;
  --danger-soft: #fff1f1;
  --info-soft: #edf6ff;
  --shadow: 0 14px 34px rgba(43, 78, 117, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #fbfdff 0%, var(--bg) 100%);
  color: var(--text);
}
a { color: var(--primary-strong); text-decoration: none; }
a:hover { text-decoration: none; }
img { max-width: 100%; display: block; }
iframe { border: 0; }
input, select, textarea, option, optgroup {
  color: var(--text);
  background: #fff;
  color-scheme: light;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 300px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 18px;
  background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  border-right: 1px solid var(--line);
}
.brand-wrap { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.brand-logo {
  width: 54px; height: 54px; border-radius: 16px; overflow: hidden; object-fit: cover;
  border: 1px solid var(--line); background: #fff; box-shadow: var(--shadow);
}
.brand-fallback { display: grid; place-items: center; font-size: 24px; }
.brand { font-size: 20px; font-weight: 800; letter-spacing: 0.01em; }
.user-card {
  padding: 16px; border-radius: 18px; background: var(--panel-soft); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.user-name { font-weight: 800; }
.user-role { color: var(--muted); margin-top: 6px; }
.nav { margin-top: 18px; display: grid; gap: 8px; }
.nav a { display:flex; align-items:center; justify-content:space-between; gap:10px; padding: 12px 14px; border-radius: 12px; color: var(--text); border: 1px solid transparent; font-weight: 700; }
.nav a:hover { background: var(--accent); border-color: #c9dcf6; }
.nav a.active { background: linear-gradient(180deg, #eef5ff 0%, #e7f0ff 100%); border-color: #b8d2f6; color: var(--primary-strong); box-shadow: inset 0 0 0 1px rgba(45,126,247,.08); }
.nav-badge { display:inline-flex; align-items:center; justify-content:center; min-width:20px; height:20px; padding:0 6px; border-radius:999px; background:#ff5b5b; color:#fff; font-size:11px; font-weight:800; }
.main { padding: 26px; }
.main.full { max-width: 1120px; margin: 0 auto; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 28px; }
.pill, .badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 800; border: 1px solid #cbe0ff; background: #eef5ff; color: var(--primary-strong);
}
.badge.success { background: #eefaf4; border-color: #bde7cf; color: var(--success); }
.badge.warning { background: #fff6e8; border-color: #f0dbb6; color: var(--warning); }
.badge.neutral { background: #f3f6fa; border-color: #d8e3ee; color: var(--muted); }
.badge.info { background: #edf6ff; border-color: #cce1ff; color: #2a75d6; }
.badge.danger { background: var(--danger-soft); border-color: #f1c3c3; color: var(--danger); }
.badge.soft, .badge.danger.soft { background: #fff7f7; border-color: #f4d6d6; color: #bf4444; }
.flash { padding: 14px 16px; border-radius: 14px; margin-bottom: 14px; border: 1px solid var(--line); background: #f7fbff; }
.flash.success { border-color: #bde7cf; background: #eefaf4; }
.flash.error { border-color: #f3c1c1; background: #fff2f2; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: 22px; padding: 20px; box-shadow: var(--shadow);
}
.hero-card { background: linear-gradient(180deg, #ffffff 0%, #f5faff 100%); }
.card h2 { margin: 0 0 8px; font-size: 20px; }
.card p { margin: 8px 0 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.compact { gap: 12px; }
.stats-grid { display: grid; gap: 16px; margin-bottom: 18px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stats-grid.three-cols { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat-card {
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%); border: 1px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: var(--shadow);
}
.stat-card span { display: block; color: var(--muted); font-size: 13px; }
.stat-card strong { display: block; margin-top: 8px; font-size: 34px; }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 14px; }
.section-head h2, .section-head h3 { margin: 0; }
.legend-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.header-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end; }
.form-actions { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-top:14px; }
.form-actions form { margin:0; }
.form-actions .btn { min-width:140px; justify-content:center; }
.danger-actions .btn { min-width:140px; }
.recipient-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
.recipient-check span { display:grid; gap:4px; }
.recipient-check small { color: var(--muted); font-size:12px; font-weight:600; }
.file-stack { display:grid; gap:8px; margin-top:10px; }
.file-link { display:inline-flex; align-items:center; gap:8px; padding:10px 12px; border:1px solid var(--line); border-radius:12px; background:#f8fbff; color:var(--text); font-weight:700; }
.file-link:hover { border-color:#bdd5f4; background:#eef5ff; }
.mini-link { color: var(--primary-strong); font-size: 13px; font-weight: 700; }
.list-item, .link-card {
  display: block; border-radius: 18px; border: 1px solid var(--line); background: var(--panel-soft); padding: 14px 16px;
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.list-item:hover, .link-card:hover, .photo-card:hover, .video-card:hover {
  border-color: #bdd5f4; box-shadow: var(--shadow); transform: translateY(-1px);
}
.list-item { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.list-item.vertical { align-items: flex-start; }
.no-link { cursor: default; }
.list-item + .list-item, .comment-item + .comment-item, .attendance-row + .attendance-row, .message-row + .message-row { margin-top: 12px; }
.summary-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); font-size: 13px; }
.align-right { text-align: right; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.metric-card { padding: 14px; border-radius: 18px; background: #fbfdff; border: 1px solid var(--line); }
.metric-card span { display: block; color: var(--muted); font-size: 12px; }
.metric-card strong { display: block; margin-top: 6px; font-size: 24px; }
.metric-card.compact strong { font-size: 18px; }
.delta { margin-top: 6px; font-size: 12px; font-weight: 800; }
.delta.up { color: var(--success); }
.delta.down { color: var(--danger); }
.btn {
  appearance: none; border: 1px solid #c8daf1; cursor: pointer; color: var(--text); background: #fff;
  padding: 11px 16px; border-radius: 14px; font-weight: 800; transition: .18s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.primary { color: #fff; border-color: transparent; background: linear-gradient(180deg, var(--primary), var(--primary-strong)); }
.btn.danger { color: #fff; border-color: transparent; background: linear-gradient(180deg, #ef6666, #d94c4c); }
.btn.small { padding: 8px 12px; font-size: 12px; }
input, select, textarea {
  width: 100%; margin-top: 6px; border: 1px solid var(--line-strong); border-radius: 14px; padding: 11px 12px; outline: none; font: inherit;
}
input:focus, select:focus, textarea:focus { border-color: #87b8ff; box-shadow: 0 0 0 4px rgba(45,126,247,.12); }
textarea { resize: vertical; }
label { display: block; font-weight: 700; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 24px; }
.check input { width: auto; margin: 0; }
.stack { display: grid; gap: 16px; }
.compact-stack { gap: 10px; }
.table-wrap { overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 12px 10px; text-align: left; vertical-align: top; }
.table th { font-size: 13px; color: var(--muted); }
.login-wrap { min-height: calc(100vh - 80px); display: flex; flex-wrap: wrap; gap: 24px; align-items: stretch; justify-content: center; max-width: 1120px; margin: 0 auto; padding: 32px 0; }
.login-wrap > .card { flex: 1 1 420px; min-width: 320px; }
.login-main .page-head { margin-bottom: 12px; }
.login-card form { display:grid; gap:14px; }
.demo-box { background: #f4f8ff; border-radius: 18px; border: 1px solid var(--line); padding: 16px; margin-top: 18px; }
.inline-form { display: grid; grid-template-columns: 140px 1fr auto; gap: 8px; align-items: center; }
.attendance-row { display: flex; justify-content: space-between; gap: 14px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.thumb { width: 68px; height: 68px; border-radius: 16px; object-fit: cover; border: 1px solid var(--line); background: #f3f7fc; }
.form-card { margin-bottom: 16px; }
.empty { padding: 24px; border-radius: 16px; text-align: center; color: var(--muted); background: #fbfdff; border: 1px dashed var(--line); }
.calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.calendar-dow { text-align: center; font-size: 12px; font-weight: 800; color: var(--muted); padding: 8px 0; }
.calendar-cell {
  min-height: 170px; border: 1px solid var(--line); border-radius: 18px; background: #fff; padding: 10px; display: flex; flex-direction: column; gap: 8px;
}
.calendar-cell.is-outside { background: #f7fafd; opacity: .75; }
.calendar-date { font-weight: 800; font-size: 14px; color: var(--text); }
.calendar-date-row { display:flex; align-items:center; justify-content:space-between; gap:8px; }
.calendar-count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: var(--primary); color: #fff; font-size: 11px; font-weight: 800; display:inline-flex; align-items:center; justify-content:center; line-height:1; }
.calendar-more { font-size: 10px; font-weight: 800; color: #557089; line-height: 1; }
.calendar-cell.has-events { border-color: #bdd3ee; background: #f8fbff; }
.calendar-items { display: grid; gap: 8px; }
.calendar-event {
  border-radius: 12px; padding: 9px 10px; border: 1px solid #d5e5f7; background: var(--info-soft); color: var(--text); display: grid; gap: 4px;
}
.calendar-event strong { font-size: 12px; line-height: 1.35; }
.calendar-event span { font-size: 11px; color: #47627a; line-height: 1.35; }
.calendar-event.danger, .event-card.danger, .calendar-event.danger-soft, .event-card.danger-soft {
  background: #fff3f3; border-color: #efc1c1;
}
.calendar-event.info, .event-card.info { background: #edf6ff; }
.team-select-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 8px 0 14px; }
.team-check {
  position: relative; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line-strong); border-radius: 14px; padding: 12px 14px; background: #fff;
}
.team-check input { width: auto; margin: 0; }
.mention-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.mention { display: inline-block; padding: 2px 8px; border-radius: 999px; background: #eef5ff; color: #275fba; font-weight: 800; }
.message-row { padding: 12px 0; border-bottom: 1px solid var(--line); }
.photo-meta { font-size: 13px; color: var(--muted); margin-top: 8px; }
.video-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.video-card { border-radius: 18px; border: 1px solid var(--line); background: var(--panel-soft); padding: 12px; }
.video-card iframe { width: 100%; aspect-ratio: 16 / 9; border-radius: 14px; background: #000; }
.sparkline { width: 100%; height: auto; }
@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .stats-grid, .stats-grid.three-cols, .grid.two, .grid.three, .grid.four, .login-wrap { grid-template-columns: 1fr; }
  .calendar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .team-select-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .main { padding: 18px; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .calendar-grid { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .attendance-row { flex-direction: column; }
  .summary-row { flex-direction: column; align-items: flex-start; }
}

.comment-thread{margin-top:18px;padding-top:14px;border-top:1px solid var(--line);}
.unread-card{border-color:#f0c98c;background:#fffaf1;}
.note-card{background:linear-gradient(180deg,#fffdf6 0%,#fffbef 100%);border-color:#f1e0b6;}
.table{min-width:700px;}
.sidebar .muted{line-height:1.4;}
@media (max-width: 1100px) {
  .sidebar { padding:16px; }
  .nav { display:flex; flex-wrap:nowrap; overflow:auto; padding-bottom:6px; }
  .nav a { white-space:nowrap; min-width:max-content; }
  .brand-wrap { margin-bottom:12px; }
  .user-card { margin-bottom:12px; }
  .main { padding:16px; }
  .calendar-cell { min-height: 150px; }
}
@media (max-width: 720px) {
  body { font-size:15px; }
  .card, .stat-card { padding:16px; border-radius:18px; }
  .login-wrap { grid-template-columns: 1fr; min-height:auto; padding:18px 0 28px; }
  .hero-card { order:2; }
  .login-card { order:1; }
  .sidebar { border-right:none; border-bottom:1px solid var(--line); }
  .brand { font-size:18px; }
  .page-head h1 { font-size:22px; }
  .calendar-cell { min-height: unset; }
  .calendar-event strong { font-size: 12px; }
  .team-select-grid, .grid.two, .grid.three, .grid.four, .stats-grid, .stats-grid.three-cols { grid-template-columns:1fr; }
  .video-grid { grid-template-columns:1fr; }
  .table { min-width: 620px; }
}

/* responsive polish */
body { -webkit-text-size-adjust: 100%; }
.main { min-width: 0; }
.card, .stat-card, .calendar-cell, .video-card, .list-item, .link-card { overflow-wrap: anywhere; }
button, input, select, textarea { font-size: 16px; }
.page-head .pill { flex-shrink: 0; }
.event-tools-grid { margin-bottom: 16px; }

@media (max-width: 1100px) {
  .app-shell { display: block; }
  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }
  .brand-wrap {
    align-items: center;
    margin-bottom: 10px;
  }
  .user-card {
    margin-bottom: 12px;
  }
  .nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0,1fr));
    gap: 8px;
  }
  .nav a {
    min-width: 0;
    padding: 12px;
  }
  .main { padding: 16px; }
  .page-head { margin-bottom: 14px; }
  .stats-grid, .stats-grid.three-cols, .grid.two, .grid.three, .grid.four, .event-tools-grid {
    grid-template-columns: 1fr;
  }
  .calendar-grid { gap: 8px; }
  .calendar-cell { min-height: 132px; padding: 8px; }
}

@media (max-width: 720px) {
  .sidebar { padding: 12px; }
  .brand-wrap {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 10px;
  }
  .brand-logo { width: 48px; height: 48px; border-radius: 14px; }
  .brand { font-size: 17px; line-height: 1.3; }
  .user-card { padding: 12px; border-radius: 16px; }
  .nav { grid-template-columns: 1fr; }
  .nav a { border-radius: 12px; font-size: 14px; }
  .main { padding: 12px; }
  .page-head { align-items: flex-start; gap: 8px; }
  .page-head h1 { font-size: 22px; line-height: 1.3; }
  .card, .stat-card, .video-card { padding: 14px; border-radius: 16px; }
  .section-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .summary-row, .attendance-row { flex-direction: column; align-items: flex-start; }
  .inline-form { grid-template-columns: 1fr; }
  .team-select-grid { grid-template-columns: 1fr; }
  .recipient-grid { grid-template-columns: 1fr; }

  .calendar-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 4px;
  }
  .calendar-dow {
    display: block;
    font-size: 11px;
    font-weight: 800;
    padding: 2px 0 6px;
    letter-spacing: 0.02em;
  }
  .calendar-dow:nth-child(1) { color: #d45454; }
  .calendar-dow:nth-child(7) { color: #3f73d8; }
  .calendar-cell.is-outside { display: flex; opacity: .55; }
  .calendar-cell {
    min-height: 72px;
    aspect-ratio: 1 / 1;
    padding: 5px;
    border-radius: 12px;
    gap: 4px;
    justify-content: flex-start;
  }
  .calendar-date-row {
    align-items: flex-start;
    gap: 4px;
  }
  .calendar-date {
    font-size: 11px;
    line-height: 1;
  }
  .calendar-count {
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 9px;
  }
  .calendar-items {
    display: grid;
    gap: 3px;
    margin-top: auto;
  }
  .calendar-event {
    width: 100%;
    height: 8px;
    min-height: 8px;
    padding: 0;
    border-radius: 999px;
    border-width: 0;
  }
  .calendar-event:nth-child(n+3) { display: none; }
  .calendar-event strong,
  .calendar-event span { display: none; }
  .calendar-more {
    font-size: 8px;
    text-align: right;
  }

  .login-wrap {
    grid-template-columns: 1fr;
    max-width: 520px;
    width: 100%;
    gap: 14px;
    padding: 12px 0 20px;
    align-items: stretch;
  }
  .login-card, .hero-card { width: 100%; }
  .login-card form { gap: 12px; }
  .hero-card { order: 1; }
  .login-card { order: 2; }
  .demo-box { margin-top: 14px; }
  .video-grid { grid-template-columns: 1fr; }
  .table-wrap { margin: 0 -14px; padding: 0 14px 2px; }
  .table { min-width: 560px; }
  .thumb { width: 56px; height: 56px; }
}

@media (max-width: 420px) {
  .brand-wrap { grid-template-columns: 42px 1fr; }
  .brand-logo { width: 42px; height: 42px; }
  .brand { font-size: 16px; }
  .page-head h1 { font-size: 20px; }
  .card, .stat-card { padding: 12px; }
  .btn, .btn.small { width: 100%; justify-content: center; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .header-actions { width: 100%; justify-content: flex-start; }
  .legend-row { width: 100%; }
  .legend-row .btn, .legend-row form { width: 100%; }
  .legend-row form .btn { width: 100%; }
}

.mention-field { position: relative; }
.mention-suggestions { display:none; position:absolute; left:0; right:0; top:calc(100% + 6px); z-index:20; background:#fff; border:1px solid var(--line-strong); border-radius:14px; box-shadow:var(--shadow); max-height:240px; overflow:auto; }
.mention-field.open .mention-suggestions { display:block; }
.mention-option { width:100%; text-align:left; background:#fff; border:0; border-bottom:1px solid #eef3f8; padding:10px 12px; cursor:pointer; display:grid; gap:2px; }
.mention-option:last-child{border-bottom:0;}
.mention-option strong{color:var(--primary-strong); font-size:14px;}
.mention-option span{color:var(--muted); font-size:12px;}
.mention-option.active,.mention-option:hover{background:#eef5ff;}
.field-hint{display:block; margin-top:6px; color:var(--muted); font-size:12px; font-weight:500;}
.read-card{opacity:.82;}
@media (max-width: 960px){ .login-wrap{display:grid; grid-template-columns:1fr; max-width:560px; gap:16px; align-items:stretch;} .login-wrap>.card{min-width:0;} }

.coach-summary{display:flex;align-items:flex-start;gap:14px;min-width:0;}
.coach-thumb{flex:0 0 72px;width:72px;height:72px;border-radius:18px;object-fit:cover;}
.coach-fallback{display:grid;place-items:center;background:#f4f8ff;font-size:26px;}
.coach-edit-preview{margin:10px 0 4px;}
.menu-toggle,.sidebar-backdrop{display:none;}
@media (max-width: 860px) {
  .menu-toggle{display:inline-flex;align-items:center;justify-content:center;gap:8px;position:fixed;top:12px;left:12px;z-index:45;padding:10px 14px;border-radius:999px;border:1px solid var(--line-strong);background:#fff;box-shadow:var(--shadow);font-weight:800;color:var(--text);}
  .sidebar-backdrop{display:block;position:fixed;inset:0;background:rgba(18,34,53,.28);opacity:0;pointer-events:none;transition:.2s ease;z-index:34;}
  .sidebar{position:fixed;top:0;left:0;bottom:0;width:min(86vw,320px);height:100vh;overflow:auto;transform:translateX(-104%);transition:.24s ease;z-index:40;border-right:1px solid var(--line);border-bottom:none;padding-top:64px;}
  body.menu-open .sidebar{transform:translateX(0);}
  body.menu-open .sidebar-backdrop{opacity:1;pointer-events:auto;}
  .main{padding-top:68px;}
  .coach-summary{flex-direction:row;align-items:flex-start;}
}

.reaction-bar{display:flex;flex-wrap:wrap;gap:8px;margin-top:8px;}
.reaction-bar form{margin:0;}
.reaction-btn{display:inline-flex;align-items:center;gap:6px;padding:6px 10px;border-radius:999px;border:1px solid var(--line-strong);background:#fff;cursor:pointer;font-weight:700;color:var(--text);} 
.reaction-btn.active{background:#eef5ff;border-color:#9fc2f3;color:var(--primary-strong);} 
.card-subsection{margin-top:14px;padding-top:14px;border-top:1px solid var(--line);} 
.compact-check{margin-top:0;font-size:13px;font-weight:700;white-space:nowrap;} 
.mobile-toolbar{display:none;justify-content:flex-end;margin-bottom:10px;} 
@media (max-width: 860px){ .mobile-toolbar{display:flex;} .mobile-toolbar .btn{width:auto;} }

.view-switch form{margin:0;}
.view-switch .btn{min-width:150px;}
@media (max-width: 720px) {
  .view-switch{display:grid;grid-template-columns:1fr;gap:8px;align-items:stretch;}
  .view-switch form{width:100%;}
  .view-switch .btn{width:100%;justify-content:center;min-height:44px;}
}

.calendar-list-head { padding-top: 8px; border-top: 1px solid var(--line); }
