:root {
    --primary: #1677ff;
    --primary-dark: #0958d9;
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 18px 45px rgba(21, 42, 89, .08);
    --sidebar-width: 248px;
    --topbar-bg: rgba(255, 255, 255, .92);
    --soft-bg: #f1f5f9;
    --soft-bg-2: #eef6ff;
    --soft-bg-3: #e8f3ff;
    --table-head-bg: #fafafa;
    --input-bg: #ffffff;
    --control-bg: #ffffff;
    --overlay-bg: rgba(15, 23, 42, .45);
    --menu-hover-bg: #f4f8ff;
    --danger-soft-bg: #fef2f2;
    --danger-soft-border: #fecaca;
}

html[data-theme="dark"] {
    --primary: #3b82f6;
    --primary-dark: #60a5fa;
    --bg: #0b1220;
    --surface: #111827;
    --text: #e5e7eb;
    --muted: #94a3b8;
    --border: #243044;
    --shadow: 0 18px 45px rgba(0, 0, 0, .35);
    --topbar-bg: rgba(17, 24, 39, .92);
    --soft-bg: #1e293b;
    --soft-bg-2: #172554;
    --soft-bg-3: #1e293b;
    --table-head-bg: #0f172a;
    --input-bg: #0f172a;
    --control-bg: #1e293b;
    --overlay-bg: rgba(2, 6, 23, .72);
    --menu-hover-bg: #1e293b;
    --danger-soft-bg: #3f1d1d;
    --danger-soft-border: #7f1d1d;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

a { color: inherit; text-decoration: none; }

.admin-shell { min-height: 100vh; }

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 24;
    width: var(--sidebar-width);
    height: 100vh;
    overflow-y: auto;
    color: #dbeafe;
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    padding: 22px 16px;
    display: flex;
    flex-direction: column;
}

