/* Assignments page — reference layout with purple theme */
:root {
  --paper: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #fbfaf8;
  --ink: #1b2130;
  --ink-2: #586173;
  --ink-3: #8b94a4;
  --line: #e8e6df;
  --line-2: #f0eee9;
  --brand: #4D3E77;
  --brand-2: #8067aa;
  --brand-soft: #EDE8F5;
  --success: #6B52A8;
  --success-soft: #EDE8F5;
  --warn: #d9901a;
  --warn-soft: #fbf1da;
  --danger: #dc4a40;
  --danger-soft: #fce9e7;
  --indigo: #5b5ef0;
  --indigo-soft: #ebebfe;
  --amber: #e89a24;
  --amber-soft: #fcf0db;
  --slate: #647187;
  --slate-soft: #eef1f5;
  --shadow-sm: 0 1px 2px rgba(27, 33, 48, .04), 0 1px 3px rgba(27, 33, 48, .05);
  --shadow-md: 0 4px 14px rgba(27, 33, 48, .06), 0 2px 6px rgba(27, 33, 48, .04);
  --shadow-lg: 0 18px 40px rgba(27, 33, 48, .10), 0 6px 14px rgba(27, 33, 48, .05);
  --r: 18px;
  --r-sm: 12px;
  --r-pill: 999px;
  --sans: 'Manrope', '-apple-system', "Segoe UI", sans-serif;
  --serif: 'Fraunces', 'Georgia', serif;
  --sidebar-w: 248px;
}

body.assignments-page,
body.student-portal-page.assignments-page {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  line-height: 1.45;
  letter-spacing: -.005em;
  min-height: 100vh;
  margin: 0;
  padding: 0;
}

body.assignments-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(900px 480px at 78% -8%, rgba(77, 62, 119, .10), transparent 60%),
    radial-gradient(700px 420px at 12% 4%, rgba(91, 94, 240, .06), transparent 55%);
}

body.assignments-page #layout-wrapper,
body.assignments-page .container-fluid {
  padding: 0;
  margin: 0;
  max-width: none;
}

body.assignments-page a { color: inherit; text-decoration: none; }
body.assignments-page button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

body.assignments-page ::-webkit-scrollbar { width: 10px; height: 10px; }
body.assignments-page ::-webkit-scrollbar-thumb { background: #d8d6cf; border-radius: 99px; border: 2px solid var(--paper); }
body.assignments-page ::-webkit-scrollbar-thumb:hover { background: #c3c1b8; }

.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  z-index: 40;
  transition: transform .3s ease;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(145deg, var(--brand-2) 0%, var(--brand) 100%);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 4px 12px rgba(77, 62, 119, .35);
}
.brand-mark img { width: 28px; height: 28px; object-fit: contain; }
.brand-name { font-family: var(--serif); font-weight: 600; font-size: 17px; line-height: 1.1; }
.brand-name span { display: block; font-family: var(--sans); font-size: 10.5px; font-weight: 600; color: var(--ink-3); letter-spacing: .12em; text-transform: uppercase; margin-top: 2px; }

.nav-label { font-size: 10.5px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--ink-3); padding: 14px 12px 8px; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 11px; font-size: 13.5px; font-weight: 600; color: var(--ink-2); transition: all .16s ease; position: relative; }
.nav-item svg, .nav-item i { width: 18px; height: 18px; flex-shrink: 0; font-size: 18px; }
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); }
.nav-item.active::before { content: ""; position: absolute; left: -14px; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; background: var(--brand); border-radius: 0 3px 3px 0; }
.nav-sub { margin: 2px 0 4px 30px; padding-left: 10px; border-left: 1.5px solid var(--line); display: flex; flex-direction: column; gap: 1px; }
.nav-sub a { font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding: 7px 10px; border-radius: 8px; transition: all .15s; display: flex; align-items: center; gap: 9px; }
.nav-sub a svg, .nav-sub a i { width: 15px; height: 15px; font-size: 15px; }
.nav-sub a:hover { background: var(--surface-2); color: var(--ink); }
.nav-sub a.active { background: var(--brand-soft); color: var(--brand); }
.sidebar .nav-scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  margin: 0 -4px;
  padding: 0 4px;
}
.sidebar .nav-scroll::-webkit-scrollbar { width: 0; }
.side-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line-2); }

