:root {
    --bg: #07111f;
    --bg2: #0b1730;
    --text: #ecf7ff;
    --muted: #9bb7cc;
    --card: rgba(16, 33, 59, .72);
    --card2: rgba(255,255,255,.08);
    --line: rgba(255,255,255,.13);
    --primary: #00d4ff;
    --primary2: #a86bff;
    --danger: #ff5f7e;
    --ok: #3dffb5;
    --shadow: 0 20px 60px rgba(0,0,0,.32);
}

:root[data-theme="light"] {
    --bg: #eef7ff;
    --bg2: #f8fbff;
    --text: #152235;
    --muted: #52657a;
    --card: rgba(255,255,255,.76);
    --card2: rgba(0, 70, 130, .06);
    --line: rgba(40, 80, 130, .16);
    --shadow: 0 18px 50px rgba(60, 90, 130, .18);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    min-height: 100vh;
    font-family: "Microsoft JhengHei", "Segoe UI", system-ui, sans-serif;
    background: radial-gradient(circle at 18% 12%, rgba(0,212,255,.20), transparent 26%),
                radial-gradient(circle at 86% 5%, rgba(168,107,255,.18), transparent 30%),
                linear-gradient(135deg, var(--bg), var(--bg2));
    color: var(--text);
    overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.bg-orb {
    position: fixed;
    width: 320px;
    height: 320px;
    border-radius: 999px;
    filter: blur(30px);
    opacity: .28;
    pointer-events: none;
    animation: floatOrb 9s ease-in-out infinite;
}
.orb-a { background: #00d4ff; top: 10%; left: -120px; }
.orb-b { background: #a86bff; top: 35%; right: -140px; animation-delay: -3s; }
.orb-c { background: #3dffb5; bottom: -180px; left: 35%; animation-delay: -5s; }
@keyframes floatOrb { 0%,100% { transform: translateY(0) scale(1); } 50% { transform: translateY(-28px) scale(1.08); } }

.stars {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(255,255,255,.42) 1px, transparent 1px);
    background-size: 42px 42px;
    mask-image: linear-gradient(to bottom, rgba(0,0,0,.7), transparent 80%);
    opacity: .28;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px clamp(16px, 4vw, 42px);
    backdrop-filter: blur(18px);
    background: rgba(7, 17, 31, .62);
    border-bottom: 1px solid var(--line);
}
:root[data-theme="light"] .topbar { background: rgba(244,250,255,.74); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand img, .login-logo img { width: 48px; height: 48px; filter: drop-shadow(0 0 14px rgba(0,212,255,.45)); }
.brand strong { display: block; font-size: 18px; letter-spacing: .5px; }
.brand small { display: block; color: var(--muted); margin-top: 2px; }
.topnav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.topnav a, .theme-toggle, .user-chip {
    border: 1px solid var(--line);
    background: var(--card2);
    color: var(--text);
    border-radius: 999px;
    padding: 9px 13px;
    transition: .18s ease;
}
.topnav a:hover, .theme-toggle:hover { transform: translateY(-1px); border-color: rgba(0,212,255,.7); }
.theme-toggle { cursor: pointer; }
.logout { color: #ffd6dd !important; }

.page-shell { width: min(1220px, calc(100% - 32px)); margin: 28px auto 48px; position: relative; z-index: 1; }
.glass-card, .hero-panel, .site-card, .login-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}
.hero-panel {
    display: grid;
    grid-template-columns: 1.5fr .9fr;
    gap: 22px;
    padding: clamp(24px, 4vw, 42px);
    overflow: hidden;
    position: relative;
}
.hero-panel::after {
    content: "";
    position: absolute;
    inset: -1px;
    background: linear-gradient(120deg, transparent, rgba(0,212,255,.15), transparent);
    pointer-events: none;
}
.eyebrow { color: var(--primary); text-transform: uppercase; letter-spacing: 2px; font-size: 12px; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
.hero-panel h1 { font-size: clamp(36px, 6vw, 72px); margin: 8px 0 12px; line-height: 1; }
.hero-panel p { color: var(--muted); font-size: 18px; line-height: 1.8; max-width: 720px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-content: center; }
.hero-stats div { padding: 18px; border-radius: 22px; background: var(--card2); border: 1px solid var(--line); text-align: center; }
.hero-stats strong { display: block; font-size: 32px; color: var(--primary); }
.hero-stats span { color: var(--muted); font-size: 13px; }

.toolbar { margin: 22px 0; padding: 18px; }
.search-box { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 1px solid var(--line); border-radius: 20px; background: rgba(0,0,0,.12); }
.search-box input { width: 100%; background: transparent; border: 0; outline: 0; color: var(--text); font-size: 16px; }
.search-box input::placeholder { color: var(--muted); }
.filter-tabs { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.tab { border: 1px solid var(--line); background: var(--card2); color: var(--text); border-radius: 999px; padding: 9px 14px; cursor: pointer; transition: .18s ease; }
.tab:hover, .tab.active { border-color: var(--primary); box-shadow: 0 0 18px rgba(0,212,255,.22); transform: translateY(-1px); }

.section-title { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 26px 4px 16px; }
.section-title h2 { margin-bottom: 0; font-size: 28px; }
.section-title p { margin-bottom: 0; color: var(--muted); }
.site-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.site-card { padding: 20px; position: relative; overflow: hidden; transition: .22s ease; border-color: color-mix(in srgb, var(--accent) 32%, var(--line)); }
.site-card:hover { transform: translateY(-5px) scale(1.01); box-shadow: 0 24px 70px rgba(0,0,0,.38), 0 0 28px color-mix(in srgb, var(--accent) 28%, transparent); }
.card-glow { position: absolute; inset: auto -40px -60px auto; width: 170px; height: 170px; background: var(--accent); opacity: .14; border-radius: 999px; filter: blur(18px); pointer-events: none; }
.site-card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.site-icon { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 20px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 28%, transparent), rgba(255,255,255,.06)); border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--line)); font-size: 30px; }
.site-actions { display: flex; align-items: center; gap: 8px; }
.favorite-badge, .mini-btn { border: 1px solid var(--line); border-radius: 999px; background: var(--card2); color: var(--text); padding: 7px 9px; }
.mini-btn { cursor: pointer; }
.mini-btn:disabled { opacity: .5; cursor: wait; }
.site-card h3 { margin: 16px 0 8px; font-size: 22px; }
.site-category { color: var(--primary); font-size: 14px; margin-bottom: 12px; }
.site-card p { color: var(--muted); line-height: 1.7; min-height: 54px; }
.status-line { font-size: 13px; color: var(--muted); padding: 8px 10px; border-radius: 14px; background: rgba(0,0,0,.14); border: 1px solid var(--line); }
.status-line.online { color: var(--ok); border-color: rgba(61,255,181,.35); }
.status-line.offline { color: #ff9caf; border-color: rgba(255,95,126,.35); }
.status-line.checking { color: var(--primary); }
.card-footer { display: flex; gap: 10px; margin-top: 14px; }
.launch-btn, .primary-btn, .ghost-btn, .danger-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    cursor: pointer;
    border-radius: 16px;
    padding: 11px 15px;
    color: #061120;
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    font-weight: 800;
    box-shadow: 0 12px 25px rgba(0,212,255,.18);
    transition: .18s ease;
}
.launch-btn { flex: 1; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 45%, #a86bff)); }
.primary-btn:hover, .launch-btn:hover, .ghost-btn:hover, .danger-btn:hover { transform: translateY(-1px); }
.ghost-btn { background: var(--card2); color: var(--text); border: 1px solid var(--line); box-shadow: none; }
.danger-btn { background: rgba(255,95,126,.16); color: #ffd6dd; border: 1px solid rgba(255,95,126,.32); box-shadow: none; }
.small { padding: 7px 10px; border-radius: 12px; font-size: 13px; }
.full { width: 100%; }

.admin-head { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 24px; margin-bottom: 18px; }
.admin-head h1 { margin: 6px 0; }
.admin-head p { margin-bottom: 0; color: var(--muted); }
.table-card { overflow: auto; padding: 8px; }
.data-table { width: 100%; border-collapse: collapse; min-width: 850px; }
.data-table th, .data-table td { padding: 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table th { color: var(--primary); font-size: 13px; letter-spacing: .6px; }
.data-table td { color: var(--text); }
.data-table a { color: var(--primary); }
.row-icon { display: inline-flex; width: 28px; }
.row-actions { display: flex; gap: 8px; align-items: center; }
.row-actions form { margin: 0; }
.pill { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 5px 9px; font-size: 12px; color: var(--muted); }
.pill.ok { color: var(--ok); border-color: rgba(61,255,181,.35); }
.pill.off { color: #ff9caf; border-color: rgba(255,95,126,.35); }
.color-dot { display: inline-block; width: 14px; height: 14px; border-radius: 999px; vertical-align: -2px; margin-right: 6px; }

.form-card { padding: 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-stack, .compact-form { display: grid; gap: 14px; }
.compact-form { max-width: 620px; }
label span { display: block; margin-bottom: 7px; color: var(--muted); font-size: 14px; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(0,0,0,.14);
    color: var(--text);
    padding: 12px 14px;
    outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(0,212,255,.12); }
.wide { display: block; margin: 16px 0; }
.switch-row { display: flex; gap: 18px; flex-wrap: wrap; margin: 18px 0; }
.check { display: inline-flex; align-items: center; gap: 9px; width: auto; }
.check input { width: auto; }
.check span { margin: 0; color: var(--text); }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }

.flash { padding: 13px 16px; border-radius: 16px; margin-bottom: 16px; border: 1px solid var(--line); background: var(--card); }
.flash.success { border-color: rgba(61,255,181,.35); color: var(--ok); }
.flash.error { border-color: rgba(255,95,126,.35); color: #ffd6dd; }
.empty-state { grid-column: 1 / -1; padding: 32px; text-align: center; }
.empty-state p { color: var(--muted); }

.footer { position: relative; z-index: 1; width: min(1220px, calc(100% - 32px)); margin: 0 auto 24px; color: var(--muted); display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }

.login-body { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(460px, 100%); padding: 34px; text-align: center; position: relative; z-index: 1; }
.login-logo { display: flex; justify-content: center; margin-bottom: 14px; }
.login-card h1 { font-size: 34px; margin-bottom: 8px; }
.login-card p { color: var(--muted); line-height: 1.7; }
.login-hint { margin-top: 16px; color: var(--muted); font-size: 13px; }

@media (max-width: 960px) {
    .hero-panel { grid-template-columns: 1fr; }
    .site-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .topnav { justify-content: flex-start; }
    .site-grid { grid-template-columns: 1fr; }
    .hero-stats { grid-template-columns: 1fr; }
    .section-title { display: block; }
    .admin-head { display: block; }
    .admin-head .primary-btn { margin-top: 14px; }
    .card-footer, .form-actions { flex-direction: column; }
}
