/* Dojo Circle design system — self-contained, no external fonts/CDNs */
:root {
  --ink: #1c1917;
  --ink-soft: #57534e;
  --ink-faint: #a8a29e;
  --paper: #fafaf9;
  --card: #ffffff;
  --border: #e7e5e4;
  --border-soft: #f0eeed;
  --brand: #9f1d1d;
  --brand-dark: #7a1616;
  --brand-soft: #fdeceb;
  --accent: #1f6f5c;
  --accent-soft: #e7f5f1;
  --warn: #b45309;
  --warn-soft: #fef3e2;
  --danger: #b91c1c;
  --danger-soft: #fdeceb;
  --info: #2563a8;
  --info-soft: #eaf1fb;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(28,25,23,.06);
  --shadow-md: 0 4px 14px rgba(28,25,23,.08);
  --sidebar-w: 248px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--paper);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
}
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0 0 4px 0; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0 0 8px 0; }
.icon { width: 18px; height: 18px; flex-shrink: 0; }
.icon-sm { width: 14px; height: 14px; }
.icon-lg { width: 28px; height: 28px; }

/* ---------- Auth / login ---------- */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
}
.auth-visual {
  background: radial-gradient(circle at 20% 20%, #b3282180, transparent 45%), linear-gradient(160deg, var(--brand-dark), #2b0f0f 70%);
  color: #fff;
  padding: 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.auth-visual .brand { font-size: 22px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.auth-visual .pitch h2 { font-size: 34px; line-height: 1.15; max-width: 480px; }
.auth-visual .pitch p { color: #f1d9d9; max-width: 440px; }
.auth-visual .feature-list { display: flex; flex-direction: column; gap: 14px; margin-top: 24px; }
.auth-visual .feature-list div { display: flex; gap: 10px; align-items: flex-start; color: #f5e6e6; font-size: 14px; }
/* Must come after the unconditional .auth-visual rule above -- same
   specificity, so source order decides, and this is the one that needs to win
   under 900px (previously ordered before it, so this was dead code and the
   hero pitch never actually hid on mobile, pushing the real login form
   below a full extra screen of decorative content). */
@media (max-width: 900px) { .auth-shell { grid-template-columns: 1fr; } .auth-visual { display: none; } }
.auth-form-wrap {
  display: flex; align-items: center; justify-content: center; padding: 40px 24px;
}
.auth-card { width: 100%; max-width: 380px; }
.auth-card .logo-mark { width: 44px; height: 44px; border-radius: 12px; background: var(--brand); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px; margin-bottom: 18px;}
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-soft); }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
textarea { resize: vertical; min-height: 90px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 16px; border-radius: 8px; font-weight: 600; font-size: 14px;
  border: 1px solid transparent; cursor: pointer; transition: all .12s ease;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--border); }
.btn-secondary:hover { background: var(--border-soft); }
.btn-ghost { background: transparent; color: var(--ink-soft); }
.btn-ghost:hover { background: var(--border-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fadada; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.demo-accounts { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 16px; }
.demo-accounts summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.demo-account-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px dashed var(--border-soft); font-size: 12.5px; }
.demo-account-row:last-child { border-bottom: none; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: #1c1917; color: #e7e5e4;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px; font-weight: 800; font-size: 17px; color: #fff; border-bottom: 1px solid #33302e; }
.sidebar-brand .logo-mark { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); display:flex; align-items:center; justify-content:center; font-size:14px; }
.sidebar-role-badge { margin: 14px 18px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #a8a29e; font-weight: 700; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 4px 10px; }
.sidebar-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; font-size: 14px; color: #d6d3d1; margin-bottom: 2px; font-weight: 500; }
.sidebar-nav a:hover { background: #2a2624; color: #fff; }
.sidebar-nav a.active { background: var(--brand); color: #fff; }
.sidebar-foot { padding: 14px 18px; border-top: 1px solid #33302e; font-size: 12.5px; color: #a8a29e; }
.sidebar-foot a { display:flex; align-items:center; gap:8px; color: #e7e5e4; font-weight:600; }

.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; padding: 14px 28px;
  background: #fff; border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 19px; }
.topbar .sub { color: var(--ink-soft); font-size: 13px; margin: 0; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .meta { line-height: 1.2; }
.user-chip .name { font-weight: 600; font-size: 13.5px; }
.user-chip .role { font-size: 11.5px; color: var(--ink-soft); }
.content { padding: 26px 28px 60px; max-width: 1320px; width: 100%; margin: 0 auto; }

.flash-stack { padding: 0 28px; margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 8px; font-size: 13.5px; font-weight: 500; }
.flash-success { background: var(--accent-soft); color: var(--accent); }
.flash-error { background: var(--danger-soft); color: var(--danger); }

/* ---------- Cards / stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat-card .label { font-size: 12.5px; color: var(--ink-soft); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; display:flex; align-items:center; gap:6px; }
.stat-card .value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.stat-card .delta { font-size: 12.5px; margin-top: 4px; font-weight: 600; }
.stat-card .delta.up { color: var(--accent); }
.stat-card .delta.down { color: var(--danger); }

.panel { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: 22px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-soft); }
.panel-head h3 { font-size: 15px; }
.panel-head .sub { font-size: 12.5px; color: var(--ink-soft); }
.panel-body { padding: 18px 20px; }
.panel-body.no-pad { padding: 0; }
.two-col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 22px; }
.two-col-even { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
@media (max-width: 980px) { .two-col, .two-col-even { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 20px; gap: 16px; flex-wrap: wrap; }
.page-head .desc { color: var(--ink-soft); font-size: 13.5px; max-width: 640px; }
.table-toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.table-toolbar form { display: flex; align-items: center; gap: 8px; flex: 1; }
.table-toolbar input[type=text] { max-width: 260px; }
table { width: 100%; border-collapse: collapse; }
thead th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); padding: 10px 20px; border-bottom: 1px solid var(--border); background: #fbfaf9; }
tbody td { padding: 12px 20px; border-bottom: 1px solid var(--border-soft); font-size: 13.75px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fbfaf9; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty-state { padding: 48px 20px; text-align: center; color: var(--ink-soft); }
.empty-state .icon-lg { margin: 0 auto 10px; color: var(--ink-faint); }

/* ---------- Badges / chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; text-transform: capitalize; }
.badge-neutral { background: var(--border-soft); color: var(--ink-soft); }
.badge-success { background: var(--accent-soft); color: var(--accent); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.belt-chip { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 13px; }
.belt-swatch { width: 22px; height: 10px; border-radius: 3px; border: 1px solid rgba(0,0,0,.15); display: inline-block; }
.pill-select { display: inline-flex; gap: 4px; flex-wrap: wrap; }

/* ---------- Forms ---------- */
.form-card { max-width: 640px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .span-2 { grid-column: span 2; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } .form-grid .span-2 { grid-column: span 1; } }
.form-actions { display: flex; gap: 10px; margin-top: 18px; }
.help-text { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; margin: 0 0 14px; }
legend { font-weight: 700; font-size: 13px; padding: 0 6px; }

/* ---------- Misc ---------- */
.divider { border: none; border-top: 1px solid var(--border-soft); margin: 18px 0; }
.muted { color: var(--ink-soft); }
.small { font-size: 12.5px; }
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.progress-track { background: var(--border-soft); border-radius: 999px; height: 8px; overflow: hidden; }
.progress-fill { background: var(--brand); height: 100%; border-radius: 999px; }
.child-switch { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.child-switch a { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: #fff; font-weight: 600; font-size: 13px; }
.child-switch a.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.kv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.kv-grid .kv-item .k { font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); font-weight: 700; }
.kv-grid .kv-item .v { font-size: 14.5px; font-weight: 600; margin-top: 3px; }
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item { display: flex; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.attendance-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(26px, 1fr)); gap: 4px; max-width: 460px; }
.att-cell { width: 100%; aspect-ratio: 1; border-radius: 4px; }
.msg-list a { display: block; padding: 14px 20px; border-bottom: 1px solid var(--border-soft); }
.msg-list a:hover { background: #fbfaf9; }
.msg-list .top-row { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 3px; }
.msg-list .snippet { font-size: 12.5px; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-list a.unread .top-row .from { font-weight: 800; }
.bubble { max-width: 70%; padding: 10px 14px; border-radius: 14px; margin-bottom: 10px; font-size: 13.75px; }
.bubble.mine { background: var(--brand); color: #fff; margin-left: auto; border-bottom-right-radius: 3px; }
.bubble.theirs { background: var(--border-soft); color: var(--ink); border-bottom-left-radius: 3px; }
.bubble .meta { font-size: 10.5px; opacity: .7; margin-top: 4px; }
.checklist-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border-soft); gap: 12px; }
.checklist-row:last-child { border-bottom: none; }
.cat-tag { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; color: var(--ink-faint); }

@media (max-width: 780px) {
  .sidebar { position: fixed; left: -260px; z-index: 20; transition: left .2s ease; }
  .sidebar.open { left: 0; }
  .content { padding: 18px; }
  .topbar { padding: 12px 16px; }
}
