/* ==========================================================
   PH Portal — Admin
   สีมาจากตัวแปร --ph-* (ธีมสี) เช่นเดียวกับหน้าเว็บ
   ========================================================== */

:root {
    --ph-primary: #f0857a; --ph-primary-rgb: 240, 133, 122; --ph-primary-dark: #bb4135; --ph-primary-soft: #fde7e4;
    --ph-accent: #f7b38f; --ph-accent-rgb: 247, 179, 143; --ph-accent-ink: #a15933; --ph-accent-soft: #fdefe8; --ph-accent-2: #f9d2c3;
    --ph-bg: #fefaf7; --ph-surface: #fff; --ph-surface-2: #fffcfa; --ph-border: #fce9e3;
    --ph-text: #34201d; --ph-muted: #74625f; --ph-on-primary: #fff;
    --ph-btn-from: #ea5849; --ph-btn-to: #e95b11; --ph-btn-text: #fff;
    --ph-blob-opacity: .5;

    --ph-shadow: 0 1px 2px rgba(var(--ph-primary-rgb), .06), 0 4px 14px rgba(var(--ph-primary-rgb), .07);
    --ph-shadow-lg: 0 18px 40px -12px rgba(var(--ph-primary-rgb), .35);
    --ease-out: cubic-bezier(.22, 1, .36, 1);
    --ease-spring: cubic-bezier(.34, 1.56, .64, 1);
}
[data-bs-theme="dark"] {
    --ph-shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .28);
    --ph-shadow-lg: 0 18px 40px -12px rgba(0, 0, 0, .7);
}
:root, [data-bs-theme="light"], [data-bs-theme="dark"] {
    --bs-body-bg: var(--ph-bg);
    --bs-body-color: var(--ph-text);
    --bs-body-font-family: "Sarabun", system-ui, -apple-system, "Segoe UI", sans-serif;
    --bs-border-color: var(--ph-border);
    --bs-secondary-color: var(--ph-muted);
    --bs-link-color-rgb: var(--ph-primary-rgb);
    --bs-link-hover-color-rgb: var(--ph-primary-rgb);
}

body { background: var(--ph-bg); min-height: 100vh; display: flex; flex-direction: column; }
.admin-main { flex: 1; }
h1, h2, .page-title, .login-title, .navbar-brand { font-family: "Prompt", var(--bs-body-font-family); }
.text-brand { color: var(--ph-primary-dark); }
a { color: var(--ph-primary-dark); }
::selection { background: var(--ph-primary); color: var(--ph-on-primary); }

