/* EdPro PWA — мобільний стиль. Бренд: primary #FFB800, accent #4AD292. */
:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e2e4e9;
  --text: #1a1a2e;
  --muted: #7a8194;
  --primary: #ffb800;
  --primary-dark: #e6a500;
  --accent: #4ad292;
  --accent-dark: #2faa5e;
  --danger: #c0392b;
  --link: #2f6df6;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  position: relative;
}

/* ── шапка ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.brand { font-weight: 800; font-size: 16px; color: var(--text); }
.brand::before { content: "●"; color: var(--primary); margin-right: 6px; }
.topbar-right { display: flex; align-items: center; gap: 10px; min-width: 0; }
.auth-box { display: flex; align-items: center; gap: 8px; min-width: 0; }
.auth-status { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
.icon-btn { padding: 6px 10px; font-size: 16px; line-height: 1; }

.settings-panel {
  position: absolute; top: calc(48px + var(--safe-top)); right: 12px; z-index: 40;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: 14px; width: min(320px, 86vw);
  display: flex; flex-direction: column; gap: 10px;
}
.settings-panel-head { font-weight: 700; font-size: 14px; }
.settings-panel-hint { font-size: 12px; margin: 0; }
.settings-panel-result { font-size: 12px; }

/* ── кнопки ── */
.btn {
  border: none; background: var(--primary); color: var(--text);
  padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 600;
  cursor: pointer; min-height: 44px; transition: filter .14s, background .14s, transform .1s;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: scale(.98); }
