/* Japanese Ninjas Institute — theme
   Palette inspired by traditional Japanese colour names:
   Ai-iro (indigo) for structure, Shu-iro (vermillion) for action/accent,
   washi paper cream for background, sumi ink for text. */
:root {
  --indigo: #16233b;
  --indigo-dark: #0c1524;
  --indigo-mid: #3a5a86;
  --vermillion: #a5352a;
  --vermillion-dark: #832920;
  --gold: #b6944e;
  --gold-soft: #e8dcc0;
  --bg: #f5f1e8;
  --card: #fffefc;
  --border: #e3dcc9;
  --text: #241f1a;
  --muted: #7a7266;
  --green: #2e7d32;
  --red: #a5352a;
  --amber: #a56a1a;
  --amber-bg: #f8eedb;
  --green-bg: #e6f2e7;
  --red-bg: #f8e9e6;
  --shadow-sm: 0 1px 3px rgba(12,21,36,0.06);
  --shadow-md: 0 10px 26px rgba(12,21,36,0.10);
  --shadow-lg: 0 20px 48px rgba(12,21,36,0.18);
}
* { box-sizing: border-box; }
/* Off-canvas panels (mobile nav drawer, chat thread pane) hide themselves with
   transform: translateX(...) rather than display:none, so their layout box
   still exists just outside the viewport — without this, that box silently
   extends the whole page's scrollable width, leaving a blank strip you can
   swipe/zoom into on a phone even though nothing looks wrong at a glance. */
html { scrollbar-color: var(--gold) transparent; overflow-x: hidden; }
body {
  overflow-x: hidden;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Washi paper base + a faint kumiko lattice (the diagonal joinery grid seen in
     shoji screens) — straight-line, geometric, kept subtle so it never fights
     with readability. */
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='52' height='52' viewBox='0 0 52 52'%3E%3Cpath d='M0 0L52 52M52 0L0 52' stroke='%2316233b' stroke-width='0.8' fill='none' opacity='0.05'/%3E%3C/svg%3E");
  background-attachment: fixed;
}
a { color: var(--indigo-mid); text-decoration: none; }
::selection { background: var(--gold); color: var(--indigo-dark); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gold-soft); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
.shell { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 226px;
  background: linear-gradient(180deg, var(--indigo-dark) 0%, var(--indigo) 100%);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 22px 0;
  flex-shrink: 0;
  position: relative;
  border-right: 3px solid var(--vermillion);
  overflow: hidden;
}
.sidebar::before {
  content: "";
  position: absolute;
  right: -60px;
  bottom: -60px;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  border: 10px solid rgba(255,255,255,0.035);
  border-right-color: transparent;
  pointer-events: none;
}
.brand {
  font-weight: 700;
  font-size: 17px;
  padding: 0 20px 20px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: 0.01em;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  position: relative;
}
.brand::after {
  content: "";
  position: absolute;
  left: 20px;
  bottom: -1px;
  width: 34px;
  height: 1px;
  background: var(--gold);
}
.brand-seal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--vermillion);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15);
  flex-shrink: 0;
}
.brand-logo {
  height: 36px;
  width: auto;
  flex-shrink: 0;
  border-radius: 6px;
  background: #fff;
  padding: 2px;
}
.login-card .brand-logo {
  height: 64px;
  display: block;
  margin: 0 auto 10px;
}
.sidebar nav { display: flex; flex-direction: column; flex: 1; }
.sidebar nav a {
  color: #cfd9e8;
  padding: 10px 20px;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  transition: background 0.15s ease, padding-left 0.15s ease, color 0.15s ease;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.07); color: #fff; padding-left: 24px; }
