/* Admin panel – Giriulla Zonal Education Office */
:root { --navy: #1E2A5E; --gold: #F4C430; --navy-deep: #121a3f; --ink: #1c2340; --muted: #555c80; --line: #e1e4f0; --soft: #f4f5fb; --sb-w: 250px; }
body.admin { background: var(--soft); color: var(--ink); font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans Sinhala', sans-serif; font-size: .95rem; }
a { color: var(--navy); }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.skip-link { position: absolute; left: -9999px; z-index: 2000; background: var(--gold); color: var(--navy); padding: .6rem 1rem; }
.skip-link:focus { left: 1rem; top: 1rem; }
.text-navy { color: var(--navy); }

.btn-navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-navy:hover, .btn-navy:focus { background: var(--navy-deep); border-color: var(--navy-deep); color: #fff; }

/* Layout */
.admin-wrap { display: flex; min-height: 100vh; }
.sidebar { width: var(--sb-w); background: var(--navy); color: #fff; flex-shrink: 0; }
@media (min-width: 992px) { .sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; } }
.sidebar.offcanvas-lg { --bs-offcanvas-width: 270px; --bs-offcanvas-bg: var(--navy); --bs-offcanvas-color: #fff; }
.sb-head { display: flex; align-items: center; justify-content: space-between; padding: 1.1rem 1rem; border-bottom: 1px solid rgba(255,255,255,.1); }
.sb-brand { display: flex; align-items: center; gap: .7rem; color: #fff; text-decoration: none; }
.sb-brand strong { display: block; line-height: 1.2; }
.sb-brand small, .login-head small { display: block; color: var(--gold); font-size: .75rem; }
.sb-crest { width: 40px; height: 40px; border-radius: 50%; border: 2px solid var(--gold); color: var(--gold); display: inline-flex; align-items: center; justify-content: center; font-size: 1.1rem; flex-shrink: 0; }
.sb-nav { padding: .6rem .6rem 2rem; display: flex; flex-direction: column; width: 100%; }
.sb-group { color: #9aa3cc; text-transform: uppercase; font-size: .7rem; letter-spacing: .08em; margin: 1.1rem .6rem .35rem; }
.sb-nav a { display: flex; align-items: center; gap: .7rem; color: #dfe3f5; text-decoration: none; padding: .6rem .7rem; border-radius: 6px; min-height: 42px; }
.sb-nav a i { font-size: 1.05rem; width: 1.2rem; text-align: center; }
.sb-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sb-nav a.active { background: rgba(255,255,255,.12); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }
.sb-badge { margin-left: auto; background: var(--gold); color: var(--navy); font-weight: 700; font-size: .75rem; padding: .05rem .5rem; border-radius: 999px; }

.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: .8rem; padding: .6rem 1.4rem; position: sticky; top: 0; z-index: 1000; }
.tb-menu { border: 0; background: none; font-size: 1.7rem; color: var(--navy); width: 44px; height: 44px; }
.tb-title { font-size: 1.2rem; font-weight: 700; color: var(--navy); margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-user { border: 0; background: none; display: flex; align-items: center; gap: .5rem; color: var(--ink); min-height: 44px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--navy); color: var(--gold); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.content { padding: 1.5rem 1.4rem 4rem; max-width: 1400px; width: 100%; }

/* Panels */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 1.3rem; margin-bottom: 1rem; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .8rem; }
.panel-head h2, .panel-title { font-size: 1.05rem; font-weight: 700; color: var(--navy); margin: 0 0 .9rem; }
.panel-head h2 { margin: 0; }
.empty { color: var(--muted); background: var(--soft); padding: 1rem; border-radius: 6px; margin: 0; }
.lead-sm { color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; gap: .8rem; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.req { color: #b02a37; }

/* Stats */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 1.2rem 1.3rem; text-decoration: none; color: var(--ink); border-top: 4px solid var(--navy); }
.stat:hover { border-color: var(--navy); color: var(--ink); }
.stat .v { display: block; font-size: 2.1rem; font-weight: 700; color: var(--navy); line-height: 1.1; }
.stat .l { color: var(--muted); }
.stat.s-new { border-top-color: var(--gold); }
.stat.s-done { border-top-color: #1e7d4f; }

/* Status badges */
.st { display: inline-block; font-size: .78rem; font-weight: 700; padding: .2rem .6rem; border-radius: 999px; white-space: nowrap; }
.st-new { background: #fff3c4; color: #6b5200; }
.st-in_progress { background: #dbe5ff; color: #1f3a8a; }
.st-completed { background: #d6f2e3; color: #145c38; }
.st-rejected { background: #fbdcdc; color: #8a1f1f; }

/* Tabs + filters */
.tabs { display: flex; gap: .2rem; border-bottom: 2px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .65rem 1rem; text-decoration: none; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs a.active { color: var(--navy); font-weight: 700; border-bottom-color: var(--gold); }
.filters { display: flex; flex-wrap: wrap; gap: .8rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 1rem; margin-bottom: 1rem; }
.filters > div { min-width: 170px; }
.filters .f-grow { flex: 1 1 260px; }
.filters .form-label { font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
tr.is-new td:first-child { box-shadow: inset 4px 0 0 var(--gold); }
.table th { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: none; white-space: nowrap; }

/* Request view */
.req-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; border-left: 5px solid var(--gold); }
.kv { margin: 0; }
.kv div { display: grid; grid-template-columns: minmax(130px, 38%) 1fr; gap: .8rem; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.kv div:last-child { border-bottom: 0; }
.kv dt { font-weight: 400; color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.file-list { list-style: none; padding: 0; margin: 0; }
.file-list li { display: flex; align-items: center; gap: .5rem; padding: .45rem .6rem; background: var(--soft); border-radius: 6px; margin-bottom: .35rem; }
.file-list a { word-break: break-all; }
.file-list .small { margin-left: auto; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 3px solid var(--navy); padding: .2rem 0 .9rem 1rem; position: relative; }
.timeline li.int { border-left-color: #b9bfd8; }
.tl-meta { font-size: .8rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.tl-vis { margin-left: auto; font-size: .72rem; background: var(--soft); padding: .05rem .45rem; border-radius: 4px; }
.timeline li.int .tl-vis { background: #eceefa; }
.tl-note { margin-top: .25rem; }
.action-panel { border-top: 4px solid var(--navy); }
@media (min-width: 1200px) { .action-panel { position: sticky; top: 76px; } }
.status-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; }
.status-pick .btn { min-height: 42px; }
.btn-check:checked + .st-btn-new { background: #fff3c4; color: #6b5200; border-color: #d9b100; }
.btn-check:checked + .st-btn-in_progress { background: #dbe5ff; color: #1f3a8a; border-color: #1f3a8a; }
.btn-check:checked + .st-btn-completed { background: #1e7d4f; color: #fff; border-color: #1e7d4f; }
.btn-check:checked + .st-btn-rejected { background: #a32626; color: #fff; border-color: #a32626; }
.msg-body { background: var(--soft); padding: 1rem 1.2rem; border-radius: 6px; }

/* Forms */
.current-file { display: flex; align-items: center; gap: 1rem; margin-bottom: .5rem; }
.thumb { max-width: 160px; max-height: 110px; border-radius: 6px; border: 1px solid var(--line); }
.sticky-save { position: sticky; bottom: 0; background: rgba(244,245,251,.95); padding: .9rem 0; border-top: 1px solid var(--line); margin-top: 1rem; display: flex; gap: .5rem; z-index: 5; }

/* Form builder */
.fb-field { border: 1px solid var(--line); border-radius: 8px; padding: .9rem; margin-bottom: .7rem; background: #fff; }
.fb-field.dragging { opacity: .5; }
.fb-top { display: flex; gap: .5rem; align-items: center; margin-bottom: .6rem; }
.fb-num { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: .8rem; flex-shrink: 0; }
.fb-tools { margin-left: auto; display: flex; gap: .25rem; }
.fb-tools button { width: 36px; height: 36px; }
.fb-empty { border: 2px dashed var(--line); border-radius: 8px; padding: 1.4rem; text-align: center; color: var(--muted); }

/* Login */
.login-page { min-height: 100vh; background: var(--navy); display: flex; align-items: center; justify-content: center; padding: 1rem; font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif; }
.login-card { background: #fff; width: 100%; max-width: 420px; padding: 2rem; border-radius: 10px; border-top: 6px solid var(--gold); }
.login-head { display: flex; gap: .8rem; align-items: center; margin-bottom: 1.5rem; }
.login-head small { color: #7a5d00; }
.login-card h1 { font-size: 1.5rem; color: var(--navy); font-weight: 700; margin-bottom: 1rem; }
.login-foot { font-size: .85rem; color: var(--muted); margin: 1rem 0 0; text-align: center; }

/* Phones: tables become cards */
@media (max-width: 767.98px) {
  .content { padding: 1rem .8rem 3rem; }
  .topbar { padding: .5rem .8rem; }
  .req-table thead { display: none; }
  .req-table tr { display: block; padding: .8rem 1rem; border-bottom: 1px solid var(--line); }
  .req-table td { display: flex; justify-content: space-between; gap: 1rem; border: 0; padding: .2rem 0; text-align: right; }
  .req-table td::before { content: attr(data-label); color: var(--muted); font-size: .8rem; text-align: left; }
  .req-table td small { text-align: right; }
  tr.is-new td:first-child { box-shadow: none; }
  tr.is-new { box-shadow: inset 4px 0 0 var(--gold); }
  .kv div { grid-template-columns: 1fr; gap: .1rem; }
  .filters > div { flex: 1 1 100%; }
}
@media (min-width: 992px) { .sidebar.offcanvas-lg { background-color: var(--navy) !important; } }
.action-panel legend { font-size: .95rem; margin-bottom: .5rem; }
.img-setting { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; border: 1px dashed var(--line); border-radius: 8px; padding: .8rem; }
.img-setting.on-dark .img-prev, .img-setting.on-dark .img-empty { background: var(--navy); }
.img-prev { max-width: 220px; max-height: 120px; object-fit: contain; border-radius: 6px; padding: 6px; background: var(--soft); }
.img-empty { width: 160px; height: 90px; display: flex; align-items: center; justify-content: center; border-radius: 6px; background: var(--soft); color: var(--muted); font-size: .85rem; }
.img-setting.on-dark .img-empty { color: #c5cbe6; }
.list-thumb-wrap { display: inline-flex; align-items: center; gap: .8rem; }
.list-thumb { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; background: var(--soft); }
.list-thumb.wide { width: 120px; height: 56px; }
.album-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 1rem; }
.album-chips a { padding: .4rem .9rem; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: .9rem; }
.album-chips a span { color: var(--muted); font-size: .8rem; margin-left: .2rem; }
.album-chips a.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.album-chips a.active span { color: var(--gold); }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem; margin-bottom: .8rem; }
.bulk-bar .form-select, .bulk-bar .form-control { width: auto; min-width: 180px; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .8rem; }
.photo-item { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.photo-item:has(input:checked) { outline: 3px solid var(--gold); }
.ph-check { position: absolute; top: .4rem; left: .4rem; z-index: 2; background: rgba(255,255,255,.9); border-radius: 6px; padding: .25rem .35rem; line-height: 1; }
.ph-check input { width: 1.2rem; height: 1.2rem; margin: 0; }
.ph-link { display: block; text-decoration: none; color: var(--ink); }
.ph-link img { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block; }
.ph-cap { display: block; padding: .45rem .6rem 0; font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ph-tags { display: flex; flex-wrap: wrap; gap: .3rem; padding: .35rem .6rem .6rem; }
.ph-tags span { font-size: .72rem; background: var(--soft); padding: .1rem .45rem; border-radius: 4px; color: var(--muted); }
.ph-tags .home { background: #fff3c4; color: #6b5200; }
.sort-link { color: var(--muted); text-decoration: none; }
.sort-link.on { color: var(--navy); font-weight: 700; }
.sort-link.on::after { content: " ▾"; }
.album-chips a.chip-warn { border-color: #e7c65b; }
.album-chips a.chip-warn.active { background: #6b5200; border-color: #6b5200; }
.sticky-bulk { position: sticky; top: 60px; z-index: 20; box-shadow: 0 4px 14px rgba(30,42,94,.08); }
.sel-count { font-weight: 700; color: var(--navy); min-width: 90px; }
.school-table .chk { width: 44px; }
.school-table .chk input { width: 1.25rem; height: 1.25rem; }
.school-table tr.row-sel td { background: #fff8dc; }
.row-muted td { opacity: .6; }
.preview-wrap { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 1rem; }
.preview-wrap th { position: sticky; top: 0; background: var(--soft); }
.map-table td:nth-child(2) { max-width: 360px; }
kbd { background: var(--navy); }
@media (max-width: 767.98px) {
  .school-table thead { display: none; }
  .school-table tr { display: grid; grid-template-columns: 36px 1fr; padding: .7rem .8rem; border-bottom: 1px solid var(--line); }
  .school-table td { border: 0; padding: .1rem 0; grid-column: 2; }
  .school-table td.chk { grid-column: 1; grid-row: 1 / span 7; }
  .school-table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .8rem; }
  .school-table td[data-label="School"]::before { content: ""; }
  .school-table td.text-end { text-align: left !important; }
  .sticky-bulk { top: 56px; }
}
.report-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.report-card { display: flex; flex-direction: column; gap: .35rem; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 1.2rem; text-decoration: none; color: var(--ink); border-left: 4px solid var(--gold); }
.report-card:hover { border-color: var(--navy); color: var(--ink); }
.report-card i { font-size: 1.6rem; color: var(--navy); }
.report-card strong { color: var(--navy); }
.report-card span { color: var(--muted); font-size: .88rem; }
.col-pick summary { cursor: pointer; color: var(--navy); font-weight: 600; padding: .3rem 0; }
.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .2rem 1rem; padding: .5rem 0; }
.report-wrap { max-height: 70vh; }
.report-table thead th { position: sticky; top: 0; background: #fff; box-shadow: inset 0 -1px 0 var(--line); }
.report-table tfoot th { background: var(--soft); }
.tb-search { position: relative; flex: 0 1 340px; }
.tb-search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.tb-search input { width: 100%; border: 1px solid var(--line); background: var(--soft); border-radius: 999px; padding: .5rem .9rem .5rem 2.2rem; min-height: 40px; }
.tb-search input:focus { background: #fff; border-color: var(--navy); outline: none; box-shadow: 0 0 0 3px rgba(244,196,48,.45); }
.search-list { list-style: none; padding: 0; margin: 0; }
.search-list a { display: block; padding: .55rem .2rem; border-bottom: 1px solid var(--line); text-decoration: none; }
.search-list li:last-child a { border-bottom: 0; }
.search-list a:hover { background: var(--soft); }
.sl-t { display: block; font-weight: 600; color: var(--navy); }
.sl-m { display: block; font-size: .82rem; color: var(--muted); }
@media (max-width: 575.98px) { .tb-title { display: none; } .tb-search { flex: 1 1 auto; } }
.list-thumb.round { width: 42px; height: 42px; border-radius: 50%; object-fit: cover; }
.list-thumb.empty { display: inline-flex; align-items: center; justify-content: center; color: var(--muted); font-size: 1.2rem; }