.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand-logo {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    display: grid;
    place-items: center;
    background: var(--primary);
    color: #fff;
    font-weight: 800;
}
.brand strong { display: block; color: #fff; font-size: 16px; }
.brand small { color: #93c5fd; }

.menu { display: grid; gap: 8px; }
.menu-item {
    padding: 12px 14px;
    border-radius: 12px;
    color: #cbd5e1;
    transition: .2s;
}
.menu-item:hover, .menu-item.active { color: #fff; background: rgba(22, 119, 255, .22); }
.sidebar-footer {
    margin-top: auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: #64748b;
    font-size: 12px;
}
.sidebar-footer-copy {
    color: #64748b;
}
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    border: 1px solid rgba(148, 163, 184, .28);
    border-radius: 10px;
    padding: 0;
    background: rgba(15, 23, 42, .55);
    color: #e2e8f0;
    cursor: pointer;
    transition: .2s;
}
.theme-toggle:hover {
    border-color: rgba(96, 165, 250, .55);
    background: rgba(22, 119, 255, .18);
    color: #fff;
}
.theme-toggle-icon { display: none; line-height: 0; }
html:not([data-theme="dark"]) .theme-toggle-icon-moon { display: inline-flex; }
html[data-theme="dark"] .theme-toggle-icon-sun { display: inline-flex; }

.main {
    width: calc(100% - var(--sidebar-width));
    min-width: 0;
    margin-left: var(--sidebar-width);
}
.topbar {
    min-height: 76px;
    padding: 0 32px;
    background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar h1 { margin: 0; font-size: 24px; line-height: 1.2; }
.topbar-title { min-width: 0; }
.profile { display: flex; gap: 10px; align-items: center; min-width: 0; }
.profile-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-jobs-btn {
    flex: 0 0 auto;
    padding: 6px 12px;
    font-size: 13px;
}
.profile-balance { padding: 6px 10px; border-radius: 999px; background: var(--soft-bg-2); color: var(--primary-dark); font-size: 12px; font-weight: 700; white-space: nowrap; }
.avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--soft-bg-3);
    color: var(--primary-dark);
    font-weight: 700;
}
.notify-dot { width: 9px; height: 9px; border-radius: 50%; background: #ff4d4f; }

.content { padding: 28px 32px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.stats-grid--5 {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}
.stats-grid--5 .stat-card {
    padding: 16px 14px;
    min-width: 0;
}
.stats-grid--5 .stat-card strong {
    font-size: 22px;
    margin: 8px 0;
    line-height: 1.25;
    word-break: break-word;
}
.stats-grid--5 .stat-card span,
.stats-grid--5 .stat-card small {
    font-size: 12px;
    line-height: 1.4;
}
.stats-grid--5 .stat-card small {
    display: block;
}
.stat-card, .panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: var(--shadow);
}
.stat-card { padding: 22px; }
.stat-card span, .stat-card small { color: var(--muted); }
.stat-card strong { display: block; margin: 12px 0; font-size: 30px; }
.stat-card small { color: #10b981; }

.panel { padding: 22px; margin-bottom: 18px; }
.panel-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; }
.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.panel-header h2 { margin: 0; font-size: 18px; }
.btn-primary, .btn-link {
    border: 0;
    border-radius: 10px;
    padding: 10px 16px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
}
.btn-primary:hover, .btn-link:hover { background: var(--primary-dark); }

.chart-card { height: 260px; display: flex; align-items: end; gap: 16px; padding-top: 28px; }
.bar { flex: 1; border-radius: 12px 12px 4px 4px; background: linear-gradient(180deg, #69b1ff, #1677ff); }
.quick-list { display: grid; gap: 12px; }
.quick-list a { padding: 14px; border-radius: 12px; background: var(--soft-bg); color: var(--primary-dark); }
.activity-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 14px; }
.activity-list span { display: inline-block; width: 8px; height: 8px; margin-right: 10px; border-radius: 50%; background: var(--primary); }
.ranking-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ranking-table { min-width: 640px; }
.pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
    color: var(--muted);
    font-size: 13px;
}
.pager .disabled {
    opacity: .45;
    pointer-events: none;
    cursor: not-allowed;
}
.pager-pages {
    display: flex;
    align-items: center;
    gap: 6px;
}
.pager-page {
    display: inline-grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
}
.pager-page:hover {
    border-color: #91caff;
    background: #eef6ff;
    color: var(--primary-dark);
}
.pager-page.is-active {
    border-color: var(--primary);
    background: var(--primary);
    color: #fff;
    font-weight: 600;
}
.pager-summary {
    white-space: nowrap;
}

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: 14px 12px; border-bottom: 1px solid var(--border); text-align: left; }
.data-table th { color: var(--muted); font-weight: 600; background: var(--table-head-bg); }
.tag { padding: 4px 9px; border-radius: 999px; background: var(--soft-bg-3); color: var(--primary-dark); font-size: 12px; }
.empty-state { padding: 42px; text-align: center; color: var(--muted); border: 1px dashed var(--border); border-radius: 16px; background: var(--table-head-bg); }
.empty-state strong { display: block; margin-bottom: 8px; color: var(--text); font-size: 20px; }

@media (max-width: 960px) {
    .admin-shell { display: block; }
    .main { width: 100%; margin-left: 0; }
    .sidebar { width: 100%; min-height: auto; }
    .stats-grid, .panel-grid { grid-template-columns: 1fr; }
    .stats-grid.stats-grid--5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .topbar { min-height: 64px; gap: 12px; padding: 12px 16px; align-items: center; }
    .topbar-left { flex: 1; min-width: 0; }
    .topbar h1 { font-size: 19px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .content { padding: 18px; }
}

.login-body {
    min-height: 100vh;
    background: radial-gradient(circle at top left, rgba(22, 119, 255, .22), transparent 34%), #f5f7fb;
}
.login-shell {
    width: min(1040px, calc(100% - 32px));
    min-height: 100vh;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 1.1fr .9fr;
    align-items: center;
    gap: 28px;
}
.login-shell-simple {
    width: min(420px, calc(100% - 32px));
    grid-template-columns: 1fr;
}
.login-hero, .login-card {
    background: rgba(255, 255, 255, .86);
    border: 1px solid rgba(255, 255, 255, .72);
    border-radius: 28px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(16px);
}
.login-hero { padding: 52px; }
.login-hero h1 { margin: 24px 0 12px; font-size: 40px; }
.login-hero p { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.8; }
.login-switch { display: flex; gap: 12px; margin-top: 34px; }
.login-switch a {
    padding: 11px 16px;
    border-radius: 999px;
    color: var(--primary-dark);
    background: #e8f3ff;
}
.login-switch a.active { color: #fff; background: var(--primary); }
.login-card { padding: 38px; }
.login-card h2 { margin: 0 0 8px; font-size: 28px; }
.login-subtitle { margin: 0 0 24px; color: var(--muted); }
.login-form { display: grid; gap: 18px; }
.login-form label { display: grid; gap: 8px; font-weight: 600; }
.login-form input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 13px 14px;
    font-size: 15px;
    outline: none;
}
.login-form input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22, 119, 255, .12); }
.login-submit { width: 100%; margin-top: 4px; font-size: 16px; }
.alert-error {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 12px;
    color: #b42318;
    background: #fff1f0;
    border: 1px solid #ffccc7;
}
.demo-account {
    display: grid;
    gap: 6px;
    margin-top: 22px;
    padding: 14px;
    border-radius: 14px;
    color: var(--muted);
    background: #fafafa;
}
.demo-account strong { color: var(--text); }
.logout-form { margin: 0; }
.logout-form button {
    border: 1px solid var(--border);
    background: var(--control-bg);
    color: var(--muted);
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
}
.logout-form button:hover { color: var(--primary-dark); border-color: #91caff; }
.profile-list { list-style: none; display: grid; gap: 14px; margin: 0; padding: 0; }
.profile-list li { display: flex; justify-content: space-between; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.profile-list span { color: var(--muted); }
.welcome-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 22px;
    margin-bottom: 18px;
    padding: 30px;
    color: #fff;
    background: linear-gradient(135deg, #1677ff, #36cfc9);
    border-radius: 22px;
    box-shadow: var(--shadow);
}
.welcome-panel span { opacity: .9; }
.welcome-panel h2 { margin: 8px 0; font-size: 32px; }
.welcome-panel p { margin: 0; opacity: .9; }
.avatar-large { width: 58px; height: 58px; font-size: 22px; background: rgba(255, 255, 255, .2); color: #fff; }
.user-card-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-bottom: 18px; }
.user-card {
    padding: 24px;
    border-radius: 18px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.user-card span, .user-card p { color: var(--muted); }
.user-card strong { display: block; margin: 12px 0 6px; font-size: 30px; }
.user-card p { margin: 0; }

@media (max-width: 960px) {
    .login-shell, .user-card-grid { grid-template-columns: 1fr; }
    .login-shell { padding: 24px 0; }
    .login-hero, .login-card { padding: 28px; }
    .login-hero h1 { font-size: 30px; }
}


.panel-subtitle { margin: 8px 0 0; color: var(--muted); }
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-secondary {
    border: 1px solid var(--border);
    background: var(--control-bg);
    color: var(--text);
    border-radius: 10px;
    padding: 10px 16px;
    cursor: pointer;
}
.btn-secondary:hover { border-color: #91caff; color: var(--primary-dark); }
.table-toolbar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.table-toolbar-item {
    padding: 10px 14px;
    border-radius: 12px;
    background: var(--soft-bg);
    color: var(--muted);
    border: 1px solid var(--border);
}
.table-toolbar-item.success { color: #059669; background: #ecfdf5; border-color: #a7f3d0; }
.table-toolbar-item.warning { color: #b45309; background: #fffbeb; border-color: #fde68a; }
.table-toolbar-item.danger { color: #b42318; background: #fff1f0; border-color: #ffccc7; }
.table-wrap { overflow: auto; }
.admin-user-table { min-width: 960px; }
.user-cell { display: flex; align-items: center; gap: 10px; }
.user-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px rgba(22, 119, 255, .12); }
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.status-badge.status-success { color: #059669; background: #ecfdf5; }
.status-badge.status-warning { color: #b45309; background: #fffbeb; }
.status-badge.status-info { color: #155e75; background: #ecfeff; }
.status-badge.status-danger { color: #b42318; background: #fff1f0; }
.action-group { display: flex; gap: 14px; flex-wrap: wrap; }
.action-group a { color: var(--primary-dark); }
.action-group a:hover { text-decoration: underline; }


.filter-form {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 160px auto auto;
    gap: 12px;
    align-items: center;
    margin: 18px 0;
    padding: 14px;
    border-radius: 16px;
    background: var(--soft-bg);
    border: 1px solid var(--border);
}
.download-filter-form {
    grid-template-columns: minmax(260px, 1fr) auto auto;
}
.filter-radio-group {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}
.filter-radio-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text);
    cursor: pointer;
}
.filter-radio-item input {
    margin: 0;
}
.search-field {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
}
.search-field span { color: var(--muted); font-size: 18px; }
.search-field input, .filter-form select {
    width: 100%;
    height: 42px;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    -webkit-appearance: none;
    appearance: none;
}
.search-field input[type="search"]::-webkit-search-decoration,
.search-field input[type="search"]::-webkit-search-cancel-button,
.search-field input[type="search"]::-webkit-search-results-button,
.search-field input[type="search"]::-webkit-search-results-decoration {
    display: none;
}
.filter-form select,
.filter-form > input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
    background: var(--input-bg);
    color: var(--text);
    font-size: 14px;
}
.visit-filter-form { grid-template-columns: minmax(260px, 1.4fr) 150px 180px 190px 190px auto auto; }
.visit-table { min-width: 880px; }

.geo-map-panel { overflow: hidden; }
.geo-map-toolbar {
    align-items: center;
    gap: 10px;
}
.geo-map-site-filter {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    color: var(--muted);
}
.geo-map-site-filter select {
    min-width: 180px;
    max-width: min(320px, 42vw);
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card-bg, #fff);
    color: inherit;
    padding: 0 10px;
}
.geo-map-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.geo-map-actions .btn-secondary.is-active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.geo-map-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
    gap: 16px;
    align-items: stretch;
}
.geo-map-canvas-wrap {
    position: relative;
    min-height: 420px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: linear-gradient(180deg, #f8fafc 0%, #eef2f7 100%);
    overflow: hidden;
}
.geo-map-canvas {
    width: 100%;
    height: 420px;
}
.geo-map-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    padding: 24px;
    text-align: center;
    pointer-events: none;
    z-index: 2;
}
.geo-map-empty[hidden] { display: none !important; }
.geo-map-side {
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    background: var(--surface, #fff);
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 420px;
}
.geo-map-meta {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.geo-map-meta > div {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
}
.geo-map-meta span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    margin-bottom: 4px;
}
.geo-map-meta strong {
    font-size: 18px;
}
.geo-map-top {
    list-style: none;
    margin: 0;
    padding: 0;
    overflow: auto;
    flex: 1;
    max-height: 320px;
}
.geo-map-top li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.geo-map-top li:last-child { border-bottom: 0; }
.geo-map-top .geo-rank {
    color: var(--muted);
    width: 1.6em;
    flex-shrink: 0;
}
.geo-map-top .geo-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.geo-map-top .geo-value {
    font-weight: 600;
    flex-shrink: 0;
}
html[data-theme="dark"] .geo-map-canvas-wrap {
    background: linear-gradient(180deg, #111827 0%, #0b1220 100%);
}
html[data-theme="dark"] .geo-map-side {
    background: var(--panel-bg, #111827);
}

@media (max-width: 1100px) {
    .geo-map-layout { grid-template-columns: 1fr; }
    .geo-map-side { min-height: 0; max-height: none; }
    .geo-map-top { max-height: 240px; }
}
.filter-reset { display: inline-flex; justify-content: center; align-items: center; height: 42px; }
.table-empty { padding: 34px; text-align: center; color: var(--muted); }

@media (max-width: 960px) {
    .filter-form { grid-template-columns: 1fr; }
}



.alert-success {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 12px;
    color: #065f46;
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
}
.alert-error {
    margin-bottom: 18px;
    padding: 12px 14px;
    border-radius: 12px;
    color: #b42318;
    background: #fff1f0;
    border: 1px solid #ffccc7;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.sidebar-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--control-bg);
    cursor: pointer;
    font-size: 18px;
    color: var(--text);
}
.mobile-sidebar-mask {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--overlay-bg);
    z-index: 18;
}
.modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    background: var(--overlay-bg);
    z-index: 30;
}
.modal-overlay.active { display: flex; }
.modal-overlay-nested {
    z-index: 40;
}
.modal-card {
    position: relative;
    width: min(560px, 100%);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overscroll-behavior: contain;
    margin: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow);
    padding: 24px;
}
.modal-header {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: start;
    margin-bottom: 18px;
}
.modal-header h3 { margin: 0 0 8px; font-size: 22px; }
.modal-header p { margin: 0; color: var(--muted); }
.modal-close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: var(--soft-bg);
    color: var(--muted);
    font-size: 22px;
    cursor: pointer;
}
.modal-form { display: grid; gap: 14px; }
[hidden] { display: none !important; }
.site-create-loading,
.modal-loading {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 28px;
    text-align: center;
    border-radius: 22px;
    background: rgba(255, 255, 255, .88);
    backdrop-filter: blur(8px);
}
.site-create-loading strong,
.modal-loading strong { font-size: 20px; color: var(--text); }
.site-create-loading p,
.modal-loading p { max-width: 360px; margin: 0; color: var(--muted); line-height: 1.7; }
.loading-spinner {
    width: 46px;
    height: 46px;
    border: 4px solid #dbeafe;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: loading-spin .8s linear infinite;
}
@keyframes loading-spin { to { transform: rotate(360deg); } }
.apk-upload-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 23, 42, .78);
    backdrop-filter: blur(8px);
}
.apk-upload-panel {
    width: min(420px, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 32px 28px;
    text-align: center;
    border-radius: 22px;
    background: #fff;
    box-shadow: 0 24px 60px rgba(15, 23, 42, .28);
}
.apk-upload-panel strong { font-size: 20px; color: var(--text); }
.apk-upload-panel p {
    max-width: 320px;
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}
.apk-upload-progress {
    width: min(320px, 100%);
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}
.apk-upload-progress-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb, #38bdf8);
    transition: width .25s ease;
}
.apk-upload-progress-text {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
}
.apk-upload-panel.is-error .apk-upload-progress-bar {
    background: #ef4444;
}
.apk-upload-panel.is-error .apk-upload-progress-text {
    color: #ef4444;
}
.modal-form label { display: grid; gap: 8px; font-weight: 600; }
.modal-form input,
.modal-form textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text);
}

.password-field {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--input-bg);
    overflow: hidden;
}
.password-field input {
    border: 0;
    border-radius: 0;
    flex: 1;
}
.password-toggle {
    width: 46px;
    height: 42px;
    border: 0;
    border-left: 1px solid var(--border);
    background: var(--soft-bg);
    color: var(--text);
    cursor: pointer;
    font-size: 16px;
}
.password-toggle:hover { background: var(--soft-bg-2); }
.field-help {
    color: var(--muted);
    font-weight: 400;
    font-size: 12px;
}

