:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-alt: #f5f7fb;
  --ink: #0b0f1a;          /* black */
  --ink-soft: #1c2433;
  --muted: #5b6578;
  --border: #e3e8f0;
  --border-strong: #cfd7e4;
  --blue: #1d4ed8;         /* primary blue */
  --blue-dark: #1e40af;
  --blue-light: #3b82f6;
  --blue-soft: #eff4ff;
  --success: #16a34a;
  --success-soft: #e8f7ee;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warning: #b45309;
  --warning-soft: #fff4e0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 15, 26, 0.04), 0 8px 24px rgba(11, 15, 26, 0.06);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 24px; }

/* ---------- Top nav ---------- */
.navbar {
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 20;
}
.navbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 10px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.brand img { width: 38px; height: 38px; display: block; }
.brand b { color: var(--blue); }
.nav-links { display: flex; align-items: center; gap: 6px; font-size: 0.92rem; }
.nav-links a {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.nav-links a:hover { color: var(--ink); background: var(--surface-alt); text-decoration: none; }
.nav-links a.active { color: var(--blue); background: var(--blue-soft); }
.nav-user { display: flex; align-items: center; gap: 12px; font-size: 0.9rem; }
.nav-user .who { color: var(--ink-soft); font-weight: 600; }
.badge-role {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--ink);
  color: #fff;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
}
.dot-new {
  width: 8px; height: 8px; border-radius: 50%; background: var(--success); display: inline-block;
}
@media (max-width: 760px) {
  .nav-user .who { display: none; }
  .navbar-inner { flex-wrap: wrap; }
}