@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes shake { 10%, 90% { transform: translateX(-1px); } 20%, 80% { transform: translateX(3px); } 30%, 50%, 70% { transform: translateX(-6px); } 40%, 60% { transform: translateX(6px); } }
@keyframes float1 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(60px, -40px) scale(1.15); } }
@keyframes float2 { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(-50px, 50px) scale(1.1); } }
@keyframes popIn { from { opacity: 0; transform: scale(.92) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes flashSave { 0% { box-shadow: 0 0 0 0 rgba(var(--ph-primary-rgb), .6); } 100% { box-shadow: 0 0 0 10px rgba(var(--ph-primary-rgb), 0); } }
.shake { animation: shake .5s both; }

/* ---------- Buttons & forms ---------- */
.btn-brand {
    background: linear-gradient(135deg, var(--ph-btn-from), var(--ph-btn-to));
    border: 0; color: var(--ph-btn-text); font-weight: 500; border-radius: 12px;
    box-shadow: 0 8px 20px -8px rgba(var(--ph-primary-rgb), .85);
    transition: transform .3s var(--ease-spring), box-shadow .3s, filter .2s;
}
.btn-brand:hover, .btn-brand:focus-visible { color: var(--ph-btn-text); transform: translateY(-2px); box-shadow: 0 12px 26px -8px rgba(var(--ph-primary-rgb), .95); filter: brightness(1.05); }
.btn-brand:active, .btn-brand:first-child:active { transform: scale(.97); color: var(--ph-btn-text) !important; background: linear-gradient(135deg, var(--ph-btn-from), var(--ph-btn-to)) !important; }

.btn-soft, .btn-soft-danger, .btn-ghost {
    border: 1px solid var(--ph-border); background: var(--ph-surface); border-radius: 10px; transition: all .2s;
}
.btn-soft { color: var(--ph-primary-dark); }
.btn-soft:hover { background: var(--ph-primary-soft); border-color: var(--ph-primary); color: var(--ph-primary-dark); }
.btn-ghost { color: var(--ph-text); }
.btn-ghost:hover { background: var(--ph-surface-2); border-color: var(--ph-primary); color: var(--ph-text); }
.btn-soft-danger { color: #b42318; }
.btn-soft-danger:hover { background: #fde2df; border-color: #e57368; color: #9b1c12; }
[data-bs-theme="dark"] .btn-soft-danger { color: #ff8a80; }
[data-bs-theme="dark"] .btn-soft-danger:hover { background: rgba(255, 100, 90, .12); color: #ffa39b; }

.btn-icon {
    width: 38px; height: 38px; border-radius: 50%; padding: 0; flex-shrink: 0;
    display: grid; place-items: center;
    background: var(--ph-surface); color: var(--ph-primary-dark); border: 1px solid var(--ph-border);
    transition: transform .3s var(--ease-spring);
}
.btn-icon:hover { transform: rotate(-15deg) scale(1.08); background: var(--ph-primary-soft); color: var(--ph-primary-dark); }

.form-control, .form-select, .input-group-text { border-color: var(--ph-border); border-radius: 10px; }
.form-control { background-color: var(--ph-surface); }
.form-control:focus, .form-select:focus { border-color: var(--ph-primary); box-shadow: 0 0 0 .25rem rgba(var(--ph-primary-rgb), .18); }
.form-check-input:checked { background-color: var(--ph-primary); border-color: var(--ph-primary); }
.form-check-input:focus { border-color: var(--ph-primary); box-shadow: 0 0 0 .25rem rgba(var(--ph-primary-rgb), .18); }
.form-switch .form-check-input { width: 2.6em; height: 1.4em; cursor: pointer; }
.form-switch .form-check-input:focus:not(:checked) {
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23999'/%3e%3c/svg%3e");
}
.form-floating > label::after { background-color: transparent !important; }
.input-group-text { background: var(--ph-surface-2); color: var(--ph-primary-dark); }

/* ---------- Navbar ---------- */
.admin-nav {
    background: color-mix(in srgb, var(--ph-surface) 86%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--ph-border);
}
.admin-nav .navbar-brand { font-size: 1rem; min-width: 0; margin-right: .5rem; }
.admin-nav .navbar-brand small { font-family: var(--bs-body-font-family); font-size: .75rem; }
.brand-text { min-width: 0; }
.brand-text > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-logo {
    width: 40px; height: 40px; border-radius: 12px; overflow: hidden; flex-shrink: 0;
    display: grid; place-items: center; color: var(--ph-on-primary); font-size: 1.2rem;
    background: linear-gradient(135deg, var(--ph-primary), var(--ph-accent));
}
.nav-logo.has-img { background: #fff; border: 1px solid var(--ph-border); }
.nav-logo img { width: 100%; height: 100%; object-fit: contain; padding: 2px; }
.admin-nav .nav-link {
    border-radius: 10px; padding: .5rem .85rem !important; color: var(--ph-muted); font-weight: 500;
    display: flex; align-items: center; gap: .4rem; transition: background-color .2s, color .2s;
}
.admin-nav .nav-link:hover, .admin-nav .nav-link.active { color: var(--ph-primary-dark); background: var(--ph-primary-soft); }
.navbar-toggler { color: var(--ph-text); padding: .25rem .5rem; }
.navbar-toggler:focus { box-shadow: 0 0 0 .2rem rgba(var(--ph-primary-rgb), .25); }
.user-chip {
    display: inline-flex; align-items: center; gap: .35rem; font-size: .88rem; min-width: 0;
    padding: .35rem .8rem; border-radius: 999px; background: var(--ph-surface-2); border: 1px solid var(--ph-border);
}
@media (max-width: 991.98px) {
    .admin-nav .navbar-collapse { border-top: 1px solid var(--ph-border); margin-top: .6rem; }
    .admin-nav .navbar-nav { gap: .2rem; }
    .nav-tools { border-top: 1px dashed var(--ph-border); padding-top: .8rem; margin-top: .6rem; }
    .nav-tools form { margin-left: auto !important; }
}

/* ---------- Page ---------- */
.page-head {
    display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    margin-bottom: 1.6rem; animation: fadeUp .6s var(--ease-out) both;
}
.page-title { font-size: clamp(1.3rem, 3vw, 1.6rem); font-weight: 600; margin: 0 0 .25rem; }
.back-link { display: inline-flex; gap: .35rem; font-size: .9rem; text-decoration: none; margin-bottom: .35rem; color: var(--ph-muted); }
.back-link:hover { color: var(--ph-primary-dark); }
.flash-alert { border-radius: 14px; animation: popIn .45s var(--ease-spring) both; }

.panel {
    background: var(--ph-surface); border: 1px solid var(--ph-border);
    border-radius: 20px; box-shadow: var(--ph-shadow);
    animation: fadeUp .6s var(--ease-out) both; animation-delay: .1s;
}
.panel-pad { padding: 1.5rem; }
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem 1rem; flex-wrap: wrap;
    padding: 1rem 1.25rem; border-bottom: 1px solid var(--ph-border);
}
.panel-title { font-size: 1.05rem; font-weight: 600; margin-bottom: 1.1rem; display: flex; gap: .5rem; align-items: center; }
.panel-title i { color: var(--ph-primary-dark); }
.panel-sub { font-size: .86rem; color: var(--ph-muted); margin: -.6rem 0 1.1rem; }

/* ---------- Stat cards ---------- */
.stat-card {
    display: flex; align-items: center; gap: .9rem; height: 100%;
    padding: 1.1rem 1.2rem; border-radius: 18px;
    background: var(--ph-surface); border: 1px solid var(--ph-border); box-shadow: var(--ph-shadow);
    animation: fadeUp .6s var(--ease-out) both; animation-delay: calc(var(--i) * 80ms);
    transition: transform .35s var(--ease-spring), box-shadow .3s;
}
.stat-card:hover { transform: translateY(-4px); box-shadow: var(--ph-shadow-lg); }
.stat-icon { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.stat-num { font-family: "Prompt", sans-serif; font-size: 1.6rem; font-weight: 600; line-height: 1.1; }
.stat-label { font-size: .85rem; color: var(--ph-muted); }
.tone-peach .stat-icon { background: var(--ph-primary-soft); color: var(--ph-primary-dark); }
.tone-accent .stat-icon { background: var(--ph-accent-soft); color: var(--ph-accent-ink); }
.tone-green .stat-icon { background: rgba(46, 160, 110, .13); color: #1d7a50; }
.tone-amber .stat-icon { background: rgba(230, 160, 40, .15); color: #8f5d07; }
[data-bs-theme="dark"] .tone-green .stat-icon { color: #6fd6a3; }
[data-bs-theme="dark"] .tone-amber .stat-icon { color: #f3c162; }

/* ---------- Systems list ---------- */
.search-mini { position: relative; min-width: 220px; }
.search-mini i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--ph-muted); font-size: .85rem; }
.search-mini .form-control { padding-left: 2rem; border-radius: 999px; }

.sys-list { list-style: none; margin: 0; padding: .5rem; }
.sys-row {
    display: flex; align-items: center; gap: .9rem;
    padding: .85rem 1rem; border-radius: 14px;
    border: 1px solid transparent; background: var(--ph-surface);
    animation: fadeUp .5s var(--ease-out) both; animation-delay: calc(var(--i) * 35ms + .15s);
    transition: background-color .2s, border-color .2s, box-shadow .2s, opacity .2s;
}
.sys-row + .sys-row { margin-top: .35rem; }
.sys-row:hover { background: var(--ph-surface-2); border-color: var(--ph-border); }
.sys-row.is-off .sys-icon, .sys-row.is-off .sys-info { opacity: .5; }
.sys-row.saved { animation: flashSave .8s ease-out; }
.drag-handle { cursor: grab; color: var(--ph-muted); font-size: 1.2rem; padding: .25rem; border-radius: 8px; touch-action: none; flex-shrink: 0; }
.drag-handle:hover { background: var(--ph-primary-soft); color: var(--ph-primary-dark); }
.drag-handle:active { cursor: grabbing; }
.sortable-ghost { opacity: .35; background: var(--ph-primary-soft) !important; border: 1px dashed var(--ph-primary) !important; }
.sortable-chosen { box-shadow: var(--ph-shadow-lg); }

.sys-icon {
    width: 46px; height: 46px; border-radius: 13px; flex-shrink: 0;
    display: grid; place-items: center; font-size: 1.3rem;
    background: var(--ph-primary-soft); color: var(--ph-primary-dark);
}
.sys-row:nth-child(even) .sys-icon { background: var(--ph-accent-soft); color: var(--ph-accent-ink); }
.sys-info { flex: 1; min-width: 0; }
.sys-name { font-weight: 600; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; overflow-wrap: anywhere; }
.sys-name .badge { font-weight: 500; font-size: .7rem; border-radius: 999px; }
.badge-peach { background: var(--ph-primary-soft); color: var(--ph-primary-dark); }
.text-bg-secondary-subtle { background: var(--bs-secondary-bg); color: var(--ph-muted); }
.sys-desc, .sys-url { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sys-desc { font-size: .86rem; color: var(--ph-muted); }
.sys-url { font-size: .8rem; margin-top: .15rem; }
.sys-url a { text-decoration: none; }
.sys-url a:hover { text-decoration: underline; }
.sys-actions { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

/* ---------- System form ---------- */
.icon-live { font-size: 1.2rem; min-width: 48px; justify-content: center; }
.icon-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: .4rem;
    max-height: 196px; overflow-y: auto; padding: .5rem;
    border: 1px solid var(--ph-border); border-radius: 12px; background: var(--ph-surface-2);
}
.icon-opt {
    aspect-ratio: 1; border: 1px solid transparent; border-radius: 10px;
    background: var(--ph-surface); color: var(--ph-text); font-size: 1.15rem;
    transition: transform .25s var(--ease-spring), background-color .2s, color .2s;
}
.icon-opt:hover { transform: scale(1.12); color: var(--ph-primary-dark); border-color: var(--ph-border); }
.icon-opt.active { background: linear-gradient(135deg, var(--ph-btn-from), var(--ph-btn-to)); color: var(--ph-btn-text); transform: scale(1.05); }
.option-box { padding: .85rem 1rem; border: 1px solid var(--ph-border); border-radius: 14px; background: var(--ph-surface-2); height: 100%; }

.preview-sticky { position: sticky; top: 96px; animation: fadeUp .6s var(--ease-out) .2s both; }
.preview-stage {
    padding: 2rem 1.5rem; border-radius: 20px;
    background:
        radial-gradient(circle at 15% 20%, rgba(var(--ph-primary-rgb), .16), transparent 50%),
        radial-gradient(circle at 85% 80%, rgba(var(--ph-accent-rgb), .2), transparent 50%),
        var(--ph-bg);
    border: 1px dashed var(--ph-border);
}
.pv-card {
    position: relative; display: flex; gap: 1rem; padding: 1.3rem; border-radius: 20px;
    background: var(--ph-surface); border: 1px solid var(--ph-border); box-shadow: var(--ph-shadow-lg);
    transition: transform .4s var(--ease-spring);
}
.pv-card:hover { transform: translateY(-6px); }
.pv-card.bump { animation: popIn .35s var(--ease-spring); }
.pv-icon {
    width: 58px; height: 58px; border-radius: 17px; flex-shrink: 0;
    display: grid; place-items: center; font-size: 1.7rem;
    background: linear-gradient(135deg, var(--ph-primary), var(--ph-accent)); color: var(--ph-on-primary);
}
.pv-body { flex: 1; min-width: 0; padding-right: 1.6rem; }
.pv-name { font-family: "Prompt", sans-serif; font-weight: 600; font-size: 1.04rem; margin: .2rem 0 .3rem; overflow-wrap: anywhere; }
.pv-desc { font-size: .88rem; color: var(--ph-muted); overflow-wrap: anywhere; }
.pv-badges { display: flex; gap: .35rem; margin-top: .6rem; flex-wrap: wrap; }
.badge-soft { font-size: .72rem; font-weight: 500; padding: .15rem .6rem; border-radius: 999px; background: var(--ph-primary-soft); color: var(--ph-primary-dark); }
.badge-soft.muted { background: transparent; border: 1px dashed var(--ph-border); color: var(--ph-muted); }
.pv-arrow {
    position: absolute; top: 1.1rem; right: 1.1rem; width: 32px; height: 32px; border-radius: 50%;
    display: grid; place-items: center; background: var(--ph-surface-2); color: var(--ph-primary-dark);
}

/* ---------- Settings: ธีมสี ---------- */
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: .6rem; }
.preset {
    display: flex; flex-direction: column; align-items: stretch; gap: .45rem;
    padding: .55rem; border-radius: 14px; text-align: left;
    background: var(--ph-surface); border: 1.5px solid var(--ph-border); color: var(--ph-text); font-size: .82rem;
    transition: transform .25s var(--ease-spring), border-color .2s, box-shadow .2s;
}
.preset:hover { transform: translateY(-3px); box-shadow: var(--ph-shadow-lg); }
.preset.active { border-color: var(--ph-text); box-shadow: 0 0 0 3px rgba(var(--ph-primary-rgb), .2); }
.preset-swatch { height: 34px; border-radius: 9px; display: flex; overflow: hidden; }
.preset-swatch span { flex: 1; }
.preset-name { display: flex; align-items: center; justify-content: space-between; gap: .25rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preset .bi-check-circle-fill { display: none; color: var(--ph-text); }
.preset.active .bi-check-circle-fill { display: inline; }

.color-field { display: flex; align-items: center; gap: .65rem; padding: .6rem; border: 1px solid var(--ph-border); border-radius: 14px; background: var(--ph-surface-2); }
.color-field input[type="color"] {
    width: 48px; height: 48px; flex-shrink: 0; padding: 0; border: 0; border-radius: 12px; background: none; cursor: pointer;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-field input[type="color"]::-webkit-color-swatch { border: 2px solid rgba(0, 0, 0, .08); border-radius: 12px; }
.color-field input[type="color"]::-moz-color-swatch { border: 2px solid rgba(0, 0, 0, .08); border-radius: 12px; }
.color-field .form-control { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-transform: lowercase; }

.theme-preview {
    --tp-p: #f0857a; --tp-s: #f7b38f;
    border-radius: 18px; padding: 1.1rem; overflow: hidden; position: relative;
    background: color-mix(in srgb, var(--tp-s) 8%, #fff);
    border: 1px solid color-mix(in srgb, var(--tp-p) 18%, #fff);
    color: #2b2422;
}
.theme-preview::before, .theme-preview::after { content: ""; position: absolute; border-radius: 50%; filter: blur(30px); opacity: .45; }
.theme-preview::before { width: 140px; height: 140px; top: -60px; left: -40px; background: var(--tp-p); }
.theme-preview::after { width: 120px; height: 120px; bottom: -60px; right: -30px; background: var(--tp-s); }
.theme-preview > * { position: relative; z-index: 1; }
.tp-title {
    font-family: "Prompt", sans-serif; font-weight: 700; font-size: 1.3rem; margin-bottom: .6rem;
    background: linear-gradient(100deg, color-mix(in srgb, var(--tp-p) 75%, #000), var(--tp-p), var(--tp-s));
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.tp-row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; }
.tp-card { flex: 1 1 150px; display: flex; gap: .6rem; align-items: center; padding: .65rem; border-radius: 14px; background: #fff; border: 1px solid color-mix(in srgb, var(--tp-p) 15%, #fff); font-size: .85rem; font-weight: 600; }
.tp-ic { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex-shrink: 0; }
.tp-ic.p { background: color-mix(in srgb, var(--tp-p) 15%, #fff); color: color-mix(in srgb, var(--tp-p) 60%, #000); }
.tp-ic.s { background: color-mix(in srgb, var(--tp-s) 18%, #fff); color: color-mix(in srgb, var(--tp-s) 55%, #000); }
.tp-btn { padding: .45rem .9rem; border-radius: 10px; color: #fff; font-size: .85rem; font-weight: 500; background: linear-gradient(135deg, color-mix(in srgb, var(--tp-p) 85%, #000), color-mix(in srgb, var(--tp-s) 85%, #000)); }

/* ---------- Settings: รูปภาพ ---------- */
.upload-box { display: flex; gap: 1rem; align-items: flex-start; }
.upload-preview {
    width: 88px; height: 88px; flex-shrink: 0; border-radius: 20px; overflow: hidden;
    display: grid; place-items: center; font-size: 2.2rem; color: var(--ph-on-primary);
    background: linear-gradient(135deg, var(--ph-primary), var(--ph-accent));
    box-shadow: var(--ph-shadow); transition: transform .4s var(--ease-spring);
}
.upload-preview.has-img { background: #fff; border: 1px solid var(--ph-border); }
.upload-preview img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.upload-preview.changed { animation: popIn .45s var(--ease-spring); }
.fav-preview { width: 64px; height: 64px; border-radius: 14px; font-size: 1.6rem; }
.upload-box .flex-grow-1 { min-width: 0; }

.browser-mock { border-radius: 12px 12px 0 0; background: var(--ph-surface-2); border: 1px solid var(--ph-border); border-bottom: 0; padding: .55rem .7rem 0; display: flex; align-items: flex-end; gap: .7rem; }
.bm-dots { display: flex; gap: 5px; padding-bottom: .65rem; }
.bm-dots span { width: 10px; height: 10px; border-radius: 50%; background: #f2665c; }
.bm-dots span:nth-child(2) { background: #f5bd4f; }
.bm-dots span:nth-child(3) { background: #5ec269; }
.bm-tab { flex: 1; min-width: 0; display: flex; align-items: center; gap: .5rem; background: var(--ph-surface); border: 1px solid var(--ph-border); border-bottom: 0; border-radius: 10px 10px 0 0; padding: .45rem .7rem; font-size: .8rem; }
.bm-fav { width: 16px; height: 16px; flex-shrink: 0; display: grid; place-items: center; font-size: .75rem; color: var(--ph-primary-dark); }
.bm-fav img { width: 16px; height: 16px; object-fit: contain; }
.bm-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.save-bar {
    position: sticky; bottom: 0; z-index: 1020; margin: 0 calc(50% - 50vw);
    padding: .8rem 0 calc(.8rem + env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--ph-surface) 88%, transparent);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--ph-border);
}

/* ---------- Login ---------- */
.login-page { overflow-x: hidden; }
.login-bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.login-bg .blob { position: absolute; border-radius: 50%; filter: blur(70px); opacity: var(--ph-blob-opacity); }
.login-bg .b1 { width: 480px; height: 480px; top: -150px; left: -120px; background: var(--ph-primary); animation: float1 16s ease-in-out infinite; }
.login-bg .b2 { width: 420px; height: 420px; bottom: -160px; right: -100px; background: var(--ph-accent); animation: float2 20s ease-in-out infinite; }
.login-bg .b3 { width: 260px; height: 260px; top: 40%; left: 55%; background: var(--ph-accent-2); animation: float1 24s ease-in-out infinite reverse; }
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 1.5rem 1rem; }
.login-card {
    width: 100%; max-width: 420px; padding: 2.4rem 2rem;
    background: color-mix(in srgb, var(--ph-surface) 82%, transparent);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border: 1px solid var(--ph-border);
    border-radius: 26px; box-shadow: var(--ph-shadow-lg);
    animation: popIn .7s var(--ease-spring) both;
}
.login-logo {
    width: 72px; height: 72px; margin: 0 auto 1rem; border-radius: 22px; overflow: hidden;
    display: grid; place-items: center; font-size: 2rem; color: var(--ph-on-primary);
    background: linear-gradient(135deg, var(--ph-primary), var(--ph-accent));
    box-shadow: 0 12px 28px -10px rgba(var(--ph-primary-rgb), .9);
    animation: popIn .7s var(--ease-spring) .15s both;
}
.login-logo.has-img { background: #fff; }
.login-logo img { width: 100%; height: 100%; object-fit: contain; padding: 6px; }
.login-title { font-size: 1.45rem; font-weight: 600; margin-bottom: .3rem; }
.login-card .form-floating > .form-control { border-radius: 14px; background: var(--ph-surface); }
.login-card .form-floating > label { color: var(--ph-muted); }
.pw-field { position: relative; }
.pw-field .form-control { padding-right: 3rem; }
.pw-toggle { position: absolute; right: .6rem; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--ph-muted); width: 36px; height: 36px; border-radius: 50%; z-index: 5; }
.pw-toggle:hover { background: var(--ph-primary-soft); color: var(--ph-primary-dark); }

.admin-footer { border-top: 1px solid var(--ph-border); }
.toast { border-radius: 14px; border: 1px solid var(--ph-border); }

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 991.98px) {
    .preview-sticky { position: static; }
}
@media (max-width: 767.98px) {
    .admin-main { padding-top: 1.25rem !important; padding-bottom: 1.5rem !important; }
    .panel-pad { padding: 1.15rem; }
    .stat-card { padding: .85rem; gap: .65rem; border-radius: 16px; }
    .stat-icon { width: 40px; height: 40px; font-size: 1.1rem; border-radius: 12px; }
    .stat-num { font-size: 1.3rem; }
    .stat-label { font-size: .78rem; }
}
@media (max-width: 575.98px) {
    .page-head { align-items: stretch; }
    .page-head > .btn { width: 100%; }
    .panel { border-radius: 16px; }
    .panel-head { padding: .85rem 1rem; }
    .search-mini { min-width: 0; width: 100%; }
    .sys-list { padding: .35rem; }
    .sys-row { flex-wrap: wrap; padding: .8rem; gap: .7rem; }
    .sys-info { flex-basis: calc(100% - 100px); }
    .sys-actions { width: 100%; justify-content: flex-end; padding-top: .55rem; border-top: 1px dashed var(--ph-border); }
    .sys-actions .form-switch { margin-right: auto !important; }
    .upload-preview { width: 72px; height: 72px; }
    .fav-preview { width: 56px; height: 56px; }
    .save-bar .btn { flex: 1; }
    .save-bar .d-flex.gap-2 { width: 100%; }
    .login-card { padding: 2rem 1.25rem; border-radius: 22px; }
    .preview-stage { padding: 1.25rem .9rem; }
    .pv-card { padding: 1rem; }
    .pv-icon { width: 48px; height: 48px; font-size: 1.4rem; }
    .nav-logo { width: 36px; height: 36px; }
    .admin-nav .navbar-brand { font-size: .92rem; }
}

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