:root {
    --ink: #14213d;
    --muted: #64748b;
    --surface: #ffffff;
    --surface-soft: #f5f7fb;
    --line: #d9e2ec;
    --primary: #0f766e;
    --primary-dark: #115e59;
    --accent: #f59e0b;
    --accent-soft: #fff7ed;
    --danger: #dc2626;
    --shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--ink);
    background:
        linear-gradient(rgba(245, 247, 251, 0.96), rgba(245, 247, 251, 0.96)),
        url("../../back/bg1.jpg");
    background-size: 260px auto;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

a {
    color: var(--primary);
}

a:hover {
    color: var(--primary-dark);
}

.app-container {
    max-width: 1480px;
}

.app-navbar {
    border-bottom: 1px solid rgba(217, 226, 236, 0.85);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(16px);
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--ink);
}

.navbar-brand small {
    display: block;
    color: var(--muted);
    font-size: 0.75rem;
    line-height: 1;
}

.brand-mark {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border-radius: 8px;
    color: #ffffff;
    background: var(--primary);
    font-weight: 800;
}

.icon-button {
    display: inline-grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--ink);
    background: var(--surface);
    transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-button:hover,
.icon-button:focus {
    border-color: rgba(15, 118, 110, 0.38);
    background: #eefaf8;
    transform: translateY(-1px);
}

.icon-button svg,
.btn svg,
.learning-link svg,
.aside-heading svg {
    width: 19px;
    height: 19px;
    stroke-width: 2;
}

.btn {
    border-radius: 8px;
    font-weight: 700;
}

.btn-primary {
    border-color: var(--primary);
    background: var(--primary);
}

.btn-primary:hover,
.btn-primary:focus {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
}

.btn-outline-primary {
    border-color: rgba(15, 118, 110, 0.55);
    color: var(--primary);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
    border-color: var(--primary);
    background: var(--primary);
}

.btn-ghost {
    border: 1px solid rgba(20, 33, 61, 0.16);
    color: var(--ink);
    background: rgba(255, 255, 255, 0.72);
}

.btn-user {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    border: 1px solid var(--line);
    color: var(--ink);
    background: var(--surface);
}

.hero-section {
    padding: 3rem 0 2rem;
    background: #e7f4f1;
    border-bottom: 1px solid rgba(15, 118, 110, 0.13);
}

.hero-copy {
    max-width: 760px;
}

.eyebrow,
.section-kicker {
    display: inline-flex;
    margin-bottom: 0.75rem;
    color: var(--primary-dark);
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.hero-copy h1 {
    max-width: 760px;
    margin: 0;
    color: var(--ink);
    font-size: 4.4rem;
    line-height: 0.98;
    letter-spacing: 0;
}

.hero-copy p {
    max-width: 640px;
    margin: 1.1rem 0 0;
    color: #334155;
    font-size: 1.08rem;
    line-height: 1.7;
}

.hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.hero-media {
    overflow: hidden;
    max-width: 520px;
    margin-left: auto;
    border: 1px solid rgba(15, 118, 110, 0.16);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow);
}

.hero-media img {
    display: block;
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
}

.learning-layout {
    display: grid;
    grid-template-columns: 284px minmax(0, 1fr) 260px;
    gap: 1.2rem;
    padding-top: 1.35rem;
    padding-bottom: 2rem;
}

.learning-sidebar,
.learning-aside {
    min-width: 0;
}

.sidebar-inner,
.aside-panel,
.content-shell {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 12px 36px rgba(15, 23, 42, 0.06);
}

.sidebar-inner {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 108px);
    padding: 1rem;
    overflow: auto;
}

.form-label {
    color: #334155;
    font-weight: 700;
}

.search-box {
    position: relative;
}

.search-box svg {
    position: absolute;
    top: 50%;
    left: 0.85rem;
    width: 18px;
    height: 18px;
    color: var(--muted);
    transform: translateY(-50%);
}

.search-box .form-control {
    min-height: 44px;
    padding-left: 2.55rem;
    border-color: var(--line);
    border-radius: 8px;
}

.nav-section {
    margin-top: 1.25rem;
}

.nav-section-title {
    margin: 0 0 0.45rem;
    color: var(--muted);
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
}

.learning-link {
    display: flex;
    align-items: center;
    min-height: 42px;
    gap: 0.65rem;
    margin-bottom: 0.25rem;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    color: #334155;
    font-weight: 700;
    text-decoration: none;
}

.learning-link:hover {
    background: #eefaf8;
    color: var(--primary-dark);
}

.learning-link.active {
    color: #ffffff;
    background: var(--primary);
}

.learning-link[hidden] {
    display: none;
}

.content-shell {
    min-width: 0;
    padding: 1.1rem;
}

.db-alert {
    border-radius: 8px;
}

.content-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--line);
}

.content-toolbar h2 {
    margin: 0;
    font-size: 2.1rem;
    line-height: 1.14;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

#pageJump {
    width: min(330px, 42vw);
    min-height: 42px;
    border-radius: 8px;
    font-weight: 700;
}

