:root {
  --bg: var(--tg-theme-bg-color, #f4f6fb);
  --card: var(--tg-theme-secondary-bg-color, #ffffff);
  --text: var(--tg-theme-text-color, #182033);
  --muted: var(--tg-theme-hint-color, #758095);
  --primary: var(--tg-theme-button-color, #3559d8);
  --primary-text: var(--tg-theme-button-text-color, #ffffff);
  --line: rgba(74, 90, 120, .13);
  --soft-primary: rgba(53, 89, 216, .09);
  --success: #179451;
  --success-soft: #eaf7ef;
  --warning: #d68a09;
  --warning-soft: #fff5df;
  --danger: #ca4450;
  --danger-soft: #fff0f1;
  --shadow: 0 12px 34px rgba(28, 39, 67, .07);
  --shadow-soft: 0 5px 18px rgba(28, 39, 67, .055);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 90% -10%, rgba(87, 112, 224, .13), transparent 30%),
    var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(86px + env(safe-area-inset-bottom));
}
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.topbar {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.eyebrow { color: var(--primary); font-size: 10px; font-weight: 900; letter-spacing: .16em; }
h1 { margin: 2px 0 0; font-size: 26px; letter-spacing: -.035em; }
h2 { margin: 0; font-size: 20px; letter-spacing: -.018em; }
.avatar {
  width: 42px; height: 42px; border-radius: 15px;
  display: grid; place-items: center;
  color: #fff; font-weight: 900;
  background: linear-gradient(145deg, #3559d8, #7590ef);
  box-shadow: 0 9px 25px rgba(53, 89, 216, .25);
}
main { max-width: 900px; margin: 0 auto; padding: 0 14px 44px; }
.muted { color: var(--muted); font-size: 12.5px; line-height: 1.45; }

.panel, .week-hero, .dashboard-card, .member-tile, .quick-card, .reporter-card, .history-card, .org-overall, .data-block {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}
.panel { border-radius: 22px; padding: 28px; }
.centered { text-align: center; }
.spinner {
  width: 30px; height: 30px; margin: 0 auto 12px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--primary);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.week-hero {
  min-height: 106px;
  border-radius: 24px;
  padding: 17px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
  margin-bottom: 14px;
}
.week-hero::after {
  content: "";
  position: absolute;
  width: 145px; height: 145px; border-radius: 50%;
  right: -55px; top: -72px;
  background: linear-gradient(145deg, rgba(53,89,216,.12), rgba(53,89,216,.02));
}
.week-label { font-size: 20px; font-weight: 900; margin-top: 2px; letter-spacing: -.02em; }
.deadline-line { margin-top: 8px; color: #8a5c00; font-size: 12px; font-weight: 750; }
.week-mark {
  width: 52px; height: 52px; border-radius: 18px;
  background: var(--soft-primary); color: var(--primary);
  display: grid; place-items: center;
  font-weight: 900; font-size: 20px; z-index: 1;
}

.dashboard-card {
  border-radius: 24px;
  padding: 17px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.dashboard-copy h2 { font-size: 23px; margin: 2px 0 4px; }
.progress-sentence { color: var(--muted); font-size: 13px; }
.progress-ring {
  --progress: 0deg;
  width: 82px; height: 82px; border-radius: 50%; flex: 0 0 82px;
  background: conic-gradient(var(--success) var(--progress), rgba(108,123,150,.14) 0);
  position: relative; display: grid; place-items: center;
}
.progress-ring::before { content: ""; width: 66px; height: 66px; border-radius: 50%; background: var(--card); position: absolute; }
.progress-ring > div { position: relative; text-align: center; display:flex; flex-direction:column; line-height:1; }
.progress-ring strong { font-size: 18px; }
.progress-ring span { font-size: 9px; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.progress-track { height: 8px; background: rgba(107,121,147,.13); border-radius: 999px; overflow: hidden; margin: 11px 6px 16px; }
.progress-fill { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #7189e7); transition: width .3s ease; }

.member-toolbar { margin: 8px 0 5px; }
.search-wrap {
  height: 45px; border: 1px solid var(--line); border-radius: 15px;
  background: var(--card); display: flex; align-items: center; gap: 8px; padding: 0 12px;
  box-shadow: var(--shadow-soft);
}
.search-wrap span { color: var(--muted); font-size: 21px; transform: rotate(-15deg); }
.search-wrap input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 14px; }
.search-wrap input::placeholder { color: var(--muted); }
.filter-row { display: flex; gap: 7px; margin-top: 9px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip {
  border: 1px solid var(--line); background: var(--card); color: var(--muted);
  border-radius: 999px; padding: 7px 12px; font-size: 11px; font-weight: 800; white-space: nowrap;
}
.filter-chip.active { background: var(--text); color: var(--card); border-color: transparent; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 19px 2px 10px; }
.section-head p { margin: 4px 0 0; }
.text-action { border: 0; background: transparent; color: var(--primary); font-size: 12px; font-weight: 850; padding: 8px 0; }
.tjn-section { margin: 16px 0 20px; }
.tjn-title-row { display:flex; align-items:center; justify-content:space-between; gap:10px; margin: 0 3px 8px; }
.tjn-title { font-size: 12px; font-weight: 900; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.tjn-count { font-size: 10px; color: var(--muted); }
.member-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.member-tile {
  min-height: 158px;
  border-radius: 21px;
  padding: 13px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  transition: transform .12s ease, box-shadow .12s ease;
}
.member-tile:active { transform: scale(.985); }
.member-avatar {
  width: 54px; height: 54px; border-radius: 19px;
  display: grid; place-items: center;
  font-size: 18px; font-weight: 900;
  color: #3157c9; background: linear-gradient(145deg, #edf1ff, #dfe7ff);
}
.member-avatar.large { width: 58px; height: 58px; border-radius: 20px; flex: 0 0 58px; }
.member-avatar.tone-1 { color:#79610e; background:linear-gradient(145deg,#fff6cf,#ffedab); }
.member-avatar.tone-2 { color:#28735d; background:linear-gradient(145deg,#e1f8ef,#c8f0e3); }
.member-avatar.tone-3 { color:#8b4d73; background:linear-gradient(145deg,#f9e8f2,#f3d7e8); }
.member-avatar.tone-4 { color:#6d56a4; background:linear-gradient(145deg,#f0eaff,#e3d8ff); }
.tile-status {
  position: absolute; top: 9px; right: 9px;
  width: 23px; height: 23px; border-radius: 50%;
  display: grid; place-items: center; font-size: 11px; font-weight: 900;
  color: #8a93a3; background: #f1f3f7; border: 2px solid var(--card);
}
.tile-status.complete { color:#fff; background:var(--success); }
.tile-status.started { color:#8a5900; background:#ffdda0; }
.tile-copy { width:100%; min-width:0; margin-top:8px; }
.member-name { font-weight: 900; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.member-meta { display:flex; align-items:center; justify-content:center; gap:6px; margin-top:5px; min-height:20px; }
.role-badge {
  display: inline-flex; align-items: center; width: max-content;
  padding: 4px 7px; border-radius: 7px; font-size: 9px; font-weight: 900; letter-spacing: .045em;
  background: var(--soft-primary); color: var(--primary);
}
.role-badge[data-role="TJN"] { background:#eee8ff; color:#6c4ec1; }
.role-badge[data-role="KGN"] { background:#e8efff; color:#3157c9; }
.role-badge[data-role="GYJN"] { background:#e5f7f1; color:#24765d; }
.role-badge[data-role="JYJN"] { background:#fff0f2; color:#b8475d; }
.tile-totals { display:flex; justify-content:center; gap:7px; margin-top:7px; font-size:10px; color:var(--muted); }
.tile-totals span { background: rgba(108,123,150,.08); padding:4px 6px; border-radius:7px; }
.open-pill { width:100%; margin-top:9px; border:0; border-radius:10px; padding:7px 8px; font-size:10px; font-weight:900; color:var(--primary); background:var(--soft-primary); }
.empty-state { text-align:center; padding:28px 16px; color:var(--muted); }

.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 14px; padding: 11px 14px; font-weight: 850; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap:6px;
}
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: transparent; }
.btn.success { background: var(--success); color: #fff; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.compact { padding: 8px 11px; font-size: 11px; }
.btn.wide { width: 100%; }
.submit-wrap { margin-top: 17px; }
.submit-wrap .btn { box-shadow: 0 8px 25px rgba(23,148,81,.18); }

.quick-card { border-radius: 19px; margin-bottom: 10px; overflow: hidden; }
.quick-card-head { padding: 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--line); }
.quick-name { font-weight: 900; font-size: 13px; }
.quick-complete { display:flex; align-items:center; gap:5px; font-size:11px; color:var(--muted); }
.quick-grid { display: grid; grid-template-columns: 72px repeat(5, minmax(54px, 1fr)); gap: 1px; background: var(--line); overflow-x: auto; }
.quick-grid > div { background: var(--card); min-width:54px; padding: 7px 4px; text-align:center; font-size:10px; }
.quick-grid .row-label { min-width:72px; position:sticky; left:0; z-index:2; font-weight:900; background:var(--card); }
.quick-input { width: 44px; max-width: 100%; border:1px solid var(--line); border-radius:9px; background:var(--bg); color:var(--text); padding:7px 3px; text-align:center; font-weight:800; }
.quick-save { width: 100%; margin-top: 12px; }
.quick-titlebar { display:flex; align-items:center; justify-content:space-between; gap:10px; margin:16px 2px 10px; }

.org-overall { border-radius: 23px; padding: 17px; margin-bottom: 12px; }
.org-overall-top { display:flex; align-items:center; justify-content:space-between; gap:14px; }
.big-number { font-size: 25px; font-weight: 900; letter-spacing:-.025em; }
.small-progress { height: 7px; background: rgba(108,123,150,.13); border-radius:999px; overflow:hidden; margin-top:10px; }
.small-progress > div { height:100%; background:linear-gradient(90deg,var(--primary),#7289e7); border-radius:inherit; }
.reporter-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; }
.reporter-card { border-radius:20px; padding:13px; min-height:122px; display:flex; flex-direction:column; justify-content:space-between; }
.reporter-card:active { transform:scale(.987); }
.reporter-top { display:flex; justify-content:space-between; gap:8px; align-items:flex-start; }
.reporter-name { font-size:14px; font-weight:900; line-height:1.2; }
.reporter-score { font-size:16px; font-weight:900; white-space:nowrap; }
.reporter-state { margin-top:4px; font-size:10px; color:var(--muted); }
.organizer-member-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:9px; margin-top:10px; }
.back-line { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:10px; }

.history-card { border-radius:19px; padding:14px; margin-bottom:9px; display:flex; align-items:center; justify-content:space-between; gap:10px; }
.history-icon { width:40px; height:40px; border-radius:13px; background:var(--soft-primary); color:var(--primary); display:grid; place-items:center; font-size:18px; }
.history-main { flex:1; }

.bottom-nav {
  position: fixed;
  left: 10px; right: 10px; bottom: max(8px, env(safe-area-inset-bottom));
  max-width: 620px; margin: auto;
  z-index: 30;
  border: 1px solid var(--line);
  background: var(--card);
  backdrop-filter: blur(18px);
  border-radius: 22px;
  box-shadow: 0 14px 38px rgba(26,37,64,.18);
  padding: 6px;
  display:flex;
}
.nav-item {
  flex:1; min-width:0; border:0; background:transparent; color:var(--muted);
  border-radius:16px; padding:7px 5px 6px;
  display:flex; flex-direction:column; align-items:center; gap:2px;
}
.nav-item > span { font-size:19px; line-height:1; }
.nav-item small { font-size:9px; font-weight:850; }
.nav-item.active { color:var(--primary); background:var(--soft-primary); }

.backdrop { position: fixed; inset: 0; background: rgba(16, 23, 38, .45); z-index: 40; backdrop-filter: blur(3px); }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-height: 94vh; overflow-y: auto;
  background: var(--bg); border-radius: 28px 28px 0 0;
  padding: 9px 14px max(18px, env(safe-area-inset-bottom));
  box-shadow: 0 -22px 60px rgba(16,24,40,.22);
}
.sheet-handle { width:42px; height:5px; border-radius:999px; background:#c9ced8; margin:0 auto 13px; }
.sheet-member-hero { display:flex; align-items:center; gap:12px; padding:0 2px 14px; }
.sheet-member-copy { flex:1; min-width:0; }
.sheet-title-line { display:flex; align-items:center; gap:7px; min-width:0; }
.sheet-title-line h2 { font-size:21px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.icon-btn { width:36px; height:36px; border-radius:12px; border:0; background:rgba(109,124,151,.11); color:var(--text); font-size:24px; }
.data-block { border-radius:20px; padding:13px; margin-bottom:10px; }
.block-heading { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; margin-bottom:7px; }
.block-heading > div { display:flex; align-items:center; gap:6px; }
.block-heading strong { font-size:15px; }
.block-icon { font-size:17px; }
.counter-list { display:grid; gap:2px; }
.counter-row { min-height:48px; display:flex; align-items:center; justify-content:space-between; gap:10px; border-top:1px solid rgba(90,105,132,.08); }
.counter-row:first-child { border-top:0; }
.language-name { font-size:13px; font-weight:750; }
.counter-control { display:grid; grid-template-columns:34px 44px 34px; gap:4px; align-items:center; }
.counter-btn { width:34px; height:34px; border:0; border-radius:11px; background:var(--soft-primary); color:var(--primary); font-size:20px; font-weight:700; line-height:1; }
.counter-input { width:44px; height:34px; border:1px solid var(--line); border-radius:10px; background:var(--bg); color:var(--text); text-align:center; font-size:15px; font-weight:900; outline:0; }
.counter-input:focus { border-color:var(--primary); box-shadow:0 0 0 3px rgba(53,89,216,.08); }
.sheet-actions-secondary { display:grid; grid-template-columns:1fr 1fr; gap:8px; margin:3px 0 8px; }
#saveNextBtn { box-shadow:0 9px 24px rgba(53,89,216,.23); }

.toast {
  position: fixed; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 80; max-width: 90%; text-align:center;
  background: #172033; color:#fff; padding:10px 14px; border-radius:13px;
  box-shadow:0 10px 30px rgba(17,24,39,.22); font-size:12px;
}

@media (min-width: 620px) {
  .member-grid, .organizer-member-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .reporter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .sheet { left:50%; right:auto; transform:translateX(-50%); width:580px; border-radius:28px 28px 0 0; }
}
@media (min-width: 840px) {
  .member-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .reporter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 360px) {
  .member-grid, .reporter-grid, .organizer-member-list { grid-template-columns:1fr 1fr; gap:7px; }
  .member-tile { min-height:150px; padding:11px; }
  .week-label { font-size:18px; }
  .dashboard-copy h2 { font-size:20px; }
}