.sidebar nav a.active { background: rgba(165,53,42,0.22); color: #fff; border-left-color: var(--vermillion); font-weight: 600; box-shadow: inset 0 0 16px rgba(165,53,42,0.15); }
.nav-divider { height: 1px; background: rgba(255,255,255,0.09); margin: 10px 20px; flex-shrink: 0; }
.sidebar-footer { padding: 16px 20px 0; border-top: 1px solid rgba(255,255,255,0.14); margin-top: 12px; }
.sidebar-footer a { display: block; color: #cfd9e8; font-size: 12.5px; margin-bottom: 8px; }
.link-btn { background: none; border: none; color: #e8a79c; font-size: 12.5px; padding: 0; cursor: pointer; }

/* ---------- Layout ---------- */
.content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 28px;
  display: flex;
  justify-content: flex-end;
  font-size: 14px;
  box-shadow: var(--shadow-sm);
  position: relative;
  z-index: 3;
}
.role-badge {
  text-transform: capitalize;
  background: #eef2f8;
  color: var(--indigo);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 11.5px;
  margin-left: 6px;
  border: 1px solid #dbe3ee;
}
.page { padding: 24px 28px 60px; max-width: 1200px; animation: page-in 0.28s ease; }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

h1 { font-size: 22px; margin: 0 0 4px; color: var(--indigo-dark); letter-spacing: -0.01em; }
h2 { font-size: 16px; margin: 0 0 12px; color: var(--indigo); font-weight: 700; }
.subtitle { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.page-header h1 { display: flex; flex-direction: column; }
.page-header h1::after {
  content: "";
  display: block;
  width: 34px;
  height: 3px;
  background: linear-gradient(90deg, var(--vermillion), var(--gold));
  margin-top: 8px;
  border-radius: 2px;
}

.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.22s ease, transform 0.22s ease, border-color 0.22s ease;
}
.card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--vermillion), var(--gold));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}
.card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); border-color: #d8cead; }
.card:hover::before { transform: scaleX(1); }

.btn {
  position: relative;
  display: inline-block;
  background: var(--vermillion);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: normal;
  vertical-align: middle;
  cursor: pointer;
  text-decoration: none;
  overflow: hidden;
  transition: background 0.12s ease, transform 0.12s ease, box-shadow 0.12s ease;
}
.btn::before {
  content: "";
  position: absolute;
  top: 0; bottom: 0; left: -60%;
  width: 40%;
  background: linear-gradient(115deg, transparent, rgba(255,255,255,0.28), transparent);
  transform: skewX(-20deg);
  transition: left 0.5s ease;
}
.btn:hover::before { left: 120%; }
.btn:hover { background: var(--vermillion-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(165,53,42,0.28); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-secondary { background: #eef1ea; color: var(--indigo-dark); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e4e0d3; }
.btn-danger { background: var(--red); }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 700; font-size: 11.5px; text-transform: uppercase; letter-spacing: .03em; border-bottom: 2px solid var(--gold-soft); }
tbody tr { transition: background 0.12s ease, box-shadow 0.15s ease; box-shadow: inset 0 0 0 var(--vermillion); }
tbody tr:hover { box-shadow: inset 3px 0 0 var(--vermillion); }
tr:hover td { background: #fbf8f0; }
.row-dropped td { background: var(--red-bg); }
.row-dropped:hover td { background: #f3d6d1; }
.table-wrap { overflow-x: auto; }

/* Row actions (schedule a class, add notes, request a postpone) used to
   expand a <details> right inside its table cell, stretching the whole row's
   height and squeezing every other column. Native <dialog> fixes this
   properly: browsers render it in a dedicated top layer that's immune to any
   ancestor's overflow/stacking (a hand-rolled position:fixed popover was
   tried first, but got clipped/mis-stacked by .card's own overflow:hidden —
   exactly the kind of ancestor interference <dialog> is designed to avoid). */
.row-action-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  font-size: 12px; color: var(--indigo-mid); text-decoration: none;
}
.row-action-btn:hover { text-decoration: underline; }
dialog.row-dialog {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 20px;
  width: 340px;
  max-width: 90vw;
  max-height: 80vh;
}
dialog.row-dialog::backdrop { background: rgba(12,21,36,0.55); }
dialog.row-dialog h2 { margin-bottom: 14px; }

.badge { padding: 2px 9px; border-radius: 10px; font-size: 11.5px; font-weight: 600; display: inline-block; border: 1px solid transparent; }
.badge-green { background: var(--green-bg); color: var(--green); border-color: rgba(46,125,50,0.18); }
.badge-red { background: var(--red-bg); color: var(--red); border-color: rgba(165,53,42,0.18); }
.badge-amber { background: var(--amber-bg); color: var(--amber); border-color: rgba(165,106,26,0.18); }
.badge-gray { background: #eef1ea; color: var(--muted); border-color: var(--border); }

form.inline { display: inline; }
label { display: block; font-size: 12.5px; font-weight: 700; color: var(--muted); margin: 12px 0 4px; }
label:first-child { margin-top: 0; }
input, select, textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--indigo-mid);
  box-shadow: 0 0 0 3px rgba(42,74,115,0.12);
}

.pw-field { position: relative; display: block; width: 100%; }
.pw-field input[type="password"], .pw-field input[type="text"] { padding-right: 36px; }
.pw-toggle {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px; padding: 0; display: flex; align-items: center; justify-content: center;
  background: none; border: none; border-radius: 5px; color: var(--muted); cursor: pointer;
}
.pw-toggle:hover { color: var(--indigo-mid); background: rgba(42,74,115,0.08); }
.pw-toggle svg { width: 17px; height: 17px; }
textarea { resize: vertical; min-height: 60px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-actions { margin-top: 18px; display: flex; gap: 10px; }

.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 24px; }
.kpi {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--vermillion);
  border-radius: 8px;
  padding: 16px 18px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.22s ease, transform 0.22s ease, border-left-color 0.22s ease;
}
.kpi::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, transparent 40%, rgba(182,148,78,0.10) 50%, transparent 60%);
  transform: translateX(-120%);
  transition: transform 0.55s ease;
  pointer-events: none;
}
.kpi:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-left-color: var(--gold);
}
.kpi:hover::after { transform: translateX(120%); }
.kpi .num { font-size: 26px; font-weight: 700; color: var(--indigo-dark); position: relative; }
.kpi .label { font-size: 12.5px; color: var(--muted); margin-top: 2px; position: relative; }

