/* ==========================================================================
   TIGMEIN Gombe — Design System v2
   Brand: Maroon & Tan (from the official logo)
   Every module reads the same tokens, so light/dark switch everywhere.
   ========================================================================== */

:root,
[data-theme="light"] {
    --brand-900: #3A110B;
    --brand-800: #5A1C12;
    --brand-700: #7A2E1E;
    --brand-600: #93402B;
    --brand-500: #A9533A;
    --tan-500: #C9A27A;
    --tan-400: #D8B894;
    --tan-100: #F6EDE3;

    --bg-main: #F6F2ED;
    --bg-soft: #EFE8E0;
    --panel-bg: #FFFFFF;
    --panel-raised: #FFFFFF;
    --text-main: #1E1411;
    --text-muted: #6D605A;
    --text-faint: #9A8E88;
    --accent-primary: #7A2E1E;
    --accent-primary-hover: #5A1C12;
    --accent-secondary: #A87B4F;
    --accent-contrast: #FFFFFF;
    --glass-border: rgba(90, 28, 18, 0.10);
    --glass-border-strong: rgba(90, 28, 18, 0.18);
    --glass-hover: rgba(122, 46, 30, 0.06);
    --accent-soft: rgba(122, 46, 30, 0.09);
    --success: #15803D;
    --success-soft: rgba(21, 128, 61, 0.10);
    --warning: #B45309;
    --warning-soft: rgba(180, 83, 9, 0.10);
    --danger: #DC2626;
    --danger-soft: rgba(220, 38, 38, 0.10);
    --info: #1D4ED8;
    --info-soft: rgba(29, 78, 216, 0.10);

    --shadow-xs: 0 1px 2px rgba(58, 17, 11, 0.06);
    --shadow-soft: 0 1px 2px rgba(58, 17, 11, 0.05), 0 8px 24px -12px rgba(58, 17, 11, 0.14);
    --shadow-lg: 0 24px 60px -20px rgba(58, 17, 11, 0.35);

    /* legacy aliases used by older modules */
    --tm-gold: #B8895A;
    --tm-gold-light: #D8B894;
    --feed-gold: #B8895A;
    --feed-gold-light: #D8B894;
    --glass-bg: var(--panel-bg);
    --bg-color: var(--bg-main);

    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --sidebar-w: 272px;
    --topbar-h: 68px;
    --bottomnav-h: 64px;
    --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-display: 'Playfair Display', Georgia, serif;
    --ease: cubic-bezier(.4, 0, .2, 1);
    color-scheme: light;
}

[data-theme="dark"] {
    --bg-main: #120C0A;
    --bg-soft: #1A1210;
    --panel-bg: #1C1411;
    --panel-raised: #241A16;
    --text-main: #F5EEE8;
    --text-muted: #B3A69F;
    --text-faint: #7F726C;
    --accent-primary: #C0614A;
    --accent-primary-hover: #D2745C;
    --accent-secondary: #D8B894;
    --glass-border: rgba(216, 184, 148, 0.10);
    --glass-border-strong: rgba(216, 184, 148, 0.18);
    --glass-hover: rgba(216, 184, 148, 0.06);
    --accent-soft: rgba(192, 97, 74, 0.14);
    --success: #4ADE80;
    --success-soft: rgba(74, 222, 128, 0.12);
    --warning: #FBBF24;
    --warning-soft: rgba(251, 191, 36, 0.12);
    --danger: #F87171;
    --danger-soft: rgba(248, 113, 113, 0.12);
    --info: #60A5FA;
    --info-soft: rgba(96, 165, 250, 0.12);
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-soft: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 30px -14px rgba(0, 0, 0, 0.6);
    --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.8);
    --tm-gold: #D8B894;
    --feed-gold: #D8B894;
    color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
