:root {
  --bg: #f5f4ef; --card: #ffffff; --ink: #1d2420; --muted: #6b726d; --line: #e4e2da;
  --green: #16803c; --green-2: #e7f4ea; --red: #c8352b; --red-2: #fbeae8; --blue: #2563a8; --blue-2: #e8f0fa;
  --amber: #a36200; --amber-2: #fbf1dc; --side: #13301f; --side-ink: #cfe3d4;
  --radius: 10px; --font: "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.neg { color: var(--red); } .pos { color: var(--green); } .muted { color: var(--muted); }
.hidden { display: none !important; }

.layout { display: flex; min-height: 100vh; }
.side { width: 228px; background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; }
.brand b { color: #fff; display: block; font-size: 15px; } .brand small { color: #8fb39a; }
.ball { width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff 0 22%, #2fbf5f 23%); box-shadow: 0 0 0 3px #1f4d31; }
nav { display: flex; flex-direction: column; padding: 6px 8px; gap: 2px; }
nav a { color: var(--side-ink); padding: 9px 12px; border-radius: 8px; }
nav a:hover { background: #1d4430; text-decoration: none; }
nav a.active { background: #2fbf5f; color: #06210f; font-weight: 600; }
nav a[data-r="mark"] { margin-bottom: 6px; border: 1px dashed #3d7a54; }
.side-foot { margin-top: auto; padding: 14px 16px; font-size: 12px; display: grid; gap: 6px; } .side-foot a { color: #8fb39a; }
#who { color: #fff; font-size: 13px; } #who small { display: block; color: #8fb39a; }
.login-bg { position: fixed; inset: 0; z-index: 300; background: radial-gradient(circle at 20% 10%, #1f5a36, var(--side) 60%); display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { background: #fff; border-radius: 16px; padding: 28px; width: 100%; max-width: 380px; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.login .brand { padding: 0 0 18px; } .login .brand b { color: var(--ink); } .login .brand small { color: var(--muted); }
.login .btn { width: 100%; padding: 10px; margin-top: 6px; }
.main { flex: 1; min-width: 0; }
.top { position: sticky; top: 0; z-index: 20; display: flex; gap: 12px; align-items: center; padding: 10px 24px; background: rgba(245,244,239,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); }
.menu-btn { display: none; }
.month { display: flex; align-items: center; gap: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.month span { min-width: 130px; text-align: center; font-weight: 600; text-transform: capitalize; }
.month button { border: 0; background: transparent; width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 18px; }
.month button:hover { background: var(--green-2); }
.top-actions { margin-left: auto; display: flex; gap: 8px; position: relative; }
#search { width: 240px; }
.dropdown { position: absolute; top: 40px; left: 0; width: 340px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.12); max-height: 360px; overflow: auto; z-index: 50; }
.dropdown div { padding: 8px 12px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.dropdown div:hover, .dropdown div.on { background: var(--green-2); }
main { padding: 22px 24px 60px; max-width: 1500px; }

h1 { font-size: 22px; margin: 0 0 4px; } h2 { font-size: 16px; margin: 0 0 12px; }
.head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.head .sub { color: var(--muted); }
.head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid #cfccc2; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid #2fbf5f; outline-offset: 1px; }
.btn { font: inherit; border: 1px solid #cfccc2; background: #fff; padding: 7px 14px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #9a978d; } .btn.primary { background: var(--green); border-color: var(--green); color: #fff; font-weight: 600; }
.btn.primary:hover { background: #106a31; } .btn.danger { color: var(--red); } .btn.sm { padding: 3px 9px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: transparent; }

.grid { display: grid; gap: 12px; }
.kpis { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .l { color: var(--muted); font-size: 12.5px; } .kpi .v { font-size: 23px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .h { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.main { background: var(--side); color: #fff; border-color: var(--side); } .kpi.main .l, .kpi.main .h { color: #9cc4a8; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 12px; align-items: start; }
.cols3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 10px; border-bottom: 1px solid #efede6; }
tr.click { cursor: pointer; } tr.click:hover td { background: #f8f7f2; }
tfoot td { font-weight: 650; border-top: 1px solid var(--line); border-bottom: 0; }
.scroll { overflow-x: auto; }

.bar { height: 8px; background: #eceae2; border-radius: 4px; overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; background: #2fbf5f; border-radius: 4px; }
.bar i.r { background: #e2867e; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; background: #eceae2; color: #4a514c; white-space: nowrap; }
.badge.active { background: var(--green-2); color: var(--green); } .badge.trial { background: var(--blue-2); color: var(--blue); }
.badge.lead { background: var(--amber-2); color: var(--amber); } .badge.left, .badge.stopped { background: #eee; color: #888; }
.alert { padding: 10px 12px; border-radius: 8px; background: var(--amber-2); color: #6a4300; margin-bottom: 8px; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; background: none; padding: 8px 14px; cursor: pointer; font: inherit; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--ink); border-color: var(--green); font-weight: 600; }

/* journal */
.jwrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.jt th, .jt td { padding: 5px 7px; font-size: 13px; }
.jt thead th { position: sticky; top: 0; background: #fbfaf6; z-index: 2; }
.jt .sticky { position: sticky; left: 0; background: #fff; z-index: 1; min-width: 190px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jt thead .sticky { z-index: 3; background: #fbfaf6; }
.jt td.c { text-align: center; min-width: 46px; cursor: pointer; border-left: 1px solid #f1efe8; user-select: none; }
.jt td.c:hover { background: var(--green-2); }
.jt td.c.paid { color: var(--ink); } .jt td.c.venue, .jt td.c.free { color: var(--green); }
.jt td.c.trial { color: var(--blue); font-weight: 600; } .jt td.c.absent { color: #aaa; }
.jt th.s { text-align: center; cursor: pointer; } .jt th.s:hover { color: var(--green); }
.jt th.s.cancel { text-decoration: line-through; color: #bbb; }
.jt tr.other td { background: #fbfaf5; }
.jt tfoot td { background: #fbfaf6; font-size: 12px; color: var(--muted); font-weight: 500; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--red); margin-right: 5px; }

.pop { position: fixed; z-index: 60; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 30px rgba(0,0,0,.16); padding: 10px; display: flex; flex-direction: column; gap: 6px; min-width: 200px; }
.pop .row { display: flex; gap: 6px; } .pop .row .btn { flex: 1; }

/* coach marking */
.markbox { max-width: 640px; }
.mark-filters { display: grid; grid-template-columns: 1fr 1fr 150px; gap: 8px; margin-bottom: 12px; }
.kid { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; }
.kid .who { flex: 1; min-width: 0; } .kid .who b { display: block; } .kid .who small { color: var(--muted); }
.seg { display: flex; border: 1px solid #cfccc2; border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 10px 14px; font: inherit; cursor: pointer; min-width: 56px; }
.seg button + button { border-left: 1px solid #e3e0d7; }
.seg button.on.present { background: var(--green); color: #fff; font-weight: 600; }
.seg button.on.trial { background: var(--blue); color: #fff; font-weight: 600; }
.seg button.on.absent { background: #8a8a8a; color: #fff; }
.sumline { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0; display: flex; gap: 14px; font-weight: 600; }

/* modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(16,24,19,.42); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; overflow: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 520px; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal h2 { margin-bottom: 14px; }
.form { display: grid; gap: 10px; } .form label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.form .err { color: var(--red); font-size: 12px; }
.modal .foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--side); color: #fff; padding: 10px 16px; border-radius: 10px; z-index: 200; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.toast.err { background: var(--red); }
.hint { font-size: 12.5px; color: var(--muted); background: #f3f6f2; border-radius: 8px; padding: 8px 10px; }
.msg { font-size: 12.5px; color: #3c443f; max-width: 460px; }

@media (max-width: 900px) {
  .side { position: fixed; left: -240px; z-index: 90; transition: left .2s; } .side.open { left: 0; }
  .menu-btn { display: block; border: 1px solid var(--line); background: #fff; border-radius: 8px; width: 36px; height: 36px; font-size: 18px; }
  .top { padding: 8px 12px; flex-wrap: wrap; } #search { width: 140px; } main { padding: 14px 12px 60px; }
  .cols, .cols3 { grid-template-columns: 1fr; } .mark-filters { grid-template-columns: 1fr; }
  .month span { min-width: 100px; }
  .top-actions { margin-left: 0; width: 100%; min-width: 0; } #search { flex: 1; width: auto; min-width: 0; }
  .main { overflow-x: hidden; } .mark-filters select, .mark-filters input { min-width: 0; width: 100%; }
  .dropdown { width: 100%; }
  .kid { flex-wrap: wrap; } .kid .seg { width: 100%; } .seg button { flex: 1; padding: 11px 6px; }
  .head .actions { margin-left: 0; }
  .kpi .v { font-size: 20px; }
}

/* offline, notes, photos */
.net { border: 1px solid #e2c36b; background: #fff7df; color: #7a5a00; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; white-space: nowrap; }
.net.off { border-color: #e7b1ab; background: var(--red-2); color: var(--red); }
.alert.off { background: #fff7df; color: #7a5a00; margin-bottom: 10px; }
.kid-act { display: flex; gap: 6px; align-items: center; }
.note-btn { border: 1px solid #cfccc2; background: #fff; border-radius: 10px; width: 42px; height: 42px; font-size: 17px; cursor: pointer; color: var(--muted); }
.note-btn.on { background: #fff7df; border-color: #e2c36b; color: #7a5a00; }
.note-btn:disabled { opacity: .35; cursor: default; }
.kid-note { font-size: 13px; font-style: italic; color: #7a5a00; margin-top: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid #cfccc2; background: #fff; border-radius: 999px; padding: 4px 10px; font: inherit; font-size: 13px; cursor: pointer; }
.chip:hover { background: var(--green-2); border-color: var(--green); }
.jt td.c.noted { position: relative; }
.jt td.c.noted::after { content: ''; position: absolute; top: 2px; right: 2px; border: 4px solid transparent; border-top-color: #d99a00; border-right-color: #d99a00; }
.media-block { margin: 18px 0 70px; }
.media-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; } .media-head h2 { margin: 0; flex: 1; font-size: 16px; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: #e9e7df; cursor: pointer; }
.tile img, .tile video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.tile .play { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font-size: 26px; text-shadow: 0 1px 6px rgba(0,0,0,.6); }
.tile.local { opacity: .7; } .tile .wait { position: absolute; left: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; padding: 1px 6px; border-radius: 6px; }
.viewer img, .viewer video { max-width: 100%; max-height: 70vh; display: block; margin: 0 auto; border-radius: 8px; background: #000; }
@media (max-width: 900px) {
  .kid-act { width: 100%; } .kid-act .seg { flex: 1; width: auto; }
  .net { order: 3; }
}