.kpi-grid .kpi { animation: tile-in 0.4s ease backwards; }
.kpi-grid .kpi:nth-child(1) { animation-delay: 0.02s; }
.kpi-grid .kpi:nth-child(2) { animation-delay: 0.06s; }
.kpi-grid .kpi:nth-child(3) { animation-delay: 0.10s; }
.kpi-grid .kpi:nth-child(4) { animation-delay: 0.14s; }
.kpi-grid .kpi:nth-child(5) { animation-delay: 0.18s; }
.kpi-grid .kpi:nth-child(6) { animation-delay: 0.22s; }
.kpi-grid .kpi:nth-child(7) { animation-delay: 0.26s; }
.kpi-grid .kpi:nth-child(8) { animation-delay: 0.30s; }
@keyframes tile-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.alert { padding: 10px 14px; border-radius: 6px; font-size: 13.5px; margin-bottom: 16px; }
.alert-error { background: var(--red-bg); color: var(--red); }
.alert-success { background: var(--green-bg); color: var(--green); }

.empty-state { color: var(--muted); font-size: 13.5px; padding: 30px 0; text-align: center; }
.small-note { color: var(--muted); font-size: 12px; margin-top: 8px; }

/* ---------- login pages ---------- */
.login-wrap {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(165,53,42,0.16) 0, transparent 45%),
    radial-gradient(circle at 80% 75%, rgba(182,148,78,0.14) 0, transparent 45%),
    var(--indigo-dark);
}
.login-wrap::before {
  content: "";
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  width: 560px;
  height: 380px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 150'%3E%3Cg fill='%23e0574a'%3E%3Crect x='8' y='10' width='184' height='14' rx='7'/%3E%3Crect x='22' y='28' width='156' height='8'/%3E%3Crect x='38' y='36' width='16' height='100'/%3E%3Crect x='146' y='36' width='16' height='100'/%3E%3Crect x='30' y='78' width='140' height='10'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: bottom center;
  background-size: contain;
  opacity: 0.10;
  z-index: 0;
  pointer-events: none;
}
.login-card {
  background: var(--card);
  padding: 38px 34px;
  border-radius: 12px;
  width: 340px;
  border-top: 4px solid var(--vermillion);
  box-shadow: var(--shadow-lg);
}
.login-card h1 { text-align: center; margin-bottom: 4px; }
.login-card .subtitle { text-align: center; }
.login-card { position: relative; z-index: 2; animation: card-rise 0.5s cubic-bezier(.2,.8,.2,1); }
@keyframes card-rise { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

/* Falling sakura petals — purely decorative, sits behind the login card */
.sakura-layer { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 1; }
.petal {
  position: absolute;
  top: -5%;
  width: 14px;
  height: 14px;
  background: linear-gradient(135deg, #ffd7cf, #ffb3a3);
  border-radius: 0 60% 0 60%;
  opacity: 0.75;
  animation: petal-fall linear infinite;
}
@keyframes petal-fall {
  0%   { transform: translate(0, 0) rotate(0deg); }
  100% { transform: translate(var(--drift, 40px), 115vh) rotate(360deg); }
}

/* ---------- Ninja loader — shown during page navigation ---------- */
#ninja-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(247,243,234,0.94);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
#ninja-loader.active { opacity: 1; pointer-events: all; }
.ninja-loader-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.ninja-sun {
  position: relative;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e0574a, var(--vermillion) 70%);
  box-shadow: 0 0 0 6px rgba(165,53,42,0.12), 0 8px 24px rgba(165,53,42,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: sun-pulse 1.1s ease-in-out infinite;
}
@keyframes sun-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
.shuriken {
  width: 40px;
  height: 40px;
  position: relative;
  animation: shuriken-spin 0.9s linear infinite;
}
.shuriken::before, .shuriken::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--indigo-dark);
  clip-path: polygon(50% 0%, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0% 50%, 38% 38%);
}
.shuriken::after { background: #fff; transform: scale(0.28); clip-path: circle(50%); }
@keyframes shuriken-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.ninja-loader-text {
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--indigo);
  animation: text-fade 1.2s ease-in-out infinite;
}
@keyframes text-fade { 0%, 100% { opacity: 0.5; } 50% { opacity: 1; } }

