/* Shared styles for staff dashboard and admin pages. Same flat look as the student pages. */
:root {
    --accent: #1e3a8a; --accent-soft: #eef2fb; --bg: #f5f7fa; --surface: #ffffff;
    --text: #1f2937; --text-light: #6b7280; --line: #e5e8ee; --radius: 10px;
    --ok-bg: #eaf6ee; --ok-fg: #1d6b3a; --bad-bg: #fdecea; --bad-fg: #b42318; --danger: #b42318;
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Poppins', system-ui, sans-serif; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--text); line-height: 1.55; font-size: 15px; min-height: 100vh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px max(16px, calc((100% - 1200px) / 2)); background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar h1 { font-size: 1.1rem; font-weight: 600; color: var(--accent); }
.page { width: 100%; max-width: 1600px; margin: 0 auto; padding: 16px; flex: 1; }
h2 { font-size: 1.05rem; font-weight: 600; margin-bottom: 12px; }
.muted { color: var(--text-light); font-size: 0.88rem; }
.pad { padding: 24px 0; }
.label { display: block; font-size: 0.75rem; color: var(--text-light); margin-bottom: 2px; }

.btn { display: inline-block; min-height: 38px; padding: 8px 16px; background: var(--accent); color: #fff; border: 1px solid var(--accent); border-radius: 8px; font-size: 0.86rem; font-weight: 500; text-decoration: none; text-align: center; cursor: pointer; transition: opacity 0.15s, background 0.15s; }
.btn:hover { opacity: 0.88; }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
.btn.ghost:hover { background: var(--accent-soft); opacity: 1; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--line); }
.btn.small { min-height: 30px; padding: 4px 10px; font-size: 0.8rem; }

/* dashboard tiles */
.tiles { display: grid; grid-template-columns: 1fr; gap: 12px; margin-top: 12px; }
.tile { display: flex; flex-direction: column; gap: 4px; padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); text-decoration: none; transition: background 0.15s; }
.tile:hover { background: var(--accent-soft); }
.tile strong { color: var(--accent); font-weight: 600; }

/* tabs, controls */
.tabs { display: flex; gap: 20px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 2px; margin-bottom: -1px; font-size: 0.92rem; font-weight: 500; color: var(--text-light); cursor: pointer; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 14px; }
input, select, textarea { width: 100%; min-height: 40px; padding: 8px 12px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px; font-size: 0.9rem; }
.controls .field { min-width: 150px; }
.controls .grow { flex: 1; }
input[type=checkbox] { width: 20px; min-height: 20px; }

/* messages */
#msg { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; font-size: 0.88rem; }
#msg.ok { background: var(--ok-bg); color: var(--ok-fg); }
#msg.bad { background: var(--bad-bg); color: var(--bad-fg); }

/* data table */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
th, td { padding: 9px 12px; text-align: left; white-space: nowrap; border-bottom: 1px solid var(--line); font-weight: 400; }
th { color: var(--text-light); font-size: 0.76rem; font-weight: 500; background: var(--bg); }
tbody tr:last-child td { border-bottom: 0; }
td.actions { display: flex; gap: 6px; }
td.wrap { white-space: normal; min-width: 220px; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

/* edit dialog */
dialog { width: min(560px, 100%); max-height: 92vh; margin: auto; padding: 0; border: 0; border-radius: 14px; background: var(--surface); color: var(--text); overflow-y: auto; }
dialog::backdrop { background: rgba(17, 24, 39, 0.4); }
.dlg-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 600; }
.dlg-body { padding: 16px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.dlg-body .full { grid-column: 1 / -1; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
@media (max-width: 520px) { .dlg-body { grid-template-columns: 1fr; } }

@media (min-width: 768px) { .page { padding: 28px 24px; } .tiles { grid-template-columns: 1fr 1fr; } }

/* ---------- data editor additions ---------- */
.check { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 0.85rem; }
#filterBox { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 15px; }
#filterBox > .btn { margin-bottom: 5px; }
#filters { display: flex; flex-direction: column; gap: 8px; }
#filters:empty { display: none; }
.frow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.frow .f-col { width: 190px; }
.frow .f-val, .frow .f-text { width: 260px; max-width: 100%; }
td .main { display: block; font-weight: 500; }
td .sub { display: block; font-size: 0.76rem; font-weight: 400; color: var(--text-light); }
td.tech { color: var(--text-light); }
td.actions { display: table-cell; white-space: nowrap; }
td.actions .btn { margin-right: 6px; }
.link { background: none; border: 0; padding: 0; text-align: left; font: inherit; color: var(--accent); cursor: pointer; }
.link:hover .main { text-decoration: underline; }
.del { color: var(--danger); font-size: 0.8rem; }
.ref { position: relative; }
.ref-list { position: absolute; z-index: 5; left: 0; right: 0; top: 100%; margin-top: 2px; max-height: 220px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08); }
.ref-item { display: block; width: 100%; padding: 8px 12px; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line); font-size: 0.85rem; cursor: pointer; }
.ref-item:hover { background: var(--accent-soft); }
.ref-more { padding: 8px 12px; }

.warn { color: #b45309; }