.modal-form input[readonly] { background: var(--soft-bg); color: var(--muted); }
.form-hint { color: var(--muted); font-size: 12px; font-weight: 400; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 6px;
}
@media (max-width: 960px) {
    .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .mobile-sidebar-mask { display: none; }
    .admin-shell { display: block; }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: 280px;
        height: 100vh;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform .25s ease;
        z-index: 20;
        min-height: 100vh;
        box-shadow: 0 0 0 rgba(0,0,0,0);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .mobile-sidebar-mask { display: block; }
    .sidebar-footer { padding-bottom: 18px; }
    .topbar { min-height: 62px; padding: 10px 14px; gap: 10px; }
    .content { padding: 16px; }
    .profile { gap: 8px; flex-wrap: nowrap; justify-content: flex-end; }
    .notify-dot, .profile-name { display: none; }
    .profile-jobs-btn { padding: 6px 10px; font-size: 12px; }
    .avatar { width: 32px; height: 32px; font-size: 13px; }
    .profile-balance { padding: 5px 8px; font-size: 11px; }
    .logout-form button { padding: 7px 10px; }
    .panel-actions { width: 100%; }
}

@media (max-width: 520px) {
    .topbar { padding: 10px 12px; }
    .sidebar-toggle { width: 36px; height: 36px; border-radius: 10px; }
    .topbar-left { gap: 10px; }
    .topbar h1 { font-size: 18px; }
    .profile { gap: 6px; }
    .profile-balance { max-width: 86px; overflow: hidden; text-overflow: ellipsis; }
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.site-row-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}
.row-actions-line {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: nowrap;
}
.row-actions-line > .btn-secondary,
.row-actions-line > .action-dropdown > .action-trigger {
    min-width: 64px;
    flex: 1 1 0;
}
.inline-form { margin: 0; }
.btn-danger {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    background: #dc2626;
    color: #fff;
    cursor: pointer;
}
.btn-danger:hover { background: #b91c1c; }
.action-dropdown { position: relative; }
.action-trigger { min-width: 72px; }
.action-menu {
    display: none;
    position: fixed;
    min-width: 168px;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    z-index: 10050;
}
.action-dropdown.open .action-menu,
.action-menu.is-ported.is-open {
    display: grid;
    gap: 6px;
}
.action-menu-group {
    display: grid;
    gap: 2px;
}
.action-menu-group + .action-menu-group {
    margin-top: 2px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
.action-menu-label {
    display: block;
    padding: 2px 10px 4px;
    color: #94a3b8;
    font-size: 12px;
    line-height: 1.2;
}
.action-menu form { margin: 0; }
.action-menu button {
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    text-align: left;
    border-radius: 9px;
    padding: 9px 10px;
    cursor: pointer;
    font-size: 14px;
}
.action-menu button:hover { background: var(--menu-hover-bg); color: var(--primary-dark); }
.action-menu button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}
.action-menu button:disabled:hover {
    background: transparent;
    color: var(--text);
}
.action-menu button.action-menu-danger {
    color: #b91c1c;
}
.action-menu button.action-menu-danger:hover {
    background: var(--danger-soft-bg);
    color: #991b1b;
}
.renew-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 14px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: linear-gradient(135deg, #f8fafc, #ffffff);
}
.renew-summary div {
    display: grid;
    gap: 6px;
    min-width: 0;
    padding: 12px 14px;
    border-radius: 12px;
    background: #fff;
}
.renew-summary span { color: var(--muted); font-size: 12px; }
.renew-summary strong {
    overflow: hidden;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.renew-options {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.renew-option {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 68px;
    padding: 16px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .04);
    cursor: pointer;
    font-weight: 700;
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease, background .18s ease;
}
.renew-option input {
    width: 18px;
    height: 18px;
    margin: 0;
    flex: 0 0 auto;
    accent-color: var(--primary);
}
.renew-option span { color: var(--text); line-height: 1.3; }
.renew-option:hover {
    border-color: rgba(59, 130, 246, .38);
    background: #f8fbff;
    transform: translateY(-1px);
}
.renew-option:has(input:checked) {
    border-color: rgba(37, 99, 235, .72);
    background: linear-gradient(135deg, #eff6ff, #ffffff);
    box-shadow: 0 12px 28px rgba(37, 99, 235, .16);
}
.renew-option:has(input:checked)::after {
    content: '已选择';
    position: absolute;
    right: 14px;
    top: 12px;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(37, 99, 235, .10);
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 700;
}
@media (max-width: 560px) {
    .renew-summary,
    .renew-options { grid-template-columns: 1fr; }
}
.modal-card-wide { width: min(640px, 100%); }

.modal-form select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
    background: var(--input-bg);
    color: var(--text);
}

.site-filter-form {
    display: flex;
    align-items: center;
    gap: 10px;
}
.site-filter-form .search-field {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    width: auto;
}
.site-filter-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 0 auto;
    margin-left: auto;
}
.site-filter-actions select {
    width: 128px;
    min-width: 128px;
    height: 38px;
    padding: 0 10px;
}
.site-filter-actions .btn-primary,
.site-filter-actions .btn-secondary,
.site-filter-actions .btn-danger,
.site-filter-actions .action-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-width: 0;
    padding: 8px 12px;
    height: 38px;
    line-height: 1;
    white-space: nowrap;
    box-sizing: border-box;
}
.site-cleanup-dropdown .action-menu {
    right: 0;
    left: auto;
}
.site-cleanup-job-table {
    min-width: 720px;
}
.modal-card-cleanup-logs {
    width: min(980px, 100%);
}
.site-cleanup-log-table {
    min-width: 860px;
}
.site-cleanup-log-table th,
.site-cleanup-log-table td {
    white-space: nowrap;
    vertical-align: middle;
}
.site-cleanup-log-table .col-site {
    white-space: normal;
}
.site-cleanup-log-table .col-message {
    white-space: nowrap;
}
.site-cleanup-log-site {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    line-height: 1.35;
}
.site-cleanup-log-site strong,
.site-cleanup-log-site span {
    white-space: nowrap;
}
.site-cleanup-log-site strong {
    font-weight: 700;
}
.site-cleanup-log-site span {
    color: var(--muted);
}
.site-cleanup-log-box {
    margin-top: 16px;
}
.site-cleanup-log-box h4 {
    margin: 0 0 6px;
}
.jobs-filter-form {
    grid-template-columns: 1fr;
}
.job-type-tab {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    cursor: pointer;
    font-family: inherit;
}
.jobs-filter-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}
.jobs-filter-select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--muted);
}
.jobs-filter-select select {
    min-width: 160px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--input-bg);
    color: var(--text);
    font-size: 13px;
    font-family: inherit;
}
.modal-card-jobs {
    width: min(1080px, 100%);
}
.job-type-tab.is-active {
    color: #fff;
    background: var(--primary);
    border-color: var(--primary);
}
.jobs-table {
    min-width: 960px;
}
.jobs-table tr.is-active td {
    background: rgba(22, 119, 255, .06);
}
.jobs-table tbody tr.is-active {
    cursor: default;
}
.jobs-detail-box {
    margin-top: 18px;
    display: grid;
    gap: 14px;
}
.jobs-log-box h4 {
    margin: 0 0 8px;
}
.jobs-log-pre {
    margin: 0;
    max-height: 360px;
    overflow: auto;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--soft-bg);
    white-space: pre-wrap;
    word-break: break-all;
    font-size: 13px;
    line-height: 1.55;
}
.site-table { min-width: 1280px; }
.domain-history-modal-card { width: min(920px, 100%); }
.domain-history-table-wrap { overflow: visible; }
.domain-history-table {
    min-width: 0;
    width: 100%;
    table-layout: fixed;
}
.domain-history-table .col-domain { width: auto; }
.domain-history-table .col-source { text-align: center;width: 120px; }
.domain-history-table .col-time { text-align: center; width: 180px; }
.domain-history-table th,
.domain-history-table td {
    vertical-align: top;
    line-height: 1.5;
}
.domain-history-table th.col-time,
.domain-history-table td.col-time,
.domain-history-table th:last-child,
.domain-history-table td:last-child {
    white-space: nowrap;
}
.domain-history-table .domain-text {
    display: block;
    white-space: normal;
    word-break: break-all;
    overflow-wrap: anywhere;
}
.tag-strong { font-weight: 700; }
.site-key-wrap {
    position: relative;
    display: inline-block;
    padding-right: 2px;
}
.site-key-wrap.has-badge,
.site-key-wrap.has-cloak {
    padding-top: 2px;
}
.site-key-badges {
    position: absolute;
    top: -8px;
    right: -10px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
    pointer-events: none;
}
.site-cloak-badge,
.site-pixel-badge {
    padding: 1px 5px;
    border-radius: 999px;
    font-size: 10px;
    line-height: 1.3;
    font-weight: 700;
    white-space: nowrap;
}
.site-cloak-badge {
    color: #9a3412;
    background: #ffedd5;
    border: 1px solid #fdba74;
}
.site-pixel-badge {
    color: #047857;
    background: #a7f3d0;
    border: 1px solid #10b981;
}
html[data-theme="dark"] .site-cloak-badge {
    color: #fdba74;
    background: #7c2d12;
    border-color: #c2410c;
}
html[data-theme="dark"] .site-pixel-badge {
    color: #6ee7b7;
    background: #064e3b;
    border-color: #34d399;
}
.domain-cell {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 260px;
}
.domain-link {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.domain-text { color: var(--primary-dark); font-weight: 600; }
.copy-icon-button {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--muted);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
}
.copy-icon-button:hover,
.copy-icon-button.copied {
    border-color: #91caff;
    background: #eef6ff;
    color: var(--primary-dark);
}