/* ---------- Custom date/month picker (public/js/datepicker.js) ---------- */
.jn-dp-trigger {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13.5px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.jn-dp-trigger:hover, .jn-dp-trigger:focus { outline: none; border-color: var(--indigo-mid); box-shadow: 0 0 0 3px rgba(58,90,134,0.12); }
.jn-dp-trigger.jn-dp-empty .jn-dp-trigger-text { color: var(--muted); }
.jn-dp-trigger-icon { flex-shrink: 0; font-size: 13px; opacity: 0.85; }
.jn-dp-trigger.jn-dp-error { border-color: var(--vermillion); animation: dp-shake 0.3s ease; }
@keyframes dp-shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

.jn-dp-panel {
  position: fixed;
  z-index: 500;
  width: 264px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 12px;
  animation: dp-in 0.15s ease;
}
.jn-dp-panel-month { width: 220px; }
@keyframes dp-in { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.jn-dp-header { display: flex; align-items: center; justify-content: space-between; gap: 2px; margin-bottom: 10px; }
.jn-dp-title { flex: 1; text-align: center; font-weight: 700; font-size: 12.5px; color: var(--indigo-dark); }
.jn-dp-nav-btn {
  width: 24px; height: 24px; flex-shrink: 0;
  border-radius: 6px; border: 1px solid var(--border); background: #fff; color: var(--indigo-dark);
  font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.jn-dp-nav-btn:hover { background: var(--indigo-dark); color: #fff; border-color: var(--indigo-dark); }
.jn-dp-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; margin-bottom: 4px; }
.jn-dp-weekdays span { font-size: 9.5px; font-weight: 700; color: var(--muted); text-align: center; text-transform: uppercase; }
.jn-dp-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.jn-dp-day {
  width: 100%; aspect-ratio: 1; border: none; background: none; border-radius: 50%;
  font-size: 12.5px; color: var(--text); cursor: pointer; transition: background 0.12s ease, color 0.12s ease;
}
.jn-dp-day.is-outside { visibility: hidden; cursor: default; }
.jn-dp-day:not(.is-outside):hover { background: var(--gold-soft); }
.jn-dp-day.is-today { box-shadow: inset 0 0 0 1.5px var(--gold); }
.jn-dp-day.is-selected { background: var(--vermillion); color: #fff; font-weight: 700; }
.jn-dp-months { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.jn-dp-month-cell {
  padding: 10px 0; border-radius: 6px; border: 1px solid var(--border); background: #fff;
  font-size: 12.5px; font-weight: 600; color: var(--text); cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.jn-dp-month-cell:hover { border-color: var(--gold); }
.jn-dp-month-cell.is-today { border-color: var(--gold); }
.jn-dp-month-cell.is-selected { background: var(--vermillion); color: #fff; border-color: var(--vermillion); }
.jn-dp-footer { display: flex; justify-content: space-between; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.jn-dp-footer button { background: none; border: none; color: var(--indigo-mid); font-size: 12px; font-weight: 700; cursor: pointer; padding: 2px 4px; }
.jn-dp-footer button:hover { text-decoration: underline; }

/* Book dispatch progress tracker — shared by staff Book Dispatch page and the
   student portal's own Book Delivery Address page, so both sides see the same thing. */
.book-track { display: flex; align-items: center; gap: 0; min-width: 260px; }
.book-track.large { min-width: 320px; margin: 16px 0 8px; }
.book-track .step { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; }
.book-track .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--border); z-index: 1; }
.book-track.large .dot { width: 16px; height: 16px; }
.book-track .step.done .dot { background: var(--vermillion); }
.book-track .step-label { font-size: 9px; color: var(--muted); margin-top: 4px; text-align: center; white-space: nowrap; }
.book-track.large .step-label { font-size: 11px; }
.book-track .line { position: absolute; top: 5px; left: -50%; width: 100%; height: 2px; background: var(--border); z-index: 0; }
.book-track.large .line { top: 7px; }
.book-track .step.done .line { background: var(--vermillion); }
.book-track .step:first-child .line { display: none; }
.book-track .car { position: absolute; top: -16px; font-size: 14px; left: 50%; transform: translateX(-50%); }
.book-track.large .car { font-size: 18px; top: -20px; }

/* Welcome banner — one-time overlay shown right after someone's very first login. */
.welcome-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(12,21,36,0.72);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  animation: welcome-fade-in 0.25s ease;
}
@keyframes welcome-fade-in { from { opacity: 0; } to { opacity: 1; } }
.welcome-card {
  background: var(--card);
  border-radius: 14px;
  max-width: 520px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: card-rise 0.4s cubic-bezier(.2,.8,.2,1);
  position: relative;
}
.welcome-banner {
  background: linear-gradient(120deg, var(--vermillion) 0%, var(--vermillion-dark) 100%);
  color: #fff;
  padding: 30px 28px 22px;
  border-radius: 14px 14px 0 0;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.welcome-banner::before {
  content: "";
  position: absolute;
  top: -30%; right: -10%;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}
.welcome-banner .seal {
  width: 52px; height: 52px;
  margin: 0 auto 10px;
  border-radius: 50%;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}
.welcome-banner h2 { margin: 0 0 6px; font-size: 20px; color: #fff; letter-spacing: -0.01em; }
.welcome-banner p { margin: 0; font-size: 13.5px; opacity: 0.95; line-height: 1.5; }
.welcome-body { padding: 22px 28px 26px; }
.welcome-body h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 0 0 12px; }
.welcome-section { margin-bottom: 16px; }
.welcome-section:last-of-type { margin-bottom: 0; }
.welcome-section-title { font-size: 13.5px; font-weight: 700; color: var(--indigo-dark); margin-bottom: 6px; display: flex; align-items: center; gap: 6px; }
.welcome-list { margin: 0; padding: 0; list-style: none; }
.welcome-list li { font-size: 13px; color: var(--text); padding: 5px 0 5px 18px; position: relative; line-height: 1.4; }
.welcome-list li::before { content: "•"; position: absolute; left: 4px; color: var(--gold); font-weight: 700; }
.welcome-footer { padding: 16px 28px 24px; text-align: center; }
.welcome-footer button {
  background: var(--indigo-dark); color: #fff; border: none;
  padding: 11px 28px; border-radius: 7px; font-size: 13.5px; font-weight: 700;
  cursor: pointer; transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.welcome-footer button:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(12,21,36,0.28); }

/* ---------- Chat (WhatsApp-style two-pane) ---------- */
.chat-badge {
  position: absolute; top: -6px; right: -10px;
  background: var(--vermillion); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 9px; padding: 1px 5px; min-width: 16px; text-align: center;
}
.chat-shell {
  display: flex; height: calc(100vh - 140px); min-height: 420px;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.chat-list-pane { width: 300px; flex-shrink: 0; border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.chat-list-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.chat-list-header h2 { margin: 0; }
.chat-search-wrap { border-bottom: 1px solid var(--border); padding: 10px; }
.chat-search-wrap input { margin-bottom: 0; }
.chat-contact-results { max-height: 240px; overflow-y: auto; margin-top: 8px; }
.chat-contact-row, .chat-convo-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer;
  border-bottom: 1px solid var(--border); transition: background 0.12s ease;
}
.chat-contact-row:hover, .chat-convo-row:hover { background: #fbf8f0; }
.chat-convo-row.active { background: var(--gold-soft); }
.chat-avatar {
  width: 38px; height: 38px; border-radius: 50%; background: var(--indigo);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.chat-convo-info { flex: 1; min-width: 0; }
.chat-convo-name { font-size: 13.5px; font-weight: 700; color: var(--text); display: flex; justify-content: space-between; gap: 6px; }
.chat-convo-preview { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-convo-sub { font-size: 10.5px; color: var(--muted); text-transform: capitalize; }
.chat-unread-dot { background: var(--vermillion); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 9px; padding: 1px 6px; flex-shrink: 0; }
.chat-conversations { flex: 1; overflow-y: auto; }
.chat-thread-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-thread-empty { flex: 1; display: flex; align-items: center; justify-content: center; }
.chat-thread { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-thread-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.chat-back-btn { display: none; background: none; border: none; font-size: 14px; color: var(--indigo-mid); cursor: pointer; padding: 4px; }
.chat-thread-title { font-size: 14px; font-weight: 700; color: var(--text); }
.chat-thread-title .sub { font-size: 11.5px; font-weight: 400; color: var(--muted); text-transform: capitalize; }
.chat-messages { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; background: #f9f6ee; }
.chat-bubble-row { display: flex; }
.chat-bubble-row.mine { justify-content: flex-end; }
.chat-bubble {
  max-width: 68%; padding: 8px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.4;
  box-shadow: var(--shadow-sm); word-wrap: break-word; white-space: pre-wrap;
}
.chat-bubble-row.mine .chat-bubble { background: var(--vermillion); color: #fff; border-bottom-right-radius: 3px; }
.chat-bubble-row:not(.mine) .chat-bubble { background: #fff; color: var(--text); border-bottom-left-radius: 3px; }
.chat-bubble img { max-width: 100%; border-radius: 8px; display: block; margin-bottom: 4px; }
.chat-bubble .file-link { display: flex; align-items: center; gap: 6px; text-decoration: underline; }
.chat-bubble-row.mine .chat-bubble .file-link { color: #fff; }
.chat-bubble-time { font-size: 10px; opacity: 0.7; margin-top: 3px; text-align: right; }
.chat-input-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--card); }
.chat-input-bar input[type="text"] { margin: 0; }
.chat-attach-btn, .chat-send-btn {
  background: var(--indigo); color: #fff; border: none; width: 38px; height: 38px; border-radius: 50%;
  font-size: 16px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  transition: background 0.12s ease;
}
.chat-send-btn { background: var(--vermillion); }
.chat-attach-btn:hover { background: var(--indigo-dark); }
.chat-send-btn:hover { background: var(--vermillion-dark); }
.chat-file-preview { display: flex; align-items: center; gap: 6px; font-size: 12px; background: var(--gold-soft); padding: 4px 10px; border-radius: 6px; }
.chat-file-preview button { background: none; border: none; cursor: pointer; font-size: 13px; }

/* ---------- Responsive: tablet & phone ---------- */
.nav-toggle {
  display: none;
  background: none; border: none; cursor: pointer; padding: 4px;
  color: var(--indigo-dark); font-size: 20px; margin-right: 10px; line-height: 1;
}
.sidebar-backdrop { display: none; }

@media (max-width: 900px) {
  .nav-toggle { display: inline-flex; align-items: center; }
  .topbar { padding: 12px 16px; justify-content: space-between; }
  .shell { position: relative; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 200;
    width: 250px; max-width: 82vw;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: var(--shadow-lg);
  }
  .shell.nav-open .sidebar { transform: translateX(0); }
  .shell.nav-open .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(12,21,36,0.55); z-index: 199;
  }
  .content { width: 100%; }
  .page { padding: 16px 14px 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .page-header { align-items: flex-start; }
  .kpi-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }

  .chat-shell { height: calc(100vh - 110px); border-radius: 0; margin: -16px -14px; }
  .chat-list-pane { width: 100%; border-right: none; }
  .chat-thread-pane { position: absolute; inset: 0; background: var(--card); transform: translateX(100%); transition: transform 0.2s ease; }
  .chat-shell.thread-open .chat-list-pane { display: none; }
  .chat-shell.thread-open .chat-thread-pane { transform: translateX(0); position: relative; }
  .chat-back-btn { display: inline-block; }
  .chat-bubble { max-width: 82%; }
}

@media (max-width: 520px) {
  .page-header .btn, .page-header .btn-secondary { padding: 8px 12px; font-size: 12px; }
  table { font-size: 12.5px; }
  th, td { padding: 7px 8px; }
}

/* ---------- Community Reels feed ---------- */
.reels-container {
  height: calc(100vh - 20px);
  max-width: 460px;
  margin: 0 auto;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  border-radius: 14px;
  background: #000;
  box-shadow: var(--shadow-lg);
}
.reels-card {
  position: relative;
  height: calc(100vh - 20px);
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
.reels-media { width: 100%; height: 100%; object-fit: contain; background: #000; }
.reels-watermark {
  position: absolute;
  top: 14px;
  left: 14px;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.28);
  padding: 5px 10px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}
.reels-author {
  position: absolute;
  bottom: 18px;
  left: 14px;
  right: 76px;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}
.reels-author strong { font-size: 14px; display: flex; align-items: center; gap: 8px; }
.reels-caption { font-size: 13px; margin-top: 6px; line-height: 1.4; }
.reels-hashtags { font-size: 12.5px; margin-top: 4px; opacity: 0.85; }
.reels-actions {
  position: absolute;
  bottom: 20px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  align-items: center;
}
.reels-action-btn {
  background: none;
  border: none;
  color: #fff;
  font-size: 26px;
  cursor: pointer;
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.reels-action-btn span { font-size: 11px; font-weight: 600; }
.reels-empty { color: #fff; text-align: center; padding: 60px 20px; }

/* YouTube Shorts reel cards */
.yt-reel-card { background: #000; }
.yt-player, .yt-player iframe { width: 100%; height: 100%; border: none; }
.yt-subscribe-gate {
  position: absolute; inset: 0; z-index: 5;
  background: rgba(6,10,18,0.88);
  display: flex; align-items: center; justify-content: center;
  opacity: 1; transition: opacity 0.25s ease;
}
.yt-subscribe-gate.yt-gate-hidden { opacity: 0; pointer-events: none; }
.yt-gate-inner { text-align: center; color: #fff; padding: 20px; }