html, body { height: 100%; }
body {
    font-family: var(--font-body);
    background: var(--bg-main);
    color: var(--text-main);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    transition: background-color .3s var(--ease), color .3s var(--ease);
}
img, svg, video { max-width: 100%; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
a { color: var(--accent-primary); }
::selection { background: var(--accent-primary); color: #fff; }
:focus-visible { outline: 2px solid var(--accent-primary); outline-offset: 2px; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--glass-border-strong); border-radius: 10px; border: 3px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Legacy background orbs — kept hidden for a cleaner look */
.ambient-orb { display: none; }

/* ---------- App Shell ---------- */
#dashboard-wrapper {
    display: flex;
    min-height: 100vh;
    min-height: 100dvh;
    width: 100%;
    background: var(--bg-main);
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--panel-bg);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .3s var(--ease), background-color .3s;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 20px 18px;
    border-bottom: 1px solid var(--glass-border);
    position: relative;
}
.brand-logo {
    width: 44px; height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    box-shadow: 0 0 0 2px var(--panel-bg), 0 0 0 3.5px var(--tan-500);
    flex-shrink: 0;
}
.brand-text h2 { font-size: 1.1rem; font-weight: 800; letter-spacing: .4px; color: var(--text-main); line-height: 1.1; }
.brand-text p { font-size: .68rem; font-weight: 700; letter-spacing: 1.2px; text-transform: uppercase; color: var(--accent-secondary); margin-top: 3px; }

.close-sidebar-btn {
    display: none;
    margin-left: auto;
    width: 36px; height: 36px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    align-items: center; justify-content: center;
}

.nav-menu {
    list-style: none;
    padding: 14px 12px;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: thin;
}
.nav-item { list-style: none; }
.nav-header {
    padding: 16px 12px 6px;
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: 1.3px;
    text-transform: uppercase;
    color: var(--text-faint);
    list-style: none;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin: 2px 0;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: .9rem;
    transition: background .2s, color .2s;
    cursor: pointer;
    position: relative;
}
.nav-link i { font-size: 1.22rem; flex-shrink: 0; }
.nav-link span { flex: 1; }
.nav-link:hover { background: var(--glass-hover); color: var(--text-main); }
.nav-link.active {
    background: var(--accent-soft);
    color: var(--accent-primary);
}
.nav-link.active::before {
    content: '';
    position: absolute;
    left: -12px; top: 8px; bottom: 8px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--accent-primary);
}
.nav-badge {
    flex: 0 0 auto !important;
    min-width: 20px; height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--danger);
    color: #fff;
    font-size: .68rem;
    font-weight: 800;
    display: inline-flex; align-items: center; justify-content: center;
}
.nav-badge:empty, .nav-badge[data-count="0"] { display: none; }
.nav-pill-new {
    flex: 0 0 auto !important;
    font-size: .6rem; font-weight: 800; letter-spacing: .6px;
    padding: 2px 7px; border-radius: 6px;
    background: var(--accent-primary); color: #fff;
}

