:root {
    --ink: #182230;
    --muted: #667085;
    --subtle: #98a2b3;
    --line: #d7e0ea;
    --paper: #ffffff;
    --soft: #f5f7fb;
    --primary: #0f8aa5;
    --primary-dark: #0b6278;
    --blue: #2563eb;
    --green: #198754;
    --red: #d92d20;
    --amber: #b7791f;
    --coral: #e05f45;
    --violet: #6d5bd0;
    --shadow: 0 18px 45px rgba(24, 34, 48, .10);
    --shadow-soft: 0 8px 24px rgba(24, 34, 48, .07);
}

* { box-sizing: border-box; }

html {
    min-height: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100%;
    color: var(--ink);
    background:
        linear-gradient(180deg, #eef8fb 0, #f8fafc 340px, #f5f7fb 100%);
    font-family: "Noto Sans Thai", Tahoma, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.68;
    letter-spacing: 0;
}

a { color: inherit; text-decoration: none; }
img {
    display: block;
    max-width: 100%;
    border-radius: 8px;
}
input, select, textarea, button { font: inherit; }
button { letter-spacing: 0; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 14px clamp(18px, 4vw, 54px);
    background: rgba(255, 255, 255, .9);
    border-bottom: 1px solid rgba(215, 224, 234, .9);
    box-shadow: 0 8px 28px rgba(24, 34, 48, .05);
    backdrop-filter: blur(14px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    min-width: max-content;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--blue) 58%, var(--coral));
    color: white;
    font-weight: 800;
    box-shadow: 0 12px 24px rgba(15, 138, 165, .24);
}

.brand strong {
    display: block;
    font-size: 17px;
    line-height: 1.25;
}

.brand small {
    display: block;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.main-nav, .admin-nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.main-nav a, .admin-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 8px 12px;
    border-radius: 8px;
    color: #344054;
    font-weight: 600;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}

.main-nav a:hover, .admin-nav a:hover {
    background: #e6f5f8;
    color: var(--primary-dark);
    transform: translateY(-1px);
}

