/* =========================================================
   EduSphere – mobile-first app UI
   ========================================================= */
:root {
  --primary: #4f46e5; --primary-2: #7c3aed; --primary-soft: #eef2ff;
  --bg: #f4f5fb; --card: #fff; --text: #111827; --muted: #6b7280; --line: #e8eaf1;
  --green: #059669; --red: #dc2626; --amber: #d97706; --blue: #2563eb; --pink: #db2777; --teal: #0d9488;
  --radius: 18px; --shadow: 0 1px 2px rgba(17,24,39,.04), 0 6px 18px rgba(17,24,39,.06);
  --nav-h: 66px; --bar-h: 60px; --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body { font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
small, .muted { color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
.hide { display: none !important; }

/* ---------------- shell ---------------- */
.shell { min-height: 100vh; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px); }
.appbar {
  position: sticky; top: 0; z-index: 30; height: var(--bar-h); display: flex; align-items: center; gap: 6px; padding: 0 10px;
  background: linear-gradient(120deg, var(--primary), var(--primary-2)); color: #fff; box-shadow: 0 4px 18px rgba(79,70,229,.25);
}
.appbar-title { flex: 1; min-width: 0; }
.appbar-title h1 { font-size: 18px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-title small { color: rgba(255,255,255,.8); font-size: 12px; display: block; }
.icon-btn { position: relative; width: 42px; height: 42px; border-radius: 12px; border: 0; background: transparent; display: grid; place-items: center; font-size: 22px; cursor: pointer; color: inherit; }
.icon-btn:active { background: rgba(255,255,255,.18); }
.icon-btn .dot { position: absolute; top: 5px; right: 4px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: #f43f5e; font-size: 10px; font-weight: 700; display: grid; place-items: center; border: 2px solid var(--primary); }
.appbar-avatar { margin-left: 2px; }
.content { max-width: 1180px; margin: 0 auto; padding: 14px; }

/* ---------------- drawer ---------------- */
.drawer { position: fixed; z-index: 50; inset: 0 auto 0 0; width: 292px; max-width: 86vw; background: #fff; transform: translateX(-102%); transition: transform .28s cubic-bezier(.2,.8,.2,1); display: flex; flex-direction: column; box-shadow: 8px 0 30px rgba(0,0,0,.12); }
.drawer.open { transform: none; }
.scrim { position: fixed; inset: 0; z-index: 45; background: rgba(15,23,42,.45); opacity: 0; pointer-events: none; transition: opacity .25s; }
.drawer.open + .scrim { opacity: 1; pointer-events: auto; }
.drawer-head { padding: 18px 16px 14px; background: linear-gradient(140deg, var(--primary), var(--primary-2)); color: #fff; }
.drawer-head .school { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }
.drawer-head .school b { display: block; font-size: 14px; line-height: 1.2; }
.drawer-head small { color: rgba(255,255,255,.8); font-size: 12px; }
.drawer-head .me { display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,.14); padding: 10px; border-radius: 14px; }
.drawer-head .me b { display: block; }
.logo { width: 40px; height: 40px; border-radius: 12px; background: rgba(255,255,255,.2); display: grid; place-items: center; font-size: 20px; flex: none; }
.logo.xl { width: 72px; height: 72px; border-radius: 22px; font-size: 36px; background: rgba(255,255,255,.18); margin: 0 auto 12px; }
.drawer-nav { flex: 1; overflow-y: auto; padding: 8px 10px 24px; }
.nav-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #9ca3af; margin: 14px 10px 6px; }
.drawer-nav a, .drawer-nav .logout { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; font-weight: 500; color: #374151; width: 100%; border: 0; background: none; cursor: pointer; text-align: left; }
.drawer-nav a i, .drawer-nav .logout i { font-size: 18px; color: #6b7280; width: 22px; text-align: center; }
.drawer-nav a:hover { background: #f5f6fb; }
.drawer-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.drawer-nav a.active i { color: var(--primary); }
.drawer-nav .logout { color: var(--red); margin-top: 10px; }
.drawer-nav .logout i { color: var(--red); }

/* ---------------- bottom nav ---------------- */
.bottomnav { position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b); background: rgba(255,255,255,.96); backdrop-filter: blur(10px); border-top: 1px solid var(--line); display: flex; }
.bottomnav a, .bottomnav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11px; font-weight: 600; color: #9ca3af; border: 0; background: none; cursor: pointer; position: relative; }
.bottomnav i { font-size: 21px; }
.bottomnav .active { color: var(--primary); }
.bottomnav .active::before { content: ''; position: absolute; top: 0; width: 34px; height: 3px; border-radius: 0 0 4px 4px; background: var(--primary); }

@media (min-width: 1024px) {
  .drawer { transform: none; box-shadow: none; border-right: 1px solid var(--line); width: 270px; }
  .scrim, .bottomnav, .menu-btn { display: none !important; }
  .shell { margin-left: 270px; padding-bottom: 30px; }
  .appbar { padding-left: 22px; }
  .content { padding: 22px; }
}

/* ---------------- avatar / badge ---------------- */
.avatar { --hue: 240; width: 40px; height: 40px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; font-weight: 700; font-size: 14px; color: hsl(var(--hue) 55% 35%); background: hsl(var(--hue) 80% 92%); object-fit: cover; }
.avatar.sm { width: 34px; height: 34px; font-size: 12px; border: 2px solid rgba(255,255,255,.6); }
.avatar.lg { width: 46px; height: 46px; font-size: 16px; }
.avatar.xl { width: 84px; height: 84px; font-size: 28px; border: 4px solid #fff; box-shadow: var(--shadow); }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.b-green { background: #d1fae5; color: #047857; } .b-red { background: #fee2e2; color: #b91c1c; } .b-amber { background: #fef3c7; color: #b45309; }
.b-blue { background: #dbeafe; color: #1d4ed8; } .b-gray { background: #f3f4f6; color: #4b5563; } .b-purple { background: #ede9fe; color: #6d28d9; }

/* ---------------- cards ---------------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card.flush .card-head { padding: 14px 16px 0; }
.card-head h3 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-head h3 i { color: var(--primary); }
.card-head a { font-size: 13px; font-weight: 600; color: var(--primary); }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 18px 4px 10px; }
.grid { display: grid; gap: 14px; }
@media (min-width: 760px) { .grid.c2 { grid-template-columns: 1fr 1fr; } .grid.c3 { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .grid.c32 { grid-template-columns: 2fr 1fr; } }

.hero { border-radius: 22px; padding: 20px; color: #fff; background: linear-gradient(130deg, var(--primary), var(--primary-2) 60%, #c026d3); box-shadow: 0 12px 30px rgba(79,70,229,.3); margin-bottom: 16px; position: relative; overflow: hidden; }
.hero::after { content: ''; position: absolute; right: -40px; top: -40px; width: 170px; height: 170px; border-radius: 50%; background: rgba(255,255,255,.1); }
.hero h2 { font-size: 21px; font-weight: 800; }
.hero p { margin: 4px 0 0; color: rgba(255,255,255,.85); font-size: 13.5px; }
.hero .hero-row { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; position: relative; z-index: 1; }
.hero .pill { background: rgba(255,255,255,.18); padding: 8px 12px; border-radius: 12px; font-size: 13px; }
.hero .pill b { display: block; font-size: 17px; }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 14px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { --c: var(--primary); background: #fff; border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px; position: relative; overflow: hidden; }
.stat .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 18px; color: var(--c); background: color-mix(in srgb, var(--c) 13%, white); }
.stat b { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.stat span { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.stat small { position: absolute; top: 14px; right: 14px; font-size: 11.5px; font-weight: 600; }
.c-green { --c: var(--green); } .c-red { --c: var(--red); } .c-amber { --c: var(--amber); } .c-blue { --c: var(--blue); } .c-pink { --c: var(--pink); } .c-teal { --c: var(--teal); } .c-purple { --c: var(--primary-2); }

.quick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (min-width: 760px) { .quick { grid-template-columns: repeat(8, 1fr); } }
.quick a { --c: var(--primary); display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; font-size: 11.5px; font-weight: 600; color: #374151; }
.quick a i { width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; font-size: 22px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); transition: transform .15s; }
.quick a:active i { transform: scale(.92); }

/* ---------------- lists ---------------- */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.card:not(.flush) .item { padding-left: 0; padding-right: 0; }
.list .item:first-child { border-top: 0; }
.item .body { flex: 1; min-width: 0; }
.item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; }
.item .s i { margin-right: 2px; }
.item .r { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.item .acts { display: flex; gap: 4px; }
a.item:active, .item.tap:active { background: #f8f9fd; }
.ic-box { --c: var(--primary); width: 42px; height: 42px; border-radius: 13px; flex: none; display: grid; place-items: center; font-size: 19px; color: var(--c); background: color-mix(in srgb, var(--c) 12%, white); }
.date-box { width: 46px; flex: none; text-align: center; border-radius: 12px; background: var(--primary-soft); color: var(--primary); padding: 5px 0; line-height: 1.1; }
.date-box b { display: block; font-size: 18px; }
.date-box small { font-size: 10.5px; text-transform: uppercase; color: var(--primary); font-weight: 700; }
.mini-btn { width: 34px; height: 34px; border-radius: 10px; border: 0; background: #f3f4f8; display: grid; place-items: center; cursor: pointer; color: #4b5563; font-size: 15px; }
.mini-btn.danger { color: var(--red); background: #fef2f2; }
.mini-btn:active { transform: scale(.92); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 9px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; text-align: right; word-break: break-word; }

/* ---------------- buttons / forms ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 600; cursor: pointer; font-size: 14px; white-space: nowrap; transition: transform .1s, box-shadow .15s; }
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(120deg, var(--primary), var(--primary-2)); color: #fff; border: 0; box-shadow: 0 6px 16px rgba(79,70,229,.3); }
.btn.success { background: var(--green); color: #fff; border: 0; }
.btn.danger { background: #fef2f2; color: var(--red); border-color: #fecaca; }
.btn.ghost { background: var(--primary-soft); color: var(--primary); border: 0; }
.btn.sm { padding: 6px 11px; font-size: 13px; border-radius: 10px; }
.btn.lg { padding: 14px 18px; font-size: 15.5px; border-radius: 14px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.fab { position: fixed; z-index: 35; right: 18px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px); width: 58px; height: 58px; border-radius: 18px; border: 0; color: #fff; font-size: 26px; background: linear-gradient(130deg, var(--primary), var(--primary-2)); box-shadow: 0 10px 24px rgba(79,70,229,.45); cursor: pointer; display: grid; place-items: center; }
@media (min-width: 1024px) { .fab { bottom: 28px; right: 28px; } }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 12.5px; font-weight: 600; color: #4b5563; margin-bottom: 5px; }
.field input, .field select, .field textarea, .input { width: 100%; padding: 11px 13px; border-radius: 12px; border: 1.5px solid var(--line); background: #fafbff; outline: none; transition: border .15s, box-shadow .15s; font-size: 15px; }
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,70,229,.12); background: #fff; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 420px) { .form-grid.r1 { grid-template-columns: 1fr; } }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: #9ca3af; }
.input-icon input { padding-left: 38px !important; }
.input-icon .peek { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: none; color: #9ca3af; cursor: pointer; padding: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin-bottom: 12px; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

.toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.toolbar .input, .toolbar select { flex: 1; min-width: 130px; padding: 10px 12px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; }
.search { position: relative; flex: 2; min-width: 180px; }
.search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: #9ca3af; }
.search input { width: 100%; padding: 10px 12px 10px 36px; border-radius: 12px; border: 1.5px solid var(--line); background: #fff; outline: none; }
.search input:focus { border-color: var(--primary); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin-bottom: 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; background: #fff; border: 1.5px solid var(--line); font-size: 13px; font-weight: 600; color: #4b5563; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.chip.active { background: var(--text); color: #fff; border-color: var(--text); }
.chip .n { background: rgba(127,127,127,.18); border-radius: 999px; padding: 0 7px; font-size: 11.5px; }

.tabs { display: flex; background: #e9ebf3; border-radius: 14px; padding: 4px; margin-bottom: 14px; overflow-x: auto; scrollbar-width: none; }
.tabs a, .tabs button { flex: 1; padding: 9px 12px; border-radius: 11px; text-align: center; font-size: 13.5px; font-weight: 600; color: #4b5563; white-space: nowrap; border: 0; background: none; cursor: pointer; }
.tabs .active { background: #fff; color: var(--primary); box-shadow: 0 2px 6px rgba(0,0,0,.06); }

/* ---------------- bottom sheet ---------------- */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; background: rgba(15,23,42,.5); opacity: 0; pointer-events: none; transition: opacity .2s; }
.sheet.open { opacity: 1; pointer-events: auto; }
.sheet-panel { width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; background: #fff; border-radius: 24px 24px 0 0; padding: 8px 18px calc(18px + var(--safe-b)); transform: translateY(100%); transition: transform .28s cubic-bezier(.2,.8,.2,1); }
.sheet.open .sheet-panel { transform: none; }
.sheet-handle { width: 42px; height: 5px; border-radius: 3px; background: #d1d5db; margin: 4px auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h3 { font-size: 18px; font-weight: 700; }
@media (min-width: 760px) { .sheet { align-items: center; } .sheet-panel { border-radius: 24px; transform: translateY(30px) scale(.97); } }

/* ---------------- tables ---------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; padding: 10px 12px; background: #f8f9fc; white-space: nowrap; }
.table td { padding: 10px 12px; border-top: 1px solid var(--line); white-space: nowrap; }
.table tr.total td { font-weight: 700; background: #fafbff; }
.table input.cell { width: 72px; padding: 7px 8px; border-radius: 9px; border: 1.5px solid var(--line); text-align: center; }
.table input.cell:focus { border-color: var(--primary); outline: none; }
.num { text-align: right; } .ctr { text-align: center; }

/* ---------------- attendance ---------------- */
.seg { display: inline-flex; background: #f1f2f7; border-radius: 12px; padding: 3px; gap: 2px; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: grid; place-items: center; width: 36px; height: 32px; border-radius: 9px; font-weight: 700; font-size: 13px; color: #9ca3af; cursor: pointer; }
.seg input:checked + span.p { background: var(--green); color: #fff; }
.seg input:checked + span.a { background: var(--red); color: #fff; }
.seg input:checked + span.l { background: var(--amber); color: #fff; }
.seg input:checked + span.h { background: var(--blue); color: #fff; }
.sticky-bar { position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 8px); z-index: 20; background: #fff; border-radius: 16px; padding: 10px; box-shadow: 0 10px 30px rgba(17,24,39,.15); display: flex; gap: 10px; align-items: center; justify-content: space-between; margin-top: 10px; }
@media (min-width: 1024px) { .sticky-bar { bottom: 16px; } }
.counts { display: flex; gap: 10px; font-size: 13px; font-weight: 700; }
.counts .g { color: var(--green); } .counts .rd { color: var(--red); } .counts .am { color: var(--amber); }

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; }
.cal .h { font-size: 11px; font-weight: 700; color: var(--muted); }
.cal .d { aspect-ratio: 1; border-radius: 11px; display: grid; place-items: center; font-size: 13px; font-weight: 600; background: #f5f6fa; color: #9ca3af; }
.cal .d.P { background: #d1fae5; color: #047857; } .cal .d.A { background: #fee2e2; color: #b91c1c; } .cal .d.L { background: #fef3c7; color: #b45309; } .cal .d.H { background: #dbeafe; color: #1d4ed8; }
.cal .d.today { outline: 2px solid var(--primary); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }

/* ---------------- charts ---------------- */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 18px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar .fill { width: 100%; max-width: 34px; height: var(--h); min-height: 3px; border-radius: 8px 8px 4px 4px; background: linear-gradient(180deg, var(--primary-2), var(--primary)); position: relative; }
.bar .fill::before { content: attr(data-v); position: absolute; top: -17px; left: 50%; transform: translateX(-50%); font-size: 10.5px; font-weight: 700; color: #4b5563; white-space: nowrap; }
.bar span { font-size: 11px; color: var(--muted); font-weight: 600; }
.progress { height: 8px; border-radius: 99px; background: #eef0f6; overflow: hidden; }
.progress > div { height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--primary), var(--primary-2)); }
.progress.g > div { background: var(--green); } .progress.r > div { background: var(--red); } .progress.a > div { background: var(--amber); }
.hrow { display: grid; grid-template-columns: 110px 1fr 48px; gap: 10px; align-items: center; font-size: 13px; padding: 6px 0; }
.hrow b { text-align: right; font-size: 12.5px; }
.ring { --p: 70; --c: var(--primary); width: 86px; height: 86px; border-radius: 50%; flex: none; background: conic-gradient(var(--c) calc(var(--p) * 1%), #eceef5 0); display: grid; place-items: center; }
.ring::before { content: attr(data-label); width: 66px; height: 66px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 800; font-size: 17px; }
.ring-row { display: flex; align-items: center; gap: 16px; }

/* ---------------- timetable ---------------- */
.tt { border-collapse: separate; border-spacing: 4px; width: 100%; min-width: 640px; }
.tt th { font-size: 11px; color: var(--muted); font-weight: 700; padding: 4px; }
.tt td { background: #f5f6fb; border-radius: 10px; padding: 7px 6px; font-size: 12px; text-align: center; height: 52px; vertical-align: middle; min-width: 78px; }
.tt td b { display: block; font-size: 12.5px; color: var(--text); }
.tt td small { font-size: 10.5px; }
.tt td.filled { background: hsl(var(--hue) 85% 94%); }
.tt td.edit { cursor: pointer; } .tt td.edit:hover { outline: 2px dashed var(--primary); }
.tt td.now { outline: 2px solid var(--primary); }
.period { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--line); }
.period:first-child { border-top: 0; }
.period .no { width: 34px; height: 34px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); font-weight: 800; display: grid; place-items: center; flex: none; }

/* ---------------- 360 profile ---------------- */
.profile-hero { text-align: center; padding: 22px 16px 18px; border-radius: 22px; background: linear-gradient(160deg, var(--primary), var(--primary-2)); color: #fff; margin-bottom: 14px; }
.profile-hero h2 { margin-top: 10px; font-size: 20px; }
.profile-hero p { margin: 3px 0 0; opacity: .85; font-size: 13px; }
.profile-hero .mini-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.profile-hero .mini-stats div { background: rgba(255,255,255,.16); border-radius: 12px; padding: 8px 4px; }
.profile-hero .mini-stats b { display: block; font-size: 16px; }
.profile-hero .mini-stats small { color: rgba(255,255,255,.85); font-size: 11px; }
.profile-hero .btn-row { justify-content: center; margin-top: 14px; }
.profile-hero .btn { background: rgba(255,255,255,.2); color: #fff; border: 0; }
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--line); }
.tl { position: relative; padding-bottom: 14px; }
.tl::before { content: ''; position: absolute; left: -20px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--c, var(--primary)); border: 3px solid #fff; box-shadow: 0 0 0 1px var(--line); }

/* ---------------- misc ---------------- */
.toast { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 14px; margin-bottom: 12px; font-weight: 500; font-size: 14px; animation: drop .3s ease; }
.toast span { flex: 1; } .toast button { border: 0; background: none; font-size: 20px; cursor: pointer; color: inherit; opacity: .6; }
.t-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.t-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.t-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }
@keyframes drop { from { opacity: 0; transform: translateY(-8px); } }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty i { font-size: 40px; color: #d1d5db; }
.empty p { margin: 8px 0 0; }
.alert-card { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; margin-bottom: 10px; font-size: 13.5px; }
.alert-card i { font-size: 20px; }
.alert-card.red { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.big-num { font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
.text-green { color: var(--green); } .text-red { color: var(--red); } .text-amber { color: var(--amber); } .text-primary { color: var(--primary); }
.mt { margin-top: 14px; } .mb0 { margin-bottom: 0; } .w100 { width: 100%; }
.flex { display: flex; gap: 10px; align-items: center; } .between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.note { white-space: pre-line; color: #374151; font-size: 14px; margin: 8px 0 0; }
details.more summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: 13px; list-style: none; }

/* receipts & report cards */
.doc { background: #fff; border-radius: 18px; padding: 22px; box-shadow: var(--shadow); }
.doc-head { display: flex; align-items: center; gap: 14px; border-bottom: 2px dashed var(--line); padding-bottom: 14px; margin-bottom: 14px; }
.doc-head .logo { background: var(--primary-soft); color: var(--primary); }
.doc-head h2 { font-size: 18px; }
.doc .stamp { display: inline-block; border: 2px solid var(--green); color: var(--green); font-weight: 800; padding: 4px 12px; border-radius: 8px; transform: rotate(-6deg); letter-spacing: .1em; }

/* ---------------- login ---------------- */
.login-page { min-height: 100vh; background: linear-gradient(160deg, var(--primary) 0%, var(--primary-2) 45%, var(--bg) 45.1%); display: flex; flex-direction: column; align-items: center; padding: 40px 16px; }
.login-hero { text-align: center; color: #fff; margin-bottom: 22px; }
.login-hero h1 { font-size: 22px; font-weight: 800; }
.login-hero p { margin: 6px 0 0; opacity: .85; font-size: 14px; }
.login-card { width: 100%; max-width: 420px; background: #fff; border-radius: 26px; padding: 24px 20px; box-shadow: 0 20px 50px rgba(17,24,39,.18); }
.login-card.center { text-align: center; margin-top: 80px; }
.login-card h2 { font-size: 21px; }
.login-card .muted { margin: 4px 0 16px; }
.role-pills { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 16px; }
.role-pills button { border: 1.5px solid var(--line); background: #fafbff; border-radius: 14px; padding: 10px 4px; font-size: 12px; font-weight: 600; display: flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; color: #4b5563; }
.role-pills button i { font-size: 19px; color: var(--primary); }
.role-pills button.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }
.hint { text-align: center; font-size: 12.5px; color: var(--muted); margin: 14px 0 0; }

/* ---------------- print ---------------- */
@media print {
  body { background: #fff; }
  .appbar, .drawer, .scrim, .bottomnav, .fab, .no-print, .toast, .chips, .tabs, .toolbar { display: none !important; }
  .shell { margin: 0 !important; padding: 0 !important; }
  .content { padding: 0; max-width: none; }
  .card, .doc { box-shadow: none; border: 1px solid #ddd; }
}

/* ---------------- library card ---------------- */
.libcard { position: relative; overflow: hidden; border-radius: 22px; padding: 18px; color: #fff; max-width: 440px; margin: 0 auto 14px;
  background: linear-gradient(135deg, #0f766e, #0d9488 45%, #4f46e5); box-shadow: 0 16px 36px rgba(13, 148, 136, .35); }
.libcard::before { content: ''; position: absolute; right: -50px; top: -50px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255,255,255,.1); }
.libcard.inactive { background: linear-gradient(135deg, #475569, #64748b); box-shadow: none; }
.lc-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; position: relative; }
.lc-top b { display: block; letter-spacing: .08em; font-size: 13px; } .lc-top small { color: rgba(255,255,255,.75); font-size: 11px; }
.lc-logo { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: rgba(255,255,255,.2); font-size: 18px; }
.lc-body { display: flex; gap: 14px; align-items: center; margin: 18px 0 14px; position: relative; }
.lc-body .avatar { border: 3px solid rgba(255,255,255,.6); }
.lc-name { font-size: 19px; font-weight: 800; } .lc-body small { color: rgba(255,255,255,.85); }
.lc-foot { display: grid; grid-template-columns: 1.3fr 1fr .8fr; gap: 8px; background: rgba(255,255,255,.14); border-radius: 14px; padding: 10px 12px; }
.lc-foot small { display: block; font-size: 10.5px; color: rgba(255,255,255,.75); text-transform: uppercase; letter-spacing: .05em; }
.lc-foot b { font-size: 13.5px; }
.lc-barcode { height: 34px; margin-top: 12px; border-radius: 6px; background: #fff repeating-linear-gradient(90deg, #0f172a 0 2px, transparent 2px 4px, #0f172a 4px 5px, transparent 5px 8px, #0f172a 8px 11px, transparent 11px 13px); opacity: .9; }
.lc-none { margin: 0; color: rgba(255,255,255,.9); }
.badge.on-dark { background: rgba(255,255,255,.2); color: #fff; }
@media print { .libcard { box-shadow: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; } }
