:root {
    --card-bg: #1f1f1f;
    --card-border: #313131;
    --muted: #b8b8b8;
    --accent: #3d8bfd;
    --danger: #c0392b;
    --success: #2e7d32;
}

html,
body {
    height: 100%;
    margin: 0;
}

body {
    background: #121212;
    color: #f2f2f2;
    min-height: 100vh;
    overflow-x: hidden;
    padding-bottom: 70px;
}

main {
    flex: initial;
}

.container {
    max-width: 1180px;
    margin: 20px auto;
    padding: 20px;
}

.topnav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    padding: 14px 20px;
    background: #0f0f0f;
    border-bottom: 1px solid #292929;
    position: sticky;
    top: 0;
    z-index: 3000;
    overflow: visible;
}

.topnav ul {
    display: flex;
    gap: 10px;
    align-items: center;
    list-style: none;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
    overflow: visible;
}

.topnav li {
    position: relative;
    overflow: visible;
}

.nav-link,
.button-primary,
.button-secondary,
.button-danger,
.button-small {
    border-radius: 10px;
}

.nav-link {
    display: inline-flex;
    align-items: center;
    min-height: 42px;
    padding: 10px 14px;
    text-decoration: none;
    color: #fff;
    background: transparent;
    border: none;
    cursor: pointer;
    font: inherit;
}

.nav-link:hover,
.nav-link:focus {
    background: #1e1e1e;
    outline: none;
}

/* Hover dropdowns */
.dropdown {
    position: relative;
}

.nav-drop-toggle::after {
    content: " ▾";
    font-size: 0.9em;
}

.dropdown::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    height: 12px;
}

.dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    min-width: 260px;
    background: #161616;
    border: 1px solid #303030;
    border-radius: 14px;
    padding: 6px;
    z-index: 5000;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
}

.dropdown:hover .dropdown-content,
.dropdown:focus-within .dropdown-content {
    display: block;
}

.dropdown-content a,
.dropdown-logout {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    background: transparent;
    border: none;
    border-radius: 10px;
    color: #ffffff;
    text-decoration: none;
    text-align: left;
    line-height: 1.35;
    font-size: 0.98rem;
    cursor: pointer;
    box-sizing: border-box;
    white-space: normal;
    word-break: break-word;
}

.dropdown-content a:hover,
.dropdown-content a:focus,
.dropdown-logout:hover,
.dropdown-logout:focus {
    background: #2a2a2a;
    outline: none;
}

.hero-card,
.content-card,
.stats-grid .stat-card,
.notice {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 16px;
}

.hero-card,
.content-card {
    padding: 22px;
    margin-bottom: 20px;
}

.hero-card h1 {
    margin-top: 0;
}

.home-grid {
    display: grid;
    grid-template-columns: 2fr 1.2fr;
    gap: 20px;
}

.card-head,
.table-actions,
.form-row {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.list-stack {
    display: grid;
    gap: 14px;
}

.list-item {
    padding: 16px;
    border: 1px solid #343434;
    border-radius: 12px;
    background: #171717;
}

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 16px;
}

.gallery-item {
    display: block;
    text-decoration: none;
    color: inherit;
    background: #171717;
    border: 1px solid #303030;
    border-radius: 14px;
    overflow: hidden;
}

.gallery-thumb {
    aspect-ratio: 4 / 3;
    background: #090909;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.gallery-meta {
    padding: 12px;
}

.gallery-title {
    font-weight: 700;
}

.gallery-caption {
    color: var(--muted);
    font-size: 0.95rem;
}

.admin-form label {
    display: block;
    margin-bottom: 14px;
    font-weight: 600;
}

.admin-form input[type="text"],
.admin-form input[type="email"],
.admin-form input[type="date"],
.admin-form input[type="time"],
.admin-form input[type="number"],
.admin-form input[type="password"],
.admin-form select,
.admin-form textarea,
.login-form input {
    width: 100%;
    padding: 12px 14px;
    background: #111;
    border: 1px solid #3a3a3a;
    border-radius: 10px;
    color: #fff;
    box-sizing: border-box;
    margin-top: 6px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.module-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0;
}

.module-grid label {
    background: #171717;
    border: 1px solid #303030;
    border-radius: 12px;
    padding: 12px;
}

.button-primary,
.button-secondary,
.button-danger,
.button-small {
    display: inline-block;
    padding: 10px 14px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    color: #fff;
}

