/* ONE TEACHER: CSS viết tay, không cần build. Ưu tiên điện thoại. */
:root {
    --blue: #1867e0; --blue-d: #0b3a85; --green: #3cb84a; --red: #d93025; --orange: #e8710a; --amber: #f2a600;
    --bg: #f4f6fb; --card: #fff; --text: #1d2433; --muted: #6b7385; --line: #e3e7ef; --r: 12px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Be Vietnam Pro", sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--blue); text-decoration: none; }
h1 { font-size: 1.5rem; margin: .2em 0 .4em; }
h2 { font-size: 1.15rem; margin: 0 0 .6em; }
.muted { color: var(--muted); font-size: .92rem; }
.center { text-align: center; }

.topbar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--blue-d); color: #fff; }
.topbar .brand { color: #fff; font-size: 1.1rem; letter-spacing: .5px; }
.topbar .brand b, .login h1 b { color: var(--green); }
.topbar .who { opacity: .8; margin-right: 8px; font-size: .9rem; }
.link { background: none; border: 0; color: #fff; text-decoration: underline; cursor: pointer; font: inherit; }

.wrap { max-width: 860px; margin: 0 auto; padding: 16px 14px 120px; }
.card { background: var(--card); border-radius: var(--r); padding: 16px; margin-bottom: 14px; box-shadow: 0 1px 3px rgba(20,30,60,.08); }
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.card.empty { text-align: center; padding: 32px 16px; }
.login { margin-top: 10vh; text-align: center; }
.login form { text-align: left; }
.head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }

.alert { padding: 12px 14px; border-radius: var(--r); margin-bottom: 14px; }
.alert.ok { background: #e5f4e4; color: #1e5b24; }
.alert.err { background: #fbebeb; color: #8a1c14; }

label { display: block; margin-bottom: 12px; font-size: .92rem; color: var(--muted); }
label.check { display: flex; gap: 8px; align-items: center; color: var(--text); }
input, select, textarea { display: block; width: 100%; margin-top: 4px; padding: 11px 12px; font: inherit; color: var(--text); border: 1px solid var(--line); border-radius: 10px; background: #fff; }
label.check input { width: auto; margin: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue); border-color: transparent; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 16px; min-height: 44px; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-align: center; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.danger { background: #fff; border-color: var(--red); color: var(--red); }
.btn.full { width: 100%; }
.btn.big { min-height: 54px; font-size: 1.05rem; }

.class-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.class-item .class-name { flex: 1; color: var(--text); }
.class-item strong { display: block; font-size: 1.1rem; }
.dim { opacity: .6; }

.students { margin: 0 0 12px; padding-left: 1.6em; }
.students li { padding: 6px 0; border-bottom: 1px solid var(--line); }
details.add { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
details.add summary { cursor: pointer; color: var(--blue); font-weight: 600; padding: 6px 0; }
details.add form { margin-top: 10px; }
.danger-zone { margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--line); }

.table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.table th, .table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.scroll-x { overflow-x: auto; }
.grid th, .grid td { text-align: center; white-space: nowrap; }
.grid .sticky { position: sticky; left: 0; background: #fff; text-align: left; }
.st-present { color: var(--green); } .st-late { color: var(--amber); font-weight: 700; }
.st-absent_excused { color: var(--orange); font-weight: 700; } .st-absent { color: #fff; background: var(--red); font-weight: 700; }

/* Điểm danh */
.date-pick { display: flex; gap: 8px; align-items: center; justify-content: center; margin-bottom: 6px; }
.date-pick input { width: auto; margin: 0; }
.summary { position: sticky; top: 52px; z-index: 5; background: var(--blue-d); color: #fff; border-radius: 10px; padding: 8px 12px; margin-bottom: 10px; font-size: .92rem; text-align: center; }
.att-row { background: #fff; border-radius: var(--r); padding: 12px; margin-bottom: 8px; box-shadow: 0 1px 2px rgba(20,30,60,.06); }
.att-name { font-weight: 600; margin-bottom: 8px; }
.att-name .no { display: inline-block; min-width: 1.6em; color: var(--muted); font-weight: 400; }
.seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: flex; align-items: center; justify-content: center; min-height: 46px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: .9rem; font-weight: 600; text-align: center; cursor: pointer; user-select: none; }
.seg input:focus-visible + span { outline: 2px solid var(--blue); }
.seg-present input:checked + span { background: var(--green); border-color: var(--green); color: #fff; }
.seg-late input:checked + span { background: var(--amber); border-color: var(--amber); color: #fff; }
.seg-absent_excused input:checked + span { background: var(--orange); border-color: var(--orange); color: #fff; }
.seg-absent input:checked + span { background: var(--red); border-color: var(--red); color: #fff; }
.att-note { margin-top: 8px; padding: 8px 10px; font-size: .9rem; }
.save-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: rgba(244,246,251,.96); box-shadow: 0 -2px 8px rgba(20,30,60,.08); }
.save-bar .btn { max-width: 832px; margin: 0 auto; display: flex; }

@media (min-width: 700px) {
    .att-row { display: grid; grid-template-columns: 1.2fr 2fr 1fr; gap: 10px; align-items: center; }
    .att-name, .att-note { margin: 0; }
}

/* Điểm danh QR */
.qr-panel .head h2 { margin: 0; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 8px 0; }
.row-btns select { width: auto; margin: 0; }
.row-btns form { margin: 0; }
.center-btns { justify-content: center; }
.ok-text { color: #1e5b24; font-weight: 600; }
.pending { margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.pending-item { padding: 8px 0; border-bottom: 1px solid var(--line); margin: 0; font-size: 1rem; }
.alert { background: #eef3fd; color: var(--blue-d); }
.big-msg { font-size: 1.2rem; font-weight: 700; text-align: center; padding: 24px 14px; }
.pick { display: grid; gap: 8px; margin-bottom: 12px; }
.pick label { margin: 0; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick span { display: block; padding: 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 1.05rem; color: var(--text); background: #fff; cursor: pointer; }
.pick input:checked + span { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 700; }
.poster { text-align: center; max-width: 640px; margin: 0 auto 14px; }
.poster .qr svg { width: min(80vw, 420px); height: auto; }
.poster .qr svg path { fill: #000; }
.steps { text-align: left; display: inline-block; font-size: 1.1rem; }
@media print {
    .topbar, .no-print, .alert { display: none !important; }
    body { background: #fff; }
    .card { box-shadow: none; }
}

/* Trang quản trị */
.wrap.wide { max-width: 1200px; }
.admin-bar { background: #1d2433; }
.search { display: flex; gap: 8px; margin-bottom: 14px; }
.search input { margin: 0; }
.tag { display: inline-block; padding: 2px 10px; border-radius: 99px; font-size: .85rem; font-weight: 600; background: #eef0f5; }
.tag-active { background: #e5f4e4; color: #1e5b24; }
.tag-trial { background: #e7f1fb; color: var(--blue-d); }
.tag-expired { background: #f9eeda; color: #8a5a00; }
.tag-locked { background: #fbebeb; color: #8a1c14; }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: .85rem; }
.big-code { font-size: 1.2rem; padding: 2px 8px; background: #fff; border-radius: 6px; user-select: all; }
.narrow-left { max-width: 640px; }
.topbar a.who { color: #fff; opacity: .85; }
