:root {
    --brand: #0ea5a4;
    --brand-dark: #0b7f7e;
    --brand-soft: #ccfbf1;
    --sky: #38bdf8;
    --sun: #fbbf24;
    --coral: #fb7185;
    --ink: #0f172a;
    --muted: #64748b;
    --line: #e2e8f0;
    --bg: #f6fbff;
    --card: #ffffff;
    --radius: 18px;
    --shadow: 0 10px 30px -12px rgba(14, 116, 144, .25);
    --bs-body-font-family: "IBM Plex Sans Thai", system-ui, sans-serif;
    --bs-primary: var(--brand);
    --bs-primary-rgb: 14, 165, 164;
    --bs-link-color: var(--brand-dark);
    --bs-link-color-rgb: 11, 127, 126;
    --bs-link-hover-color: var(--brand);
}

html { font-size: 15px; }
@media (min-width: 768px) { html { font-size: 16px; } }

body {
    font-family: "IBM Plex Sans Thai", system-ui, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ---------- Top bar ---------- */
.topbar {
    background: rgba(255, 255, 255, .85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 1020;
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; }
.brand-mark {
    width: 42px; height: 42px; border-radius: 12px;
    display: grid; place-items: center;
    background: linear-gradient(135deg, var(--sun), var(--coral));
    color: #fff; font-size: 1.35rem;
    box-shadow: 0 6px 16px -6px rgba(251, 113, 133, .7);
}
.brand-title { display: block; font-weight: 700; color: var(--ink); line-height: 1.1; font-size: 1.1rem; }
.brand-sub { display: block; font-size: .8rem; color: var(--brand-dark); font-weight: 500; line-height: 1.1; }
.navbar .nav-link { color: #334155; font-weight: 500; border-radius: 10px; padding: .45rem .8rem !important; }
.navbar .nav-link:hover { background: var(--brand-soft); color: var(--brand-dark); }

/* ---------- Buttons ---------- */
.btn { border-radius: 12px; font-weight: 500; }
.btn-brand {
    background: linear-gradient(135deg, var(--brand), var(--sky));
    border: 0; color: #fff;
    box-shadow: 0 8px 18px -10px rgba(14, 165, 164, .9);
}
.btn-brand:hover, .btn-brand:focus { color: #fff; filter: brightness(1.05); transform: translateY(-1px); }
.btn-sun { background: var(--sun); border: 0; color: #78350f; }
.btn-sun:hover { background: #f59e0b; color: #451a03; }
.btn-soft { background: var(--brand-soft); color: var(--brand-dark); border: 0; }
.btn-soft:hover { background: #99f6e4; color: var(--brand-dark); }
.btn-soft-danger { background: #ffe4e6; color: #be123c; border: 0; }
.btn-soft-danger:hover { background: #fecdd3; color: #9f1239; }

/* ---------- Hero / search ---------- */
.hero {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at 85% 18%, rgba(251, 191, 36, .55) 0 70px, transparent 72px),
        linear-gradient(180deg, #bae6fd 0%, #e0f7ff 55%, var(--bg) 100%);
    padding: 3.5rem 0 7rem;
}
.hero-mountains {
    position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 150px;
    pointer-events: none;
}
.hero h1 { font-weight: 700; font-size: clamp(1.9rem, 5vw, 3rem); letter-spacing: -.01em; }
.hero h1 .accent {
    background: linear-gradient(90deg, var(--brand-dark), var(--sky));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero .lead { color: #335; font-weight: 400; }
.hero-chip {
    display: inline-flex; align-items: center; gap: .4rem;
    background: rgba(255, 255, 255, .8); border-radius: 999px;
    padding: .35rem .9rem; font-size: .9rem; color: var(--brand-dark); font-weight: 500;
}

.search-box {
    position: relative; max-width: 760px; margin: 2rem auto 0;
}
.search-box .bi-search {
    position: absolute; left: 1.4rem; top: 50%; transform: translateY(-50%);
    font-size: 1.35rem; color: var(--brand);
}
.search-box input {
    width: 100%; border: 3px solid transparent; outline: none;
    border-radius: 999px; padding: 1.1rem 3.5rem 1.1rem 3.6rem;
    font-size: 1.15rem; background: #fff;
    box-shadow: 0 18px 40px -18px rgba(2, 132, 199, .55);
    transition: border-color .2s, box-shadow .2s;
}
.search-box input:focus { border-color: #5eead4; box-shadow: 0 18px 50px -16px rgba(14, 165, 164, .6); }
.search-box .spinner-border {
    position: absolute; right: 1.4rem; top: 50%; margin-top: -.6rem;
    width: 1.2rem; height: 1.2rem; color: var(--brand); display: none;
}
.search-box.loading .spinner-border { display: block; }
.search-hint { text-align: center; color: var(--muted); margin-top: .9rem; font-size: .92rem; }

/* ---------- Results ---------- */
.results-wrap { margin-top: -4.5rem; position: relative; z-index: 2; padding-bottom: 3rem; }
.result-meta { color: var(--muted); font-size: .95rem; margin-bottom: .75rem; }
.cert-card {
    background: var(--card); border-radius: var(--radius); padding: 1.15rem 1.25rem;
    box-shadow: var(--shadow); border: 1px solid #eef6f9;
    display: flex; gap: 1rem; align-items: flex-start;
    transition: transform .15s ease, box-shadow .15s ease;
    animation: rise .25s ease both;
}
.cert-card:hover { transform: translateY(-2px); box-shadow: 0 16px 34px -14px rgba(14, 116, 144, .35); }
.cert-icon {
    flex: 0 0 52px; height: 52px; border-radius: 14px;
    display: grid; place-items: center; font-size: 1.5rem; color: #fff;
}
.cert-card:nth-child(4n+1) .cert-icon { background: linear-gradient(135deg, #2dd4bf, #0ea5a4); }
.cert-card:nth-child(4n+2) .cert-icon { background: linear-gradient(135deg, #7dd3fc, #0284c7); }
.cert-card:nth-child(4n+3) .cert-icon { background: linear-gradient(135deg, #fcd34d, #f59e0b); }
.cert-card:nth-child(4n+4) .cert-icon { background: linear-gradient(135deg, #fda4af, #f43f5e); }
.cert-name { font-weight: 600; font-size: 1.12rem; margin: 0; }
.cert-title { color: #334155; margin: .15rem 0 .45rem; }
.cert-tags { display: flex; flex-wrap: wrap; gap: .4rem; font-size: .84rem; }
.tag {
    background: #f1f5f9; color: #475569; border-radius: 999px; padding: .15rem .65rem;
    display: inline-flex; align-items: center; gap: .3rem;
}
.tag-brand { background: var(--brand-soft); color: var(--brand-dark); }
.tag-sun { background: #fef3c7; color: #92400e; }
.cert-actions { margin-left: auto; display: flex; gap: .4rem; flex-shrink: 0; }
mark { background: #fef08a; padding: 0 .1em; border-radius: 4px; }

.empty-state {
    text-align: center; padding: 3rem 1rem; color: var(--muted);
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
}
.empty-state .bi { font-size: 3rem; display: block; margin-bottom: .5rem; color: #94a3b8; }

@media (max-width: 575.98px) {
    .cert-card { flex-wrap: wrap; }
    .cert-actions { margin-left: 0; width: 100%; }
    .cert-actions .btn { flex: 1; }
}

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Admin ---------- */
.page-head { padding: 2rem 0 1rem; }
.page-head h1 { font-weight: 700; font-size: 1.7rem; margin: 0; }
.page-head p { color: var(--muted); margin: .25rem 0 0; }
.panel {
    background: #fff; border-radius: var(--radius); box-shadow: var(--shadow);
    border: 1px solid #eef6f9; padding: 1.5rem;
}
.stat {
    border-radius: var(--radius); padding: 1rem 1.25rem; color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--sky));
}
.table-cert { margin: 0; }
.table-cert thead th {
    background: #f0fdfa; color: var(--brand-dark); font-weight: 600; white-space: nowrap;
    border-bottom: 0; font-size: .9rem;
}
.table-cert td { vertical-align: middle; }
.table-cert tbody tr:hover { background: #f8fffe; }
.form-control, .form-select { border-radius: 12px; padding: .6rem .9rem; border-color: #d6e2ea; }
.form-control:focus, .form-select:focus { border-color: #5eead4; box-shadow: 0 0 0 .25rem rgba(45, 212, 191, .2); }
.form-label { font-weight: 500; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.pagination .page-link { border-radius: 10px !important; margin: 0 2px; color: var(--brand-dark); border: 0; }
.pagination .active .page-link { background: var(--brand); color: #fff; }

.dropzone {
    border: 2.5px dashed #99f6e4; border-radius: var(--radius); background: #f0fdfa;
    padding: 2.5rem 1rem; text-align: center; cursor: pointer; transition: background .2s, border-color .2s;
}
.dropzone:hover, .dropzone.drag { background: #ccfbf1; border-color: var(--brand); }
.dropzone .bi { font-size: 2.6rem; color: var(--brand); }
.step-num {
    width: 34px; height: 34px; border-radius: 50%; display: inline-grid; place-items: center;
    background: var(--sun); color: #78350f; font-weight: 700; flex-shrink: 0;
}

/* ---------- Login ---------- */
.login-wrap { min-height: calc(100vh - 160px); display: grid; place-items: center; padding: 2rem 1rem; }
.login-card { width: 100%; max-width: 420px; }
.login-card .brand-mark { width: 64px; height: 64px; font-size: 2rem; border-radius: 18px; margin: 0 auto 1rem; }

.soft-alert { border: 0; border-radius: 14px; }

.site-footer { padding: 1.25rem 0; color: var(--muted); font-size: .88rem; border-top: 1px solid var(--line); background: #fff; }
.text-muted-2 { color: #94a3b8; }