.user-profile-sm {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 12px;
    padding: 12px;
    border-radius: 14px;
    background: var(--bg-main);
    border: 1px solid var(--glass-border);
}
.avatar-circle {
    width: 40px; height: 40px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    font-size: .9rem;
    color: #fff;
    background: var(--accent-primary);
    flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: .88rem; font-weight: 700; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { font-size: .72rem; font-weight: 600; color: var(--accent-secondary); text-transform: capitalize; }
.logout-btn, .login-btn {
    width: 36px; height: 36px;
    border-radius: 10px;
    border: 1px solid var(--glass-border);
    background: var(--panel-bg);
    color: var(--text-muted);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    text-decoration: none;
    transition: .2s;
}
.logout-btn:hover { color: var(--danger); border-color: var(--danger); }
.login-btn { color: var(--accent-primary); }
.login-btn:hover { background: var(--accent-primary); color: #fff; }

.main-content {
    flex: 1;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

.top-bar {
    position: sticky;
    top: 0;
    z-index: 900;
    height: var(--topbar-h);
    padding: 0 28px;
    display: flex;
    align-items: center;
    gap: 14px;
    background: color-mix(in srgb, var(--bg-main) 82%, transparent);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
    border-bottom: 1px solid var(--glass-border);
}
.menu-toggle {
    display: none;
    width: 40px; height: 40px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--panel-bg);
    color: var(--text-main);
    font-size: 1.3rem;
    cursor: pointer;
    align-items: center; justify-content: center;
}
.topbar-brand { display: none; align-items: center; gap: 10px; text-decoration: none; }
.topbar-brand img { width: 34px; height: 34px; border-radius: 50%; background: #fff; }
.topbar-brand b { color: var(--text-main); font-size: 1rem; letter-spacing: .3px; }
.page-title-wrap { min-width: 0; }
.page-title { font-size: 1.15rem; font-weight: 800; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.2px; }
.page-crumb { font-size: .72rem; color: var(--text-muted); font-weight: 600; }
.top-bar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
    position: relative;
    width: 40px; height: 40px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    background: var(--panel-bg);
    color: var(--text-main);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    text-decoration: none;
    transition: .2s;
}
.icon-btn:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.icon-btn .dot-badge {
    position: absolute; top: -5px; right: -5px;
    min-width: 19px; height: 19px; padding: 0 5px;
    border-radius: 10px;
    background: var(--danger); color: #fff;
    font-size: .64rem; font-weight: 800;
    display: none; align-items: center; justify-content: center;
    border: 2px solid var(--bg-main);
}
.icon-btn .dot-badge.show { display: inline-flex; }
.top-login-btn {
    display: inline-flex; align-items: center; gap: 8px;
    height: 40px; padding: 0 16px;
    border-radius: 12px;
    background: var(--accent-primary); color: #fff;
    font-weight: 700; font-size: .86rem;
    text-decoration: none;
    transition: .2s;
}
.top-login-btn:hover { background: var(--accent-primary-hover); }

.content-wrapper {
    flex: 1;
    width: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 28px;
}

.overlay {
    position: fixed; inset: 0;
    background: rgba(18, 8, 6, .5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 990;
    opacity: 0; visibility: hidden;
    transition: .3s var(--ease);
}
.overlay.active { opacity: 1; visibility: visible; }

/* Bottom navigation (mobile) */
.bottom-nav {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 950;
    height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: color-mix(in srgb, var(--panel-bg) 92%, transparent);
    backdrop-filter: saturate(160%) blur(16px);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    border-top: 1px solid var(--glass-border);
}
.bottom-nav a {
    flex: 1;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: .66rem;
    font-weight: 700;
    position: relative;
}
.bottom-nav a i { font-size: 1.35rem; transition: transform .2s; }
.bottom-nav a.active { color: var(--accent-primary); }
.bottom-nav a.active i { transform: translateY(-1px); }
.bottom-nav a .dot-badge {
    position: absolute; top: 7px; left: calc(50% + 6px);
    min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 9px; background: var(--danger); color: #fff;
    font-size: .6rem; font-weight: 800;
    display: none; align-items: center; justify-content: center;
}
.bottom-nav a .dot-badge.show { display: inline-flex; }

/* ---------- Page loader ---------- */
.page-loader { display: flex; flex-direction: column; gap: 14px; padding: 8px 0; }
.skeleton {
    border-radius: var(--radius);
    background: linear-gradient(90deg, var(--glass-hover) 0%, var(--glass-border) 50%, var(--glass-hover) 100%);
    background-size: 200% 100%;
    animation: skel 1.2s ease-in-out infinite;
}
@keyframes skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }
/* opacity only: a transform here would trap position:fixed modals inside the content area */
.module-enter { animation: moduleFade .3s var(--ease) backwards; } /* no fill afterwards, so page modals can sit above the top/bottom bars */
@keyframes moduleFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes moduleIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Reusable components ---------- */
.card {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
}
.glass-panel {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
}
#dashboard-wrapper.glass-panel { border: 0; background: var(--bg-main); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 44px; padding: 0 20px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-weight: 700; font-size: .9rem;
    cursor: pointer;
    text-decoration: none;
    transition: background .2s, border-color .2s, color .2s, transform .15s, box-shadow .2s;
    white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--accent-primary); color: #fff; }
.btn-primary:hover { background: var(--accent-primary-hover); box-shadow: 0 8px 20px -8px var(--accent-primary); }
.btn-outline { background: var(--panel-bg); border-color: var(--glass-border-strong); color: var(--text-main); }
.btn-outline:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--glass-hover); color: var(--text-main); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { height: 36px; padding: 0 14px; font-size: .82rem; border-radius: 10px; }
.btn-lg { height: 52px; padding: 0 26px; font-size: 1rem; border-radius: 14px; }
.btn-block { width: 100%; }