.upgrade {
  background: linear-gradient(160deg, #2D1F45 0%, #4D3E77 100%);
  border-radius: 14px; padding: 14px; color: #fff; position: relative; overflow: hidden;
}
.upgrade::after { content: ""; position: absolute; right: -20px; top: -20px; width: 90px; height: 90px; border-radius: 50%; background: rgba(128, 103, 170, .4); filter: blur(10px); }
.upgrade h4 { font-size: 13px; font-weight: 700; position: relative; color: #fff; margin: 0; }
.upgrade p { font-size: 11.5px; color: rgba(255, 255, 255, .85); margin: 3px 0 10px; position: relative; }
.upgrade a, .upgrade button {
  background: #fff; color: #1b2130 !important; font-size: 12px; font-weight: 700;
  padding: 8px 12px; border-radius: 9px; width: 100%; position: relative;
  display: block; text-align: center; text-decoration: none;
  box-sizing: border-box; margin-top: 2px;
}

#pwa-install-sidebar-link {
  display: flex; align-items: center; gap: 9px; padding: 7px 10px; margin-bottom: 4px;
  border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--brand); font-size: 12.5px; font-weight: 600;
}

/* TOPBAR */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(246, 245, 241, .82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 13px 26px; display: flex; align-items: center; gap: 16px;
}
.hamburger { display: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.topbar h1 { font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; margin: 0; }
.topbar h1 em { font-style: normal; color: var(--brand); }
.search { flex: 1; max-width: 340px; position: relative; margin-left: 6px; }
.search input {
  width: 100%; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-pill); padding: 9px 14px 9px 38px; font-size: 13px; color: var(--ink);
  transition: border-color .16s, box-shadow .16s;
}
.search input::placeholder { color: var(--ink-3); }
.search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); }
.top-spacer { flex: 1; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; color: var(--ink-2);
  position: relative; transition: all .16s;
}
.icon-btn:hover { color: var(--ink); border-color: #d8d6cf; }
.icon-btn svg, .icon-btn i { width: 18px; height: 18px; font-size: 18px; }
.dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); }

.topbar-notif-wrap { position: relative; }
.topbar-notif-wrap .dropdown-menu { border-radius: 12px; border: 1px solid var(--line); box-shadow: var(--shadow-lg); }
.topbar-notif-wrap .btn.header-item { width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line); background: var(--surface); padding: 0; }
.topbar-notif-wrap .badge-danger { position: absolute; top: 6px; right: 6px; font-size: 10px; padding: 2px 5px; }
.topbar-notif-wrap .dropdown { display: inline-block; }
.topbar-notif-wrap .btn.header-item {
  width: 40px; height: 40px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--surface); padding: 0; display: grid; place-items: center;
}
.topbar-notif-wrap .btn.header-item i { font-size: 18px; color: var(--ink-2); }
.topbar-notif-wrap .dropdown-menu { z-index: 60; }

.avatar-btn {
  display: flex; align-items: center; gap: 9px; padding: 4px 12px 4px 4px;
  border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; position: relative;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(145deg, var(--brand-2), var(--brand));
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 13px;
}
.avatar-btn span.nm { font-size: 13px; font-weight: 700; }
.avatar-dropdown {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  box-shadow: var(--shadow-md); min-width: 140px; z-index: 50; overflow: hidden;
}
.avatar-dropdown.show { display: block; }
.avatar-dropdown a {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  font-size: 13px; font-weight: 600; color: var(--danger);
}
.avatar-dropdown a:hover { background: var(--danger-soft); }

.content { padding: 24px 26px 50px; max-width: 1480px; width: 100%; margin: 0 auto; }
.reveal { opacity: 0; transform: translateY(14px); }
.reveal.in { opacity: 1; transform: none; transition: opacity .55s cubic-bezier(.2, .7, .3, 1), transform .55s cubic-bezier(.2, .7, .3, 1); }

/* PAGE HEAD */
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .pt { font-family: var(--serif); font-size: 27px; font-weight: 600; letter-spacing: -.01em; }
.page-head .ps { font-size: 13.5px; color: var(--ink-2); font-weight: 500; margin-top: 2px; }
.btn-asg {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700;
  padding: 9px 15px; border-radius: 11px; background: var(--ink); color: #fff;
  transition: transform .14s, opacity .14s; cursor: pointer; border: none;
}
.btn-asg:hover { transform: translateY(-1px); opacity: .92; }
.btn-asg.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.btn-asg svg { width: 15px; height: 15px; }