.content-status {
    min-height: 1.5rem;
    margin: 0.8rem 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.content-status.is-loading {
    color: var(--primary-dark);
}

.legacy-content {
    overflow-x: auto;
    color: #1e293b;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 1.05rem;
    line-height: 1.72;
}

.legacy-content > *:first-child {
    margin-top: 0;
}

.legacy-content p {
    margin-bottom: 1rem;
}

.legacy-content strong {
    color: var(--ink);
}

.legacy-content table {
    width: 100%;
    max-width: 100%;
    margin: 0.75rem 0 1.1rem;
    border-collapse: collapse;
}

.legacy-content td,
.legacy-content th {
    padding: 0.42rem 0.5rem;
    vertical-align: top;
}

.legacy-content img {
    max-width: 100%;
    height: auto;
}

.legacy-content img[src*="bullet"] {
    width: 20px;
    height: auto;
    margin-right: 0.35rem;
    vertical-align: -0.2rem;
}

.legacy-content a {
    font-weight: 700;
    text-decoration-thickness: 0.08em;
    text-underline-offset: 0.18em;
}

.legacy-content span {
    color: inherit;
}

.aside-panel {
    padding: 1rem;
}

.aside-panel + .aside-panel {
    margin-top: 1rem;
}

.aside-heading {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    margin-bottom: 0.75rem;
    font-weight: 800;
}

.aside-panel a {
    display: block;
    padding: 0.65rem 0;
    border-top: 1px solid var(--line);
    color: #334155;
    font-weight: 700;
    text-decoration: none;
}

.aside-panel a:hover {
    color: var(--primary-dark);
}

.status-panel p {
    margin: 0;
    font-weight: 800;
}

.mobile-stats {
    margin-bottom: 1rem;
}

.visit-stats {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.94);
}

.visit-stats.aside-panel {
    background: rgba(255, 255, 255, 0.94);
}

.visit-stats-compact {
    padding: 1rem;
}

.visit-stats-detail {
    padding: 1rem;
}

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

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

.stat-card {
    min-height: 84px;
    padding: 0.8rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.stat-card span {
    display: block;
    min-height: 2.3rem;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
    line-height: 1.25;
}

.stat-card strong {
    display: block;
    margin-top: 0.35rem;
    color: var(--ink);
    font-size: 1.65rem;
    line-height: 1;
}

.popular-pages {
    display: grid;
    gap: 0.55rem;
    margin-top: 0.85rem;
}

.popular-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.75rem;
    align-items: center;
    padding: 0.75rem 0;
    border-top: 1px solid var(--line);
}

.popular-page-title {
    min-width: 0;
}

.popular-page strong {
    display: block;
    overflow: hidden;
    color: #334155;
    font-size: 0.95rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.popular-page span,
.stats-status,
.daily-label,
.daily-count {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
}

.popular-page-count {
    min-width: 54px;
    padding: 0.35rem 0.5rem;
    border-radius: 8px;
    color: var(--primary-dark);
    background: #eefaf8;
    font-size: 0.9rem;
    font-weight: 900;
    text-align: center;
}

.daily-visits {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.55rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.daily-item {
    display: grid;
    gap: 0.45rem;
    min-width: 0;
}

.daily-bar-track {
    display: flex;
    align-items: flex-end;
    height: 88px;
    border-radius: 8px;
    background: var(--surface-soft);
    overflow: hidden;
}

.daily-bar {
    width: 100%;
    min-height: 4px;
    background: var(--accent);
}

.daily-label,
.daily-count {
    display: block;
    overflow: hidden;
    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stats-status {
    margin-top: 0.75rem;
}

.stats-status.is-error {
    color: var(--danger);
}

.modal-content {
    border: 0;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.form-alert .alert {
    margin-bottom: 1rem;
    border-radius: 8px;
}

.activity-list {
    display: grid;
    gap: 0.75rem;
}

.activity-item {
    padding: 0.9rem 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-soft);
}

.activity-item strong {
    display: block;
    margin-bottom: 0.2rem;
}

.activity-item span {
    color: var(--muted);
    font-size: 0.92rem;
}

.empty-state {
    padding: 1rem;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    background: var(--surface-soft);
}

@media (max-width: 1199.98px) {
    .learning-layout {
        grid-template-columns: 260px minmax(0, 1fr);
    }
}

@media (max-width: 991.98px) {
    .hero-section {
        padding-top: 2rem;
    }

    .hero-media {
        margin: 0;
    }

    .hero-copy h1 {
        font-size: 3.1rem;
    }

    .content-toolbar h2 {
        font-size: 1.75rem;
    }

    .learning-layout {
        display: block;
        padding-top: 1rem;
    }

    .content-shell {
        padding: 0.85rem;
    }
}

@media (max-width: 767.98px) {
    .content-toolbar {
        display: block;
    }

    .toolbar-actions {
        margin-top: 0.8rem;
    }

    #pageJump {
        flex: 1;
        width: 100%;
        min-width: 0;
    }

    .legacy-content {
        font-size: 1rem;
    }

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

    .daily-visits {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .navbar-brand strong {
        font-size: 0.95rem;
    }

    .navbar-brand small {
        display: none;
    }

    .hero-copy h1 {
        font-size: 2.25rem;
    }

    .hero-actions .btn {
        width: 100%;
    }

    .visit-stats-detail .stats-grid,
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-card {
        min-height: 72px;
    }

    .stat-card span {
        min-height: 0;
    }

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