/* Just Consultants Campus — Material You inspired theme, mobile-first */

:root {
  --font: "Segoe UI", Roboto, -apple-system, sans-serif;
  --r-sm: 12px;
  --r-md: 16px;
  --r-lg: 24px;
  --r-pill: 999px;
  --bg: #F7F5FB;
  --surface: #FFFFFF;
  --surface-alt: #F1EEF7;
  --text: #1C1B1F;
  --muted: #625B71;
  --outline: #E2DEEA;
  --ok: #146c2e; --ok-bg: #DFF5E3;
  --bad: #ba1a1a; --bad-bg: #FFDAD6;
  --warn: #8a5300; --warn-bg: #FFECC7;
  --info: #0b5fae; --info-bg: #DCEBFF;
  --elev-1: 0 1px 2px rgba(28,27,31,.20), 0 1px 3px 1px rgba(28,27,31,.10);
  --elev-2: 0 1px 2px rgba(28,27,31,.24), 0 3px 8px 1px rgba(28,27,31,.14);
  /* Default brand tone for pages with no role-* class (e.g. the login page) */
  --primary: #6750A4; --primary-dark: #4F378B; --on-primary: #FFFFFF;
  --primary-container: #EADDFF; --on-primary-container: #21005D;
  --secondary-container: #E8DEF8;
}