.page-head-actions { margin-left: auto; display: flex; gap: 10px; flex-wrap: wrap; }

/* SUBJECT TABS */
.subj-tabs { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }
.subj-tab {
  display: flex; align-items: center; gap: 9px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 10px 16px;
  box-shadow: var(--shadow-sm); transition: all .18s; cursor: pointer;
}
.subj-tab:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.subj-tab .sdot { width: 11px; height: 11px; border-radius: 4px; flex-shrink: 0; }
.subj-tab b { font-size: 13.5px; font-weight: 700; }
.subj-tab small { font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.subj-tab.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft), var(--shadow-sm); }

/* KPI ROW */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; box-shadow: var(--shadow-sm);
  transition: transform .18s, box-shadow .18s; position: relative; overflow: hidden;
}
.kpi:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.kpi .top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.kpi .ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; }
.kpi .ico svg { width: 18px; height: 18px; stroke-width: 2; }
.kpi .lbl { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.kpi b.val { font-size: 32px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1; }
.kpi .sub { font-size: 11.5px; color: var(--ink-3); font-weight: 600; margin-top: 5px; }
.kpi .progress { height: 6px; background: var(--line-2); border-radius: 99px; margin-top: 11px; overflow: hidden; }
.kpi .progress i { display: block; height: 100%; border-radius: 99px; transition: width 1s cubic-bezier(.2, .7, .3, 1); width: 0; }
.i-brand { background: var(--brand-soft); color: var(--brand); }
.i-amber { background: var(--amber-soft); color: var(--amber); }
.i-rose { background: var(--danger-soft); color: var(--danger); }
.i-blue { background: #e6effd; color: #2f6fed; }

/* INSIGHT STRIP */
.insight {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-sm); padding: 16px 18px; margin-bottom: 16px;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
}
.insight .head { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.insight .head .ic { width: 36px; height: 36px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); display: grid; place-items: center; }
.insight .head .ic svg { width: 18px; height: 18px; }
.insight .head .t b { font-size: 13.5px; font-weight: 700; display: block; }
.insight .head .t small { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.timeline-bar { flex: 1; min-width: 0; }
.tlb { height: 30px; border-radius: 9px; overflow: hidden; display: flex; box-shadow: inset 0 0 0 1px var(--line-2); }
.tlb span {
  height: 100%; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff;
  transition: width 1s cubic-bezier(.2, .7, .3, 1); min-width: 0; overflow: hidden; white-space: nowrap;
}
.tlb-legend { display: flex; gap: 16px; margin-top: 9px; flex-wrap: wrap; }
.tlb-legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.tlb-legend i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.insight .nudge {
  flex-shrink: 0; max-width: 230px; font-size: 12px; color: var(--ink-2); font-weight: 500;
  line-height: 1.45; background: var(--warn-soft); border-radius: 11px; padding: 11px 13px;
}
.insight .nudge b { color: #8a5a06; font-weight: 700; }

/* TOOLBAR */
.toolbar { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; flex-wrap: wrap; max-width: 100%; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700;
  padding: 8px 14px; border-radius: var(--r-pill); background: var(--surface);
  border: 1px solid var(--line); color: var(--ink-2); box-shadow: var(--shadow-sm); transition: all .15s; cursor: pointer;
}
.chip:hover { border-color: #d4d2cb; color: var(--ink); }
.chip .n { font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); color: var(--ink-2); }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.on .n { background: rgba(255, 255, 255, .2); color: #fff; }
.chip.on.danger { background: var(--danger); border-color: var(--danger); }
.chip.on.warn { background: var(--warn); border-color: var(--warn); }
.chip.on.success { background: var(--success); border-color: var(--success); }
.toolbar .right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.tool-search { position: relative; }
.tool-search input {
  background: var(--surface); border: 1px solid var(--line); border-radius: 11px;
  padding: 8px 12px 8px 34px; font-size: 12.5px; font-weight: 500; color: var(--ink);
  width: 210px; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s;
}
.tool-search input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.tool-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--ink-3); }
.tool-sel {
  display: flex; align-items: center; gap: 7px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 11px; padding: 8px 12px;
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); box-shadow: var(--shadow-sm);
  min-width: 0; max-width: 100%; box-sizing: border-box;
}
.tool-sel svg { width: 14px; height: 14px; color: var(--ink-3); }
.tool-sel select {
  border: none; background: none; font-family: inherit; font-size: 12.5px; font-weight: 600;
  color: var(--ink); cursor: pointer; outline: none;
  min-width: 0; max-width: 100%;
}

/* Custom sort picker — replaces native select (overflows on mobile) */
.tool-sel.tool-sort-picker { position: relative; }
.sort-picker-native {
  position: absolute !important;
  width: 1px !important; height: 1px !important;
  padding: 0 !important; margin: -1px !important;
  overflow: hidden !important; clip: rect(0, 0, 0, 0) !important;
  border: 0 !important; white-space: nowrap !important;
}
.sort-picker-btn {
  flex: 1; min-width: 0; width: 100%;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: none; background: none; font-family: inherit;
  font-size: 12.5px; font-weight: 600; color: var(--ink);
  cursor: pointer; text-align: left; padding: 0;
}
.sort-picker-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sort-picker-btn::after {
  content: ''; flex-shrink: 0;
  border-left: 5px solid transparent; border-right: 5px solid transparent;
  border-top: 5px solid var(--ink-3);
  transition: transform .15s;
}
.tool-sort-picker.is-open .sort-picker-btn::after { transform: rotate(180deg); }
.tool-sort-picker.is-open { z-index: 120; }
.sort-picker-menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  z-index: 130; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 11px; box-shadow: var(--shadow-lg);
  max-width: 100%; box-sizing: border-box;
}
.sort-picker-menu:not([hidden]) {
  display: block;
}
.sort-picker-menu li {
  padding: 10px 12px; border-radius: 8px;
  font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.sort-picker-menu li.on,
.sort-picker-menu li:hover { background: var(--brand-soft); color: var(--brand); }

/* TABLE */
.table-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 18px;
  max-width: 100%;
}
.subject-panel { display: none; max-width: 100%; }
.subject-panel.active { display: block; }
.tbl-scroll {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.assignments-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.assignments-table thead th {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-3); text-align: left; padding: 13px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
.assignments-table thead th.center { text-align: left; }
.assignments-table tbody tr { border-bottom: 1px solid var(--line-2); transition: background .14s; }
.assignments-table tbody tr:last-child { border-bottom: none; }
.assignments-table tbody tr:hover { background: var(--surface-2); }
.assignments-table tbody tr.hidden-row { display: none; }
.assignments-table tbody td { padding: 13px 16px; vertical-align: middle; }

.asg { display: flex; align-items: center; gap: 12px; }
.asg .stat-bar { width: 4px; height: 38px; border-radius: 4px; flex-shrink: 0; }
.asg .info b { font-size: 13.5px; font-weight: 700; display: block; line-height: 1.25; color: var(--ink); }
.asg .info b a { color: var(--ink); text-decoration: none; }
.asg .info b a:hover { color: var(--brand); }
.asg .info .chap { font-size: 11.5px; color: var(--ink-3); font-weight: 600; margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.asg .info .chap .tp { padding: 1px 7px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line-2); font-size: 10px; font-weight: 700; }

.status-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 4px 11px; border-radius: 99px; white-space: nowrap; }
.status-pill svg { width: 12px; height: 12px; }
.st-graded { background: var(--success-soft); color: var(--success); }
.st-submitted { background: var(--indigo-soft); color: var(--indigo); }
.st-missing { background: var(--danger-soft); color: var(--danger); }