.wildcard-icon {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: #eef6ff;
    color: var(--primary-dark);
    font-size: 16px;
}
.download-wildcard-switch { margin-top: 10px; }
.time-info { display: grid; gap: 6px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.time-info-remaining.is-warning {
    color: #ea580c;
    font-weight: 700;
}
.time-info-remaining.is-expired {
    color: #dc2626;
    font-weight: 700;
}
html[data-theme="dark"] .time-info-remaining.is-warning {
    color: #fb923c;
}
html[data-theme="dark"] .time-info-remaining.is-expired {
    color: #f87171;
}
.domain-text-disabled {
    color: #94a3b8;
    font-weight: 600;
    cursor: default;
    text-decoration: none;
}
.site-table tr.site-row-expired > td {
    background: #f1f5f9;
    color: #64748b;
}
.site-table tr.site-row-expired .time-info {
    color: #64748b;
}
.site-table tr.site-row-expired .time-info-remaining.is-expired {
    color: #dc2626;
}
html[data-theme="dark"] .site-table tr.site-row-expired > td {
    background: rgba(148, 163, 184, 0.14);
    color: #94a3b8;
}
html[data-theme="dark"] .site-table tr.site-row-expired .time-info {
    color: #94a3b8;
}
html[data-theme="dark"] .site-table tr.site-row-expired .time-info-remaining.is-expired {
    color: #f87171;
}
.site-table tr.site-row-expired-long > td {
    background: #fee2e2;
    color: #7f1d1d;
}
.site-table tr.site-row-expired-long .time-info {
    color: #991b1b;
}
.site-table tr.site-row-expired-long .time-info-remaining.is-expired {
    color: #b91c1c;
    font-weight: 700;
}
html[data-theme="dark"] .site-table tr.site-row-expired-long > td {
    background: rgba(185, 28, 28, 0.32);
    color: #fecaca;
}
html[data-theme="dark"] .site-table tr.site-row-expired-long .time-info {
    color: #fca5a5;
}
html[data-theme="dark"] .site-table tr.site-row-expired-long .time-info-remaining.is-expired {
    color: #f87171;
}
html[data-theme="dark"] .domain-text-disabled {
    color: #64748b;
}
.modal-card-wide { width: min(720px, 100%); }
.download-modal-card { width: min(960px, 100%); }
.site-option-list { display: grid; gap: 12px; }
.site-option-switch {
    display: flex !important;
    grid-template-columns: none !important;
    align-items: center;
    gap: 12px !important;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    background: var(--surface);
    color: var(--text);
}
.site-option-switch input { width: 18px; height: 18px; flex: 0 0 auto; }
.site-option-switch span { display: grid; gap: 4px; }
.site-option-switch small { color: var(--muted); font-weight: 400; }
.cloak-options {
    display: grid;
    gap: 12px;
    margin-top: 4px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--soft-bg);
}
.cloak-options-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}
.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.input-button-group {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
}
.input-button-group .btn-secondary { white-space: nowrap; }
.template-search-box {
    position: relative;
    display: grid;
    gap: 8px;
}
.template-search-box-wide {
    width: 100%;
}
.template-search-box-wide .template-search-results {
    width: 100%;
    min-width: 100%;
}
.template-multi-picker {
    display: grid;
    gap: 8px;
}
.template-multi-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.template-multi-tags:empty {
    display: none;
}
.template-multi-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px 6px 10px;
    border-radius: 999px;
    background: #eef4ff;
    color: var(--primary-dark);
    font-size: 13px;
    user-select: none;
}
.template-multi-tag-label {
    line-height: 1.2;
    pointer-events: none;
}
.template-multi-tag-remove {
    border: 0;
    background: #dbeafe;
    color: var(--primary-dark);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    min-width: 22px;
    min-height: 22px;
    padding: 0;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}