.tg-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .7rem; font-weight: 800; letter-spacing: .3px;
    background: var(--accent-soft); color: var(--accent-primary);
}
.tg-badge.success { background: var(--success-soft); color: var(--success); }
.tg-badge.warning { background: var(--warning-soft); color: var(--warning); }
.tg-badge.danger { background: var(--danger-soft); color: var(--danger); }
.tg-badge.info { background: var(--info-soft); color: var(--info); }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label { font-size: .8rem; font-weight: 700; color: var(--text-main); }
.field > label .req { color: var(--danger); }
.field > label .opt { color: var(--text-faint); font-weight: 600; font-size: .72rem; }
.field .hint { font-size: .72rem; color: var(--text-muted); }
.field .err { font-size: .72rem; color: var(--danger); font-weight: 600; display: none; }
.field.invalid .err { display: block; }
.field.invalid .input { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.input {
    width: 100%;
    height: 46px;
    padding: 0 14px;
    background: var(--panel-bg);
    border: 1px solid var(--glass-border-strong);
    border-radius: 12px;
    color: var(--text-main);
    font-size: .95rem;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
textarea.input { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; line-height: 1.5; }
select.input {
    appearance: none; -webkit-appearance: none;
    padding-right: 40px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 256 256'%3E%3Cpath fill='%23907F78' d='M213.66 101.66l-80 80a8 8 0 0 1-11.32 0l-80-80a8 8 0 0 1 11.32-11.32L128 164.69l74.34-74.35a8 8 0 0 1 11.32 11.32Z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    cursor: pointer;
}
select.input option { background: var(--panel-bg); color: var(--text-main); }
.input:focus { border-color: var(--accent-primary); box-shadow: 0 0 0 3px var(--accent-soft); }
.input::placeholder { color: var(--text-faint); }
.input:disabled { opacity: .55; cursor: not-allowed; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-faint); font-size: 1.1rem; pointer-events: none; }
.input-icon > .input { padding-left: 42px; }

.section-title {
    font-family: var(--font-display);
    font-size: clamp(1.4rem, 2.6vw, 1.9rem);
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -.3px;
    line-height: 1.2;
}
.eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    font-size: .72rem; font-weight: 800; letter-spacing: 1.6px; text-transform: uppercase;
    color: var(--accent-secondary);
}
.eyebrow::before { content: ''; width: 18px; height: 2px; border-radius: 2px; background: currentColor; }

.empty-state { text-align: center; padding: 56px 20px; color: var(--text-muted); }
.empty-state .es-icon {
    width: 64px; height: 64px; margin: 0 auto 14px;
    border-radius: 20px;
    background: var(--accent-soft); color: var(--accent-primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem;
}
.empty-state h3 { color: var(--text-main); font-size: 1.05rem; margin-bottom: 4px; }
.empty-state p { font-size: .88rem; }

.spinner {
    width: 22px; height: 22px;
    border: 2.5px solid var(--glass-border-strong);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Generic tables inside modules */
.table-wrap { width: 100%; overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--glass-border); background: var(--panel-bg); }
.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.table th {
    text-align: left; padding: 12px 14px;
    font-size: .7rem; font-weight: 800; letter-spacing: .8px; text-transform: uppercase;
    color: var(--text-muted);
    background: var(--bg-main);
    border-bottom: 1px solid var(--glass-border);
    white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--glass-border); color: var(--text-main); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--glass-hover); }