/* ---------- Layout helpers ---------- */
.page { padding: 36px 0 70px; }
.page-header { margin-bottom: 26px; }
.page-header h1 { margin: 0 0 6px; font-size: 1.7rem; letter-spacing: -0.02em; }
.page-header p { margin: 0; color: var(--muted); }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 800px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h2, .card h3 { margin-top: 0; }
.card-muted { color: var(--muted); font-size: 0.9rem; }
.card-accent { border-top: 3px solid var(--blue); }

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  border-radius: var(--radius);
  padding: 18px 22px;
  margin-bottom: 22px;
}
.banner h3 { margin: 0 0 4px; font-size: 1.05rem; }
.banner p { margin: 0; font-size: 0.9rem; }
.banner-success { background: var(--success-soft); border: 1px solid #b7e4c7; }
.banner-success p { color: #14532d; }
.banner-info { background: var(--blue-soft); border: 1px solid #cddcfb; }
.banner-info p { color: #1e3a8a; }
.banner-dark { background: var(--ink); color: #fff; }
.banner-dark p { color: #b6c2dc; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: var(--blue);
  color: #fff;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.08s ease, background 0.15s ease, opacity 0.15s ease;
}
.btn:hover { background: var(--blue-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-outline { background: #fff; border: 1px solid var(--border-strong); color: var(--ink); }
.btn-outline:hover { background: var(--surface-alt); border-color: var(--ink); }
.btn-dark { background: var(--ink); color: #fff; }
.btn-dark:hover { background: #26304a; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-block { width: 100%; }

/* ---------- Forms ---------- */
label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 14px 0 6px;
}
label:first-of-type { margin-top: 0; }
#course-group label { margin-top: 14px; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], input[type="file"], select, textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--ink);
  font-size: 0.92rem;
  font-family: inherit;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.15);
}
.field-hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.checkbox-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.day-pill {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: all 0.12s ease;
}
.day-pill:hover { border-color: var(--ink); color: var(--ink); }
.day-pill.selected { background: var(--ink); border-color: var(--ink); color: #fff; }

/* ---------- Auth screens ---------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-side {
  background:
    radial-gradient(900px 500px at 10% 0%, rgba(59, 130, 246, 0.35), transparent 60%),
    radial-gradient(700px 500px at 100% 100%, rgba(29, 78, 216, 0.35), transparent 60%),
    var(--ink);
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 26px;
}
.auth-side .logo-tile {
  width: 96px; height: 96px; border-radius: 24px; background: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}
.auth-side .logo-tile img { width: 76px; height: 76px; }
.auth-side h1 { font-size: 2.3rem; line-height: 1.1; margin: 0; letter-spacing: -0.03em; }
.auth-side h1 span { color: #7aa7ff; }
.auth-side p { color: #b6c2dc; margin: 0; max-width: 420px; line-height: 1.55; }
.auth-points { list-style: none; padding: 0; margin: 4px 0 0; display: grid; gap: 12px; }
.auth-points li { display: flex; gap: 12px; align-items: flex-start; color: #dbe4f6; font-size: 0.95rem; }
.auth-points li::before {
  content: '✓'; flex: none; width: 22px; height: 22px; border-radius: 50%;
  background: var(--blue); color: #fff; font-size: 0.75rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; margin-top: 1px;
}
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 24px; background: #fff; }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .mobile-logo { display: none; }
.auth-card h2 { margin: 0 0 4px; font-size: 1.5rem; letter-spacing: -0.02em; }
.auth-card .sub { color: var(--muted); margin: 0 0 22px; font-size: 0.92rem; }
.role-toggle { display: flex; background: var(--surface-alt); border: 1px solid var(--border); border-radius: 10px; padding: 4px; margin-bottom: 6px; }
.role-toggle button {
  flex: 1; padding: 9px; background: transparent; border: none; border-radius: 7px;
  color: var(--muted); cursor: pointer; font-size: 0.88rem; font-weight: 700; font-family: inherit;
}
.role-toggle button.active { background: var(--ink); color: #fff; }
.auth-footer { text-align: center; margin-top: 18px; font-size: 0.87rem; color: var(--muted); }
.auth-footer a { font-weight: 700; }
@media (max-width: 860px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-side { display: none; }
  .auth-card .mobile-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-weight: 800; }
  .auth-card .mobile-logo img { width: 44px; height: 44px; }
}
.alert { padding: 10px 14px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 14px; }
.alert-error { background: var(--danger-soft); border: 1px solid #f5b5b5; color: #991b1b; }
.alert-success { background: var(--success-soft); border: 1px solid #b7e4c7; color: #14532d; }

/* ---------- Progress ---------- */
.stat { text-align: center; }
.stat .value { font-size: 1.8rem; font-weight: 800; color: var(--ink); letter-spacing: -0.02em; }
.stat .label { color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700; }
.progress-bar-track { width: 100%; height: 10px; border-radius: 999px; background: var(--surface-alt); overflow: hidden; border: 1px solid var(--border); }
.progress-bar-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--blue-light)); border-radius: 999px; transition: width 0.4s ease; }
.progress-bar-fill.complete { background: var(--success); }

/* ---------- Calendar ---------- */
.calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.calendar-header h2 { margin: 0; font-size: 1.15rem; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.calendar-dow { text-align: center; font-size: 0.75rem; font-weight: 700; color: var(--muted); padding-bottom: 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.calendar-day {
  position: relative;
  aspect-ratio: 1 / 0.85;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  padding: 8px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 0.8rem;
  cursor: default;
  color: #9aa4b7;
}
.calendar-day.empty { background: transparent; border: none; }
.calendar-day.scheduled { cursor: pointer; color: var(--ink); background: #fff; border-color: var(--border-strong); }
.calendar-day.scheduled:hover { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.12); }
.calendar-day.today { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.calendar-day.status-done { background: var(--success-soft); border-color: #86d3a3; }
.calendar-day.status-absent { background: var(--danger-soft); border-color: #f1a3a3; }
.day-num { font-weight: 700; }
.day-dot { width: 8px; height: 8px; border-radius: 50%; align-self: flex-end; }
.day-dot.done { background: var(--success); }
.day-dot.absent { background: var(--danger); }
.legend { display: flex; gap: 16px; margin-top: 14px; font-size: 0.8rem; color: var(--muted); flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(11, 15, 26, 0.55); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal-overlay.hidden { display: none; }
.modal { background: #fff; border-radius: var(--radius); padding: 26px; width: 100%; max-width: 460px; box-shadow: 0 24px 60px rgba(11, 15, 26, 0.3); max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-header h3 { margin: 0; }
.close-btn { background: none; border: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; line-height: 1; }
.close-btn:hover { color: var(--ink); }
.status-toggle { display: flex; gap: 10px; margin-top: 6px; }
.status-toggle button { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid var(--border-strong); background: #fff; color: var(--muted); cursor: pointer; font-weight: 700; font-family: inherit; }
.status-toggle button.selected.done { background: var(--success-soft); border-color: var(--success); color: #14532d; }
.status-toggle button.selected.absent { background: var(--danger-soft); border-color: var(--danger); color: #991b1b; }
.modal-photo-preview { margin-top: 10px; max-width: 100%; border-radius: 8px; border: 1px solid var(--border); display: none; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 700; font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.05em; background: var(--surface-alt); }
tr:hover td { background: #fafbfe; }
.status-chip { padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; display: inline-block; }
.status-chip.done, .status-chip.submitted { background: var(--success-soft); color: #166534; }
.status-chip.absent { background: var(--danger-soft); color: #991b1b; }
.status-chip.pending, .status-chip.draft { background: var(--warning-soft); color: var(--warning); }
.status-chip.none { background: var(--surface-alt); color: var(--muted); }
.course-chip { background: var(--blue-soft); color: var(--blue-dark); padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; display: inline-block; }

.toolbar-row { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-row select, .toolbar-row input { width: auto; min-width: 200px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .big-icon { font-size: 2.2rem; margin-bottom: 10px; }

.toast { position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 9px; box-shadow: var(--shadow); z-index: 100; font-size: 0.88rem; opacity: 0; transform: translateY(10px); transition: all 0.25s ease; pointer-events: none; border-left: 4px solid var(--blue-light); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }

.loading-spinner { width: 24px; height: 24px; border: 3px solid var(--border); border-top-color: var(--blue); border-radius: 50%; animation: spin 0.7s linear infinite; margin: 30px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Report editor (Word-style) ---------- */
.editor-shell { background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.editor-top { background: #fff; border-bottom: 1px solid var(--border); padding: 12px 16px; display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.doc-title-input { border: none !important; box-shadow: none !important; font-size: 1.05rem; font-weight: 700; padding: 6px 4px !important; min-width: 240px; flex: 1; }
.save-state { font-size: 0.8rem; color: var(--muted); }
.save-state.saved { color: var(--success); }
.save-state.error { color: var(--danger); }
.toolbar { background: #fff; border-bottom: 1px solid var(--border); padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; position: sticky; top: 59px; z-index: 5; }
.toolbar .sep { width: 1px; height: 24px; background: var(--border); margin: 0 4px; }
.tb-btn { min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid transparent; background: transparent; border-radius: 7px; cursor: pointer; font-size: 0.95rem; color: var(--ink); font-family: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.tb-btn:hover { background: var(--surface-alt); border-color: var(--border); }
.tb-btn.on { background: var(--blue-soft); border-color: #cddcfb; color: var(--blue-dark); }
.tb-btn.primary { background: var(--blue); color: #fff; font-weight: 600; }
.tb-btn.primary:hover { background: var(--blue-dark); }
.tb-select { width: auto !important; max-width: 150px; height: 34px; padding: 0 8px !important; font-size: 0.85rem !important; }
.paper-wrap { padding: 28px 16px 60px; overflow-x: auto; }
.paper {
  background: #fff;
  width: 816px;
  max-width: 100%;
  min-height: 1056px;
  margin: 0 auto;
  padding: 72px 80px;
  box-shadow: 0 6px 24px rgba(11, 15, 26, 0.12);
  font-family: 'Times New Roman', Georgia, serif;
  font-size: 12pt;
  line-height: 1.6;
  color: #111;
  outline: none;
  overflow-wrap: anywhere;
}
.paper h1 { font-size: 22pt; margin: 0.4em 0; }
.paper h2 { font-size: 16pt; margin: 1em 0 0.3em; }
.paper h3 { font-size: 13pt; margin: 0.8em 0 0.3em; }
.paper p { margin: 0 0 0.7em; }
.paper img { max-width: 100%; height: auto; cursor: pointer; }
.paper img.selected-img { outline: 3px solid var(--blue); outline-offset: 2px; }
.paper[contenteditable="false"] { background: #fcfcfd; }
@media (max-width: 760px) { .paper { padding: 28px 20px; } }
.img-bar { position: fixed; z-index: 40; background: var(--ink); color: #fff; border-radius: 10px; padding: 6px; display: none; gap: 4px; box-shadow: var(--shadow); }
.img-bar button { background: transparent; border: none; color: #fff; padding: 6px 10px; border-radius: 6px; cursor: pointer; font-size: 0.8rem; font-weight: 600; font-family: inherit; }
.img-bar button:hover { background: #26304a; }
.img-bar button.del:hover { background: var(--danger); }
.lock-card { text-align: center; padding: 48px 28px; }
.lock-card .big { font-size: 2.6rem; }
.lock-card .progress-bar-track { max-width: 360px; margin: 18px auto 8px; }

/* ---------- Daily photo picker + cropper (report editor) ---------- */
.modal.modal-wide { max-width: 760px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo-tile { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; cursor: pointer; padding: 0; text-align: left; font-family: inherit; }
.photo-tile:hover { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.photo-tile img { display: block; width: 100%; height: 110px; object-fit: cover; background: var(--surface-alt); }
.photo-tile .cap { padding: 7px 9px; font-size: 0.76rem; color: var(--muted); }
.photo-tile .cap b { display: block; color: var(--ink); font-size: 0.8rem; }
.photo-empty { text-align: center; padding: 28px 10px; color: var(--muted); }

.crop-ratios { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.crop-ratios button { border: 1px solid var(--border-strong); background: #fff; border-radius: 999px; padding: 5px 12px; font-size: 0.8rem; font-weight: 600; cursor: pointer; font-family: inherit; color: var(--ink); }
.crop-ratios button.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.crop-stage { display: flex; justify-content: center; background: #0b0f1a; border-radius: 10px; padding: 16px; overflow: hidden; }
.crop-wrap { position: relative; display: inline-block; line-height: 0; user-select: none; touch-action: none; }
.crop-wrap img { display: block; max-width: 100%; max-height: 55vh; pointer-events: none; -webkit-user-drag: none; }
.crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(11, 15, 26, 0.6); cursor: move; touch-action: none; }
.crop-box::before, .crop-box::after { content: ''; position: absolute; pointer-events: none; }
.crop-box::before { left: 33.33%; right: 33.33%; top: 0; bottom: 0; border-left: 1px dashed rgba(255,255,255,.55); border-right: 1px dashed rgba(255,255,255,.55); }
.crop-box::after { top: 33.33%; bottom: 33.33%; left: 0; right: 0; border-top: 1px dashed rgba(255,255,255,.55); border-bottom: 1px dashed rgba(255,255,255,.55); }
.crop-h { position: absolute; width: 18px; height: 18px; background: #fff; border: 2px solid var(--blue); border-radius: 50%; touch-action: none; z-index: 2; }
.crop-h[data-h="nw"] { left: -10px; top: -10px; cursor: nwse-resize; }
.crop-h[data-h="ne"] { right: -10px; top: -10px; cursor: nesw-resize; }
.crop-h[data-h="sw"] { left: -10px; bottom: -10px; cursor: nesw-resize; }
.crop-h[data-h="se"] { right: -10px; bottom: -10px; cursor: nwse-resize; }
.crop-h[data-h="n"] { left: calc(50% - 9px); top: -10px; cursor: ns-resize; }
.crop-h[data-h="s"] { left: calc(50% - 9px); bottom: -10px; cursor: ns-resize; }
.crop-h[data-h="w"] { top: calc(50% - 9px); left: -10px; cursor: ew-resize; }
.crop-h[data-h="e"] { top: calc(50% - 9px); right: -10px; cursor: ew-resize; }
.crop-info { font-size: 0.8rem; color: var(--muted); margin-top: 8px; }

/* ---------- Coordinator: course picker ---------- */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.course-card { text-align: left; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; cursor: pointer; font-family: inherit; box-shadow: var(--shadow); border-top: 3px solid var(--blue); }
.course-card:hover { border-color: var(--blue); transform: translateY(-1px); }
.course-card .cc-name { font-weight: 800; font-size: 1rem; color: var(--ink); margin-bottom: 6px; }
.course-card .cc-meta { font-size: 0.82rem; color: var(--muted); }
.course-card .cc-go { margin-top: 12px; font-size: 0.82rem; font-weight: 700; color: var(--blue); }
