/* ===========================================================
   School ERP — interface styles (Bootstrap 5 base)
   =========================================================== */
:root {
  --brand: #1f3b73;
  --accent: #f0a330;
  --ink: #18223a;
  --muted: #6b7489;
  --line: #e4e8f0;
  --bg: #f3f5f9;
  --card: #ffffff;
  --sidebar-w: 256px;
  --radius: 12px;
  --bs-body-font-family: "Segoe UI", system-ui, -apple-system, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --bs-primary: var(--brand);
  --bs-link-color: var(--brand);
  --bs-link-hover-color: #142a55;
}
body { background: var(--bg); color: var(--ink); font-size: .925rem; }
a { color: var(--brand); }
.btn-primary { --bs-btn-bg: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: #172f5d; --bs-btn-hover-border-color: #172f5d; --bs-btn-active-bg: #142a55; --bs-btn-disabled-bg: var(--brand); --bs-btn-disabled-border-color: var(--brand); }
.btn-outline-primary { --bs-btn-color: var(--brand); --bs-btn-border-color: var(--brand); --bs-btn-hover-bg: var(--brand); --bs-btn-hover-border-color: var(--brand); --bs-btn-active-bg: var(--brand); }
.btn-accent { background: var(--accent); color: #2b1b00; border-color: var(--accent); font-weight: 600; }
.btn-accent:hover { background: #e2921c; color: #2b1b00; }
.text-bg-primary { background-color: var(--brand) !important; }
.form-control:focus, .form-select:focus { border-color: #8aa2d6; box-shadow: 0 0 0 .2rem rgba(31,59,115,.15); }
.form-label { font-weight: 600; font-size: .8rem; color: #3b4560; margin-bottom: .3rem; }
.form-label .req { color: #d63939; }
.form-text { font-size: .75rem; }

/* ---------- sidebar ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 1040;
  background: linear-gradient(180deg, var(--brand) 0%, #142650 100%);
  color: #cfd8ee; overflow-y: auto; padding-bottom: 2rem; transition: transform .2s ease;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent;
}
.sidebar .brand { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.1rem 1rem; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar .brand img { width: 40px; height: 40px; object-fit: contain; background: #fff; border-radius: 10px; padding: 3px; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--accent); color: #2b1b00; display: grid; place-items: center; font-size: 1.3rem; flex: none; }
.brand-text { font-weight: 700; line-height: 1.15; font-size: .95rem; }
.brand-text small { display: block; font-weight: 500; color: #9fb0d6; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; margin-top: 2px; }
.sidebar .nav { padding: .6rem .6rem; }
.sidebar .nav-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .09em; color: #8193bd; padding: 1rem .75rem .35rem; font-weight: 700; }
.sidebar .nav-link { color: #d5ddf0; border-radius: 8px; padding: .48rem .75rem; display: flex; align-items: center; gap: .7rem; font-size: .88rem; }
.sidebar .nav-link i { font-size: 1.02rem; opacity: .85; width: 1.1rem; text-align: center; }
.sidebar .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar .nav-link.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-backdrop { display: none; }

/* ---------- main ---------- */
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 1030; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .75rem; padding: .55rem 1.25rem; min-height: 60px; }
.topbar-title { font-weight: 600; color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-icon { width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 0; font-size: 1.1rem; }
.btn-icon:hover { background: #f1f4fa; }
.dot-badge { position: absolute; top: -5px; right: -5px; background: #e5484d; color: #fff; font-size: .65rem; border-radius: 10px; padding: 1px 5px; font-weight: 700; }
.user-chip { display: flex; align-items: center; gap: .55rem; border: 1px solid var(--line); background: #fff; border-radius: 12px; padding: .25rem .6rem .25rem .3rem; font-size: .85rem; font-weight: 600; }
.user-chip small { font-weight: 500; font-size: .7rem; }
.avatar { width: 32px; height: 32px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; }
.content { padding: 1.4rem 1.5rem 2rem; flex: 1; max-width: 1500px; width: 100%; }
.app-footer { display: flex; justify-content: space-between; padding: .8rem 1.5rem; color: var(--muted); font-size: .75rem; border-top: 1px solid var(--line); }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: .8rem; margin-bottom: 1.2rem; }
.page-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.crumbs { font-size: .78rem; color: var(--muted); margin-bottom: .2rem; display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; }
.crumbs a { color: var(--muted); text-decoration: none; }
.crumbs a:hover { color: var(--brand); }
.crumbs i { font-size: .6rem; }

/* ---------- cards ---------- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { background: #fff; border-bottom: 1px solid var(--line); font-weight: 650; padding: .8rem 1rem; border-radius: var(--radius) var(--radius) 0 0 !important; display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.card-header .bi { color: var(--brand); }
.section-title { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--brand); margin: 1.4rem 0 .8rem; padding-bottom: .4rem; border-bottom: 1px dashed var(--line); display: flex; align-items: center; gap: .5rem; }
.section-title:first-child { margin-top: 0; }

.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; display: flex; gap: .9rem; align-items: center; height: 100%; text-decoration: none; color: inherit; transition: box-shadow .15s, transform .15s; }
a.stat:hover { box-shadow: 0 6px 18px rgba(16,24,40,.08); transform: translateY(-1px); color: inherit; }
.stat .ico { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; flex: none; }
.stat .num { font-size: 1.45rem; font-weight: 750; line-height: 1.1; letter-spacing: -.01em; }
.stat .lbl { font-size: .78rem; color: var(--muted); font-weight: 600; }
.stat .sub { font-size: .72rem; color: var(--muted); }
.ico-blue { background: #e7eeff; color: #2d5bd7; } .ico-green { background: #e3f6ec; color: #17864f; }
.ico-amber { background: #fff3dc; color: #b86e00; } .ico-red { background: #fde8e8; color: #c43535; }
.ico-violet { background: #efe9ff; color: #6b46c1; } .ico-teal { background: #dff5f4; color: #0f7c78; }

.quick-actions { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.quick-actions a { border: 1px solid var(--line); border-radius: 10px; padding: .8rem; text-align: center; text-decoration: none; color: var(--ink); background: #fff; font-size: .82rem; font-weight: 600; }
.quick-actions a i { display: block; font-size: 1.4rem; color: var(--brand); margin-bottom: .25rem; }
.quick-actions a:hover { border-color: var(--brand); background: #f6f8fd; }

/* ---------- tables ---------- */
.table { --bs-table-hover-bg: #f6f8fd; margin-bottom: 0; }
.table > thead th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; background: #f8f9fc; border-bottom-width: 1px; white-space: nowrap; }
.table td { vertical-align: middle; }
.table-card { overflow: hidden; }
.table-responsive { border-radius: 0 0 var(--radius) var(--radius); }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: end; }
.filters .form-control, .filters .form-select { min-width: 140px; }
.cell-sub { font-size: .75rem; color: var(--muted); }

.avatar-sm { width: 34px; height: 34px; border-radius: 9px; flex: none; }
.avatar-lg { width: 96px; height: 96px; border-radius: 16px; flex: none; }
.avatar-initials { display: inline-grid; place-items: center; background: #e7eeff; color: var(--brand); font-weight: 700; }
.avatar-sm.avatar-initials { font-size: .78rem; }
.avatar-lg.avatar-initials { font-size: 1.8rem; }

.kv { display: grid; grid-template-columns: minmax(130px, 38%) 1fr; gap: .45rem .9rem; font-size: .88rem; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; font-size: .8rem; }
.kv dd { margin: 0; word-break: break-word; }

.empty-state { text-align: center; padding: 2.5rem 1rem; color: var(--muted); }
.empty-state i { font-size: 2.2rem; display: block; margin-bottom: .5rem; opacity: .6; }

/* attendance */
.att-opts { display: inline-flex; gap: 4px; }
.att-opts input { display: none; }
.att-opts label { width: 34px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; font-weight: 700; font-size: .8rem; color: var(--muted); background: #fff; user-select: none; }
.att-opts input:checked + label.o-P { background: #17864f; color: #fff; border-color: #17864f; }
.att-opts input:checked + label.o-A { background: #d64545; color: #fff; border-color: #d64545; }
.att-opts input:checked + label.o-L { background: #e09a16; color: #fff; border-color: #e09a16; }
.att-opts input:checked + label.o-H { background: #6b46c1; color: #fff; border-color: #6b46c1; }
.att-opts input:checked + label.o-E { background: #2d7fd7; color: #fff; border-color: #2d7fd7; }
.att-cell { width: 26px; text-align: center; font-size: .72rem; font-weight: 700; padding: .3rem .1rem !important; }
.st-P { color: #17864f; } .st-A { color: #d64545; background: #fff1f1 !important; } .st-L { color: #c27c00; } .st-H { color: #6b46c1; } .st-E { color: #2d7fd7; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal div { aspect-ratio: 1.3; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .8rem; background: #f6f7fb; }
.cal .hd { background: none; font-weight: 700; color: var(--muted); font-size: .7rem; aspect-ratio: auto; }
.cal .d-P { background: #e3f6ec; color: #17864f; font-weight: 700; } .cal .d-A { background: #fde8e8; color: #c43535; font-weight: 700; }
.cal .d-L { background: #fff3dc; color: #b86e00; font-weight: 700; } .cal .d-H { background: #efe9ff; color: #6b46c1; } .cal .d-E { background: #e7eeff; color: #2d5bd7; }

/* timetable */
.tt th, .tt td { text-align: center; min-width: 110px; font-size: .8rem; }
.tt td .subj { font-weight: 700; } .tt td .tchr { color: var(--muted); font-size: .72rem; }
.tt td.brk { background: #fafbfd; color: var(--muted); font-style: italic; }

/* permission matrix */
.perm-table td, .perm-table th { text-align: center; }
.perm-table td:first-child, .perm-table th:first-child { text-align: left; }
.tri { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.tri input { display: none; }
.tri label { padding: .15rem .45rem; font-size: .72rem; cursor: pointer; font-weight: 600; color: var(--muted); border-left: 1px solid var(--line); }
.tri label:first-of-type { border-left: 0; }
.tri input:checked + label.t-inh { background: #eef1f7; color: var(--ink); }
.tri input:checked + label.t-yes { background: #17864f; color: #fff; }
.tri input:checked + label.t-no { background: #d64545; color: #fff; }
.eff-yes { color: #17864f; } .eff-no { color: #c9ced9; }

.nav-tabs .nav-link { font-weight: 600; font-size: .86rem; color: var(--muted); }
.nav-tabs .nav-link.active { color: var(--brand); }
.doc-tile { border: 1px solid var(--line); border-radius: 10px; padding: .75rem; display: flex; gap: .75rem; align-items: center; background: #fff; }
.doc-tile .di { width: 42px; height: 42px; border-radius: 10px; background: #f1f4fa; display: grid; place-items: center; font-size: 1.3rem; color: var(--brand); flex: none; }
.doc-missing { border-style: dashed; background: #fcfcfd; }
.notice-item { border-left: 3px solid var(--accent); padding: .6rem .9rem; background: #fff; border-radius: 0 8px 8px 0; margin-bottom: .6rem; }

/* login */
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-art { background: radial-gradient(circle at 20% 20%, rgba(240,163,48,.25), transparent 40%), linear-gradient(150deg, var(--brand), #0f1d3d); color: #fff; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.login-art h1 { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; max-width: 30rem; }
.login-art p { color: #c4d0ec; max-width: 28rem; }
.login-art .feat { display: flex; gap: .6rem; flex-wrap: wrap; }
.login-art .feat span { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.15); padding: .35rem .7rem; border-radius: 30px; font-size: .78rem; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 2rem; background: #fff; }
.login-form .box { width: 100%; max-width: 380px; }
.role-pills { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin-bottom: 1.2rem; }
.role-pills input { display: none; }
.role-pills label { border: 1px solid var(--line); border-radius: 10px; text-align: center; padding: .55rem .2rem; cursor: pointer; font-size: .78rem; font-weight: 600; color: var(--muted); }
.role-pills label i { display: block; font-size: 1.2rem; margin-bottom: 2px; }
.role-pills input:checked + label { border-color: var(--brand); color: var(--brand); background: #f3f6fd; box-shadow: 0 0 0 1px var(--brand); }

/* wizard-ish registration form */
.reg-nav { position: sticky; top: 76px; }
.reg-nav a { display: flex; align-items: center; gap: .5rem; padding: .45rem .7rem; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: .85rem; font-weight: 600; }
.reg-nav a:hover { background: #eef2fa; color: var(--brand); }
.form-section { scroll-margin-top: 80px; }
.photo-drop { width: 130px; height: 150px; border: 2px dashed #c9d2e3; border-radius: 12px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: .75rem; overflow: hidden; background: #fafbfd; cursor: pointer; position: relative; }
.photo-drop img { width: 100%; height: 100%; object-fit: cover; position: absolute; inset: 0; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(10,18,40,.45); z-index: 1035; }
  .main { margin-left: 0; }
  .content { padding: 1rem; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .reg-nav { display: none; }
}
@media print {
  .sidebar, .topbar, .app-footer, .page-actions, .no-print, .filters { display: none !important; }
  .main { margin: 0; } .content { padding: 0; } body { background: #fff; }
  .card { border: 0; box-shadow: none; }
}
.stat > div:last-child { min-width: 0; }
.stat .num { overflow-wrap: anywhere; }
h3 .badge, h5 .badge { font-size: .55em; vertical-align: middle; }
@media (max-width: 575.98px) {
  .stat { padding: .8rem; gap: .6rem; }
  .stat .ico { width: 38px; height: 38px; font-size: 1.1rem; }
  .stat .num { font-size: 1.1rem; }
  .page-head h1 { font-size: 1.2rem; }
}