.score-cell { min-width: 120px; }
.score-cell .sval { display: flex; align-items: baseline; gap: 4px; margin-bottom: 5px; }
.score-cell .sval b { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-cell .sval small { font-size: 11.5px; color: var(--ink-3); font-weight: 600; }
.score-cell .sval .pct { margin-left: auto; font-size: 11px; font-weight: 800; padding: 1px 7px; border-radius: 99px; }
.score-bar { height: 5px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.score-bar i { display: block; height: 100%; border-radius: 99px; }
.score-na { font-size: 12.5px; font-weight: 600; color: var(--ink-3); }

.date-cell { font-size: 12.5px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.date-cell small { display: block; font-size: 11px; color: var(--ink-3); font-weight: 500; }

.delay-pill { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 99px; white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.delay-ontime { background: var(--success-soft); color: var(--success); }
.delay-low { background: var(--warn-soft); color: var(--warn); }
.delay-high { background: var(--danger-soft); color: var(--danger); }

.assignments-table thead th.col-actions,
.assignments-table tbody td.col-actions {
  text-align: left;
  width: 1%;
  min-width: 108px;
  max-width: 120px;
}
.act-cell { display: flex; align-items: flex-start; gap: 7px; justify-content: flex-start; }
.act-btn {
  font-size: 11px; font-weight: 700; padding: 6px 10px; border-radius: 9px;
  white-space: nowrap; transition: transform .14s, opacity .14s;
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  border: none; text-decoration: none; font-family: inherit; line-height: 1.2;
}
.act-btn:hover { transform: translateY(-1px); }
.act-btn svg { width: 13px; height: 13px; }
.act-primary { background: var(--brand); color: #fff !important; border: none; }
.act-primary svg, .act-primary i { color: #fff !important; stroke: #fff; }
.act-submit { background: var(--danger); color: #fff !important; border: none; }
.act-submit svg, .act-submit i { color: #fff !important; }
.act-ghost { background: var(--surface); color: var(--ink) !important; border: 1px solid var(--line); }
.act-icon {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); transition: all .14s; cursor: pointer;
}
.act-icon:hover { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.act-icon svg { width: 15px; height: 15px; }

/* Hidden file inputs in action cells */
.act-cell .hidden-file-input { display: none !important; }
.act-cell .progress-container { display: none; margin-top: 6px; width: 100%; }
.act-cell .progress-bar {
  height: 6px; background: var(--brand); border-radius: 99px; text-align: center;
  font-size: 10px; color: #fff; line-height: 6px; transition: width .3s;
}
.act-cell .upload-complete { display: none; font-size: 11px; color: var(--success); font-weight: 600; }
.act-cell .file-name { font-size: 11px; color: var(--ink-3); margin-top: 4px; }
.act-cell .act-forms { display: flex; flex-direction: column; align-items: stretch; gap: 4px; width: 100%; }
.act-cell .act-btns {
  display: flex; flex-direction: column; align-items: stretch; gap: 5px; width: 100%;
}
.act-cell .act-btns > form,
.act-cell .act-btns > a.act-btn,
.act-cell .act-btns > button.act-btn,
.act-cell .act-btns > label.act-btn { width: 100%; }
.act-cell .act-btns form { display: block; width: 100%; margin: 0; }
.act-cell .act-btns .act-btn { justify-content: center; }
.act-cell .act-icon-row { display: flex; gap: 5px; width: 100%; }
.act-cell .act-icon-row .act-icon { flex: 1; width: auto; height: 30px; }
.act-generating { font-size: 12px; color: var(--ink-3); font-weight: 600; }

/* CARD VIEW (mobile) */
.cards { display: none; flex-direction: column; gap: 12px; }
.acard { background: var(--surface); border: 1px solid var(--line); border-radius: 15px; box-shadow: var(--shadow-sm); overflow: hidden; border-left: 4px solid; }
.acard .ach { padding: 14px 15px 11px; }
.acard .ach .row1 { display: flex; align-items: flex-start; gap: 10px; justify-content: space-between; }
.acard .ach b { font-size: 13.5px; font-weight: 700; line-height: 1.3; }
.acard .ach .chap { font-size: 11.5px; color: var(--ink-3); font-weight: 600; margin-top: 3px; }
.acard .abody { padding: 0 15px 13px; display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.acard .field small { font-size: 10.5px; color: var(--ink-3); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; display: block; margin-bottom: 3px; }
.acard .field .v { font-size: 12.5px; font-weight: 600; }
.acard .afoot { padding: 11px 15px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; background: var(--surface-2); flex-wrap: wrap; }
.acard .afoot .act-btn { flex: 1; justify-content: center; min-width: 80px; }

.empty-row { text-align: center; padding: 40px; color: var(--ink-3); }
.empty-row .em { font-size: 34px; margin-bottom: 8px; }
.empty-row b { font-weight: 700; font-size: 14px; color: var(--ink-2); }

.footer-asg { text-align: center; padding: 22px; color: var(--ink-3); font-size: 12px; font-weight: 500; border-top: 1px solid var(--line); }
body.student-portal-page .footer-asg { margin-top: auto; flex-shrink: 0; width: 100%; }
.footer-asg b { color: var(--ink-2); font-weight: 700; }

/* Flash / alert banners (student portal — no Bootstrap CSS required) */
body.student-portal-page .portal-flash-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 18px;
}

body.student-portal-page .portal-flash {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.5;
  border: 1px solid transparent;
  box-shadow: var(--shadow-sm);
  background: var(--surface);
}

body.student-portal-page .portal-flash-icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  margin-top: 1px;
}

body.student-portal-page .portal-flash-icon svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.student-portal-page .portal-flash-text {
  flex: 1;
  min-width: 0;
  color: inherit;
}

body.student-portal-page .portal-flash-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  margin: -4px -4px -4px 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  opacity: .55;
  transition: opacity .15s, background .15s;
}

body.student-portal-page .portal-flash-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, .06);
}

body.student-portal-page .portal-flash-warning {
  background: var(--warn-soft);
  color: #7a5200;
  border-color: #f0d88a;
}

body.student-portal-page .portal-flash-danger {
  background: var(--danger-soft);
  color: #9f2d25;
  border-color: #f5c4c0;
}

body.student-portal-page .portal-flash-success {
  background: #e8f7ee;
  color: #0f7b44;
  border-color: #b8e6cc;
}

body.student-portal-page .portal-flash-info {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: #d4c9eb;
}

.scrim { display: none; position: fixed; inset: 0; background: rgba(20, 25, 35, .45); z-index: 35; backdrop-filter: blur(2px); }
.scrim.show { display: block; }

/* Feedback gate */
#feedback-gate-overlay {
  display: none !important; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0, 0, 0, 0.65); z-index: 99999; align-items: center; justify-content: center;
}
#feedback-gate-overlay.visible { display: flex !important; }

/* Modal overrides — keep above new shell */
body.assignments-page .modal {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1060;
  display: none;
  width: 100%;
  height: 100%;
  overflow: hidden;
  outline: 0;
}

body.assignments-page .modal:not(.show),
body.assignments-page #portal-modals-root .modal:not(.show) {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

body.assignments-page .modal.show,
body.assignments-page #portal-modals-root .modal.show {
  display: block !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

body.student-portal-page.assignments-page.modal-open .portal-main,
body.student-portal-page.assignments-page.student-modal-open .portal-main {
  overflow: hidden !important;
}

body.assignments-page .modal-backdrop {
  z-index: 1050;
}
body.assignments-page #cameraFullscreenOverlay { z-index: 99999; }
body.assignments-page #previewModal { z-index: 200000; }

/* PDF preview modal — lock background scroll */
body.preview-modal-open {
  overflow: hidden;
}

body.student-portal-page.preview-modal-open .portal-main.preview-scroll-locked {
  overflow: hidden !important;
}

.preview-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200000;
  overscroll-behavior: contain;
}

.preview-modal.is-open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
}