.btn-sm { padding: 7px 12px; font-size: 13px; min-height: 38px; }
.btn-ghost { background: #eef1f6; color: var(--text); }
.btn-save { background: var(--accent); color: #08351f; }
.btn.warn { background: var(--danger); color: #fff; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.err { color: var(--danger); }

/* ── вкладки ── */
.tabs {
  display: flex; gap: 4px; padding: 10px 12px 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
  position: sticky; top: calc(44px + var(--safe-top)); z-index: 20; background: var(--bg);
}
.tab {
  border: 1px solid var(--line); border-bottom: none; background: var(--card);
  padding: 10px 16px; border-radius: 12px 12px 0 0; font-size: 14px; cursor: pointer;
  color: var(--muted); white-space: nowrap; min-height: 44px;
}
.tab.active { color: var(--text); font-weight: 700; border-color: var(--primary); border-bottom: 2px solid var(--card); }
.tab-badge { background: var(--danger); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 12px; font-weight: 700; margin-left: 4px; }
.tab-user { display: flex; align-items: center; gap: 8px; max-width: 200px; }
.tab-user > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab-close-x { flex-shrink: 0; font-size: 15px; line-height: 1; color: var(--muted); padding: 4px; border-radius: 6px; }

main { padding: 14px; padding-bottom: calc(20px + var(--safe-bottom)); }
.panel { display: none; background: var(--card); border: 1px solid var(--line); border-radius: 0 14px 14px 14px; padding: 16px; }
.panel.active { display: block; }

/* ── блок неоцінених ── */
.hw-pending { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; background: #fffdf5; }
.hw-pending-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.hw-pending-head strong { font-size: 15px; }
.hw-pending-groups { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 18px; padding: 7px 14px; font-size: 13px; cursor: pointer; min-height: 38px; }
.chip:active { border-color: var(--primary); }
.chip b { color: var(--danger); }

/* ── загубленці ── */
.hw-losty { border: 1px solid #f3c6b6; background: #fdf3f2; border-radius: 12px; padding: 12px 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 10px; }

/* ── кампанії ── */
.camp-result { display: flex; flex-direction: column; gap: 10px; }
.camp-summary { font-size: 15px; }
.camp-held { color: var(--danger); font-size: 13px; }
.camp-per-course { display: flex; flex-wrap: wrap; gap: 8px; }
.camp-course { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; font-size: 13px; background: var(--card); }
.camp-recipients { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.camp-recipients li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.losty-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 14px; }
.losty-group { border-top: 1px solid #f3c6b6; padding-top: 8px; }
.losty-group-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.losty-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; display: flex; flex-direction: column; gap: 4px; }

/* ── toolbar ── */
.hw-toolbar { display: flex; align-items: flex-end; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.hw-toolbar label { display: flex; flex-direction: column; font-size: 13px; color: var(--muted); gap: 5px; flex: 1 1 160px; }
.hw-toolbar select, .hw-toolbar input[type="search"] {
  padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px;
  min-height: 44px; background: #fff; color: var(--text); width: 100%;
}

/* ── список робіт ── */
.hw-list { display: flex; flex-direction: column; gap: 14px; }
.submission { border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.sub-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.sub-id { font-weight: 800; }
.sub-id--noid { color: #b25a00; background: #fff3e0; padding: 3px 9px; border-radius: 7px; font-size: 12px; font-weight: 700; }
.sub-email, .email-link { color: var(--link); text-decoration: none; font-size: 14px; word-break: break-all; }
.sub-email:active, .email-link:active { text-decoration: underline; }
.badge { background: #eef1f6; color: var(--muted); padding: 3px 9px; border-radius: 7px; font-size: 12px; }

.subtasks { display: flex; gap: 12px; flex-wrap: wrap; }
.subtask { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 10px; flex: 1 1 100%; }
.proof { flex-shrink: 0; }
.thumb { width: 100px; height: 76px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); cursor: zoom-in; background: #eef0f3; }
.thumb-error { object-fit: contain; padding: 6px; font-size: 10px; color: var(--muted); }
.moza { display: inline-flex; align-items: center; background: #6b3fa0; color: #fff; }
.verdict { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.verdict-select { padding: 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; min-height: 44px; width: 100%; background: #fff; }
.verdict-select.nezarah { border-color: var(--danger); color: var(--danger); background: #fdf3f2; }
.cur-verdict { color: var(--accent-dark); font-weight: 700; }
.cur-verdict--neg { color: var(--danger); }

/* ── таблиця реєстрацій ── */
.reg-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 12px; }
.reg-table { border-collapse: collapse; width: 100%; font-size: 13px; min-width: 720px; }
.reg-table th, .reg-table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.reg-table th { background: #f4f6f9; color: var(--muted); font-weight: 700; position: sticky; top: 0; }
.reg-table th.sortable { cursor: pointer; user-select: none; }
.reg-table th.sortable .sort-ind { font-size: 11px; color: #b8bec9; }
.reg-table th.sortable.is-active { color: var(--text); }
.reg-table th.sortable.is-active .sort-ind { color: var(--primary-dark); }
.reg-date { color: var(--muted); font-variant-numeric: tabular-nums; }
.reg-table tbody tr:active { background: #f8fafc; }
.reg-settlement { max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.src-badge { background: #eef1f6; color: var(--text); padding: 3px 9px; border-radius: 7px; font-size: 12px; }
.user-hw-btn { background: #eef1f6; color: var(--text); border: 1px solid var(--line); }
.reg-table tbody tr.reg-highlight td { box-shadow: inset 0 0 0 2px var(--primary); background: #fffbe6; }
.reg-stats { cursor: pointer; font-variant-numeric: tabular-nums; }
.reg-stats .rs-courses { color: var(--text); }
.reg-stats .rs-sub { margin-left: 8px; color: var(--accent-dark); font-weight: 700; }
.reg-stats--empty { color: var(--muted); text-align: center; cursor: default; }

/* ── панель дублів ── */
.reg-dup-panel { margin: 0 0 12px; border: 1px solid var(--primary); background: #fffbe6; border-radius: 12px; padding: 12px; }
.reg-dup-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: #7a5a00; margin-bottom: 8px; }
.reg-dup-group { padding: 8px 0; border-top: 1px dashed #f0d68a; }
.reg-dup-group:first-of-type { border-top: 0; }
.reg-dup-email { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.reg-dup-rows { border-collapse: collapse; width: 100%; font-size: 13px; }
.reg-dup-rows td { padding: 6px 8px; border-bottom: 1px solid #f0e3b8; }
.reg-school { color: var(--muted); }
.reg-email { color: var(--link); }
.reg-dup-act { text-align: right; }

/* ── завдання користувача ── */
.user-hw-group { margin-bottom: 20px; }
.user-hw-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; padding-bottom: 6px; border-bottom: 2px solid var(--line); flex-wrap: wrap; }

/* ── lightbox ── */
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 100; cursor: zoom-out; padding: 12px; }
.lightbox.hidden { display: none; }
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 10px; }

/* ── модалка статистики ── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 14px; }
.modal.hidden { display: none; }
.modal-box { position: relative; background: #fff; border-radius: 16px; max-width: 640px; width: 100%; max-height: 88vh; overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-x { position: absolute; top: 8px; right: 10px; width: 40px; height: 40px; border: none; background: transparent; color: #8a93a2; font-size: 26px; cursor: pointer; border-radius: 8px; }
.modal-title { font-size: 17px; font-weight: 800; margin-bottom: 12px; padding-right: 36px; }
.modal-body { font-size: 14px; line-height: 1.5; }
.hw-stats-email { font-size: 13px; color: var(--muted); margin-bottom: 12px; word-break: break-all; }
.hw-kpi { display: flex; gap: 10px; margin-bottom: 16px; }
.hw-kpi-card { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 12px 6px; background: #f4f6f9; border: 1px solid var(--line); border-radius: 12px; }
.hw-kpi-num { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.hw-kpi-lbl { font-size: 12px; color: var(--muted); }
.hw-courses { display: flex; flex-direction: column; gap: 12px; }
.hw-course-card { border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: 12px; padding: 12px 14px; }
.hw-course-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 14px; margin-bottom: 8px; }
.hw-course-head .muted { font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hw-progress { height: 8px; background: #eef1f6; border-radius: 5px; overflow: hidden; }
.hw-progress-fill { height: 100%; background: var(--accent); border-radius: 5px; transition: width .2s; }
.hw-course-sub { font-size: 12px; margin-top: 4px; }
.hw-tasks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hw-task { font-size: 12px; padding: 3px 9px; border-radius: 7px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.hw-task--ok { background: #e6f4ea; color: var(--accent-dark); }
.hw-task--neg { background: #fdecea; color: var(--danger); }
.hw-task--pending { background: #eef1f6; color: var(--muted); }

/* ── десктоп: ширші підзадачі поряд ── */
@media (min-width: 720px) {
  main { padding: 20px; }
  .panel { padding: 22px; }
  .subtask { flex: 1 1 320px; }
  .auth-status { max-width: 280px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
