:root {
    --bg: #07101f;
    --panel: #0d1a2e;
    --panel-soft: #101f36;
    --line: rgba(151, 176, 219, .14);
    --text: #edf3ff;
    --muted: #8f9eb8;
    --blue: #7b94ff;
    --green: #45d6a6;
    --amber: #f5be63;
    --red: #ff8293;
}

* { box-sizing: border-box; }
html { color-scheme: dark; }
body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans Thai", sans-serif;
    background:
        radial-gradient(circle at 8% 0%, rgba(89, 112, 255, .16), transparent 30rem),
        radial-gradient(circle at 94% 30%, rgba(43, 205, 187, .10), transparent 30rem),
        var(--bg);
}

.backup-nav {
    z-index: 30;
    border-bottom: 1px solid var(--line);
    background: rgba(7, 16, 31, .84);
    backdrop-filter: blur(18px);
}
.navbar-brand { color: var(--text); }
.navbar-brand:hover { color: white; }
.navbar-brand > span:last-child { display: grid; }
.navbar-brand strong { font-size: .98rem; }
.navbar-brand small { color: var(--muted); font-size: .64rem; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark {
    display: grid;
    width: 2.5rem;
    height: 2.5rem;
    place-items: center;
    border-radius: .8rem;
    color: white;
    font-size: .75rem;
    font-weight: 800;
    background: linear-gradient(145deg, #7895ff, #4a63dc);
    box-shadow: 0 10px 30px rgba(78, 102, 231, .28);
}

.status-chip { display: inline-flex; align-items: center; padding: .42rem .7rem; border-radius: 999px; font-size: .68rem; font-weight: 700; }
.status-running { color: #a9b8ff; background: rgba(123,148,255,.12); border: 1px solid rgba(123,148,255,.22); }
.status-success { color: #72e6bd; background: rgba(69,214,166,.1); border: 1px solid rgba(69,214,166,.2); }
.status-partial { color: #f5c878; background: rgba(245,190,99,.1); border: 1px solid rgba(245,190,99,.2); }
.status-failed { color: #ff9cab; background: rgba(255,130,147,.1); border: 1px solid rgba(255,130,147,.2); }
.status-unknown { color: #aab6cc; background: rgba(170,182,204,.08); border: 1px solid rgba(170,182,204,.15); }

.page-hero {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(17rem, 24rem);
    gap: 2rem;
    align-items: center;
    padding: clamp(1.5rem, 4vw, 3rem);
    border: 1px solid var(--line);
    border-radius: 1.4rem;
    background: linear-gradient(135deg, rgba(20, 36, 66, .96), rgba(9, 22, 41, .92));
    box-shadow: 0 28px 80px rgba(0,0,0,.2);
}
.eyebrow { color: #91a7ff; font-size: .64rem; font-weight: 800; letter-spacing: .16em; }
.page-hero h1 { margin: .45rem 0 .7rem; font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -.05em; }
.page-hero p { max-width: 48rem; margin: 0; color: #a7b5cc; line-height: 1.8; }
.progress-card { padding: 1.2rem; border: 1px solid var(--line); border-radius: 1rem; background: rgba(2, 12, 27, .38); }
.progress-card span { color: var(--muted); font-size: .72rem; }
.progress-card strong { font-size: 1.5rem; }
.progress-card .progress { height: .5rem; margin: .8rem 0; background: rgba(137,159,201,.12); }
.progress-card .progress-bar { background: linear-gradient(90deg, #6f8dff, #43d5a8); }
.progress-card small { color: var(--muted); }
.progress-card small b { color: #d8e2f5; }

.metric, .panel-card {
    border: 1px solid var(--line);
    background: rgba(13, 26, 46, .9);
    box-shadow: 0 18px 45px rgba(0,0,0,.12);
}
.metric { display: grid; height: 100%; min-height: 8.4rem; align-content: center; padding: 1.2rem; border-radius: 1rem; }
.metric span { color: var(--muted); font-size: .7rem; }
.metric strong { margin: .2rem 0; font-size: clamp(1.45rem, 2.8vw, 2.05rem); letter-spacing: -.04em; }
.metric small { color: #6f809d; font-size: .66rem; }

.panel-card { overflow: hidden; border-radius: 1.25rem; }
.table-toolbar { display: flex; justify-content: space-between; align-items: end; gap: 1.5rem; padding: 1.5rem; border-bottom: 1px solid var(--line); }
.table-toolbar h2 { margin: .35rem 0 .25rem; font-size: 1.2rem; }
.table-toolbar p { margin: 0; color: var(--muted); font-size: .75rem; }
.search-form { display: flex; min-width: min(100%, 31rem); gap: .5rem; }
.search-form .form-control { border-color: var(--line); color: var(--text); background: rgba(3,12,26,.55); }
.search-form .form-control:focus { border-color: rgba(123,148,255,.55); box-shadow: 0 0 0 .2rem rgba(123,148,255,.1); }

.article-table { --bs-table-bg: transparent; --bs-table-color: #d7e0f0; min-width: 62rem; font-size: .78rem; }
.article-table thead th { padding: .8rem 1rem; color: #7183a1; border-bottom-color: var(--line); font-size: .63rem; letter-spacing: .08em; text-transform: uppercase; }
.article-table td { padding: .8rem 1rem; border-bottom-color: rgba(151,176,219,.08); }
.article-table tbody tr:hover { background: rgba(123,148,255,.035); }
.thumbnail-cell { width: 5.5rem; }
.thumbnail-cell img { width: 4.5rem; height: 3.2rem; border-radius: .55rem; object-fit: cover; background: #15243b; }
.article-id { color: #8da4ff; font-size: .65rem; font-weight: 700; }
.article-title { display: -webkit-box; max-width: 37rem; margin: .18rem 0; overflow: hidden; font-size: .82rem; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.article-table td small { display: block; max-width: 31rem; overflow: hidden; color: #72839f; font-size: .64rem; text-overflow: ellipsis; white-space: nowrap; }
.category-label { display: inline-flex; max-width: 12rem; padding: .3rem .55rem; overflow: hidden; border: 1px solid rgba(123,148,255,.16); border-radius: 999px; color: #aabbf8; background: rgba(123,148,255,.07); font-size: .65rem; text-overflow: ellipsis; white-space: nowrap; }
.image-count { display: inline-flex; min-width: 3.5rem; justify-content: center; padding: .3rem .55rem; border-radius: .55rem; color: #f2c878; background: rgba(245,190,99,.09); font-weight: 700; }
.image-count.complete { color: #68deb7; background: rgba(69,214,166,.09); }
.btn-view { color: #dbe4ff; border: 1px solid rgba(123,148,255,.25); background: rgba(123,148,255,.09); font-size: .7rem; }
.btn-view:hover { color: white; border-color: rgba(123,148,255,.45); background: rgba(123,148,255,.18); }
.empty-state { padding: 4rem !important; color: var(--muted) !important; text-align: center; }
.table-footer { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1rem 1.5rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .72rem; }
.pagination { --bs-pagination-bg: rgba(3,12,26,.5); --bs-pagination-border-color: var(--line); --bs-pagination-color: #aab8d0; --bs-pagination-hover-bg: rgba(123,148,255,.1); --bs-pagination-hover-color: white; --bs-pagination-active-bg: #6f86e9; --bs-pagination-active-border-color: #6f86e9; }
.site-footer { display: flex; justify-content: space-between; gap: 1rem; padding: 1.4rem .25rem; color: #657590; font-size: .66rem; }

.article-shell { width: min(100% - 2rem, 68rem); margin: 0 auto; padding: clamp(1.5rem, 4vw, 3.5rem) 0; }
.article-reader { overflow: hidden; border: 1px solid var(--line); border-radius: 1.35rem; background: rgba(13,26,46,.94); box-shadow: 0 28px 80px rgba(0,0,0,.22); }
.article-header { padding: clamp(1.4rem, 5vw, 3.5rem); background: linear-gradient(150deg, rgba(23,41,73,.96), rgba(10,23,42,.94)); }
.article-header h1 { max-width: 58rem; margin: 0; font-size: clamp(1.8rem, 4.5vw, 3rem); line-height: 1.3; letter-spacing: -.04em; }
.article-meta { display: flex; flex-wrap: wrap; gap: .7rem 1.4rem; margin-top: 1.2rem; color: var(--muted); font-size: .72rem; }
.article-cover { display: block; width: 100%; max-height: 36rem; margin-top: 2rem; border-radius: 1rem; object-fit: contain; background: #07101f; }
.backup-notice { margin: 1.25rem clamp(1.2rem, 5vw, 4rem) 0; padding: .85rem 1rem; border: 1px solid rgba(245,190,99,.2); border-radius: .8rem; color: #f3cb82; background: rgba(245,190,99,.08); font-size: .76rem; }
.article-content { padding: clamp(1.4rem, 5vw, 4rem); color: #dce5f3; font-size: clamp(1rem, 1.8vw, 1.08rem); line-height: 1.9; }
.article-content p, .article-content div { overflow-wrap: anywhere; }
.article-content img { display: block; width: auto; max-width: 100%; max-height: 52rem; margin: 1.7rem auto; border-radius: .8rem; object-fit: contain; background: #091427; }
.article-content a { color: #9fb3ff; }
.article-content table { display: block; max-width: 100%; overflow-x: auto; }
.article-end { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 1.25rem clamp(1.4rem, 5vw, 4rem); border-top: 1px solid var(--line); color: var(--muted); font-size: .68rem; }

.login-page { display: grid; min-height: 100vh; place-items: center; }
.ambient { position: fixed; width: 26rem; height: 26rem; border-radius: 50%; filter: blur(90px); opacity: .12; pointer-events: none; }
.ambient-one { top: -12rem; left: -12rem; background: #526bff; }
.ambient-two { right: -12rem; bottom: -12rem; background: #23c9bd; }
.login-shell { width: 100%; padding: 1.25rem; }
.login-card { width: min(100%, 28rem); margin: 0 auto; padding: clamp(1.6rem, 5vw, 2.5rem); border: 1px solid var(--line); border-radius: 1.35rem; background: linear-gradient(145deg, rgba(19,33,60,.98), rgba(9,21,39,.96)); box-shadow: 0 32px 90px rgba(0,0,0,.34); }
.login-brand { margin-bottom: 1.5rem; }
.login-card h1 { margin: .4rem 0 0; font-size: 2rem; letter-spacing: -.04em; }
.login-card > p { margin: .8rem 0 1.5rem; color: #9dabc3; line-height: 1.7; font-size: .86rem; }
.login-form { display: grid; gap: 1rem; }
.login-form .form-label { color: #bdc8dc; font-size: .74rem; }
.login-form .form-control { min-height: 3rem; border-color: var(--line); color: var(--text); background: rgba(4,13,27,.5); }
.login-button { min-height: 3rem; border: 0; color: #07131f; font-weight: 750; background: linear-gradient(135deg, #59e0b3, #55c9dc); }
.login-button:hover { color: #07131f; background: linear-gradient(135deg, #6ae8bd, #65d4e3); }
.login-alert { margin-bottom: 1rem; padding: .8rem; border: 1px solid rgba(255,130,147,.2); border-radius: .7rem; color: #ffabb6; background: rgba(255,130,147,.08); font-size: .75rem; }
.login-security { margin-top: 1.25rem; color: #6f809b; font-size: .64rem; }
.status-dot { display: inline-block; width: .45rem; height: .45rem; margin-right: .35rem; border-radius: 50%; background: var(--green); }

@media (max-width: 991.98px) {
    .page-hero { grid-template-columns: 1fr; }
    .table-toolbar { align-items: stretch; flex-direction: column; }
    .search-form { min-width: 0; }
}

@media (max-width: 575.98px) {
    .status-chip { display: none; }
    .page-hero, .panel-card, .article-reader { border-radius: 1rem; }
    .metric { min-height: 7.5rem; padding: .9rem; }
    .search-form { display: grid; grid-template-columns: 1fr auto; }
    .search-form .form-control { grid-column: 1 / -1; }
    .table-footer, .site-footer, .article-end { align-items: stretch; flex-direction: column; }
    .pagination { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}
