/* Admin panel — builds on style.css tokens */
body.admin { background: #f4f6f5; font-size: 15px; }
.admin-shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: 100vh; }

.sidebar { background: var(--green-950); color: #b8d3c4; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.07); }
.sidebar-brand img { width: 36px; background: #fff; border-radius: 6px; padding: 2px; }
.sidebar-brand span { font-weight: 600; line-height: 1.2; }
.sidebar-brand small { display: block; font-weight: 400; font-size: .75rem; color: var(--gold); }
.sidebar-nav { display: flex; flex-direction: column; padding: 12px 10px; gap: 2px; flex: 1; }
.sidebar-nav a { display: flex; justify-content: space-between; align-items: center; color: #b8d3c4; text-decoration: none; padding: 9px 12px; border-radius: 7px; font-size: .92rem; }
.sidebar-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.active { background: var(--green-800); color: #fff; font-weight: 500; box-shadow: inset 3px 0 0 var(--gold); }
.nav-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: #6f9582; padding: 16px 12px 6px; }
.badge { background: var(--gold); color: var(--green-950); font-size: .72rem; font-weight: 700; border-radius: 999px; padding: 1px 8px; }
.sidebar-foot { padding: 14px 22px; border-top: 1px solid rgba(255,255,255,.07); font-size: .85rem; }
.sidebar-foot a { color: var(--gold); text-decoration: none; }

.admin-main { min-width: 0; display: flex; flex-direction: column; }
.admin-top { display: flex; align-items: center; gap: 14px; background: #fff; border-bottom: 1px solid var(--line); padding: 0 28px; min-height: 64px; position: sticky; top: 0; z-index: 20; }
.admin-top h1 { font-size: 1.25rem; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-toggle { display: none; background: none; border: 1px solid var(--line); border-radius: 8px; width: 40px; height: 40px; font-size: 1.2rem; cursor: pointer; }
.admin-user { display: flex; align-items: center; gap: 16px; }
.admin-user a { text-decoration: none; text-align: right; line-height: 1.2; }
.admin-user-link { display: flex; align-items: center; gap: 10px; border-radius: 999px; padding: 3px; }
.admin-user-link:hover .avatar { box-shadow: 0 0 0 2px var(--green-700); }

/* User avatars: initials on a per-user colour */
.avatar { --av-size: 36px; display: inline-flex; align-items: center; justify-content: center; flex: none; width: var(--av-size); height: var(--av-size); border-radius: 50%; font-size: calc(var(--av-size) * .38); font-weight: 600; letter-spacing: .02em; line-height: 1; color: #fff; user-select: none; }
.tone-0 { background: #146c43; } .tone-1 { background: #b7791f; } .tone-2 { background: #0e7490; }
.tone-3 { background: #6d28d9; } .tone-4 { background: #be185d; } .tone-5 { background: #475569; }
.avatar-guest { background: #e2e8f0; color: #94a3b8; }
.user-cell { display: flex; align-items: center; gap: 12px; }
.user-cell > div { min-width: 0; }
.activity-by { gap: 6px; flex-wrap: wrap; margin-top: 3px; }
.account-card { padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.account-card strong { display: block; color: var(--ink); font-size: 1.05rem; }
.admin-user strong { display: block; color: var(--ink); font-size: .9rem; }
.admin-user small { color: var(--muted); font-size: .75rem; }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--green-700); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-size: .9rem; }
.btn-link.danger { color: var(--red); }
.admin-content { padding: 26px 28px 60px; max-width: 1400px; width: 100%; }
.admin-content h2 { font-size: 1.1rem; }

.btn-sm { padding: 7px 14px; font-size: .85rem; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #912018; color: #fff; }

.panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin-bottom: 20px; }
.panel-flush { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
fieldset.panel { padding-top: 14px; }
fieldset.panel legend { font-weight: 600; color: var(--green-800); padding: 0 6px; }
.form fieldset.panel { margin-bottom: 20px; }
.back { display: inline-block; margin-bottom: 14px; text-decoration: none; font-size: .9rem; }
.hint { font-size: .85rem; color: var(--muted); margin: 0; }
.small { font-size: .8rem; }
.nowrap { white-space: nowrap; }
.code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: .82rem; background: var(--bg-soft); border: 1px solid var(--line); padding: 1px 6px; border-radius: 4px; white-space: nowrap; }
.flag { color: var(--gold-600); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 30px !important; }

.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
.span-2 { grid-column: span 2; }
.option-row { display: flex; flex-wrap: wrap; gap: 4px 26px; margin-bottom: 14px; align-items: center; }
.option-row .check { margin-bottom: 6px; }
.form-actions { margin-bottom: 20px; }
.narrow-form { max-width: 640px; }
.sticky-save { position: sticky; bottom: 0; background: linear-gradient(transparent, #f4f6f5 30%); padding: 20px 0 10px; }
.thumb-row { display: flex; align-items: center; gap: 14px; }
.thumb { width: 120px; border-radius: 8px; border: 1px solid var(--line); }
.thumb.round { width: 72px; height: 72px; object-fit: cover; border-radius: 50%; }
.thumb-sm { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; }
.thumb-rect { width: 64px; height: 42px; border-radius: 6px; object-fit: cover; flex: none; }
.with-thumb { display: flex; align-items: center; gap: 10px; }
.map-preview iframe { width: 100%; height: 240px; border: 1px solid var(--line); border-radius: 8px; }
.tabs-inline { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }
.tabs-inline a { font-size: .85rem; padding: 6px 12px; border-radius: 999px; background: #fff; border: 1px solid var(--line); text-decoration: none; color: var(--text); }
.tabs-inline a:hover { border-color: var(--green-700); color: var(--green-800); }
.hint-box { font-size: .88rem; color: var(--muted); margin: 14px 0; }
.hint-box summary { cursor: pointer; color: var(--green-700); }
.steps { padding-left: 1.2em; color: var(--text); }
.steps li { margin-bottom: 6px; }
.scroll-list { max-height: 260px; overflow: auto; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; text-decoration: none; color: var(--text); }
a.kpi:hover { border-color: var(--green-700); color: var(--text); }
.kpi-label { font-size: .8rem; color: var(--muted); font-weight: 500; }
.kpi-num { font-size: 2rem; font-weight: 700; color: var(--ink); line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.kpi-alert { border-color: var(--gold); background: var(--gold-50); }
.kpis-sm .kpi-num { font-size: 1.5rem; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.dash-grid, .detail-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; align-items: start; }

/* Toolbars & filters */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar p { margin: 0; }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { flex: 1 1 260px; min-height: 38px; padding: 7px 12px; }
.filters select, .filters input[type=date] { width: auto; min-height: 38px; padding: 6px 10px; font-size: .9rem; }
.inline-date { display: flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--muted); }
.filter-chips { margin-bottom: 14px; }
.filter-chips a { font-size: .85rem; background: #fff; }
.pager-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.pager-row .pagination { margin-top: 0; }
.per-page select { width: auto; min-height: 36px; padding: 4px 8px; font-size: .85rem; }
.per-page label { font-size: .85rem; color: var(--muted); display: flex; gap: 8px; align-items: center; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--bg-soft); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th a { color: inherit; text-decoration: none; }
.table th a::after { content: " ↕"; opacity: .4; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafcfb; }
.table td a { text-decoration: none; }
.table td a strong { color: var(--ink); }
.table td a:hover strong { color: var(--green-800); }
td.row-actions { text-align: right; white-space: nowrap; }
td.row-actions > * + * { margin-left: 14px; }
div.row-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.row-actions a { font-size: .9rem; }
.row-actions form { display: inline; margin: 0; }
.panel > .table-wrap { margin: 0 -24px -22px; }

.pill { display: inline-block; font-size: .74rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; margin: 1px 2px 1px 0; }
.pill-pending { background: var(--gold-50); color: #8a6a0f; }
.pill-reviewing { background: #eff8ff; color: #175cd3; }
.pill-interview_scheduled { background: #f4f3ff; color: #5925dc; }
.pill-approved, .pill-active { background: var(--green-50); color: var(--green-800); }
.pill-graduated, .pill-hafiza_completed { background: var(--green-800); color: #fff; }
.pill-rejected { background: var(--red-50); color: var(--red); }
.pill-withdrawn { background: #f2f4f7; color: #475467; }

/* Activity / audit */
.activity { list-style: none; margin: 0; padding: 0; }
.activity li { display: flex; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.activity li:last-child { border-bottom: 0; }
.act { flex: none; font-size: .66rem; font-weight: 700; letter-spacing: .04em; padding: 3px 7px; border-radius: 4px; background: #f2f4f7; color: #475467; height: fit-content; min-width: 64px; text-align: center; }
.act-create { background: var(--green-50); color: var(--green-800); }
.act-update { background: #eff8ff; color: #175cd3; }
.act-delete, .act-login_failed, .act-login_blocked, .act-password_change_failed { background: var(--red-50); color: var(--red); }
.act-login, .act-logout { background: #f4f3ff; color: #5925dc; }
.act-export_pdf, .act-export_csv, .act-import, .act-import_start { background: var(--gold-50); color: #8a6a0f; }
.act-push_broadcast { background: #fff1f3; color: #c01048; }
.diff { margin-top: 6px; font-size: .8rem; background: var(--bg-soft); border-radius: 6px; padding: 6px 10px; }
.diff del { color: var(--red); } .diff ins { color: var(--green-800); text-decoration: none; }
.audit-table td { font-size: .86rem; }
.audit-diff summary { cursor: pointer; color: var(--green-700); font-size: .8rem; margin-top: 4px; }
.audit-diff table { border-collapse: collapse; margin-top: 6px; font-size: .78rem; width: 100%; }
.audit-diff th, .audit-diff td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; vertical-align: top; word-break: break-word; }
.audit-diff th { background: var(--bg-soft); }

.dl-grid { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 8px 16px; margin: 0 0 12px; font-size: .92rem; }
.dl-grid dt { color: var(--muted); }
.dl-grid dd { margin: 0; color: var(--ink); }
h3.sub { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--green-800); border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.danger-zone { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 1px solid #fecdca; background: var(--red-50); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 20px; font-size: .88rem; color: #7a271a; }

/* Gallery manager */
.admin-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin-bottom: 16px; }
.ag-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.ag-card.is-hidden .gallery-media { opacity: .55; }
.ag-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; font-size: .88rem; }
.ag-body > a { text-decoration: none; }
.ag-body strong { color: var(--ink); font-weight: 600; line-height: 1.3; }
.ag-actions { display: flex; gap: 14px; margin-top: 6px; align-items: center; }
.ag-actions a, .ag-actions .btn-link { font-size: .85rem; }
.ag-actions form { margin: 0; }
.hidden-badge { position: absolute; top: 10px; right: 10px; font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; background: #475467; color: #fff; padding: 2px 8px; border-radius: 4px; }
.video-preview { width: 320px; max-width: 100%; margin-bottom: 12px; background: #000; }
.drop-field input[type=file] { padding: 18px; border: 2px dashed #cbd5e1; border-radius: 10px; background: var(--bg-soft); width: 100%; }

/* Storage */
.r2-fields { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px 4px; margin: 16px 0; }
.r2-fields legend { font-weight: 600; color: var(--green-800); padding: 0 6px; }
.check-list { list-style: none; padding: 0; margin: 0 0 14px; font-size: .9rem; }
.check-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.check-list .ok { color: var(--green-800); }
.check-list .bad { color: var(--red); }
.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.setup-guide summary { color: var(--ink); }
.setup-guide code { font-size: .82rem; }
div.row-actions.left { justify-content: flex-start; }

/* Inbox */
.inbox { display: grid; gap: 8px; margin-bottom: 16px; }
.inbox-item { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.inbox-item.unread { border-left: 3px solid var(--gold); }
.inbox-item.unread strong { color: var(--ink); }
.inbox-item.open { border-color: var(--green-700); }
.inbox-summary { display: grid; grid-template-columns: 200px minmax(0, 1fr) auto; gap: 14px; padding: 14px 18px; text-decoration: none; color: var(--text); }
.inbox-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inbox-summary time { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.inbox-body { padding: 0 18px 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.inbox-body .row-actions { justify-content: flex-start; }

/* Login */
.login-page { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(135deg, var(--green-950), var(--green-800)); padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 16px; padding: 36px 32px; box-shadow: 0 30px 60px rgba(0,0,0,.25); text-align: center; }
.login-card img { margin: 0 auto 8px; width: 80px; }
.login-card h1 { font-size: 1.35rem; margin: 6px 0 20px; }
.login-card .form { text-align: left; }
.login-note { font-size: .8rem; color: var(--muted); margin: 18px 0 8px; }
.login-back { font-size: .85rem; text-decoration: none; }

@media (max-width: 1100px) {
  .dash-grid, .detail-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .admin-shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.4); }
  .sidebar-toggle { display: inline-block; }
  .admin-top { padding: 0 16px; }
  .admin-content { padding: 18px 16px 50px; }
  .admin-user-text { display: none; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .inbox-summary { grid-template-columns: 1fr auto; }
  .inbox-subject { grid-column: 1 / -1; grid-row: 2; }
}
@media (max-width: 640px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .panel { padding: 18px 16px; }
  .panel > .table-wrap { margin: 0 -16px -18px; }
  .dl-grid { grid-template-columns: 1fr; gap: 2px; }
  .dl-grid dd { margin-bottom: 8px; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi { padding: 14px; }
  .kpi-num { font-size: 1.5rem; }
  .danger-zone { flex-direction: column; align-items: flex-start; }
  .filters > * { flex: 1 1 100%; }
  .filters select { width: 100%; }
  .table { font-size: .85rem; }
  .table th, .table td { padding: 10px; }
  td.row-actions { text-align: left; }
}