.template-multi-tag-remove:hover {
    background: #fee2e2;
    color: #dc2626;
}
.template-search-input-wrap {
    position: relative;
    min-width: 0;
}
.template-search-input-wrap input {
    padding-right: 42px;
}
.template-search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 50%;
    background: #eef2f7;
    color: var(--muted);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    transform: translateY(-50%);
}
.template-search-clear:hover {
    background: #dbeafe;
    color: var(--primary-dark);
}
.template-search-results {
    position: absolute;
    left: 0;
    right: 0;
    top: 48px;
    z-index: 40;
    max-height: 320px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fff;
    box-shadow: var(--shadow);
}
.template-search-option {
    width: 100%;
    border: 0;
    border-radius: 9px;
    padding: 10px 12px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
    font: inherit;
}
.template-search-option:hover {
    background: #f4f8ff;
    color: var(--primary-dark);
}
@media (max-width: 720px) {
    .form-grid-2,
    .input-button-group { grid-template-columns: 1fr; }
}
.qr-modal-card { width: min(420px, 100%); }
.qr-box {
    display: grid;
    justify-items: center;
    gap: 12px;
    padding: 8px 0 4px;
}
.qr-code {
    display: grid;
    place-items: center;
    width: 260px;
    height: 260px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 10px 28px rgba(15, 23, 42, .08);
}
.qr-code canvas,
.qr-code table {
    width: 240px !important;
    height: 240px !important;
}
.qr-domain {
    max-width: 100%;
    color: var(--primary-dark);
    font-weight: 700;
    text-align: center;
    word-break: break-all;
}
.domain-table { min-width: 760px; }
.template-table { min-width: 820px; }
.server-switch-progress {
    display: grid;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #f8fbff;
}
.server-switch-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    color: var(--text);
}
.server-switch-progress-head span {
    color: var(--primary);
    font-weight: 700;
}
.server-switch-progress-bar {
    height: 10px;
    overflow: hidden;
    border-radius: 999px;
    background: #e2e8f0;
}
.server-switch-progress-bar div {
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #2563eb, #38bdf8);
    transition: width .25s ease;
}
.server-switch-progress p,
.server-switch-progress small {
    margin: 0;
    color: var(--muted);
    line-height: 1.5;
}
.settings-form { display: grid; gap: 18px; }
.settings-card {
    display: grid;
    gap: 16px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #fbfdff;
}
.template-ftp-list { display: grid; gap: 14px; }
.template-ftp-item {
    display: grid;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: #fff;
}
.template-ftp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.template-ftp-remove { padding: 8px 12px; }
.template-ftp-remove.is-disabled { opacity: .45; cursor: not-allowed; }
.template-ftp-actions { display: flex; justify-content: flex-start; }
.settings-card-title h3 { margin: 0 0 6px; font-size: 18px; }
.settings-card-title p { margin: 0; color: var(--muted); }
.settings-form label { display: grid; gap: 8px; font-weight: 600; }
.settings-form input,
.settings-form textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    font-size: 14px;
    font-family: inherit;
}
.settings-form textarea {
    min-height: 116px;
    line-height: 1.6;
    resize: vertical;
}
.form-help {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
}
.settings-actions { display: flex; justify-content: flex-end; }
@media (max-width: 720px) {
    .settings-actions .btn-primary { width: 100%; }
}

