/* TISD Student Portal — exam platform styles. No build step: plain CSS. */
:root {
  --navy: #1a3c6e; --navy-2: #24508f; --navy-soft: #eef3fa;
  --green: #16a34a; --green-soft: #dcfce7; --red: #dc2626; --red-soft: #fee2e2;
  --amber: #b45309; --amber-soft: #fef3c7;
  --ink: #0f172a; --muted: #64748b; --line: #e2e8f0; --bg: #f5f7fb; --card: #fff;
  --radius: 10px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.08);
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--navy-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6rem; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .8rem; }
small, .muted { color: var(--muted); }
code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: .85em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.2rem 0; }

/* Layout */
.has-sidebar { padding-left: 232px; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 232px; background: var(--navy); color: #fff; display: flex; flex-direction: column; padding: 1rem .75rem; z-index: 40; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .5rem; color: #fff; font-weight: 700; padding: 0 .4rem .9rem; border-bottom: 1px solid rgba(255,255,255,.12); margin-bottom: .75rem; }
.brand:hover { text-decoration: none; }
.brand span { letter-spacing: .02em; font-size: .8rem; white-space: nowrap; }
.brand img { height: 32px; background: #fff; border-radius: 6px; padding: 2px 4px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-nav a { color: #dbe6f5; padding: .55rem .75rem; border-radius: 8px; font-size: .95rem; }
.side-nav a:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
.side-nav a.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--green); }
.side-foot { border-top: 1px solid rgba(255,255,255,.12); padding-top: .75rem; display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.side-foot form { margin: 0; }
.side-user { color: #fff; display: flex; flex-direction: column; line-height: 1.3; padding: .2rem .5rem; border-radius: 6px; }
.side-user small { color: #a9bddb; font-size: .78rem; }
.side-user:hover { background: rgba(255,255,255,.1); text-decoration: none; }
.linkbtn { background: none; border: 0; color: #dbe6f5; cursor: pointer; font: inherit; padding: .3rem .5rem; border-radius: 6px; }
.linkbtn:hover { background: rgba(255,255,255,.14); color: #fff; }
.topbar { position: sticky; top: 0; z-index: 30; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 1rem; padding: .6rem 1.25rem; min-height: 58px; }
.page-title { font-weight: 700; font-size: 1.1rem; color: var(--navy); flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-search { margin: 0; width: min(360px, 45vw); }
.top-search input { width: 100%; padding: .5rem .8rem; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); font: inherit; }
.top-search input:focus { outline: 2px solid var(--navy-2); outline-offset: 0; background: #fff; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; font-size: 1.1rem; padding: .25rem .6rem; cursor: pointer; color: var(--navy); }
.sidebar-backdrop { display: none; }
.search-group { margin-bottom: 1rem; }
.search-group ul { list-style: none; margin: 0; padding: 0; }
.search-group li { padding: .55rem 0; border-top: 1px solid var(--line); }
.search-group li:first-child { border-top: 0; }
.lang { display: inline-flex; border: 1px solid rgba(255,255,255,.35); border-radius: 6px; overflow: hidden; }
.lang button { background: none; border: 0; color: #dbe6f5; padding: .2rem .5rem; cursor: pointer; font-size: .8rem; }
.lang button.on { background: #fff; color: var(--navy); font-weight: 700; }
.container { max-width: 1200px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
.narrow { max-width: 760px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* Cards & grids */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.1rem; margin-bottom: 1rem; }
.card > h2:first-child { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.stat .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.stat .value { font-size: 1.6rem; font-weight: 700; color: var(--navy); }

/* Course cards (student) */
.course-card { display: flex; flex-direction: column; gap: .5rem; }
.course-card .title { font-size: 1.1rem; font-weight: 700; color: var(--navy); }
.course-card .meta { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .9rem; color: var(--muted); }
.course-card.ended { opacity: .7; }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .55rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); background: #f8fafc; white-space: nowrap; }
tr:hover td { background: #fafcff; }
td.num, th.num { text-align: right; white-space: nowrap; }
.empty { text-align: center; color: var(--muted); padding: 1.5rem; }

/* Badges */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #f1f5f9; color: #334155; white-space: nowrap; }
.badge.green { background: var(--green-soft); color: #166534; }
.badge.red { background: var(--red-soft); color: #991b1b; }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.blue { background: var(--navy-soft); color: var(--navy); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--navy); background: var(--navy); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { background: var(--navy-2); text-decoration: none; }
.btn.secondary { background: #fff; color: var(--navy); border-color: #c7d3e6; }
.btn.secondary:hover { background: var(--navy-soft); }
.btn.green { background: var(--green); border-color: var(--green); }
.btn.green:hover { background: #15803d; }
.btn.danger { background: #fff; color: var(--red); border-color: #fca5a5; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { padding: .3rem .6rem; font-size: .82rem; }
.btn.lg { padding: .8rem 1.4rem; font-size: 1.05rem; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.inline { display: inline; margin: 0; }
td.row-actions { display: table-cell; white-space: nowrap; }
td.row-actions > * { margin: 0 .2rem .2rem 0; }
.row-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.row-actions select { max-width: 15rem; min-width: 0; }
.card-head > * { max-width: 100%; min-width: 0; }

/* Forms */
.form-grid { display: grid; gap: .9rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.field { display: flex; flex-direction: column; gap: .3rem; }
.field.full { grid-column: 1 / -1; }
label { font-weight: 600; font-size: .9rem; }
.hint { font-size: .8rem; color: var(--muted); font-weight: 400; }
input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #93c5fd; border-color: var(--navy-2); }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 500; }
.error-text { color: var(--red); font-size: .82rem; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { min-width: 150px; }
.filters input, .filters select { padding: .45rem .6rem; }

/* Alerts */
.alert { padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.alert.success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.info { background: var(--navy-soft); border-color: #c7d3e6; color: var(--navy); }
.alert ul { margin: .3rem 0 0; padding-left: 1.2rem; }

/* Auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: linear-gradient(160deg, var(--navy) 0%, #0f2a52 60%, #0b1f3d 100%); }
.auth-card { width: 100%; max-width: 400px; background: #fff; border-radius: 14px; padding: 1.8rem; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-card .logo { text-align: center; margin-bottom: 1rem; }
.auth-card .logo img { height: 48px; }
.auth-card h1 { text-align: center; font-size: 1.25rem; color: var(--navy); }
.auth-card .sub { text-align: center; color: var(--muted); margin-bottom: 1.2rem; }
.auth-card .btn { width: 100%; }
.auth-lang { display: flex; justify-content: center; gap: .5rem; margin-top: 1rem; }
.auth-lang button { background: none; border: 1px solid var(--line); border-radius: 6px; padding: .2rem .6rem; cursor: pointer; }
.auth-lang button.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Progress bars & charts */
.bar { height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--green); }
.chart { width: 100%; height: auto; display: block; }
.chart text { font-size: 10px; fill: var(--muted); }

/* Question list (admin) */
.q-text { font-weight: 600; }
.q-alt { color: var(--muted); font-size: .88rem; }
.opt-list { margin: .3rem 0 0; padding-left: 1.1rem; font-size: .88rem; }
.opt-list li.correct { color: #166534; font-weight: 600; }
.thumb { width: 64px; height: 64px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.option-row { display: grid; grid-template-columns: 34px 1fr 1fr; gap: .5rem; align-items: center; margin-bottom: .5rem; }
.option-row input[type=radio] { width: 20px; height: 20px; justify-self: center; }

/* ========== Exam screen ========== */
.secure, .secure * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.secure input, .secure textarea { -webkit-user-select: text; user-select: text; }
.secure img { pointer-events: none; -webkit-user-drag: none; }
.exam-bar { position: sticky; top: 0; z-index: 20; background: var(--navy); color: #fff; box-shadow: 0 2px 6px rgba(0,0,0,.15); }
.exam-bar .inner { max-width: 1000px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem; justify-content: space-between; flex-wrap: wrap; }
.timer { font-variant-numeric: tabular-nums; font-size: 1.3rem; font-weight: 700; background: rgba(255,255,255,.12); padding: .2rem .7rem; border-radius: 8px; }
.timer.low { background: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .7; } }
.exam-wrap { max-width: 1000px; margin: 0 auto; padding: 1rem; display: grid; grid-template-columns: 1fr 230px; gap: 1rem; }
@media (max-width: 800px) { .exam-wrap { grid-template-columns: 1fr; } .palette { grid-template-columns: repeat(8, 1fr); } }
.question-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 1.3rem; box-shadow: var(--shadow); min-height: 320px; }
.question-card[hidden] { display: none; }
.q-number { color: var(--muted); font-size: .85rem; font-weight: 600; margin-bottom: .4rem; }
.q-body { font-size: 1.15rem; font-weight: 600; margin-bottom: 1rem; }
.q-image { text-align: center; margin: 0 0 1rem; }
.q-image img { max-width: 100%; max-height: 260px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.choices { display: grid; gap: .6rem; }
.choice { display: flex; gap: .75rem; align-items: center; padding: .8rem 1rem; border: 2px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; text-align: left; font: inherit; color: inherit; width: 100%; }
.choice:hover { border-color: #93c5fd; background: #f8fbff; }
.choice .letter { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #f1f5f9; font-weight: 700; color: var(--navy); }
.choice.selected { border-color: var(--navy); background: var(--navy-soft); }
.choice.selected .letter { background: var(--navy); color: #fff; }
.choice.saving { opacity: .6; }
.q-nav { display: flex; justify-content: space-between; margin-top: 1.2rem; gap: .5rem; }
.palette { display: grid; grid-template-columns: repeat(5, 1fr); gap: .35rem; }
.palette button { border: 1px solid #cbd5e1; background: #fff; border-radius: 6px; padding: .35rem 0; font: inherit; font-size: .85rem; cursor: pointer; font-weight: 600; color: var(--ink); }
.palette button.answered { background: var(--green); border-color: var(--green); color: #fff; }
.palette button.current { outline: 3px solid #93c5fd; }
.legend { display: flex; gap: .8rem; font-size: .78rem; color: var(--muted); margin: .6rem 0; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: 3px; border: 1px solid #cbd5e1; }
.legend i.a { background: var(--green); border-color: var(--green); }
.watermark { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; opacity: .07; display: flex; flex-wrap: wrap; align-content: flex-start; gap: 60px 80px; transform: rotate(-24deg) scale(1.5); }
.watermark span { font-size: 15px; font-weight: 700; white-space: nowrap; color: #000; }
.shield { position: fixed; inset: 0; z-index: 100; background: rgba(15,23,42,.96); color: #fff; display: none; align-items: center; justify-content: center; text-align: center; padding: 2rem; }
.shield.on { display: flex; }
.shield .box { max-width: 420px; }
.shield h2 { font-size: 1.4rem; }
.blurred .exam-wrap { filter: blur(14px); }
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.6); z-index: 90; display: none; align-items: center; justify-content: center; padding: 1rem; }
.modal.on { display: flex; }
.modal .box { background: #fff; border-radius: 12px; padding: 1.5rem; max-width: 420px; width: 100%; }
.toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: .6rem 1rem; border-radius: 8px; z-index: 95; font-size: .9rem; display: none; max-width: 90vw; }
.toast.on { display: block; }

/* Result & review */
.score-ring { font-size: 3rem; font-weight: 800; }
.score-ring.pass { color: var(--green); } .score-ring.fail { color: var(--red); }
.review-item { border: 1px solid var(--line); border-radius: 10px; padding: 1rem; margin-bottom: .8rem; background: #fff; }
.review-item.right { border-left: 5px solid var(--green); }
.review-item.wrong { border-left: 5px solid var(--red); }
.review-opt { padding: .4rem .7rem; border-radius: 6px; margin: .25rem 0; border: 1px solid var(--line); }
.review-opt.correct { background: var(--green-soft); border-color: #86efac; font-weight: 600; }
.review-opt.picked-wrong { background: var(--red-soft); border-color: #fca5a5; }
.explain { background: #f8fafc; border-radius: 6px; padding: .6rem .8rem; margin-top: .5rem; font-size: .92rem; }

.pagination { display: flex; gap: .25rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }
.pagination a, .pagination span { padding: .3rem .65rem; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: .88rem; }
.pagination .on { background: var(--navy); color: #fff; border-color: var(--navy); }
.pagination .off { color: #cbd5e1; }

@media print {
  body * { display: none !important; }
  body::after { content: "Printing is not allowed. TISD Student Portal."; display: block !important; font-size: 20px; padding: 40px; }
}
@media (max-width: 900px) {
  .has-sidebar { padding-left: 0; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 24px rgba(0,0,0,.25); }
  .sidebar-open .sidebar { transform: none; }
  .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 35; }
  .menu-btn { display: block; }
  .topbar { padding: .5rem .75rem; gap: .6rem; }
}
@media (max-width: 640px) {
  .option-row { grid-template-columns: 30px 1fr; }
  .option-row input[type=text]:last-child { grid-column: 2; }
}

/* Topics editor (course page) */
.alert.warning { background: var(--amber-soft); border-color: #fcd34d; color: #78350f; }
.topic-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .75rem; }
.topic-row { display: flex; gap: .5rem; align-items: center; }
.topic-row > form:first-child { flex: 1; }
.topic-row form { margin: 0; }
.topic-edit { display: grid; grid-template-columns: 1fr 1fr auto auto; gap: .5rem; align-items: center; }
.topic-edit .count { font-size: .85rem; white-space: nowrap; }
.topic-new { grid-template-columns: 1fr 1fr auto; }
@media (max-width: 640px) {
  .topic-edit, .topic-new { grid-template-columns: 1fr 1fr; }
  .topic-edit .count { grid-column: 1; }
  .topic-row { align-items: flex-start; border-bottom: 1px solid var(--line); padding-bottom: .5rem; }
}
.export-btns { display: inline-flex; gap: .35rem; flex-wrap: wrap; }

/* Tabs, credentials, check lists */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; font-weight: 600; }
.tabs a.on { color: var(--navy); border-bottom-color: var(--navy); }
.tabs a:hover { text-decoration: none; color: var(--navy); }
.filters .field.grow { flex: 2 1 200px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
.credentials { border: 2px solid var(--green); }
.cred-grid { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0 0 .8rem; }
.cred-grid dt { color: var(--muted); }
.cred-grid dd { margin: 0; word-break: break-all; }
code.big { font-size: 1.2rem; padding: .2rem .5rem; letter-spacing: .05em; }
.cred-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.cred-actions form { margin: 0; }
.check-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .4rem; }
[hidden] { display: none !important; }

/* Performance page */
.stat .delta { font-size: .8rem; margin-top: .15rem; color: var(--ink); }
.stat .delta.up { color: #166534; } .stat .delta.down { color: #991b1b; }
.week-chart .hit:hover path { fill: #24508f; }
.week-chart text { font-size: 10.5px; }
.week-chart .value-label { fill: var(--ink); font-weight: 700; font-size: 11px; }
.week-chart { max-height: 260px; }
.table-toggle { margin-top: .5rem; } .table-toggle summary { cursor: pointer; color: var(--navy-2); font-size: .9rem; padding: .3rem 0; }
.ready-row { margin-bottom: 1rem; }
.ready-head { display: flex; justify-content: space-between; gap: .5rem; margin-bottom: .3rem; }
.seg { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; background: #f1f5f9; }
.seg span { display: block; min-width: 4px; }
.s-ready { background: #16a34a; } .s-practising { background: #f59e0b; } .s-not_started { background: #cbd5e1; }
.seg-legend { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .8rem; color: var(--muted); margin-top: .3rem; }
.seg-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: -1px; }
.topic-bar { margin-bottom: .75rem; }
.topic-bar-head { display: flex; justify-content: space-between; gap: .5rem; font-size: .92rem; }
.bar > span.low { background: var(--amber); }
.person-list, .q-list { list-style: none; margin: 0; padding: 0; }
.person-list li { display: grid; grid-template-columns: 1fr auto; gap: .2rem .6rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.person-list li:first-child { border-top: 0; }
.person-list .tags { display: flex; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
.person-list .call { grid-column: 1 / -1; font-size: .88rem; }
.q-list li { padding: .45rem 0; border-top: 1px solid var(--line); font-size: .92rem; }
.small { font-size: .82rem; }

/* Exam papers */
/* Exam papers list */
.paper-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: .75rem 1rem; padding: .85rem 1rem; }
.paper-toolbar .field { flex: 1 1 200px; max-width: 320px; }
.toggle-chip { display: inline-flex; align-items: center; gap: .45rem; min-height: 42px; padding: 0 .9rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; cursor: pointer; font-weight: 500; white-space: nowrap; }
.toggle-chip input { width: 18px; height: 18px; margin: 0; accent-color: var(--navy); }
.toggle-chip:has(input:checked) { border-color: var(--navy-2); background: var(--navy-soft); color: var(--navy); }
.status-tabs { display: inline-flex; margin-left: auto; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.status-tabs a { display: inline-flex; align-items: center; gap: .35rem; min-height: 42px; padding: 0 .9rem; color: var(--ink); font-size: .9rem; border-left: 1px solid var(--line); }
.status-tabs a:first-child { border-left: 0; }
.status-tabs a b { font-size: .75rem; font-weight: 600; background: #f1f5f9; color: var(--muted); border-radius: 999px; padding: .05rem .45rem; }
.status-tabs a:hover { background: var(--navy-soft); text-decoration: none; }
.status-tabs a.on { background: var(--navy); color: #fff; font-weight: 600; }
.status-tabs a.on b { background: rgba(255,255,255,.2); color: #fff; }
.paper-list { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); }
.paper-card { display: flex; flex-direction: column; gap: .6rem; margin: 0; border-top: 4px solid var(--amber); }
.paper-card.is-final { border-top-color: var(--green); }
.paper-top { display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.paper-title { font-size: 1.05rem; line-height: 1.35; margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.7em; }
.paper-title a { color: var(--ink); }
.paper-title a:hover { color: var(--navy-2); }
.paper-facts { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin: 0; padding: .6rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.paper-facts div { min-width: 0; }
.paper-facts dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.paper-facts dd { margin: .1rem 0 0; font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.paper-by { margin: 0; }
.paper-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: auto; }
.paper-actions .btn { white-space: nowrap; }
@media (max-width: 640px) {
  .paper-toolbar .field { max-width: none; flex-basis: 100%; }
  .status-tabs { margin-left: 0; width: 100%; }
  .status-tabs a { flex: 1; justify-content: center; padding: 0 .4rem; }
  .paper-actions { display: grid; grid-template-columns: 1fr auto auto; }
  .paper-title { min-height: 0; }
}
.download-bar { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.topic-picker { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); margin-bottom: .9rem; }
.topic-pick { display: flex; align-items: center; justify-content: space-between; gap: .75rem; border: 1px solid var(--line); border-radius: 8px; padding: .5rem .7rem; }
.topic-pick span { display: flex; flex-direction: column; min-width: 0; }
.topic-pick input { width: 5.5rem; text-align: center; }
.form-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.chips { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .6rem; }
.paper-questions { margin: 0; padding-left: 1.6rem; }
.paper-questions > li { display: flex; gap: .6rem; justify-content: space-between; padding: .7rem 0; border-top: 1px solid var(--line); }
.paper-questions > li:first-child { border-top: 0; }
.pq-body { min-width: 0; flex: 1; }
.pq-body .thumb { margin: .4rem 0; }
.danger-zone { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: space-between; }
.bank-list { list-style: none; margin: 0; padding: 0; }
.bank-list > li { display: flex; gap: .7rem; padding: .8rem 0; border-top: 1px solid var(--line); }
.bank-list > li:first-child { border-top: 0; }
.bank-list .pick { flex: 0 0 auto; padding-top: .15rem; }
.bank-list .pick input { width: 22px; height: 22px; }
.bank-list li.on-paper { opacity: .7; }
.sticky-actions { position: sticky; bottom: 0; background: rgba(245,247,251,.95); padding: .75rem 0; border-top: 1px solid var(--line); z-index: 5; }
.sticky-actions .btn { width: 100%; }
@media (min-width: 641px) { .sticky-actions .btn { width: auto; } }

/* ---------- Phones ---------- */
@media (max-width: 640px) {
  .table-wrap:has(> table.stack) { overflow: visible; }
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { padding: .55rem 0; border-bottom: 1px solid var(--line); }
  table.stack td { border: 0; padding: .2rem 0; text-align: right; overflow-wrap: anywhere; }
  table.stack td::after { content: ""; display: block; clear: both; }
  table.stack td::before { content: attr(data-label); float: left; color: var(--muted); font-size: .8rem; font-weight: 600; text-align: left; width: 38%; padding-right: .5rem; }
  table.stack td:not([data-label])::before, table.stack td[data-label=""]::before { display: none; }
  table.stack td:first-child { font-size: 1rem; }
  table.stack td.empty { text-align: center; }
  table.stack td.row-actions { text-align: left; }
  table.stack td.row-actions::before { display: none; }
  table.stack td > div { text-align: left; }
  .container { padding: 1rem .75rem 3rem; }
  .card { padding: .9rem; }
  .page-head .actions { width: 100%; }
  .stats { grid-template-columns: 1fr 1fr; gap: .6rem; }
  .stat .value { font-size: 1.35rem; }
  h1 { font-size: 1.3rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .filters .field { flex: 1 1 140px; min-width: 0; }
}
/* Touch screens: comfortable tap targets and no iOS zoom on inputs. */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn.sm { min-height: 38px; padding: .4rem .75rem; }
  .side-nav a { padding: .8rem .9rem; }
  input[type=text], input[type=tel], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea { font-size: 16px; min-height: 44px; }
  .lang button { min-height: 34px; padding: .3rem .7rem; }
}
.person-list .tags { align-items: flex-start; align-content: flex-start; }
.person-list .tags .badge { height: auto; }
@media (max-width: 640px) {
  table.stack td > * { max-width: 100%; }
  .hide-sm { display: none !important; }
  table.stack .badge { white-space: normal; }
  table.stack td form { display: inline-flex; flex-wrap: wrap; gap: .3rem; justify-content: flex-end; }
  table.stack td input[type=date] { width: auto; min-width: 0; flex: 1 1 130px; }
}
.filters input, .filters select { width: 100%; min-width: 0; max-width: 100%; }
.filters .field { min-width: 0; }
input[type=date] { min-width: 0; max-width: 100%; }

/* Password box with a Show/Hide button inside it. */
.pw-field { position: relative; display: block; }
.pw-field input { width: 100%; padding-right: 4.6rem; }
.pw-toggle { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); min-height: 36px; padding: .25rem .7rem; border: 0; border-radius: 6px; background: var(--navy-soft); color: var(--navy); font: inherit; font-size: .85rem; font-weight: 600; cursor: pointer; }
.pw-toggle:hover { background: #dbe6f5; }

/* Settings dropdown in the sidebar (native <details>, no script needed). */
.side-group { margin-top: .4rem; border-top: 1px solid rgba(255,255,255,.12); padding-top: .4rem; }
.side-group summary { list-style: none; display: flex; align-items: center; justify-content: space-between; color: #dbe6f5; padding: .55rem .75rem; border-radius: 8px; font-size: .95rem; cursor: pointer; user-select: none; }
.side-group summary::-webkit-details-marker { display: none; }
.side-group summary::after { content: ""; width: .45rem; height: .45rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin-right: .2rem; transition: transform .15s; }
.side-group[open] summary::after { transform: rotate(-135deg); }
.side-group summary:hover { background: rgba(255,255,255,.1); color: #fff; }
.side-group[open] summary { color: #fff; font-weight: 600; }
.side-group a { display: block; padding-left: 1.6rem; font-size: .9rem; }
@media (max-width: 900px) { .side-group summary { padding: .8rem .9rem; } }

/* Change password: one even column of boxes. */
.pw-card { max-width: 30rem; margin-inline: auto; }
.pw-form { display: flex; flex-direction: column; gap: 1.1rem; margin-top: 1rem; }
.pw-form label { font-weight: 600; }
.pw-form .btn { width: 100%; margin-top: .3rem; }
.pw-field input[aria-invalid=true] { border-color: var(--red); }


/* Roles and permissions table. */
.perm-table .perm-col { text-align: center; width: 8.5rem; }
.perm-box { width: 22px; height: 22px; cursor: pointer; }
@media (max-width: 640px) {
  .perm-table td.perm-fixed { display: none; }
  table.stack.perm-table tr { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: .75rem; }
  table.stack.perm-table td { text-align: left; width: auto; }
  table.stack.perm-table td.perm-teacher::before { content: none; }
}
