/* ============================================================
   CFC TANZANIA — paneli ya msimamizi na ukurasa wa kuingia.
   Inajenga juu ya site.css (tokens, vitufe, fomu).
   ============================================================ */

body.admin { background: var(--bg); font-size: 15px; }
.muted { color: var(--muted); }

/* ---------- Mpangilio ---------- */
.adm-shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.adm-side {
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
    background: #06112e; color: rgba(255,255,255,.75); padding: 1.1rem .8rem;
}
.adm-brand { padding: .3rem .6rem 1.2rem; }
.adm-brand img { width: 32px; }
.adm-brand .brand-text strong { color: #fff; }
.adm-brand .brand-text strong em { color: var(--gold); }
.adm-brand .brand-text small { color: rgba(255,255,255,.5); }
.adm-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.adm-group { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: rgba(255,255,255,.4); padding: 1rem .8rem .35rem; }
.adm-nav a, .adm-side-foot a {
    display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: 10px;
    color: rgba(255,255,255,.75); font-weight: 600; font-size: .9rem;
}
.adm-nav a:hover, .adm-side-foot a:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.adm-nav a.on { background: linear-gradient(90deg, rgba(210,31,44,.9), rgba(210,31,44,.65)); color: #fff; box-shadow: 0 6px 16px rgba(210,31,44,.25); }
.adm-side-foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: .6rem; display: grid; gap: 2px; }

.adm-main { min-width: 0; display: flex; flex-direction: column; }
.adm-top {
    position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 1rem;
    padding: .8rem 1.75rem; background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: blur(12px); border-bottom: 1px solid var(--border);
}
.adm-top .header-tools { margin-left: auto; }
.adm-search { max-width: 360px; }
.adm-search input { padding: .6rem 0; }
.adm-menu { display: none; }
.has-dot { position: relative; }
.has-dot::after { content: ""; position: absolute; top: 9px; right: 10px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.avatar {
    display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; flex: 0 0 auto;
    background: linear-gradient(135deg, var(--primary-solid), #2e5bd6); color: #fff; font: 700 .85rem var(--font-head);
}
.avatar.sm { width: 34px; height: 34px; border-radius: 10px; font-size: .75rem; }

.adm-preview {
    margin: 1.25rem 1.75rem 0; padding: .55rem .9rem; border-radius: 10px; font-size: .84rem;
    background: var(--gold-soft); color: var(--text); display: flex; gap: .5rem; align-items: center;
}
.adm-preview .icon { color: var(--gold); }
.adm-content { padding: 1.5rem 1.75rem 3rem; }

.adm-backdrop { display: none; }
@media (max-width: 960px) {
    .adm-shell { grid-template-columns: 1fr; }
    .adm-side { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
    .sidebar-open .adm-side { transform: none; }
    .sidebar-open .adm-backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.45); }
    .adm-menu { display: inline-grid; }
    .adm-top, .adm-content { padding-left: 1rem; padding-right: 1rem; }
    .adm-preview { margin: 1rem 1rem 0; }
    .adm-search { display: none; }
}

/* ---------- Kichwa cha ukurasa ---------- */
.adm-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.adm-head h1 { font-size: 1.6rem; margin: 0 0 .15rem; }
.adm-head p { margin: 0; }

/* ---------- Takwimu ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat { position: relative; display: flex; align-items: center; gap: .9rem; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.1rem 1.2rem; }
.stat > div { display: flex; flex-direction: column; min-width: 0; }
.stat-icon { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: var(--primary-soft); color: var(--primary); flex: 0 0 auto; }
.stat-icon .icon { width: 22px; height: 22px; }
.stat:nth-child(2) .stat-icon { background: var(--gold-soft); color: var(--gold); }
.stat:nth-child(3) .stat-icon { background: var(--accent-soft); color: var(--accent); }
.stat-label { font-size: .8rem; color: var(--muted); }
.stat-value { font: 700 1.35rem/1.2 var(--font-head); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-strong { background: linear-gradient(135deg, var(--primary-solid), #16389a); border-color: transparent; color: #fff; }
.stat-strong .stat-label { color: rgba(255,255,255,.75); }
.stat-strong .stat-icon { background: rgba(255,255,255,.14); color: var(--gold); }
.delta { align-self: flex-start; margin-left: auto; font-size: .72rem; font-weight: 700; padding: .15rem .45rem; border-radius: 999px; }
.delta.up { background: #e3f6ea; color: #18804a; }
.delta.warn { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .stat-grid { grid-template-columns: 1fr; } }

/* ---------- Paneli ---------- */
.adm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.adm-grid.wide-left { grid-template-columns: 1.6fr 1fr; align-items: start; }
@media (max-width: 1100px) { .adm-grid, .adm-grid.wide-left { grid-template-columns: 1fr; } }
.stack { display: grid; gap: 1.25rem; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 1.3rem 1.4rem; min-width: 0; }
.panel.flush { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-head h2 { font-size: 1.05rem; margin: 0; }
.panel-head.sub { margin-top: .75rem; padding-top: 1.1rem; border-top: 1px solid var(--border); }
.grid-3 { display: grid; grid-template-columns: 1fr 1.4fr 1fr; gap: 0 .75rem; }
.grid-3 .field { margin-bottom: .6rem; }

/* Chati ya mihimili (CSS tu) */
.bars { display: flex; align-items: flex-end; gap: .45rem; height: 210px; padding-top: 1.2rem; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; gap: .35rem; }
.bar {
    position: relative; width: 100%; max-width: 30px; margin-top: auto; border-radius: 8px 8px 3px 3px;
    background: linear-gradient(180deg, #3a66d8, var(--primary-solid)); transition: filter .15s;
}
.bar-col:last-child .bar { background: linear-gradient(180deg, #ef4a55, var(--accent)); }
.bar em { position: absolute; top: -1.3rem; left: 50%; transform: translateX(-50%); font-style: normal; font-size: .68rem; color: var(--muted); opacity: 0; transition: opacity .15s; }
.bar-col:hover .bar em, .bar-col:last-child .bar em { opacity: 1; }
.bar-col small { font-size: .7rem; color: var(--muted); }

.event-list.compact .event-item { padding: .65rem .8rem; }
.people { list-style: none; margin: 0; padding: 0; display: grid; }
.people li { display: flex; align-items: center; gap: .8rem; padding: .7rem 0; border-top: 1px solid var(--border); }
.people li:first-child { border-top: 0; padding-top: 0; }
.people li > div { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.people small { color: var(--muted); }
.people .muted { font-size: .8rem; }
.meter-row { margin-bottom: 1rem; }
.meter-label { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: .35rem; }
.meter-label strong { font-variant-numeric: tabular-nums; }
.meter { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary-solid), #3a66d8); }
.meter-row:nth-child(3) .meter span { background: linear-gradient(90deg, var(--accent), #ef6a72); }
.meter-row:nth-child(4) .meter span { background: linear-gradient(90deg, var(--gold), #f3c865); }

/* ---------- Jedwali ---------- */
.table-tools { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; }
.tabs a { padding: .45rem .75rem; border-radius: 9px; font-weight: 600; font-size: .86rem; color: var(--muted); }
.tabs a:hover { text-decoration: none; background: var(--surface-2); color: var(--text); }
.tabs a.on { background: var(--primary-soft); color: var(--primary); }
.tabs a span { font-size: .72rem; margin-left: .2rem; opacity: .75; }
.select-sm { width: auto; padding: .45rem .7rem; font-size: .86rem; }
.table-wrap { overflow-x: auto; }
.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: 700; padding: .75rem 1.1rem; background: var(--surface-2); white-space: nowrap; }
.table td { padding: .8rem 1.1rem; border-top: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .mono { font-size: .82rem; }
.table .date-chip { width: 48px; padding: .3rem 0; }
.table .date-chip strong { font-size: 1.05rem; }
.cell-person { display: flex; align-items: center; gap: .7rem; }
.row-actions { text-align: right; }
.row-actions .icon-btn { margin-left: .25rem; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 9px; }
.icon-btn.sm .icon { width: 16px; height: 16px; }
.play-btn.sm { width: 32px; height: 32px; box-shadow: none; }
.play-btn.sm .icon { width: 13px; height: 13px; }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: .75rem 1.1rem; border-top: 1px solid var(--border); font-size: .85rem; }
.pager { display: flex; gap: .3rem; }

.badge { display: inline-flex; align-items: center; gap: .3rem; font-size: .75rem; font-weight: 700; padding: .22rem .55rem; border-radius: 999px; white-space: nowrap; }
.badge .icon { width: 13px; height: 13px; }
.badge.ok { background: #e3f6ea; color: #18804a; }
.badge.info { background: var(--primary-soft); color: var(--primary); }
.badge.warn { background: var(--gold-soft); color: #9a6c05; }
.badge.danger { background: var(--accent-soft); color: var(--accent); }
.badge.muted { background: var(--surface-2); color: var(--muted); }
:root[data-theme="dark"] .badge.ok, :root[data-theme="dark"] .delta.up { background: #12301f; color: #5fd08f; }
:root[data-theme="dark"] .badge.warn { color: var(--gold); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .badge.ok, :root:not([data-theme="light"]) .delta.up { background: #12301f; color: #5fd08f; }
    :root:not([data-theme="light"]) .badge.warn { color: var(--gold); }
}

/* ---------- Fomu za paneli ---------- */
.upload {
    display: flex; align-items: center; justify-content: center; gap: .5rem; padding: 1.1rem; margin-bottom: 1rem;
    border: 1.5px dashed var(--border); border-radius: 12px; color: var(--muted); font-size: .88rem; cursor: pointer;
}
.upload:hover { border-color: var(--primary); color: var(--primary); }
.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: .85rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon input { padding-left: 2.5rem; }
.brand-preview { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; padding: .8rem; background: var(--surface-2); border-radius: 12px; }
.brand-preview img { width: 48px; }
.brand-preview div { display: flex; flex-direction: column; }
.swatches { display: flex; gap: .5rem; }
.swatches span { width: 34px; height: 34px; border-radius: 10px; cursor: pointer; border: 3px solid transparent; }
.swatches span.on { border-color: var(--surface); box-shadow: 0 0 0 2px var(--primary); }

/* ---------- Ujumbe ---------- */
.inbox { display: grid; grid-template-columns: 380px 1fr; gap: 1.25rem; align-items: start; }
.inbox-list { list-style: none; margin: 0; }
.inbox-list li { display: flex; gap: .8rem; padding: .95rem 1.1rem; border-top: 1px solid var(--border); cursor: pointer; }
.inbox-list li:first-child { border-top: 0; }
.inbox-list li:hover { background: var(--surface-2); }
.inbox-list li.on { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.inbox-list li > div { flex: 1; min-width: 0; }
.inbox-row { display: flex; justify-content: space-between; gap: .5rem; }
.inbox-row small { color: var(--muted); font-size: .75rem; }
.inbox-list li:not(.unread) strong { font-weight: 500; }
.inbox-list li.unread .inbox-row strong::after { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-left: .4rem; vertical-align: middle; }
.inbox-subj { font-size: .78rem; color: var(--accent); font-weight: 600; }
.inbox-list p { margin: .1rem 0 0; font-size: .84rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inbox-read h2 { font-size: 1.25rem; margin: .5rem 0 .15rem; }
.inbox-read .muted { margin: 0; font-size: .85rem; }
@media (max-width: 1000px) { .inbox { grid-template-columns: 1fr; } }

/* ---------- Kuingia ---------- */
body.auth { background: var(--bg); }
.auth-wrap { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }
.auth-art {
    position: relative; overflow: hidden; color: #fff; display: grid; place-items: center; padding: 3rem;
    background: linear-gradient(135deg, var(--hero-1), var(--hero-2) 60%, #16389a);
}
.auth-art-inner { position: relative; max-width: 420px; text-align: center; }
.auth-logo { width: 150px; margin: 0 auto 1.5rem; filter: drop-shadow(0 18px 36px rgba(0,0,0,.45)); }
.auth-art h2 { font-size: 1.8rem; }
.auth-art p { font-style: italic; color: rgba(255,255,255,.82); margin: 0 0 .3rem; }
.auth-art cite { color: var(--gold); font-style: normal; font-weight: 700; font-size: .9rem; }
.auth-form { display: flex; flex-direction: column; padding: 1.5rem 2rem; }
.auth-top { display: flex; justify-content: space-between; align-items: center; }
.auth-card { width: 100%; max-width: 400px; margin: auto; padding: 2rem 0; }
.auth-card h1 { font-size: 1.7rem; margin-bottom: .3rem; }
.auth-card .muted { margin-bottom: 1.75rem; }
.auth-card .check { margin-bottom: 1.25rem; }
.auth-foot { text-align: center; color: var(--muted); font-size: .8rem; margin: 0; }
@media (max-width: 860px) { .auth-wrap { grid-template-columns: 1fr; } .auth-art { display: none; } .auth-form { padding: 1rem; } }

/* ============================================================
   BACKEND — CRUD, arifa, fomu
   ============================================================ */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.adm-head h1 { display: flex; align-items: center; gap: .5rem; }
.adm-head h1 .icon { color: var(--accent); }
.link-arrow.back { font-size: .85rem; margin-bottom: .35rem; }
a.stat { color: var(--text); transition: border-color .15s, box-shadow .15s; }
a.stat:hover { text-decoration: none; border-color: var(--primary); box-shadow: var(--shadow-sm); }

.nav-count { margin-left: auto; font-style: normal; font-size: .7rem; font-weight: 800; min-width: 20px; padding: .1rem .4rem; border-radius: 999px; background: var(--accent); color: #fff; text-align: center; }
.adm-nav a.on .nav-count { background: #fff; color: var(--accent); }
.adm-side-foot form { margin: 0; }
.adm-side-foot button {
    width: 100%; display: flex; align-items: center; gap: .7rem; padding: .6rem .8rem; border-radius: 10px; border: 0; cursor: pointer;
    background: transparent; color: rgba(255,255,255,.75); font: 600 .9rem var(--font); text-align: left;
}
.adm-side-foot button:hover { background: rgba(255,255,255,.06); color: #fff; }

.user-chip { display: flex; align-items: center; gap: .6rem; color: var(--text); padding: .2rem .5rem .2rem .2rem; border-radius: 14px; }
.user-chip:hover { text-decoration: none; background: var(--surface-2); }
.user-chip-text { display: flex; flex-direction: column; line-height: 1.2; }
.user-chip-text strong { font-size: .85rem; }
.user-chip-text small { font-size: .72rem; color: var(--muted); }
@media (max-width: 700px) { .user-chip-text { display: none; } }

.adm-alert {
    display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin: 1rem 1.75rem 0; padding: .7rem 1rem;
    border-radius: 12px; font-size: .9rem; border: 1px solid transparent;
}
.adm-alert > span { flex: 1; }
.adm-alert.ok { background: #e3f6ea; color: #14683d; border-color: #bfe6cd; }
.adm-alert.bad { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.adm-alert.warn { background: var(--gold-soft); color: var(--text); border-color: color-mix(in srgb, var(--gold) 40%, transparent); }
.adm-alert.warn > .icon { color: var(--gold); }
.adm-alert.inline { margin: 0 0 1rem; }
:root[data-theme="dark"] .adm-alert.ok { background: #12301f; color: #5fd08f; border-color: #1e4a31; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .adm-alert.ok { background: #12301f; color: #5fd08f; border-color: #1e4a31; } }
@media (max-width: 960px) { .adm-alert { margin: 1rem 1rem 0; } }

/* Jedwali */
.table-tools .search { max-width: 320px; }
.table-tools .search input { padding: .55rem 0; }
.cell-link { color: var(--text); font-weight: 600; }
.cell-link:hover { color: var(--primary); }
.row-actions { display: flex; gap: .3rem; justify-content: flex-end; align-items: center; }
td.row-actions { display: table-cell; }
td.row-actions > * { display: inline-flex; vertical-align: middle; margin-left: .25rem; }
td.row-actions form { margin: 0; }
.icon-btn.danger:hover { border-color: var(--accent); color: var(--accent); }
.thumb { width: 38px; height: 46px; object-fit: contain; object-position: bottom; border-radius: 8px; background: var(--surface-2); }
.yt-thumb { position: relative; display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 8px; overflow: hidden; cursor: pointer; background: #000; }
.yt-thumb img { width: 72px; height: 40px; object-fit: cover; opacity: .85; }
.yt-thumb span { position: absolute; color: #fff; }
.yt-thumb .icon { width: 16px; height: 16px; fill: currentColor; }
.empty-mini { display: flex; flex-direction: column; align-items: center; text-align: center; gap: .6rem; padding: 1.5rem 1rem; color: var(--muted); }
.empty-mini > .icon { width: 34px; height: 34px; color: var(--border); }
.empty-mini p { margin: 0; max-width: 360px; font-size: .9rem; }
.empty-mini.big { padding: 3.5rem 1rem; }
.empty-mini.big > .icon { width: 46px; height: 46px; color: var(--primary); opacity: .35; }

/* Fomu */
.form-panel { padding: 1.6rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.25rem; }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }
.req { color: var(--accent); }
.field-check { align-self: center; padding: .6rem .8rem; margin-bottom: 1rem; border: 1.5px solid var(--border); border-radius: 12px; }
.field-check:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; padding-top: 1.1rem; margin-top: .5rem; border-top: 1px solid var(--border); }
.form-actions.sticky { position: sticky; bottom: 0; z-index: 5; margin-top: 1.25rem; padding: .9rem 0; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(8px); border-top: 1px solid var(--border); }
.image-field { display: flex; gap: 1rem; align-items: flex-start; }
.image-preview { width: 96px; height: 120px; object-fit: contain; object-position: bottom; border-radius: 12px; background: linear-gradient(170deg, #eef2fb, #d7e0f5); border: 1px solid var(--border); flex: 0 0 auto; }
.image-field input[type=file] { font: inherit; font-size: .88rem; }
.yt-preview { margin-top: .6rem; }
.yt-preview img { width: 240px; max-width: 100%; border-radius: 10px; border: 1px solid var(--border); }

.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; align-items: start; }
@media (max-width: 1100px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-grid .panel-head h2 { display: flex; align-items: center; gap: .45rem; }
.settings-grid .panel-head h2 .icon { color: var(--accent); }
.settings-grid .form-note { margin: -.6rem 0 1rem; }
.quick-links { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.quick-links a { display: flex; align-items: center; gap: .5rem; padding: .8rem .9rem; border-radius: 12px; border: 1px solid var(--border); color: var(--text); font-weight: 600; font-size: .9rem; }
.quick-links a:hover { text-decoration: none; border-color: var(--primary); color: var(--primary); }

/* Ujumbe */
.inbox-list li { padding: 0; }
.inbox-list li > a { display: flex; gap: .8rem; padding: .95rem 1.1rem; color: var(--text); }
.inbox-list li > a:hover { text-decoration: none; }
.message-body-text { padding: 1rem 1.1rem; border-radius: 12px; background: var(--surface-2); margin-bottom: 1.25rem; line-height: 1.7; }
.inbox-read .muted a { color: var(--muted); display: inline-flex; align-items: center; gap: .25rem; }
.inbox-read .btn-row form { margin: 0; }
.adm-head .tabs { align-self: center; }