/* ---------- Toasts ---------- */
#toast-container {
    position: fixed; top: 18px; right: 18px;
    z-index: 99999;
    display: flex; flex-direction: column; gap: 10px;
    pointer-events: none;
    max-width: calc(100vw - 36px);
}
.toast {
    display: flex; align-items: center; gap: 12px;
    min-width: 260px; max-width: 420px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--panel-raised);
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-lg);
    font-size: .9rem; font-weight: 600;
    pointer-events: auto;
    animation: toastIn .35s var(--ease) both;
}
.toast i { font-size: 1.35rem; flex-shrink: 0; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.info i { color: var(--info); }
.toast.fade-out { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px) scale(.97); } }

/* ---------- Confirm dialog ---------- */
.tg-dialog-backdrop {
    position: fixed; inset: 0; z-index: 99990;
    background: rgba(18, 8, 6, .55);
    backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    padding: 20px;
    animation: fadeIn .2s both;
}
.tg-dialog {
    width: 100%; max-width: 400px;
    background: var(--panel-raised);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    animation: toastIn .25s var(--ease) both;
}
.tg-dialog h3 { font-size: 1.05rem; margin-bottom: 6px; }
.tg-dialog p { color: var(--text-muted); font-size: .9rem; margin-bottom: 20px; }
.tg-dialog .actions { display: flex; gap: 10px; justify-content: flex-end; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .content-wrapper { padding: 24px 20px; }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-102%);
        box-shadow: var(--shadow-lg);
        width: min(86vw, 300px);
    }
    .sidebar.active { transform: translateX(0); }
    .close-sidebar-btn { display: inline-flex; }
    .main-content { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .top-bar { padding: 0 16px; gap: 10px; }
    .bottom-nav { display: flex; }
    .content-wrapper { padding: 18px 16px calc(var(--bottomnav-h) + 24px + env(safe-area-inset-bottom, 0px)); }
    #toast-container { top: auto; bottom: calc(var(--bottomnav-h) + 16px + env(safe-area-inset-bottom, 0px)); left: 16px; right: 16px; max-width: none; align-items: stretch; }
    .toast { max-width: none; }
}

@media (max-width: 560px) {
    body { font-size: 14.5px; }
    .page-crumb { display: none; }
    .page-title { font-size: 1.02rem; }
    .top-bar-right .hide-sm { display: none; }
    .top-login-btn span { display: none; }
    .top-login-btn { padding: 0 12px; }
    .content-wrapper { padding-left: 12px; padding-right: 12px; }
}

/* Avatars generated from names */
.tg-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 50%;
    color: #fff; font-weight: 800; letter-spacing: .3px;
    flex-shrink: 0; user-select: none;
}

/* Floating action buttons from any module sit above the mobile tab bar */
.fab-btn { z-index: 940 !important; }
@media (max-width: 992px) {
    .fab-btn { bottom: calc(var(--bottomnav-h) + 18px + env(safe-area-inset-bottom, 0px)) !important; right: 18px !important; }
}

/* ==========================================================================
   Announcement cards (shared: home, feed, single post)
   ========================================================================== */
.tg-post {
    background: var(--panel-bg);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    margin-bottom: 18px;
    animation: moduleIn .4s var(--ease) both;
}
.tgp-head { display: flex; align-items: center; gap: 12px; padding: 16px 18px 12px; }
.tgp-logo { width: 44px; height: 44px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px var(--tan-400); flex-shrink: 0; }
.tgp-meta { flex: 1; min-width: 0; }
.tgp-author { font-weight: 800; font-size: .93rem; color: var(--text-main); display: flex; align-items: center; gap: 5px; }
.tgp-verified { color: var(--accent-primary); display: inline-flex; font-size: 1rem; }
.tgp-time { font-size: .74rem; color: var(--text-muted); display: flex; align-items: center; gap: 4px; margin-top: 1px; }
.tgp-icon { width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--text-muted); font-size: 1.2rem; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.tgp-icon:hover { background: var(--glass-hover); color: var(--accent-primary); }
.tgp-body { padding: 0 18px 14px; font-size: .95rem; line-height: 1.7; color: var(--text-main); white-space: pre-line; word-wrap: break-word; overflow-wrap: anywhere; cursor: pointer; }
.tg-post.full .tgp-body { cursor: auto; font-size: 1rem; }
.tgp-body a { color: var(--accent-primary); font-weight: 600; text-decoration: none; }
.tgp-body a:hover { text-decoration: underline; }
.tgp-more { cursor: pointer; }