.button-primary {
    background: var(--accent);
}

.button-secondary {
    background: #4a4a4a;
}

.button-danger {
    background: var(--danger);
}

.button-small {
    background: #2f2f2f;
    padding: 8px 12px;
}

.notice {
    padding: 14px 16px;
    margin-bottom: 16px;
}

.notice.success {
    border-color: #2b5f32;
}

.notice.error {
    border-color: #6e2a2a;
}

.notice.info {
    border-color: #375b86;
}

.table-wrap {
    overflow: auto;
}

.site-table {
    width: 100%;
    border-collapse: collapse;
}

.site-table th,
.site-table td {
    padding: 12px;
    border-bottom: 1px solid #343434;
    text-align: left;
    vertical-align: top;
}

.site-table th {
    background: #181818;
}

.muted {
    color: var(--muted);
}

.site-footer {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    z-index: 2500;
    margin-top: 0;
    background: #0f0f0f;
    border-top: 1px solid #292929;
}

.footer-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px 20px;
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 12px;
    align-items: center;
}

.wysiwyg-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.wysiwyg-toolbar button {
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid #3b3b3b;
    background: #1a1a1a;
    color: #fff;
    cursor: pointer;
}

.wysiwyg-editor {
    min-height: 200px;
    padding: 14px;
    background: #111;
    border: 1px solid #3a3a3a;
    border-radius: 10px;
}

.wysiwyg-content p:first-child {
    margin-top: 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    padding: 18px;
}

.stat-card .label {
    color: var(--muted);
    font-size: 0.95rem;
}

.stat-card .value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 8px;
}

.section-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 20px;
}

.tag {
    display: inline-block;
    padding: 4px 8px;
    border: 1px solid #3a3a3a;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.85rem;
}

/* Login / auth */
.page-wrap {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
    box-sizing: border-box;
}

.auth-card {
    max-width: 460px;
    margin: 40px auto;
    background: #171717;
    border: 1px solid #303030;
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.auth-card h1 {
    margin-top: 0;
    margin-bottom: 10px;
}

.auth-subtitle {
    margin: 0 0 20px;
    color: #999;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-form label {
    font-weight: 600;
}

.login-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.btn-primary,
.btn-secondary {
    display: inline-block;
    padding: 12px 18px;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
}

.btn-primary {
    border: none;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
}

.btn-secondary {
    background: #444;
    color: #fff;
}

.login-error {
    background: #3a1414;
    color: #ffd5d5;
    border: 1px solid #6e2a2a;
    padding: 12px 14px;
    border-radius: 10px;
    margin-bottom: 18px;
}

@media (max-width: 900px) {
    .home-grid,
    .section-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body {
        padding-bottom: 90px;
    }
}

@media (max-width: 760px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .module-grid {
        grid-template-columns: 1fr 1fr;
    }

    .footer-inner {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .dropdown-content {
        right: 0;
        left: auto;
        min-width: 240px;
        max-width: min(320px, calc(100vw - 24px));
    }
}

@media (max-width: 560px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .module-grid {
        grid-template-columns: 1fr;
    }

    .auth-card {
        padding: 24px;
    }

    body {
        padding-bottom: 110px;
    }

    .dropdown-content {
        min-width: 220px;
        max-width: calc(100vw - 20px);
    }
}

.announcement-popup-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9999;
}

.announcement-popup-card {
    position: relative;
    width: 100%;
    max-width: 700px;
    background: #1b1b1f;
    color: #fff;
    border-radius: 16px;
    padding: 28px 24px 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.announcement-popup-card h2 {
    margin-top: 0;
    margin-bottom: 16px;
}

.announcement-popup-close {
    position: absolute;
    top: 12px;
    right: 14px;
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 30px;
    line-height: 1;
    cursor: pointer;
}

.announcement-popup-close:hover {
    opacity: 0.8;
}

.admin-form input[type="date"],
.admin-form input[type="time"] {
    width: 100%;
    box-sizing: border-box;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.14);
    background: rgba(255,255,255,0.04);
    color: #fff;
}

.admin-form input[type="date"]::-webkit-calendar-picker-indicator,
.admin-form input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}
.pw-ok {
    color: #6dd38a;
    font-weight: 600;
}

.pw-bad {
    color: #ff8a8a;
    font-weight: 600;
}

.pw-status {
    margin: 8px 0 12px;
    font-weight: 700;
}