.server-filter-form { grid-template-columns: minmax(280px, 1fr) 150px 150px auto auto; }
.server-table { min-width: 1120px; }
.server-conn-info {
    display: grid;
    gap: 5px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}
.is-hidden { display: none !important; }
@media (max-width: 960px) {
    .server-filter-form { grid-template-columns: 1fr; }
}

html[data-theme="dark"] .filter-form {
    background: var(--soft-bg);
    border-color: var(--border);
}

html[data-theme="dark"] .search-field {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

html[data-theme="dark"] .filter-form select,
html[data-theme="dark"] .filter-form > input,
html[data-theme="dark"] .modal-form input,
html[data-theme="dark"] .modal-form select,
html[data-theme="dark"] .modal-form textarea,
html[data-theme="dark"] .settings-form input,
html[data-theme="dark"] .settings-form select,
html[data-theme="dark"] .settings-form textarea,
html[data-theme="dark"] .sidebar-toggle,
html[data-theme="dark"] .table-toolbar-item,
html[data-theme="dark"] .pager-page,
html[data-theme="dark"] .template-search-results,
html[data-theme="dark"] .apk-upload-panel,
html[data-theme="dark"] .qr-box,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .template-ftp-item,
html[data-theme="dark"] .renew-summary,
html[data-theme="dark"] .site-option-list,
html[data-theme="dark"] .cloak-options,
html[data-theme="dark"] .site-option-switch,
html[data-theme="dark"] .user-card {
    background: var(--soft-bg);
    color: var(--text);
    border-color: var(--border);
}

html[data-theme="dark"] .site-option-switch {
    background: var(--surface);
}

html[data-theme="dark"] .modal-form input[readonly],
html[data-theme="dark"] .form-hint,
html[data-theme="dark"] .field-help,
html[data-theme="dark"] .table-empty,
html[data-theme="dark"] .panel-subtitle {
    color: var(--muted);
}

html[data-theme="dark"] .job-type-tab {
    background: var(--input-bg);
    color: var(--text);
}

html[data-theme="dark"] .job-type-tab.is-active {
    color: #fff;
    background: var(--primary);
}

html[data-theme="dark"] .jobs-table tr.is-active td {
    background: rgba(56, 189, 248, .12);
}

html[data-theme="dark"] .modal-form input,
html[data-theme="dark"] .modal-form select,
html[data-theme="dark"] .modal-form textarea,
html[data-theme="dark"] .settings-form input,
html[data-theme="dark"] .settings-form select,
html[data-theme="dark"] .settings-form textarea {
    background: var(--input-bg);
}

html[data-theme="dark"] .alert-success {
    color: #6ee7b7;
    background: #064e3b;
    border-color: #047857;
}

html[data-theme="dark"] .alert-error {
    color: #fecaca;
    background: #7f1d1d;
    border-color: #991b1b;
}

html[data-theme="dark"] .table-toolbar-item.success {
    color: #6ee7b7;
    background: #064e3b;
    border-color: #047857;
}

html[data-theme="dark"] .table-toolbar-item.warning,
html[data-theme="dark"] .status-badge.status-warning {
    color: #fcd34d;
    background: #78350f;
    border-color: #b45309;
}

html[data-theme="dark"] .table-toolbar-item.danger,
html[data-theme="dark"] .status-badge.status-danger,
html[data-theme="dark"] .alert-error {
    color: #fecaca;
    background: #7f1d1d;
    border-color: #991b1b;
}

html[data-theme="dark"] .status-badge.status-info {
    color: #67e8f9;
    background: #164e63;
}

html[data-theme="dark"] .action-menu button.action-menu-danger {
    color: #fca5a5;
}

html[data-theme="dark"] .action-menu button.action-menu-danger:hover {
    color: #fecaca;
}

html[data-theme="dark"] .search-field input {
    color: var(--text);
}

html[data-theme="dark"] .pager a.disabled,
html[data-theme="dark"] .pager-page.is-active {
    opacity: 1;
}

html[data-theme="dark"] .pager-page.is-active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.scrape-site-panel { min-height: calc(100vh - 140px); }
.scrape-workspace {
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr) 420px;
    gap: 18px;
    min-height: calc(100vh - 220px);
    align-items: stretch;
}
.scrape-sidebar {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--card-bg, #fff);
    padding: 18px;
}
.scrape-form label { display: block; margin-bottom: 14px; }
.scrape-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}
.scrape-actions .btn-primary,
.scrape-actions .btn-secondary {
    width: 100%;
    text-align: center;
    justify-content: center;
}
.scrape-code-pane,
.scrape-preview-pane {
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--card-bg, #fff);
    display: flex;
    flex-direction: column;
    min-height: 560px;
    overflow: hidden;
}
.scrape-preview-toolbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}
.scrape-preview-toolbar strong { font-size: 14px; }
.scrape-code-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    background: #0b1220;
}
.scrape-code-pre {
    margin: 0;
    height: 100%;
    max-height: calc(100vh - 280px);
    min-height: 480px;
    overflow: auto;
    padding: 14px 16px;
    color: #e2e8f0;
    font-size: 12px;
    line-height: 1.55;
    white-space: pre;
    tab-size: 2;
}
.scrape-code-pre code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: inherit;
}
.scrape-phone-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 16px 24px;
    background: linear-gradient(180deg, #eef2f7 0%, #e2e8f0 100%);
    min-height: 0;
}
.scrape-phone-device {
    width: 375px;
    max-width: 100%;
    height: 667px;
    max-height: calc(100vh - 280px);
    border-radius: 36px;
    background: #111827;
    padding: 12px 10px 14px;
    box-shadow:
        0 0 0 2px #1f2937,
        0 18px 40px rgba(15, 23, 42, 0.28);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.scrape-phone-notch {
    width: 120px;
    height: 10px;
    margin: 0 auto;
    border-radius: 999px;
    background: #0b1220;
    flex-shrink: 0;
}
.scrape-preview-frame-wrap {
    position: relative;
    flex: 1;
    min-height: 0;
    border-radius: 24px;
    overflow: hidden;
    background: #f3f5f9;
}
.scrape-preview-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    padding: 24px;
    text-align: center;
    z-index: 1;
}
.scrape-code-wrap > .scrape-preview-empty {
    color: #94a3b8;
}
.scrape-preview-frame {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
    display: block;
}
html[data-theme="dark"] .scrape-preview-frame-wrap { background: #0f172a; }
html[data-theme="dark"] .scrape-sidebar,
html[data-theme="dark"] .scrape-code-pane,
html[data-theme="dark"] .scrape-preview-pane { background: var(--panel-bg, #111827); }
html[data-theme="dark"] .scrape-phone-stage {
    background: linear-gradient(180deg, #111827 0%, #0b1220 100%);
}

@media (max-width: 1280px) {
    .scrape-workspace {
        grid-template-columns: minmax(240px, 300px) minmax(0, 1fr) 360px;
    }
    .scrape-phone-device {
        width: 320px;
        height: 568px;
    }
}

@media (max-width: 1100px) {
    .scrape-workspace {
        grid-template-columns: 1fr;
        min-height: auto;
    }
    .scrape-code-pane,
    .scrape-preview-pane { min-height: 0; }
    .scrape-code-pre {
        min-height: 320px;
        max-height: 50vh;
    }
    .scrape-phone-stage { padding: 16px; }
    .scrape-phone-device {
        width: min(375px, 100%);
        height: min(667px, 70vh);
    }
}

.template-preview-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
}
.template-preview-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    min-width: 0;
}
.template-preview-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.template-preview-card-head strong {
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}
.template-preview-card-head .btn-secondary {
    flex: 0 0 auto;
    padding: 6px 10px;
    font-size: 12px;
}
.template-preview-frame-box {
    width: 100%;
    max-width: 210px;
    margin: 0 auto;
}
.template-preview-phone-shell {
    box-sizing: border-box;
    width: 100%;
    padding: 12px 8px 16px;
    border: 2px solid #111827;
    border-radius: 28px;
    background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
    box-shadow: 0 10px 24px rgba(15, 23, 42, .18);
}
.template-preview-phone-notch {
    display: block;
    width: 42%;
    height: 6px;
    margin: 0 auto 10px;
    border-radius: 999px;
    background: #0b1220;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.06);
}
.template-preview-phone-viewport {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 10px;
    background: #fff;
    /* height is set by JS after scale */
    height: 0;
}
.template-preview-phone-scaler {
    position: absolute;
    top: 0;
    left: 0;
    width: 375px;
    height: 812px;
    transform-origin: top left;
    transform: scale(0.45);
}
.template-preview-phone-scaler iframe {
    width: 375px !important;
    height: 812px !important;
    border: 0;
    display: block;
    background: #fff;
}
.template-preview-card-foot {
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}
html[data-theme="dark"] .template-preview-phone-shell {
    border-color: #334155;
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    box-shadow: 0 10px 24px rgba(0, 0, 0, .35);
}
html[data-theme="dark"] .template-preview-phone-notch {
    background: #020617;
}
@media (max-width: 1400px) {
    .template-preview-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 1100px) {
    .template-preview-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
    .template-preview-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
    .template-preview-grid { grid-template-columns: 1fr; }
    .template-preview-frame-box { max-width: 260px; }
}

/* Mobile polish: layout/spacing only, no behavior changes */
@media (max-width: 960px) {
    body {
        -webkit-text-size-adjust: 100%;
        overscroll-behavior-y: contain;
    }
    body.sidebar-open {
        overflow: hidden;
    }
    .sidebar {
        width: min(300px, 86vw);
        z-index: 24;
        padding: 18px 14px;
        padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
        box-shadow: 12px 0 40px rgba(0, 0, 0, .28);
        -webkit-overflow-scrolling: touch;
    }
    .mobile-sidebar-mask {
        z-index: 22;
    }
    .brand { margin-bottom: 18px; }
    .menu { gap: 6px; }
    .menu-item {
        min-height: 44px;
        display: flex;
        align-items: center;
        padding: 12px 14px;
    }
    .topbar {
        padding-left: max(14px, env(safe-area-inset-left, 0px));
        padding-right: max(14px, env(safe-area-inset-right, 0px));
    }
    .content {
        padding: 14px;
        padding-bottom: calc(18px + env(safe-area-inset-bottom, 0px));
    }
    .panel {
        padding: 16px;
        border-radius: 16px;
        margin-bottom: 14px;
    }
    .panel-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 14px;
    }
    .panel-header h2 { font-size: 17px; }
    .panel-actions {
        width: 100%;
        gap: 8px;
    }
    .panel-actions .btn-primary,
    .panel-actions .btn-secondary {
        flex: 1 1 auto;
        min-height: 42px;
        text-align: center;
        justify-content: center;
    }
    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin-bottom: 14px;
    }
    .stats-grid.stats-grid--5 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    .stat-card { padding: 14px; }
    .stat-card strong { font-size: 24px; margin: 8px 0; }
    .stats-grid--5 .stat-card strong { font-size: 20px; }
    .table-toolbar {
        gap: 8px;
        margin-bottom: 12px;
    }
    .table-toolbar-item {
        flex: 1 1 calc(50% - 8px);
        min-width: 0;
        padding: 8px 10px;
        font-size: 12px;
    }
    .table-wrap {
        margin: 0 -4px;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-x: contain;
    }
    .data-table th,
    .data-table td {
        padding: 12px 10px;
        font-size: 13px;
        vertical-align: top;
    }
    .domain-text,
    .data-table td {
        word-break: break-word;
    }
    .row-actions,
    .site-row-actions {
        gap: 8px;
    }
    .row-actions .btn-secondary,
    .row-actions .btn-danger,
    .row-actions .btn-primary,
    .action-trigger {
        min-height: 38px;
        padding: 8px 12px;
    }
    .action-menu {
        /* Keep fixed positioning driven by JS (left/top); do not set right here. */
        min-width: min(220px, calc(100vw - 48px));
        max-width: calc(100vw - 32px);
        z-index: 10050;
    }
    .table-wrap {
        /* Avoid iOS overflow clipping side-effects on nested fixed menus (menus are ported to body). */
        -webkit-overflow-scrolling: auto;
    }
    .filter-form {
        gap: 10px;
        padding: 12px;
    }
    .filter-form .btn-primary,
    .filter-form .btn-secondary,
    .filter-reset {
        width: 100%;
        min-height: 42px;
    }
    .site-filter-form {
        flex-wrap: wrap;
    }
    .site-filter-form .search-field {
        flex: 1 1 100%;
        width: 100%;
    }
    .site-filter-actions {
        width: 100%;
        justify-content: flex-end;
        flex-wrap: wrap;
    }
    .site-filter-actions .btn-primary,
    .site-filter-actions .btn-secondary,
    .site-filter-actions .btn-danger,
    .site-filter-actions .action-trigger,
    .site-filter-form .filter-reset {
        width: auto;
        min-height: 38px;
    }
    .search-field { width: 100%; }
    .pager {
        justify-content: center;
        gap: 8px;
        margin-top: 16px;
    }
    .pager-edge { display: none; }
    .pager-summary {
        width: 100%;
        text-align: center;
        order: 5;
    }
    .modal-overlay {
        align-items: stretch;
        padding: 0;
    }
    .modal-card,
    .modal-card-wide,
    .download-modal-card,
    .domain-history-modal-card,
    .qr-modal-card {
        width: 100%;
        max-width: 100%;
        min-height: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
        padding: 16px;
        padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    }
    .modal-header h3 { font-size: 18px; }
    .modal-header p { font-size: 13px; line-height: 1.5; }
    .modal-actions {
        flex-wrap: wrap;
        gap: 8px;
    }
    .modal-actions .btn-primary,
    .modal-actions .btn-secondary,
    .modal-actions .btn-danger {
        flex: 1 1 calc(50% - 8px);
        min-height: 42px;
        justify-content: center;
        text-align: center;
    }
    .settings-actions { justify-content: stretch; }
    .settings-actions .btn-primary { width: 100%; min-height: 44px; }
    .scrape-site-panel { min-height: auto; }
    .scrape-workspace { gap: 12px; }
    .scrape-sidebar { padding: 14px; border-radius: 14px; }
    .scrape-code-pane,
    .scrape-preview-pane { border-radius: 14px; min-height: 0; }
    .scrape-preview-toolbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        padding: 10px 12px;
    }
    .scrape-code-pre {
        min-height: 280px;
        max-height: 45vh;
    }
    .scrape-phone-device {
        width: min(375px, calc(100vw - 64px));
        height: min(620px, 62vh);
    }
    .qr-code {
        width: min(260px, calc(100vw - 64px));
        height: min(260px, calc(100vw - 64px));
    }
    .qr-code canvas,
    .qr-code table {
        width: min(240px, calc(100vw - 84px)) !important;
        height: min(240px, calc(100vw - 84px)) !important;
    }
}

@media (max-width: 520px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .content { padding: 12px; }
    .panel { padding: 14px; border-radius: 14px; }
    .panel-actions .btn-primary,
    .panel-actions .btn-secondary {
        flex: 1 1 100%;
    }
    .table-toolbar-item { flex: 1 1 100%; }
    .modal-actions .btn-primary,
    .modal-actions .btn-secondary,
    .modal-actions .btn-danger {
        flex: 1 1 100%;
    }
    .pager .btn-secondary {
        padding: 8px 12px;
        font-size: 13px;
    }
    .scrape-phone-device {
        width: min(320px, calc(100vw - 48px));
        height: min(560px, 55vh);
    }
}