.tgp-grid { display: grid; gap: 3px; background: var(--glass-border); }
.tgp-grid.g1 { grid-template-columns: 1fr; }
.tgp-grid.g2 { grid-template-columns: 1fr 1fr; }
.tgp-grid.g3 { grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; }
.tgp-grid.g3 .tgp-grid-item:first-child { grid-row: 1 / 3; }
.tgp-grid.g4 { grid-template-columns: 1fr 1fr; }
.tgp-grid-item { position: relative; border: 0; padding: 0; cursor: zoom-in; background: var(--bg-soft); overflow: hidden; aspect-ratio: 1 / 1; display: block; }
.tgp-grid.g1 .tgp-grid-item { aspect-ratio: auto; max-height: 560px; }
.tgp-grid.g1 .tgp-grid-item img { max-height: 560px; height: auto; }
.tgp-grid.g3 .tgp-grid-item:first-child { aspect-ratio: auto; }
.tgp-grid-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .5s var(--ease); }
.tgp-grid-item:hover img { transform: scale(1.03); }
.tgp-grid-more { position: absolute; inset: 0; background: rgba(20, 8, 6, .55); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 1.8rem; font-weight: 800; }

.tgp-video { position: relative; display: block; width: 100%; border: 0; padding: 0; cursor: pointer; background: #000; aspect-ratio: 16 / 9; overflow: hidden; }
.tgp-video img { width: 100%; height: 100%; object-fit: cover; opacity: .88; transition: opacity .3s, transform .5s var(--ease); }
.tgp-video:hover img { opacity: 1; transform: scale(1.02); }
.tgp-play { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 68px; height: 68px; border-radius: 50%; background: rgba(255, 0, 0, .92); color: #fff; font-size: 1.9rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 10px 30px rgba(0,0,0,.4); transition: transform .2s; }
.tgp-video:hover .tgp-play { transform: translate(-50%, -50%) scale(1.08); }
.tgp-yt-badge { position: absolute; left: 12px; bottom: 12px; background: rgba(0,0,0,.72); color: #fff; font-size: .72rem; font-weight: 700; padding: 4px 10px; border-radius: 8px; display: inline-flex; gap: 5px; align-items: center; }

.tgp-stats { display: flex; justify-content: space-between; align-items: center; padding: 12px 18px 10px; font-size: .8rem; color: var(--text-muted); }
.tgp-stats i { color: #E0245E; }
.tgp-stats a { cursor: pointer; color: var(--text-muted); text-decoration: none; }
.tgp-stats a:hover { text-decoration: underline; color: var(--text-main); }
.tgp-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px 10px 10px; border-top: 1px solid var(--glass-border); margin: 0 8px; }
.tgp-btn { display: flex; align-items: center; justify-content: center; gap: 7px; height: 42px; margin-top: 6px; border: 0; border-radius: 10px; background: transparent; color: var(--text-muted); font-weight: 700; font-size: .86rem; cursor: pointer; transition: background .2s, color .2s; }
.tgp-btn i { font-size: 1.25rem; }
.tgp-btn:hover { background: var(--glass-hover); color: var(--text-main); }
.tgp-btn.liked { color: #E0245E; }
.tgp-btn.pop i { animation: likePop .45s var(--ease); }
@keyframes likePop { 0% { transform: scale(1); } 40% { transform: scale(1.45); } 100% { transform: scale(1); } }

@media (max-width: 560px) {
    .tg-post { border-radius: 16px; margin-bottom: 14px; }
    .tgp-head { padding: 14px 14px 10px; }
    .tgp-body { padding: 0 14px 12px; font-size: .92rem; }
    .tgp-stats { padding: 10px 14px 8px; }
    .tgp-btn span { font-size: .8rem; }
}

/* ---------- Bottom sheet (share) ---------- */
.sheet-backdrop {
    position: fixed; inset: 0; z-index: 99000;
    background: rgba(18, 8, 6, .5);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    opacity: 0; visibility: hidden; transition: .25s var(--ease);
    display: flex; align-items: flex-end; justify-content: center;
}
.sheet-backdrop.open { opacity: 1; visibility: visible; }
.sheet {
    width: 100%; max-width: 520px;
    background: var(--panel-raised);
    border-radius: 24px 24px 0 0;
    padding: 10px 20px calc(22px + env(safe-area-inset-bottom, 0px));
    box-shadow: var(--shadow-lg);
    transform: translateY(100%); transition: transform .35s var(--ease);
}
.sheet-backdrop.open .sheet { transform: none; }
@media (min-width: 640px) {
    .sheet-backdrop { align-items: center; }
    .sheet { border-radius: 24px; transform: translateY(30px) scale(.97); }
}
.sheet-grip { width: 42px; height: 5px; border-radius: 5px; background: var(--glass-border-strong); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h3 { font-size: 1.05rem; }
.share-preview { display: flex; gap: 12px; align-items: center; padding: 10px; border: 1px solid var(--glass-border); border-radius: 14px; background: var(--bg-main); margin-bottom: 18px; }
.share-preview img { width: 84px; height: 44px; object-fit: cover; border-radius: 8px; flex-shrink: 0; background: var(--bg-soft); }
.share-preview small { display: block; font-size: .68rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }
.share-preview b { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: .86rem; line-height: 1.3; }
.share-targets { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-bottom: 18px; }
.share-targets button { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 7px; font-size: .72rem; font-weight: 700; color: var(--text-main); cursor: pointer; padding: 6px 0; border-radius: 12px; }
.share-targets button:hover { background: var(--glass-hover); }
.share-targets span { width: 50px; height: 50px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: 1.5rem; }
@media (max-width: 440px) { .share-targets { grid-template-columns: repeat(3, 1fr); row-gap: 12px; } }
.share-link { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--glass-border-strong); border-radius: 12px; }
.share-link i { color: var(--text-muted); }
.share-link input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font-size: .82rem; color: var(--text-muted); }

/* ---------- Lightbox / video ---------- */
.tg-lightbox {
    position: fixed; inset: 0; z-index: 99500;
    background: rgba(8, 4, 3, .94);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; visibility: hidden; transition: .25s;
    padding: 56px 12px;
}
.tg-lightbox.open { opacity: 1; visibility: visible; }
.tg-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; user-select: none; }
.tg-lb-btn { position: absolute; width: 46px; height: 46px; border-radius: 50%; border: 0; background: rgba(255,255,255,.12); color: #fff; font-size: 1.35rem; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: background .2s; }
.tg-lb-btn:hover { background: rgba(255,255,255,.25); }
.tg-lb-close { top: 14px; right: 14px; }
.tg-lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.tg-lb-next { right: 14px; top: 50%; transform: translateY(-50%); }
.tg-lightbox.single .tg-lb-prev, .tg-lightbox.single .tg-lb-next { display: none; }
.tg-lb-count { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); color: #fff; font-size: .8rem; font-weight: 700; background: rgba(255,255,255,.12); padding: 5px 14px; border-radius: 20px; }
.tg-lb-count:empty { display: none; }
.yt-frame { width: min(100%, 960px); aspect-ratio: 16 / 9; background: #000; border-radius: 12px; overflow: hidden; }
.yt-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 600px) { .tg-lb-prev, .tg-lb-next { width: 40px; height: 40px; } .tg-lb-prev { left: 6px; } .tg-lb-next { right: 6px; } }

[hidden] { display: none !important; }

/* Older admin pages: their sticky toolbar sits just below the app top bar */
.admin-header-area {
    top: calc(var(--topbar-h) - 1px) !important;
    margin: 0 0 16px 0 !important;
    border-radius: 16px !important;
    z-index: 800 !important;
}
@media (max-width: 560px) {
    .admin-header-area { margin: -6px -4px 14px -4px !important; border-radius: 14px !important; padding: 12px !important; }
}