.hero {
    position: relative;
    overflow: hidden;
    min-height: 460px;
    display: grid;
    align-items: center;
    padding: 72px clamp(18px, 5vw, 76px);
    color: white;
    background:
        linear-gradient(120deg, rgba(11, 98, 120, .98) 0%, rgba(15, 138, 165, .92) 42%, rgba(37, 99, 235, .82) 100%),
        radial-gradient(circle at 80% 20%, rgba(255, 255, 255, .22), transparent 28%),
        linear-gradient(45deg, #0f8aa5, #2563eb);
}

.hero::before {
    content: "";
    position: absolute;
    inset: 0;
    opacity: .24;
    background-image:
        linear-gradient(90deg, rgba(255,255,255,.28) 1px, transparent 1px),
        linear-gradient(0deg, rgba(255,255,255,.18) 1px, transparent 1px);
    background-size: 58px 58px;
    mask-image: linear-gradient(90deg, black 0%, black 60%, transparent 100%);
}

.hero::after {
    content: "";
    position: absolute;
    right: clamp(20px, 8vw, 110px);
    bottom: 48px;
    width: 280px;
    height: 200px;
    opacity: .44;
    background:
        linear-gradient(135deg, transparent 0 44%, rgba(255,255,255,.9) 45% 47%, transparent 48%),
        radial-gradient(circle at 18% 32%, white 0 6px, transparent 7px),
        radial-gradient(circle at 54% 54%, white 0 6px, transparent 7px),
        radial-gradient(circle at 88% 18%, white 0 6px, transparent 7px);
}

.hero > div {
    position: relative;
    z-index: 1;
}

.hero h1 {
    max-width: 820px;
    margin: 0 0 16px;
    font-size: 58px;
    line-height: 1.12;
    font-weight: 800;
    letter-spacing: 0;
    text-wrap: balance;
}

.hero p {
    max-width: 760px;
    margin: 0 0 28px;
    color: rgba(255, 255, 255, .9);
    font-size: 19px;
}

.hero-actions, .actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.container {
    width: min(1160px, calc(100% - 36px));
    margin: 0 auto;
    padding: 42px 0;
}

.section-title {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 18px;
    margin-bottom: 18px;
}

.section-title h1, .section-title h2 {
    margin: 0;
    line-height: 1.2;
    font-weight: 800;
    letter-spacing: 0;
}

.section-title h1 { font-size: 34px; }
.section-title h2 { font-size: 27px; }

.section-title p {
    margin: 6px 0 0;
    color: var(--muted);
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.card, .panel {
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(215, 224, 234, .92);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.card {
    padding: 20px;
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.card:hover {
    transform: translateY(-2px);
    border-color: rgba(15, 138, 165, .28);
    box-shadow: var(--shadow);
}

.card h3 {
    margin: 0 0 8px;
    font-size: 20px;
    line-height: 1.35;
    font-weight: 800;
}

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

.activity-topline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.swatch {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,.8);
    border-radius: 6px;
    flex: 0 0 auto;
    box-shadow: 0 0 0 1px rgba(24, 34, 48, .12);
}

.meta {
    color: var(--muted);
    font-size: 14px;
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 42px;
    padding: 9px 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--ink);
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(24, 34, 48, .05);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 24px rgba(24, 34, 48, .11);
}

.btn.primary {
    border-color: var(--primary);
    background: linear-gradient(135deg, var(--primary), var(--blue));
    color: white;
}

.btn.success {
    border-color: var(--green);
    background: var(--green);
    color: white;
}

.btn.danger {
    border-color: var(--red);
    background: var(--red);
    color: white;
}

.btn.ghost {
    background: rgba(255,255,255,.16);
    color: white;
    border-color: rgba(255,255,255,.58);
    box-shadow: none;
}

.btn.ghost:hover {
    background: rgba(255,255,255,.24);
}

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

.field {
    display: grid;
    gap: 7px;
}

.field.full { grid-column: 1 / -1; }

label {
    color: #344054;
    font-weight: 800;
}

input, select, textarea {
    width: 100%;
    border: 1px solid #cfd9e5;
    border-radius: 8px;
    padding: 11px 13px;
    background: #ffffff;
    color: var(--ink);
    outline: none;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(15, 138, 165, .13);
}

textarea {
    min-height: 118px;
    resize: vertical;
}

input[type="color"] {
    min-height: 46px;
    padding: 5px;
}

input[type="checkbox"] {
    accent-color: var(--primary);
}

.help {
    color: var(--muted);
    font-size: 13px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid rgba(215, 224, 234, .96);
    border-radius: 8px;
    background: white;
    box-shadow: var(--shadow-soft);
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 760px;
}

th, td {
    padding: 13px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

th {
    background: #eef6f8;
    color: #344054;
    font-weight: 800;
}

tbody tr:nth-child(even) td {
    background: #fbfdff;
}

tbody tr:hover td {
    background: #f3fafc;
}

tbody tr:last-child td {
    border-bottom: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
    white-space: nowrap;
}

.badge.success { background: #dcf7e9; color: #116146; }
.badge.danger { background: #ffe4e0; color: #a4261d; }
.badge.warning { background: #fff1cf; color: #805100; }
.badge.muted { background: #eef2f6; color: #475467; }

.alert {
    padding: 13px 15px;
    border-radius: 8px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-weight: 600;
}

.alert.success {
    background: #e2f7ea;
    border-color: #b9ebcd;
    color: #125c3d;
}

.alert.danger {
    background: #ffe7e3;
    border-color: #ffc5bc;
    color: #9b281f;
}

.site-footer {
    margin-top: 24px;
    padding: 30px 24px;
    text-align: center;
    color: var(--muted);
    background: #ffffff;
    border-top: 1px solid var(--line);
}

.admin-body {
    display: grid;
    grid-template-columns: 286px minmax(0, 1fr);
    min-height: 100vh;
    background:
        radial-gradient(circle at 76% 0%, rgba(224, 95, 69, .10), transparent 28%),
        linear-gradient(180deg, #edf8fa 0, #f6f8fb 330px, #f6f8fb 100%);
}

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 18px 16px;
    background:
        linear-gradient(180deg, rgba(255,255,255,.98), rgba(249,252,253,.98)),
        #ffffff;
    border-right: 1px solid var(--line);
    box-shadow: 10px 0 34px rgba(24, 34, 48, .06);
    overflow-y: auto;
}

.admin-brand {
    margin-bottom: 14px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--line);
}

.admin-brand .brand-mark {
    background: linear-gradient(135deg, #0f8aa5, #2563eb);
}

.admin-user-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    margin-bottom: 18px;
    border: 1px solid #dce7ef;
    border-radius: 8px;
    background: #f7fbfc;
}

.admin-avatar {
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    flex: 0 0 auto;
    border-radius: 8px;
    background: #e2f4f7;
    color: var(--primary-dark);
    font-weight: 800;
}

.admin-user-card strong,
.admin-user-card small {
    display: block;
    line-height: 1.35;
}

.admin-user-card small {
    color: var(--muted);
    font-size: 12px;
}

.admin-nav {
    display: grid;
    gap: 6px;
}

.admin-nav-label {
    margin: 12px 8px 4px;
    color: #7a8798;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.admin-nav a {
    justify-content: flex-start;
    gap: 10px;
    min-height: 44px;
    padding: 9px 10px;
    border: 1px solid transparent;
    color: #475467;
}

.admin-nav a:hover {
    background: #eef8fa;
    border-color: #d4edf2;
    color: var(--primary-dark);
    transform: translateX(2px);
}

.admin-nav a.active {
    background: linear-gradient(135deg, rgba(15, 138, 165, .14), rgba(37, 99, 235, .10));
    border-color: rgba(15, 138, 165, .25);
    color: var(--primary-dark);
    box-shadow: inset 3px 0 0 var(--primary);
}

.nav-mark {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    border-radius: 8px;
    background: #eef2f6;
    color: #53657a;
    font-size: 12px;
    font-weight: 800;
}

.admin-nav a.active .nav-mark,
.admin-nav a:hover .nav-mark {
    background: var(--primary);
    color: white;
}

.admin-main {
    min-width: 0;
    padding: 32px;
}

.admin-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 22px;
    padding: 20px 22px;
    border: 1px solid rgba(215, 224, 234, .92);
    border-radius: 8px;
    background:
        linear-gradient(135deg, rgba(255,255,255,.98), rgba(244,251,252,.94));
    box-shadow: var(--shadow-soft);
}

.admin-kicker {
    display: inline-flex;
    margin-bottom: 5px;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 800;
}

.admin-top h1 {
    margin: 0;
    font-size: 32px;
    line-height: 1.2;
    font-weight: 800;
}

.admin-top p {
    margin: 5px 0 0;
    color: var(--muted);
}

.role-pill {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 5px 12px;
    border: 1px solid #cce7ed;
    border-radius: 999px;
    background: #eaf8fb;
    color: var(--primary-dark);
    font-weight: 800;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat {
    position: relative;
    overflow: hidden;
    padding: 21px;
    background: white;
    border: 1px solid rgba(215, 224, 234, .94);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
    transition: transform .18s ease, box-shadow .18s ease;
}

.stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--blue), var(--coral));
}

.stat span {
    color: var(--muted);
    font-weight: 700;
}

.stat strong {
    display: block;
    margin-top: 8px;
    font-size: 34px;
    line-height: 1.05;
    color: var(--ink);
}

.admin-main .panel,
.admin-main .table-wrap {
    margin-bottom: 22px;
}

.admin-main .panel {
    padding: 22px;
}

.admin-main .panel:hover {
    transform: none;
}

.admin-main .section-title {
    margin-top: 8px;
}

.admin-quick-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 24px;
}

.quick-card {
    display: grid;
    gap: 7px;
    padding: 18px;
    border: 1px solid rgba(215, 224, 234, .94);
    border-radius: 8px;
    background: white;
    box-shadow: var(--shadow-soft);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

.quick-card:hover {
    transform: translateY(-2px);
    border-color: rgba(15, 138, 165, .32);
    box-shadow: var(--shadow);
}

.quick-mark {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary), var(--blue));
    color: white;
    font-weight: 800;
}

.quick-card strong {
    font-size: 18px;
    line-height: 1.35;
}

.quick-card small {
    color: var(--muted);
    line-height: 1.5;
}

.admin-main form .actions {
    margin-bottom: 0;
}

.admin-main td .field {
    min-width: 220px;
}

.compact-stats {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.judging-list {
    display: grid;
    gap: 16px;
}

.judging-card {
    display: grid;
    grid-template-columns: minmax(260px, .9fr) minmax(360px, 1.1fr);
    gap: 18px;
    padding: 20px;
    border: 1px solid rgba(215, 224, 234, .94);
    border-radius: 8px;
    background: white;
    box-shadow: var(--shadow-soft);
}

.judging-info h2 {
    margin: 0 0 6px;
    font-size: 22px;
    line-height: 1.35;
}

.judging-info p {
    margin: 8px 0;
}

.judging-form {
    padding: 16px;
    border: 1px solid #dce7ef;
    border-radius: 8px;
    background: #f8fbfc;
}

.judging-form textarea {
    min-height: 86px;
}

.publish-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px dashed #bddde5;
    border-radius: 8px;
    background: #eff9fb;
}

.publish-toggle input {
    width: auto;
}

.file-stack {
    display: grid;
    gap: 10px;
    align-items: start;
}

.image-preview-link {
    display: inline-grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    color: var(--primary-dark);
    font-weight: 700;
}

.thumb {
    width: 72px;
    height: 54px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #eef2f6;
}

.judging-image {
    display: grid;
    gap: 8px;
    margin-top: 14px;
    color: var(--primary-dark);
    font-weight: 700;
}

.judging-image img {
    width: min(100%, 420px);
    max-height: 260px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #eef2f6;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        linear-gradient(135deg, rgba(15, 138, 165, .12), rgba(37, 99, 235, .10)),
        #f6f8fb;
}

.login-card {
    width: min(440px, 100%);
    padding: 26px;
}

@media (max-width: 980px) {
    .hero h1 {
        font-size: 42px;
    }
    .hero::after {
        opacity: .18;
    }
}

@media (max-width: 820px) {
    .site-header {
        align-items: flex-start;
        flex-direction: column;
    }
    .main-nav {
        width: 100%;
    }
    .main-nav a {
        min-height: 36px;
        padding: 7px 10px;
    }
    .hero {
        min-height: 420px;
        padding-top: 54px;
        padding-bottom: 54px;
    }
    .hero h1 {
        font-size: 34px;
    }
    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }
    .section-title h1 {
        font-size: 29px;
    }
    .section-title h2 {
        font-size: 24px;
    }
    .admin-body {
        grid-template-columns: 1fr;
    }
    .admin-sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
    .admin-main {
        padding: 20px;
    }
    .admin-top {
        align-items: flex-start;
        flex-direction: column;
    }
    .judging-card {
        grid-template-columns: 1fr;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 520px) {
    body {
        font-size: 15px;
    }
    .container {
        width: min(100% - 28px, 1160px);
        padding: 30px 0;
    }
    .hero h1 {
        font-size: 30px;
    }
    .hero p {
        font-size: 16px;
    }
    .btn {
        width: 100%;
    }
    .actions .btn, .hero-actions .btn {
        flex: 1 1 100%;
    }
    .card {
        padding: 17px;
    }
    .admin-top h1 {
        font-size: 26px;
    }
}