/* ---- Role tonal palettes (Material You style: primary / container / on-container) ---- */
body.role-admin {
  --primary: #6750A4; --primary-dark: #4F378B; --on-primary: #FFFFFF;
  --primary-container: #EADDFF; --on-primary-container: #21005D;
  --secondary-container: #E8DEF8;
}
body.role-teacher {
  --primary: #00696D; --primary-dark: #004F52; --on-primary: #FFFFFF;
  --primary-container: #9DF3EF; --on-primary-container: #002020;
  --secondary-container: #CDE7E5;
}
body.role-parent {
  --primary: #B4460A; --primary-dark: #8F3900; --on-primary: #FFFFFF;
  --primary-container: #FFDBC6; --on-primary-container: #341100;
  --secondary-container: #F6DDC3;
}
body.role-management {
  --primary: #3A57A6; --primary-dark: #2A4483; --on-primary: #FFFFFF;
  --primary-container: #DCE1FF; --on-primary-container: #001358;
  --secondary-container: #E0E1F9;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.55;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; font-weight: 700; letter-spacing: -.01em; }
h1 { font-size: 25px; }
h2 { font-size: 20px; }
h3 { font-size: 17px; }
p { margin: 0 0 1em; }
:focus-visible { outline: 2.5px solid var(--primary); outline-offset: 2px; }
.icon { width: 20px; height: 20px; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }

/* ---- Login page ---- */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(60% 55% at 12% 8%, #EADDFF 0%, transparent 60%),
    radial-gradient(55% 50% at 92% 12%, #9DF3EF 0%, transparent 60%),
    radial-gradient(60% 55% at 85% 92%, #FFDBC6 0%, transparent 60%),
    radial-gradient(55% 55% at 8% 90%, #DCE1FF 0%, transparent 60%),
    linear-gradient(135deg, #6750A4 0%, #3A57A6 100%);
  background-color: #6750A4;
}
.login-card {
  background: var(--surface);
  border-radius: 28px;
  box-shadow: var(--elev-2);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
}
.login-card .btn { width: 100%; }
.login-card h1 { font-size: 22px; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 14px; }

/* ---- App shell ---- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.scrim { display: none; }
.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: #fff;
  padding: 24px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
}
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.avatar {
  width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,.22);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px;
  flex-shrink: 0; color: #fff;
}
.avatar-sm { width: 32px; height: 32px; font-size: 13px; background: var(--primary-container); color: var(--on-primary-container); }
.sidebar .brand { font-weight: 700; font-size: 15px; line-height: 1.3; }
.sidebar .role-tag {
  display: inline-block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  background: rgba(255,255,255,.2); padding: 2px 9px; border-radius: var(--r-pill); margin-top: 3px;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 14px; color: rgba(255,255,255,.9); padding: 12px 14px; border-radius: var(--r-pill);
  margin-bottom: 4px; font-size: 14px; font-weight: 500; text-decoration: none; transition: background .15s;
}
.sidebar nav a span { flex: 1; }
.sidebar nav a:hover { background: rgba(255,255,255,.14); }
.sidebar nav a.active { background: rgba(255,255,255,.94); color: var(--primary-dark); font-weight: 700; }
.sidebar .nav-group {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
  color: rgba(255,255,255,.55); padding: 0 14px; margin: 16px 0 6px;
}
.sidebar .user-box { margin-top: 20px; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.22); font-size: 13px; }
.sidebar .user-box .name { font-weight: 600; margin-bottom: 8px; padding: 0 14px; }
.sidebar .user-box a { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.85); font-size: 13px; padding: 8px 14px; border-radius: var(--r-pill); }
.sidebar .user-box a:hover { background: rgba(255,255,255,.14); text-decoration: none; }

.main { flex: 1; min-width: 0; }
.topbar {
  display: none;
  background: var(--primary); color: var(--on-primary);
  box-shadow: var(--elev-1);
  padding: 12px 16px; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 20;
  padding-top: max(12px, env(safe-area-inset-top));
}
.topbar strong { flex: 1; font-size: 16px; font-weight: 700; }
.ay-chip {
  font-size: 11px; font-weight: 700; padding: 4px 10px; border-radius: var(--r-pill);
  background: rgba(255,255,255,.2); color: inherit; text-decoration: none; white-space: nowrap;
  flex-shrink: 0;
}
a.ay-chip:hover { background: rgba(255,255,255,.3); }
.icon-btn {
  background: rgba(255,255,255,.18); border: none; color: #fff; width: 40px; height: 40px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255,255,255,.3); }
.content { padding: 24px 28px 48px; max-width: 1200px; }

/* ---- Components ---- */
.card {
  background: var(--surface); border: 1px solid var(--outline); border-radius: var(--r-lg);
  padding: 20px; margin-bottom: 18px; box-shadow: var(--elev-1);
}
.card h2, .card h3 { margin-top: 0; }
a.card { display: block; color: inherit; transition: box-shadow .15s, transform .15s; }
a.card:hover { text-decoration: none; box-shadow: var(--elev-2); transform: translateY(-1px); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat {
  background: linear-gradient(135deg, var(--primary-container), var(--secondary-container));
  color: var(--on-primary-container);
  border-radius: var(--r-lg); padding: 16px 18px; position: relative; overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--elev-1); }
.stat .num { font-size: 28px; font-weight: 800; line-height: 1.1; }
.stat .label { font-size: 12.5px; margin-top: 3px; opacity: .85; font-weight: 600; }
.stat .stat-icon {
  position: absolute; top: 12px; right: 12px; width: 30px; height: 30px; border-radius: 50%;
  background: rgba(255,255,255,.35); display: flex; align-items: center; justify-content: center;
}
.stat .stat-icon .icon { width: 16px; height: 16px; }
.stat-secondary { background: var(--secondary-container); color: var(--on-primary-container); }
.stat-ok { background: var(--ok-bg); color: var(--ok); }
.stat-bad { background: var(--bad-bg); color: var(--bad); }
.stat-warn { background: var(--warn-bg); color: var(--warn); }
.stat-info { background: var(--info-bg); color: var(--info); }
.stat-icon { color: inherit; }

/* ---- Mini bar-chart widget (no JS/library, server-computed heights) ---- */
.trend { display: flex; align-items: flex-end; gap: 8px; height: 110px; padding: 10px 4px 0; }
.trend-bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 6px; }
.trend-bar .bar-track { flex: 1; width: 100%; max-width: 30px; display: flex; align-items: flex-end; }
.trend-bar .bar { width: 100%; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, var(--primary), var(--primary-dark)); min-height: 3px; transition: height .3s; }
.trend-bar .lbl { font-size: 10.5px; color: var(--muted); font-weight: 700; text-transform: uppercase; }
.trend-bar .val { font-size: 11px; font-weight: 800; }

/* ---- Donut chart (pure CSS conic-gradient, no JS/library) ---- */
.donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.donut { width: 132px; height: 132px; border-radius: 50%; position: relative; flex-shrink: 0; }
.donut-hole {
  position: absolute; inset: 20px; background: var(--surface); border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; box-shadow: var(--elev-1);
}
.donut-num { font-size: 22px; font-weight: 800; line-height: 1.1; }
.donut-label { font-size: 10px; color: var(--muted); text-transform: uppercase; font-weight: 700; letter-spacing: .03em; }
.donut-legend { display: flex; flex-direction: column; gap: 9px; font-size: 14px; }
.donut-legend-item { display: flex; align-items: center; gap: 9px; }
.donut-legend .dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }

/* ---- Horizontal bar-comparison chart (pure CSS) ---- */
.hbar-chart { display: flex; flex-direction: column; gap: 12px; }
.hbar-row { display: flex; align-items: center; gap: 12px; }
.hbar-label { width: 130px; flex-shrink: 0; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { flex: 1; background: var(--surface-alt); border-radius: var(--r-pill); height: 14px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: var(--r-pill); transition: width .4s; }
.hbar-fill-ok { background: linear-gradient(90deg, var(--ok), #1e9146); }
.hbar-fill-warn { background: linear-gradient(90deg, var(--warn), #c47f00); }
.hbar-val { width: 42px; flex-shrink: 0; text-align: right; font-size: 13px; font-weight: 800; }
@media (max-width: 480px) {
  .hbar-label { width: 90px; font-size: 12.5px; }
}

table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
th, td { text-align: left; padding: 12px; border-bottom: 1px solid var(--outline); }
th { color: var(--muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:nth-child(even) td { background: var(--surface-alt); }
tbody tr:hover td { background: var(--primary-container); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: var(--on-primary); border: none;
  padding: 11px 22px; border-radius: var(--r-pill); font-size: 14px; cursor: pointer; font-weight: 700;
  min-height: 44px; transition: box-shadow .15s, transform .1s, filter .15s;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; box-shadow: var(--elev-1); }
.btn:active { transform: scale(.97); }
.btn-outline { background: transparent; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-outline:hover { background: var(--primary-container); color: var(--on-primary-container); border-color: transparent; }
.btn-sm { padding: 7px 16px; font-size: 13px; min-height: 36px; }
.btn-danger { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #93000a; }

form .field { margin-bottom: 16px; }
label { display: block; font-size: 13.5px; font-weight: 700; margin-bottom: 6px; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=number], input[type=tel], input[type=email], select, textarea {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--outline); border-radius: var(--r-md); font-size: 16px; font-family: var(--font);
  background: var(--surface-alt); color: var(--text); min-height: 48px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: var(--surface); box-shadow: 0 0 0 3px var(--primary-container); }
textarea { resize: vertical; min-height: 90px; }
::placeholder { color: var(--muted); opacity: .7; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row > .field { flex: 1; min-width: 160px; }

.alert { padding: 14px 18px; border-radius: var(--r-md); margin-bottom: 16px; font-size: 14px; font-weight: 500; }
.alert-success { background: var(--ok-bg); color: var(--ok); }
.alert-error { background: var(--bad-bg); color: var(--bad); }
.alert-info { background: var(--info-bg); color: var(--info); }

.badge { display: inline-block; padding: 4px 12px; border-radius: var(--r-pill); font-size: 12px; font-weight: 700; text-decoration: none; }
a.badge:hover { filter: brightness(.95); text-decoration: none; }
.badge-present { background: var(--ok-bg); color: var(--ok); }
.badge-absent { background: var(--bad-bg); color: var(--bad); }
.badge-late { background: var(--warn-bg); color: var(--warn); }
.badge-half_day { background: var(--info-bg); color: var(--info); }
.badge-leave { background: var(--surface-alt); color: var(--muted); }

.subject-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.subject-pick-row {
  display: flex; align-items: center; gap: 8px; border: 1.5px solid var(--outline); background: var(--surface-alt);
  padding: 6px 10px; border-radius: var(--r-md); font-weight: 600; font-size: 13.5px; cursor: pointer; margin: 0;
}
.subject-pick-row input[type="checkbox"] { width: auto; min-height: 0; }
.subject-pick-row input[type="number"] { min-height: 32px; padding: 4px 8px; font-size: 13px; }

.pill-group { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-btn {
  border: 1.5px solid var(--outline); background: var(--surface); padding: 8px 16px; border-radius: var(--r-pill);
  font-size: 13px; cursor: pointer; font-weight: 700; color: var(--muted); min-height: 38px;
}
.pill-btn.active { background: var(--secondary-container); border-color: transparent; color: var(--on-primary-container); }
.pill-btn.active:hover { background: var(--primary-container); }
.pill-btn[data-status="present"].active { background: var(--ok-bg); border-color: transparent; color: var(--ok); }
.pill-btn[data-status="absent"].active { background: var(--bad-bg); border-color: transparent; color: var(--bad); }
.pill-btn[data-status="late"].active { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.pill-btn[data-status="half_day"].active { background: var(--info-bg); border-color: transparent; color: var(--info); }

.muted { color: var(--muted); }
.text-right { text-align: right; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.mt-0 { margin-top: 0; }
table.timetable th, table.timetable td { text-align: center; vertical-align: top; font-size: 13px; white-space: nowrap; }
table.timetable tbody th { text-align: left; white-space: nowrap; }
table.timetable select { min-width: 108px; font-size: 12.5px; padding: 5px 7px; margin-bottom: 3px; }
.tt-today { background: var(--primary-container); }
.tt-clash { background: var(--bad-bg); }
details.card > summary { cursor: pointer; font-size: 15px; list-style-position: inside; }
details.card[open] > summary { margin-bottom: 14px; }
.setup-list { list-style: none; padding: 0; margin: 0; }
.setup-list li { padding: 7px 0; font-size: 14.5px; border-bottom: 1px solid var(--outline); }
.setup-list li:last-child { border-bottom: 0; }
.setup-list li.done { color: var(--muted); }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 28px 0 12px; }
.card-compact { padding: 12px 16px; }

/* ---- Compact attendance sheet ---- */
.att-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--outline); border-radius: var(--r-lg);
  padding: 12px 16px; margin-bottom: 10px;
}
.att-title { flex: 1 1 180px; display: flex; flex-direction: column; gap: 1px; font-size: 14px; }
.att-title strong { font-size: 15px; }
.att-counts { display: flex; gap: 6px; flex-wrap: wrap; }
.ac { font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: var(--r-pill); white-space: nowrap; }
.ac-present { background: var(--ok-bg); color: var(--ok); }
.ac-absent { background: var(--bad-bg); color: var(--bad); }
.ac-late { background: var(--warn-bg); color: var(--warn); }
.ac-half_day { background: var(--info-bg); color: var(--info); }
.ac-leave { background: var(--surface-alt); color: var(--muted); }

.att-list { display: flex; flex-direction: column; gap: 8px; }
.att-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--outline); border-radius: var(--r-md); padding: 10px 12px 10px 16px;
}
.att-row-leave { opacity: 0.85; border-color: var(--muted); background: var(--surface-alt); }
.att-info { flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; }
button.att-name-toggle {
  flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; align-items: flex-start;
  background: transparent; border: none; padding: 0; cursor: pointer; text-align: left; color: inherit; font: inherit;
}
.att-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-adm { font-size: 12px; color: var(--muted); }
.att-quick { display: flex; gap: 8px; flex-wrap: wrap; }
.att-hint { margin: 0 0 10px; font-size: 13px; }
.att-toolbar-sticky { position: sticky; top: 0; z-index: 8; }

.seg { gap: 8px; flex-shrink: 0; }
.seg-btn {
  width: 48px; height: 48px; min-height: 48px; border-radius: 12px; border: 1.5px solid var(--outline);
  background: var(--surface-alt); font-size: 15px; font-weight: 800; color: var(--muted); padding: 0; cursor: pointer;
  transition: transform .1s, background .1s;
}
.seg-btn:active { transform: scale(.94); }
.seg-present.active { background: var(--ok); border-color: transparent; color: #fff; box-shadow: var(--elev-1); }
.seg-absent.active { background: var(--bad); border-color: transparent; color: #fff; box-shadow: var(--elev-1); }
.seg-late.active { background: var(--warn); border-color: transparent; color: #fff; box-shadow: var(--elev-1); }
.seg-half_day.active { background: var(--info); border-color: transparent; color: #fff; box-shadow: var(--elev-1); }
.seg-leave.active { background: var(--muted); border-color: transparent; color: #fff; box-shadow: var(--elev-1); }

.notif-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.notif-list li { padding-bottom: 10px; border-bottom: 1px solid var(--outline); }
.notif-list li:last-child { border-bottom: none; padding-bottom: 0; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; left: -290px; z-index: 50; width: 280px;
    transition: left .25s ease; box-shadow: var(--elev-2);
    padding-top: max(24px, env(safe-area-inset-top));
  }
  .sidebar.open { left: 0; }
  .scrim {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,0); z-index: 40;
    opacity: 0; pointer-events: none; transition: opacity .2s, background .2s;
  }
  .scrim.show { background: rgba(0,0,0,.4); opacity: 1; pointer-events: auto; }
  .topbar { display: flex; }
  .content { padding: 18px 16px 40px; }
  h1 { font-size: 21px; }
  form > .btn:last-child { width: 100%; }
  td, th { padding: 10px 8px; font-size: 13.5px; }
  .att-row { padding: 12px 10px 12px 14px; gap: 10px; }
  .seg { width: 100%; justify-content: space-between; }
  .seg-btn { flex: 1; min-width: 0; height: 52px; min-height: 52px; font-size: 15px; }
  .att-toolbar { padding: 10px 12px; }
  .att-counts { width: 100%; justify-content: space-between; }
  .ac { flex: 1; text-align: center; font-size: 10px; padding: 4px 6px; }
  .att-quick { width: 100%; }
  .att-quick .btn { flex: 1; }
  .btn-sticky {
    position: sticky; bottom: max(12px, env(safe-area-inset-bottom)); z-index: 10; width: 100%;
    box-shadow: var(--elev-2); margin-top: 16px;
  }
}

@media (min-width: 861px) {
  .scrim { display: none !important; }
}

/* ---- Install-app banner ---- */
.install-banner {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 60;
  max-width: 480px; margin: 0 auto;
  background: var(--primary-dark); color: #fff;
  border-radius: var(--r-lg); box-shadow: var(--elev-2);
  padding: 14px 16px; padding-bottom: max(14px, env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-size: 13.5px; animation: install-banner-in .25s ease;
}
.install-banner span:first-child { flex: 1 1 200px; }
.install-banner-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; margin-left: auto; }
.install-banner .btn { background: #fff; color: var(--primary-dark); min-height: 34px; padding: 6px 16px; }
.install-banner .btn:hover { background: var(--primary-container); }
.icon-btn-ghost { width: 30px; height: 30px; background: rgba(255,255,255,.18); font-size: 18px; line-height: 1; }
.icon-btn-ghost:hover { background: rgba(255,255,255,.3); }
@keyframes install-banner-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