.preview-modal-dialog {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 12px;
  width: min(96vw, 1100px);
  height: min(88vh, 900px);
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
}

.preview-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: #fff;
}

.preview-modal-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
}

.preview-modal-close {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(27, 33, 48, 0.08);
  color: var(--danger);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}

.preview-modal-close:hover {
  background: rgba(220, 74, 64, 0.12);
}

.preview-modal-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.preview-modal-body iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  touch-action: pan-y;
}

@media (max-width: 768px) {
  .preview-modal.is-open {
    align-items: stretch;
    justify-content: stretch;
  }

  .preview-modal-dialog {
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }

  .preview-modal-header {
    padding: 12px 14px;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .preview-modal-close {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow-sm);
  }
}

/* Camera / modal styles preserved from original */
#captureModal .modal-dialog { max-width: 90%; width: 800px; }
#cameraPreview { width: 100%; max-width: 100%; height: auto; background-color: #000; border-radius: 4px; margin-bottom: 15px; }
#capturedImagesPreview { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; max-height: 300px; overflow-y: auto; padding: 10px; border: 1px solid #ddd; border-radius: 4px; margin-top: 15px; }
.captured-image-item { position: relative; width: 100%; padding-bottom: 100%; background-color: #f5f5f5; border-radius: 4px; overflow: hidden; }
.captured-image-item img { position: absolute; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; }
.captured-image-item .delete-image-btn { position: absolute; top: 5px; right: 5px; background-color: rgba(220, 53, 69, 0.9); color: white; border: none; border-radius: 50%; width: 24px; height: 24px; font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; line-height: 1; padding: 0; }
#imageCount { font-weight: bold; margin-top: 10px; color: var(--brand-2); }
#cameraFullscreenOverlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #000; z-index: 99999; display: none; flex-direction: column; overflow: hidden; }
#cameraFullscreenOverlay .fs-topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: rgba(0, 0, 0, 0.6); color: #fff; }
#fullscreenPreviewHost { flex: 1; display: flex; align-items: center; justify-content: center; padding: 10px; padding-bottom: 100px; overflow: hidden; }
#cameraFullscreenOverlay .fs-controls { background: rgba(0, 0, 0, 0.7); padding: 20px; display: flex; justify-content: center; gap: 15px; position: absolute; bottom: 0; left: 0; right: 0; z-index: 100; }
.camera-preview-wrapper { position: relative; width: 100%; max-width: 100%; }
#cameraCropOverlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 10; }
.camera-crop-corner, .crop-corner { position: absolute; background-color: var(--brand-2); border-radius: 50%; cursor: move; pointer-events: all; z-index: 20; transform: translate(-50%, -50%); touch-action: none; user-select: none; }
.camera-crop-corner { width: 20px; height: 20px; border: 2px solid white; }
.crop-corner { width: 28px; height: 28px; border: 3px solid white; }
#cropCanvasContainer { position: relative; width: 100%; max-height: 70vh; overflow: hidden; background-color: #000; border-radius: 4px; }
.crop-instructions { text-align: center; color: #666; font-size: 14px; margin-bottom: 15px; }
.captured-image-item .edit-indicator { position: absolute; bottom: 5px; left: 5px; background-color: rgba(128, 103, 170, 0.9); color: white; border-radius: 4px; padding: 2px 6px; font-size: 10px; }
#previewPdfImages { background-color: #f8f9fa; padding: 20px; border-radius: 4px; }
.preview-pdf-page-header { font-weight: 600; color: var(--brand-2); margin-bottom: 10px; font-size: 14px; }
#captureFlash { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: white; opacity: 0; pointer-events: none; z-index: 100000; transition: opacity 0.1s ease-out; }
#captureFlash.active { opacity: 0.9; }
#captureToast { position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%); background-color: rgba(0, 0, 0, 0.85); color: white; padding: 12px 24px; border-radius: 8px; font-size: 16px; z-index: 100001; opacity: 0; transition: opacity 0.2s ease-out; display: flex; align-items: center; gap: 8px; }
#captureToast.show { opacity: 1; }
.header-shaded { background-color: var(--brand-2); color: #FFFFFF; }

/* Previous Assignments modal — match revamped UI */
.prev-asg-modal .modal-dialog { max-width: 960px; margin: 1.5rem auto; }
.prev-asg-modal .modal-content {
  font-family: var(--sans);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  background: var(--surface);
}
.prev-asg-modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  border-bottom: none;
}
.prev-asg-modal .modal-title {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -.02em;
  color: #fff !important;
}
.prev-asg-modal .prev-modal-close {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}
.prev-asg-modal .prev-modal-close:hover { background: rgba(255, 255, 255, .24); }
.prev-asg-modal .prev-modal-close svg { width: 16px; height: 16px; }
.prev-asg-modal .modal-body {
  padding: 0;
  background: var(--surface);
}
.prev-asg-modal .prev-asg-scroll { overflow-x: auto; }
.prev-asg-modal .prev-asg-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}
.prev-asg-modal .prev-asg-table thead th {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: left;
  padding: 13px 16px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.prev-asg-modal .prev-asg-table tbody tr {
  border-bottom: 1px solid var(--line-2);
  transition: background .14s;
}
.prev-asg-modal .prev-asg-table tbody tr:last-child { border-bottom: none; }
.prev-asg-modal .prev-asg-table tbody tr:hover { background: var(--surface-2); }
.prev-asg-modal .prev-asg-table tbody td {
  padding: 14px 16px;
  vertical-align: middle;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}
.prev-asg-modal .prev-desc a {
  color: var(--ink);
  font-weight: 700;
  font-size: 13.5px;
  text-decoration: none;
}
.prev-asg-modal .prev-desc a:hover { color: var(--brand); }
.prev-asg-modal .prev-graded {
  display: block;
  margin-top: 4px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--success);
}
.prev-asg-modal .prev-subject {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 11px;
  font-weight: 700;
}
.prev-asg-modal .prev-date,
.prev-asg-modal .prev-points {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  white-space: nowrap;
}
.prev-asg-modal .prev-asg-table th.col-actions,
.prev-asg-modal .prev-asg-table td.col-actions {
  min-width: 130px;
  max-width: 150px;
}
.prev-asg-modal .prev-act-cell {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.prev-asg-modal .prev-act-cell .act-btn {
  width: 100%;
  justify-content: center;
  font-size: 11px;
  padding: 6px 10px;
}
.prev-asg-modal .prev-progress {
  height: 6px;
  background: var(--line-2);
  border-radius: 99px;
  overflow: hidden;
}
.prev-asg-modal .prev-progress-bar {
  height: 100%;
  width: 0;
  background: var(--brand);
  border-radius: 99px;
  font-size: 0;
  transition: width .3s;
}
.prev-asg-modal .prev-status {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
}
.prev-asg-modal .prev-empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 600;
}
.prev-asg-modal .modal-footer {
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  justify-content: flex-end;
}
.prev-asg-modal .modal-footer .btn-asg { min-width: 96px; justify-content: center; }

@media (max-width: 1080px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 920px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .hamburger { display: grid; place-items: center; }
  .scrim.show { display: block; }
  .search { display: none; }
  .avatar-btn span.nm { display: none; }
  .insight { flex-direction: column; align-items: stretch; }
  .insight .nudge { max-width: none; }
}
@media (max-width: 760px) {
  .page-head {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .page-head-actions {
    margin-left: 0;
    width: 100%;
  }
  .page-head-actions .btn-asg {
    flex: 1 1 auto;
    justify-content: center;
    min-width: 0;
  }
  .toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    min-width: 0;
    overflow: visible;
  }
  .toolbar .chips {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding-bottom: 2px;
    scrollbar-width: none;
  }
  .toolbar .chips::-webkit-scrollbar { display: none; }
  .toolbar .right {
    margin-left: 0;
    width: 100%;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .tool-search { width: 100%; }
  .tool-search input {
    width: 100%;
    box-sizing: border-box;
  }
  .tool-sel {
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
  }
  .tool-sel select {
    flex: 1;
    width: 100%;
  }
  .insight .timeline-bar {
    min-width: 0;
    width: 100%;
    flex: 1 1 100%;
  }
  .insight { overflow: hidden; max-width: 100%; }
  .tlb-legend { gap: 10px 12px; }
  .subj-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    padding-bottom: 4px;
    scrollbar-width: none;
  }
  .subj-tabs::-webkit-scrollbar { display: none; }
  .subj-tab { flex-shrink: 0; }
  .tbl-scroll { -webkit-overflow-scrolling: touch; }
  .assignments-table { min-width: 640px; }
}
@media (max-width: 680px) {
  .content { padding: 16px 14px 40px; }
  .topbar { padding: 11px 14px; gap: 10px; }
  .page-head .pt { font-size: 23px; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); gap: 11px; }
  .kpi b.val { font-size: 26px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
  .reveal { opacity: 1; transform: none; }
}
@media print {
  body.student-portal-page .portal-sidebar,
  body.student-portal-page .portal-topbar,
  body.student-portal-page .portal-scrim,
  body.student-portal-page .footer-asg,
  .sidebar, .topbar, .toolbar, .scrim, .act-cell, .cards { display: none !important; }
  body.student-portal-page .portal-app,
  body.student-portal-page .portal-main,
  body.student-portal-page .portal-content {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  .table-card { display: block !important; box-shadow: none; border: 1px solid #ccc; }
  .subject-panel { display: block !important; }
  body.assignments-page::before { display: none; }
}
