:root {
    --bg: #f5f7fb;
    --panel: #fff;
    --line: #e5e9f2;
    --text: #172033;
    --muted: #718096;
    --primary: #1677ff;
    --primary-soft: #eef4ff;
    --danger: #dc2626;
    --danger-soft: #fff1f2;
    --sidebar: #fff;
    --radius: 14px;
    --shadow: 0 8px 30px rgba(16, 24, 39, .06)
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif
}

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

button,
input,
select,
textarea {
    font: inherit
}

.app-shell {
    min-height: 100vh
}

.sidebar {
    border-right: 1px solid var(--line);
    position: fixed;
    inset: 0 auto 0 0;
    width: 252px;
    padding: 22px 12px;
    background: var(--sidebar);
    color: var(--muted);
    display: flex;
    flex-direction: column;
    z-index: 20
}

.brand {
    height: 48px;
    padding: 0 10px;
    display: flex;
    align-items: center;
    gap: 11px;
    color: var(--text);
    font-size: 17px;
    font-weight: 800;
    flex: 0 0 auto
}

.brand-mark {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, #1677ff, #0e5fdb);
    border-radius: 10px
}

.sidebar nav {
    display: grid;
    gap: 3px;
    margin-top: 22px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 4px;
    align-content: start;
    scrollbar-width: thin
}
.sidebar nav::-webkit-scrollbar { width: 6px }
.sidebar nav::-webkit-scrollbar-thumb { background: rgba(148, 163, 184, .45); border-radius: 99px }
.sidebar nav::-webkit-scrollbar-track { background: transparent }

.sidebar nav a,
.sidebar-actions a,
.sidebar-action,
.logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 13px;
    border-radius: 9px;
    font-weight: 600
}

.sidebar nav a i,
.sidebar-actions a i,
.sidebar-action i,
.logout i {
    width: 18px;
    text-align: center
}

.sidebar nav a:hover,
.sidebar nav a.active,
.sidebar-actions a:hover,
.sidebar-actions a.active,
.sidebar-action:hover {
    color: var(--primary);
    background: var(--primary-soft)
}

.logout:hover {
    color: var(--danger);
    background: var(--danger-soft)
}

.sidebar-action {
    width: 100%;
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer
}

.sidebar-actions {
    margin-top: auto;
    display: grid;
    gap: 4px;
    padding-top: 12px;
    border-top: 1px solid var(--line)
}

.logout {
    margin-top: 4px
}

.sidebar {
    transition: transform .22s ease
}

.app-shell.sidebar-hidden .sidebar {
    transform: translateX(-100%)
}

.app-shell.sidebar-hidden .main {
    margin-left: 0;
    width: 100%
}

.main {
    transition: margin-left .22s ease, width .22s ease;
    margin-left: 240px;
    width: calc(100% - 240px);
    max-width: none;
    padding: clamp(22px, 2vw, 38px) clamp(24px, 2.5vw, 48px) 60px
}

.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px
}

.topbar>div {
    flex: 1
}

.topbar h1 {
    margin: 0;
    font-size: 20px;
    line-height: 1.25
}

.topbar p,
.panel-head p {
    margin: 2px 0 0;
    color: var(--muted);
    font-size: 12px
}

.menu-btn {
    display: block;
    border: 0;
    background: transparent;
    font-size: 20px
}

.btn {
    min-height: 39px;
    padding: 0 15px;
    border: 1px solid transparent;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 700
}

.btn.primary {
    background: var(--primary);
    color: #fff
}

.btn.ghost {
    background: #fff;
    border-color: var(--line)
}

.btn.danger {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #fecdd3
}

.btn.small {
    min-height: 34px;
    padding: 0 11px;
    font-size: 12px
}

.btn.full {
    width: 100%
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(130px, 1fr));
    gap: 15px;
    margin-bottom: 18px
}

.stat-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow)
}

.stat-card small {
    display: block;
    color: var(--muted);
    margin-bottom: 2px
}

.stat-card strong {
    font-size: 24px
}

.stat-icon {
    width: 43px;
    height: 43px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    font-size: 17px
}

.stat-icon.blue {
    background: #dbeafe;
    color: #1677ff
}

.stat-icon.violet {
    background: #e8f0ff;
    color: var(--primary)
}

.stat-icon.green {
    background: #e8f0ff;
    color: var(--primary)
}

.stat-icon.orange {
    background: #e8f0ff;
    color: var(--primary)
}

.stat-icon.red {
    background: #fee2e2;
    color: #dc2626
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 14px
}

.panel.narrow {
    width: 100%;
    max-width: none
}

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

.panel h2 {
    font-size: 15px;
    line-height: 1.3;
    margin: 0
}

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

.chart-box {
    height: 300px;
    display: flex;
    justify-content: center
}

.system-list {
    margin: 0
}

.system-list>div {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 15px 0;
    border-bottom: 1px solid var(--line)
}

.system-list>div:last-child {
    border: 0
}

.system-list dt {
    color: var(--muted)
}

.system-list dd {
    margin: 0;
    font-weight: 700
}

.filters {
    display: flex;
    gap: 9px;
    flex-wrap: wrap;
    margin-bottom: 18px
}

.filters input,
.filters select,
input,
textarea,
select {
    min-height: 40px;
    padding: 8px 11px;
    border: 1px solid #d8deea;
    border-radius: 8px;
    background: #fff;
    color: var(--text);
    outline: none
}

.filters .search {
    flex: 1;
    min-width: 220px
}

.filters .logs-keyword-search {
    flex: 0 1 220px;
    min-width: 110px
}

.filters:has(>input[name="page"][value="logs"]) select:not([name="per_page"]) {
    width: calc(4em + 38px);
    min-width: calc(4em + 38px)
}

.log-date-ranges {
    display: inline-flex;
    gap: 5px;
    order: 1
}

.log-date-ranges .btn {
    min-height: 36px;
    padding-inline: 11px
}

input:focus,
textarea:focus,
select:focus {
    border-color: #6b9bf7;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .1)
}

.check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.check input[type="checkbox"] {
    width: 16px;
    height: 16px;
    min-height: 0;
    margin: 0;
    padding: 0;
    flex: 0 0 16px;
}

.table-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
    color: var(--muted)
}

.table-actions .actions {
    flex-wrap: wrap;
    justify-content: flex-end
}

.auto-refresh.paused {
    color: var(--muted);
    background: #f8fafc
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 10px
}

.detailed-log-table {
    min-width: 1898px;
    table-layout: fixed
}

.detailed-log-table th,
.detailed-log-table td {
    padding: 9px 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 0;
    height: 42px
}

.detailed-log-table .truncate {
    max-width: 0
}

.detailed-log-table .badge {
    vertical-align: middle;
    padding: 2px 3px;
    font-size: 11px
}

.detailed-log-table th {
    position: relative
}

.column-resizer {
    position: absolute;
    z-index: 2;
    top: 0;
    right: -3px;
    width: 7px;
    height: 100%;
    cursor: col-resize;
    touch-action: none
}

.column-resizer:after {
    content: "";
    position: absolute;
    top: 25%;
    bottom: 25%;
    left: 3px;
    width: 1px;
    background: #cbd5e1
}

.column-resizer:hover:after,
.resizing-columns .column-resizer:after {
    background: var(--primary);
    width: 2px
}

.resizing-columns {
    cursor: col-resize;
    user-select: none
}

.detail-groups {
    max-height: 68vh;
    overflow: auto;
    text-align: left;
    display: grid;
    gap: 12px
}

.detail-group {
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden
}

.detail-group h3 {
    margin: 0;
    padding: 8px 12px;
    background: #f8fafc;
    font-size: 13px
}

.detail-row {
    display: grid;
    grid-template-columns: 130px minmax(0, 1fr);
    gap: 12px;
    padding: 7px 12px;
    border-top: 1px solid var(--line)
}

.detail-row b {
    color: #58677d
}

.detail-row span {
    word-break: break-all
}

.detail-raw summary {
    cursor: pointer;
    font-weight: 700;
    padding: 8px
}

.detail-raw pre {
    white-space: pre-wrap;
    word-break: break-all;
    background: #0f172a;
    color: #dbeafe;
    padding: 12px;
    border-radius: 8px;
    max-height: 260px;
    overflow: auto
}

table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed
}

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

th {
    background: #f8fafc;
    color: #58677d;
    font-size: 12px;
    text-transform: uppercase
}

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

tbody tr.editable-row {
    cursor: pointer
}

tbody tr:hover {
    background: #fafcff
}

.nowrap {
    white-space: nowrap
}

.mono {
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 12px
}

.truncate {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px
}

.empty {
    text-align: center !important;
    padding: 45px !important;
    color: var(--muted)
}

.badge {
    display: inline-flex;
    padding: 3px 9px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 10px
}

.badge.click {
    background: #dcfce7;
    color: #15803d
}

.badge.visit {
    background: #ffedd5;
    color: #c2410c
}

.badge.cloak {
    background: #fee2e2;
    color: #b91c1c
}

.inline-input {
    width: 100%;
    min-width: 80px;
    height: 34px;
    padding: 5px 7px;
    border: 1px solid #93b4f5;
    border-radius: 6px;
    background: #fff
}

.editing td {
    padding: 7px
}

.icon-btn {
    width: 33px;
    height: 33px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    display: inline-grid;
    place-items: center;
    cursor: pointer
}

.icon-btn.danger {
    color: var(--danger)
}

.actions {
    display: flex;
    gap: 6px
}

.status-toggle {
    cursor: pointer;
    user-select: none
}

.status-toggle:hover {
    background: var(--primary-soft)
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 7px
}

.status-dot.on {
    background: #22c55e
}

.status-dot.off {
    background: #94a3b8
}

.pagination {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 18px
}

.pagination a {
    width: 35px;
    height: 35px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px
}

.pagination a.active {
    background: var(--primary);
    color: #fff
}

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

.conversion-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 16px
}

.conversion-card label {
    display: grid;
    gap: 6px;
    margin-top: 12px
}

.conversion-title,
.conversion-values {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px
}

.conversion-title .check {
    display: flex;
    margin: 0
}

.conversion-title .conversion-switch {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0;
    cursor: pointer
}

.conversion-switch input {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 0;
    padding: 0;
    border: 0;
    opacity: 0
}

.conversion-switch span {
    position: relative;
    width: 40px;
    height: 22px;
    border-radius: 999px;
    background: #cbd5e1;
    transition: background .18s
}

.conversion-switch span::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .28);
    transition: transform .18s
}

.conversion-switch input:checked+span {
    background: var(--primary)
}

.conversion-switch input:checked+span::after {
    transform: translateX(18px)
}

.conversion-switch input:focus-visible+span {
    outline: 2px solid var(--primary);
    outline-offset: 2px
}

.conversion-switch em {
    font-style: normal;
    font-weight: 600
}

.conversion-values label {
    flex: 1
}

.code-editor {
    width: 100%;
    font: 13px/1.6 "SFMono-Regular", Consolas, monospace;
    background: #0f172a;
    color: #dbeafe;
    border: 0;
    padding: 18px
}

.form-footer,
.dialog-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 15px;
    color: var(--muted)
}

dialog {
    width: min(620px, calc(100% - 30px));
    padding: 0;
    border: 0;
    border-radius: 14px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, .3)
}

dialog::backdrop {
    background: rgba(15, 23, 42, .55)
}

dialog form {
    padding: 22px
}

dialog textarea {
    width: 100%
}

.dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px
}

.dialog-head h2 {
    margin: 0
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px
}

.form-grid label {
    display: grid;
    gap: 6px;
    font-weight: 700
}

#userPagePermissionsForm .panel-head h3 {
    margin: 0;
    font-size: 14px;
    line-height: 1.3
}

#userPagePermissionsForm .permission-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px 12px
}

#userPagePermissionsForm .link-permission-grid,
#userPagePermissionsForm .page-permission-grid,
#userPagePermissionsForm .access-permission-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr))
}

#userPagePermissionsForm .permission-grid label {
    gap: 4px
}

#userPagePermissionsForm .permission-grid select {
    min-width: 0
}

#userPagePermissionsForm .permission-switch {
    display: grid;
    grid-template-columns: 68px 240px;
    justify-content: start;
    align-items: center;
    gap: 6px;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0
}

#userPagePermissionsForm .permission-switch-title {
    margin: 0;
    padding: 0;
    font-size: 12px;
    font-weight: 700
}

#userPagePermissionsForm .permission-segments {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--bg)
}

#userPagePermissionsForm .permission-segments label {
    display: block;
    min-width: 0;
    font-size: 11px;
    cursor: pointer;
    font-weight: 600
}

#userPagePermissionsForm .permission-segments label+label {
    border-left: 1px solid var(--line)
}

#userPagePermissionsForm .permission-segments input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none
}

#userPagePermissionsForm .permission-segments span {
    display: block;
    padding: 5px 1px;
    color: var(--muted);
    text-align: center;
    white-space: nowrap;
    transition: background .15s, color .15s
}

#userPagePermissionsForm .permission-segments label:hover span {
    background: var(--panel)
}

#userPagePermissionsForm .permission-segments input:focus-visible+span {
    box-shadow: inset 0 0 0 2px var(--primary)
}

#userPagePermissionsForm .permission-segments input[value="hidden"]:checked+span {
    background: #64748b;
    color: #fff
}

#userPagePermissionsForm .permission-segments input[value="read"]:checked+span {
    background: #1677ff;
    color: #fff
}

#userPagePermissionsForm .permission-segments input[value="edit"]:checked+span {
    background: #16a34a;
    color: #fff
}

@media(max-width:1199px) {
    #userPagePermissionsForm .permission-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr))
    }
}

@media(max-width:699px) {
    #userPagePermissionsForm .permission-grid {
        grid-template-columns: 1fr
    }
}

.form-grid .span-2 {
    grid-column: span 2
}

.form-grid .check {
    display: flex;
    align-items: center;
    flex-direction: row
}

.form-grid .check input {
    min-height: auto
}

.login-body {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background: radial-gradient(circle at 20% 10%, #dbeafe, transparent 35%), var(--bg)
}

.login-card {
    width: min(390px, calc(100% - 30px));
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 32px;
    box-shadow: 0 30px 80px rgba(15, 23, 42, .12)
}

.login-card>.brand-mark {
    margin-bottom: 20px
}

.login-card h1 {
    margin: 0;
    font-size: 25px
}

.login-card>p {
    margin: 5px 0 22px;
    color: var(--muted)
}

.login-card form {
    display: grid;
    gap: 10px
}

.login-card label {
    font-weight: 700
}

.alert {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 15px
}

.alert.error {
    background: #fef2f2;
    color: #b91c1c
}

.dashboard-stats .stat-card em {
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-style: normal;
    margin-top: 2px
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr);
    gap: 18px
}

.dashboard-grid.triple {
    grid-template-columns: repeat(3, minmax(0, 1fr))
}

.dashboard-wide {
    min-width: 0
}

.trend-box {
    height: 320px
}

.trend-actions {
    display: flex;
    align-items: center;
    gap: 6px
}

.health-list {
    display: grid
}

.health-list>div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 0;
    border-bottom: 1px solid var(--line)
}

.health-list>div:last-child {
    border: 0
}

.health-list span {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--muted)
}

.health-list b {
    font-size: 12px;
    text-align: right
}

.health-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #94a3b8
}

.health-dot.ok {
    background: #22c55e;
    box-shadow: 0 0 0 4px #dcfce7
}

.health-dot.warn {
    background: #f59e0b;
    box-shadow: 0 0 0 4px #fef3c7
}

.health-dot.muted {
    background: #94a3b8
}

.compact-table table {
    table-layout: auto
}

.compact-table td small {
    display: block;
    color: var(--muted);
    max-width: 480px
}

.ranking-list {
    display: grid;
    gap: 14px
}

.ranking-list>div {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 4px 12px;
    align-items: center
}

.ranking-list span small {
    display: block;
    color: var(--muted);
    font-size: 11px
}

.ranking-list em {
    font-style: normal;
    font-weight: 800
}

.ranking-list .progress {
    grid-column: 1/-1;
    height: 6px;
    background: #edf1f7;
    border-radius: 99px;
    overflow: hidden
}

.ranking-list .progress u {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    border-radius: inherit
}

.ranking-list.simple>div {
    padding: 9px 0;
    border-bottom: 1px solid var(--line)
}

.ranking-list.simple>div:last-child {
    border: 0
}

.dashboard-empty {
    color: var(--muted);
    text-align: center;
    padding: 30px 10px
}

.dashboard-empty i {
    display: block;
    color: #22c55e;
    font-size: 28px;
    margin-bottom: 9px
}

.quick-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px
}

.quick-actions a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-weight: 700
}

.quick-actions a:hover {
    border-color: #93b4f5;
    background: #f7faff
}

.quick-actions i {
    color: var(--primary)
}

.dimension-panel {
    padding-bottom: 12px
}

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

.insight-card {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 11px 12px
}

.insight-grid.insight-collapsed .insight-card:nth-child(n+7) {
    display: none
}

.insight-card h3 {
    margin: 0 0 5px;
    font-size: 13px
}

.compact-rank {
    gap: 0
}

.compact-rank>div {
    min-width: 0;
    padding: 6px 0
}

.compact-rank span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.compact-rank b {
    font-size: 12px
}

.compact-rank .dashboard-empty {
    padding: 18px 4px
}

.risk-metrics {
    display: grid;
    gap: 0
}

.risk-metrics>div {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line)
}

.risk-metrics>div:last-child {
    border: 0
}

.risk-metrics span {
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap
}

.risk-metrics b {
    color: var(--danger)
}

.dimension-switch {
    display: flex;
    justify-content: flex-end;
    gap: 3px;
    margin: -25px 0 6px
}

.dimension-switch button {
    border: 0;
    border-radius: 6px;
    padding: 3px 7px;
    background: #eef2f7;
    color: var(--muted);
    font-size: 11px;
    cursor: pointer
}

.dimension-switch button.active {
    background: var(--primary);
    color: #fff
}

.dimension-chart {
    height: 230px;
    min-width: 0
}

.insight-card .dimension-chart {
    height: 220px
}

html[data-theme="dark"] {
    color-scheme: dark
}

[data-theme="dark"] {
    --bg: #0b1220;
    --panel: #111b2e;
    --line: #26344a;
    --text: #e5edf8;
    --muted: #91a0b8;
    --sidebar: #070d18;
    --primary-soft: #172b4d;
    --danger-soft: #351923;
    --shadow: 0 8px 30px rgba(0, 0, 0, .24)
}

[data-theme="dark"] .sidebar {
    color: #aab4c5;
    border-right-color: #26344a
}

[data-theme="dark"] .brand {
    color: #fff
}

[data-theme="dark"] .sidebar nav a:hover,
[data-theme="dark"] .sidebar nav a.active,
[data-theme="dark"] .sidebar-actions a:hover,
[data-theme="dark"] .sidebar-actions a.active,
[data-theme="dark"] .sidebar-action:hover {
    color: #fff;
    background: rgba(255, 255, 255, .1)
}

[data-theme="dark"] .sidebar-actions {
    border-top-color: #26344a
}

[data-theme="dark"] .logout:hover {
    color: #fda4af;
    background: #351923
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select,
[data-theme="dark"] .btn.ghost,
[data-theme="dark"] .icon-btn,
[data-theme="dark"] .inline-input {
    background: #111b2e;
    color: var(--text);
    border-color: var(--line)
}

[data-theme="dark"] th,
[data-theme="dark"] .detail-group h3,
[data-theme="dark"] .auto-refresh.paused {
    background: #172238;
    color: #b7c4d8
}

[data-theme="dark"] tbody tr:hover,
[data-theme="dark"] tbody tr.editable-row:hover,
[data-theme="dark"] .quick-actions a:hover {
    background: #152138
}

[data-theme="dark"] .code-editor,
[data-theme="dark"] .detail-raw pre {
    background: #050a13
}

[data-theme="dark"] dialog {
    background: var(--panel);
    color: var(--text)
}

[data-theme="dark"] .dimension-switch button {
    background: #26344a;
    color: #b7c4d8
}

[data-theme="dark"] .dimension-switch button.active {
    background: var(--primary);
    color: #fff
}

/* ---------------------------------------------------------------- 分组导航 */

.nav-group { display: block }

.nav-group-head {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 13px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    text-align: left;
    cursor: pointer
}

.nav-group-head i:first-child { width: 18px; text-align: center; flex: 0 0 18px }
.nav-group-head > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.nav-group-head:hover { color: var(--text); background: var(--hover, #f1f5f9) }
.nav-group-head .nav-caret { margin-left: auto; font-size: 10px; opacity: .65; transition: transform .18s }
.nav-group.collapsed .nav-group-head .nav-caret { transform: rotate(-90deg) }
.nav-group.collapsed .nav-group-body { display: none }
.nav-group-body { display: flex; flex-direction: column; gap: 2px; padding: 2px 0 4px 10px }
.nav-group-body a { padding: 9px 13px; font-size: 12.5px }
.nav-group-body a i { font-size: 12px; flex: 0 0 14px }
.nav-group-body a > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.nav-group-body a.active { color: var(--primary); background: var(--primary-soft) }

/* 三级（如 创意管理 > 斗篷 > 投放链接）：标题更小、缩进更深 */
.nav-subgroup { margin: 2px 0 }
.nav-subgroup > .nav-group-head {
    padding: 8px 12px;
    font-size: 12.5px;
    font-weight: 600;
    gap: 10px
}
.nav-subgroup > .nav-group-head i:first-child { width: 16px; font-size: 12px }
.nav-subgroup > .nav-group-body { padding-left: 14px }
.nav-subgroup > .nav-group-body a { padding: 7px 12px; font-size: 12px }
.nav-subgroup > .nav-group-body a i { font-size: 11px }

[data-theme="dark"] .nav-group-head:hover { background: #152138 }
[data-theme="dark"] .nav-group-body a.active { background: var(--primary-soft); color: var(--primary) }

[data-theme="dark"] .btn.danger {
    background: #351923;
    color: #fda4af;
    border-color: #6b2537
}

[data-theme="dark"] .stat-icon.blue {
    background: #172b4d;
    color: #60a5fa
}

[data-theme="dark"] .stat-icon.violet {
    background: #172b4d;
    color: #60a5fa
}

[data-theme="dark"] .stat-icon.green {
    background: #172b4d;
    color: #60a5fa
}

[data-theme="dark"] .stat-icon.orange {
    background: #172b4d;
    color: #60a5fa
}

[data-theme="dark"] .stat-icon.red {
    background: #421d24;
    color: #fb7185
}

[data-theme="dark"] .badge.click {
    background: #123524;
    color: #4ade80
}

[data-theme="dark"] .badge.visit {
    background: #422514;
    color: #fb923c
}

[data-theme="dark"] .badge.cloak {
    background: #421d24;
    color: #fb7185
}

[data-theme="dark"] .table-wrap,
[data-theme="dark"] .login-card {
    background: var(--panel)
}

[data-theme="dark"] .login-body {
    background: radial-gradient(circle at 20% 10%, #172b4d, transparent 35%), var(--bg)
}

[data-theme="dark"] .pagination a,
[data-theme="dark"] .quick-actions a,
[data-theme="dark"] .insight-card,
[data-theme="dark"] .detail-group {
    border-color: var(--line)
}

[data-theme="dark"] .ranking-list .progress {
    background: #26344a
}

[data-theme="dark"] .status-toggle:hover {
    background: #172b4d
}

[data-theme="dark"] .alert.error {
    background: #351923;
    color: #fda4af
}

[data-theme="dark"] .swal2-popup {
    background: var(--panel);
    color: var(--text)
}

[data-theme="dark"] .swal2-title,
[data-theme="dark"] .swal2-html-container {
    color: var(--text)
}

[data-theme="dark"] .swal2-timer-progress-bar {
    background: #60a5fa
}

[data-theme="dark"] ::-webkit-scrollbar {
    width: 11px;
    height: 11px
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: #0b1220
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #34445e;
    border: 2px solid #0b1220;
    border-radius: 8px
}

[data-theme="dark"] ::-webkit-calendar-picker-indicator {
    filter: invert(1)
}

@media (max-width:1100px) {
    .stats-grid {
        grid-template-columns: repeat(3, 1fr)
    }

    .dashboard-grid,
    .dashboard-grid.triple {
        grid-template-columns: 1fr 1fr
    }

    .dashboard-wide {
        grid-column: 1/-1
    }
}

@media(max-width:760px) {
    .conversion-grid {
        grid-template-columns: 1fr
    }

    .sidebar {
        transform: translateX(-100%);
        transition: .2s
    }

    .sidebar.open,
    .app-shell.sidebar-hidden .sidebar.open {
        transform: none
    }

    .main {
        margin-left: 0;
        width: 100%;
        padding: 18px 14px 40px
    }

    .menu-btn {
        display: block
    }

    .topbar h1 {
        font-size: 18px
    }

    .topbar .btn.ghost {
        display: none
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr
    }

    .grid-two,
    .dashboard-grid,
    .dashboard-grid.triple {
        grid-template-columns: 1fr
    }

    .dashboard-wide {
        grid-column: auto
    }

    .filters>* {
        width: 100%
    }

    .filters:has(>input[name="page"][value="logs"]) select:not([name="per_page"]) {
        width: 100%
    }

    .log-date-ranges .btn {
        flex: 1
    }

    .filters .logs-keyword-search {
        flex-basis: 100%
    }

    .form-grid {
        grid-template-columns: 1fr
    }

    .form-grid .span-2 {
        grid-column: auto
    }

    table {
        min-width: 900px
    }
}

/* ===================================================================
   Firefly 视觉规范（覆盖层）
   参考 Firefly ADS 后台：白侧栏 + 浅灰工作区 + 8px 圆角 + #1677FF
   追加在末尾，靠层叠覆盖前面的同选择器规则；删除本段即可整体回滚
   =================================================================== */

:root {
    --bg: #f5f7fa;
    --panel: #fff;
    --line: #ebeef5;
    --text: #1f2329;
    --muted: #8a919f;
    --primary: #1677ff;
    --primary-soft: #e8f3ff;
    --danger: #f53f3f;
    --danger-soft: #ffece8;
    --sidebar: #fff;
    --radius: 8px;
    --shadow: 0 1px 2px rgba(0, 0, 0, .04);
    --hover: #f5f7fa
}

body {
    font: 14px/1.5715 -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale
}

/* ---------- 侧栏：184px、紧凑行高、选中浅蓝底 ---------- */

.sidebar {
    width: 184px;
    padding: 12px 8px;
    border-right: 1px solid var(--line)
}

.main {
    margin-left: 184px;
    width: calc(100% - 184px);
    padding: 20px 24px 40px
}

.brand {
    height: 44px;
    padding: 0 8px;
    gap: 9px;
    font-size: 15px;
    font-weight: 700
}

.brand-mark {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    font-size: 14px;
    background: linear-gradient(135deg, #1677ff, #0e5fdb)
}

.sidebar nav {
    margin-top: 14px;
    gap: 1px
}

.sidebar nav a,
.sidebar-actions a,
.sidebar-action,
.logout {
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 400;
    color: #4e5969
}

.sidebar nav a i,
.sidebar-actions a i,
.sidebar-action i,
.logout i {
    width: 15px;
    font-size: 13px
}

.sidebar nav a:hover,
.sidebar-actions a:hover,
.sidebar-action:hover {
    color: var(--primary);
    background: var(--hover)
}

.sidebar nav a.active,
.sidebar-actions a.active {
    position: relative;
    color: var(--primary);
    background: var(--primary-soft);
    font-weight: 500
}

.sidebar nav a.active::before,
.sidebar-actions a.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    width: 3px;
    height: 14px;
    margin-top: -7px;
    border-radius: 0 2px 2px 0;
    background: var(--primary)
}

.nav-group-head {
    padding: 8px 10px;
    border-radius: 6px;
    gap: 8px;
    font-size: 13px;
    font-weight: 400;
    color: #4e5969
}

.nav-group-head i:first-child {
    width: 15px;
    flex: 0 0 15px;
    font-size: 13px
}

.nav-group-head:hover {
    color: var(--primary);
    background: var(--hover)
}

.nav-group-head .nav-caret {
    font-size: 10px;
    opacity: .5
}

.nav-group-body {
    padding: 1px 0 3px 6px;
    gap: 1px
}

.nav-group-body a {
    padding: 7px 10px 7px 17px;
    font-size: 12.5px;
    font-weight: 400
}

.nav-group-body a i {
    font-size: 11px;
    flex: 0 0 13px
}

.nav-subgroup > .nav-group-head {
    padding: 7px 10px 7px 17px;
    font-size: 12.5px;
    gap: 7px
}

.nav-subgroup > .nav-group-head i:first-child {
    width: 13px;
    font-size: 11px
}

.nav-subgroup > .nav-group-body {
    padding-left: 8px
}

.nav-subgroup > .nav-group-body a {
    padding: 6px 10px 6px 19px;
    font-size: 12px
}

.sidebar-actions {
    padding-top: 8px;
    border-top: 1px solid var(--line);
    gap: 1px
}

/* ---------- 页面标题与顶栏 ---------- */

.topbar {
    margin-bottom: 14px
}

.topbar h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text)
}

.topbar p,
.panel-head p {
    font-size: 12px;
    color: var(--muted)
}

/* ---------- 卡片 ---------- */

.panel {
    padding: 18px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: none
}

.panel-head {
    margin-bottom: 14px
}

.panel h2,
.dialog-head h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text)
}

.stat-card {
    padding: 16px;
    gap: 12px;
    border-radius: var(--radius);
    box-shadow: none
}

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

.stat-card strong {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -.2px
}

.stat-icon {
    width: 38px;
    height: 38px;
    border-radius: 8px;
    font-size: 15px
}

.stat-icon.blue,
.stat-icon.violet,
.stat-icon.green,
.stat-icon.orange {
    background: var(--primary-soft);
    color: var(--primary)
}

.stat-icon.red {
    background: var(--danger-soft);
    color: var(--danger)
}

/* ---------- 按钮 ---------- */

.btn {
    min-height: 32px;
    padding: 0 14px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 400;
    gap: 6px
}

.btn.primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff
}

.btn.primary:hover {
    background: #4096ff;
    border-color: #4096ff
}

.btn.ghost {
    background: #fff;
    border-color: #d9dde3;
    color: #4e5969
}

.btn.ghost:hover {
    border-color: var(--primary);
    color: var(--primary)
}

.btn.danger {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: #ffd2cc
}

.btn.small {
    min-height: 28px;
    padding: 0 10px;
    font-size: 12px
}

.icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px
}

/* ---------- 表单 ---------- */

.filters {
    gap: 8px;
    margin-bottom: 14px
}

.filters input,
.filters select,
input,
textarea,
select {
    min-height: 32px;
    padding: 4px 10px;
    border: 1px solid #d9dde3;
    border-radius: 6px;
    font-size: 13px;
    color: var(--text);
    background: #fff
}

input::placeholder,
textarea::placeholder {
    color: #b6bcc6
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(22, 119, 255, .12)
}

.inline-input {
    height: 30px;
    border-color: #b7d3ff;
    border-radius: 6px
}

/* ---------- 表格 ---------- */

.table-wrap {
    border: 1px solid var(--line);
    border-radius: var(--radius)
}

th,
td {
    padding: 11px 12px;
    border-bottom: 1px solid #f0f2f5
}

th {
    background: #fafbfc;
    color: #646a73;
    font-size: 12px;
    font-weight: 500;
    text-transform: none;
    white-space: nowrap
}

tbody tr:hover {
    background: #f7f9fc
}

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

.empty {
    padding: 48px !important;
    color: var(--muted)
}

.badge {
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500
}

.badge.click {
    background: #e8ffea;
    color: #00a854
}

.badge.visit {
    background: #fff3e8;
    color: #d25f00
}

.badge.cloak {
    background: var(--danger-soft);
    color: var(--danger)
}

.status-dot {
    width: 6px;
    height: 6px;
    margin-right: 6px
}

/* ---------- 分页 ---------- */

.pagination {
    gap: 4px;
    margin-top: 16px;
    justify-content: flex-end
}

.pagination a {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    font-size: 13px;
    color: #4e5969
}

.pagination a:hover {
    border-color: var(--primary);
    color: var(--primary)
}

.pagination a.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff
}

/* ---------- 弹窗 ---------- */

dialog {
    border-radius: 8px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .16)
}

dialog form {
    padding: 20px 24px
}

.dialog-head {
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line)
}

.form-grid label {
    font-size: 13px;
    font-weight: 400;
    color: #4e5969
}

/* ---------- 分段控件 / 标签页 ---------- */

.links-tabs {
    background: #f2f3f5;
    border-radius: 6px;
    padding: 3px
}

.links-tabs button {
    min-height: 30px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 400;
    color: #4e5969
}

.links-tabs button.active {
    background: #fff;
    color: var(--primary);
    font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .06)
}

.dimension-switch button {
    background: #f2f3f5;
    border-radius: 4px;
    font-size: 12px;
    padding: 3px 8px
}

.dimension-switch button.active {
    background: var(--primary)
}

.dash-chip {
    border-color: var(--line);
    background: #fafbfc;
    color: var(--muted);
    font-size: 12px
}

/* ---------- 登录页 ---------- */

.login-body {
    background: #f5f7fa
}

.login-card {
    width: min(380px, calc(100% - 30px));
    border-radius: 12px;
    padding: 32px 28px;
    border-color: var(--line);
    box-shadow: 0 4px 24px rgba(0, 0, 0, .06)
}

.login-card h1 {
    font-size: 20px;
    font-weight: 600
}

.login-card label {
    font-size: 13px;
    font-weight: 400;
    color: #4e5969
}

/* ---------- 深色主题保持原样（覆盖上面的 :root） ---------- */

[data-theme="dark"] {
    --bg: #0f1218;
    --panel: #1a1d24;
    --line: #2a2f3a;
    --text: #e8eaed;
    --muted: #8a919f;
    --primary-soft: #16243c;
    --danger-soft: #35201e;
    --sidebar: #15181e;
    --hover: #23272f
}

[data-theme="dark"] .sidebar nav a,
[data-theme="dark"] .sidebar-actions a,
[data-theme="dark"] .sidebar-action,
[data-theme="dark"] .logout,
[data-theme="dark"] .nav-group-head {
    color: #a9b0bd
}

[data-theme="dark"] th {
    background: #20242c;
    color: #9aa1ad
}

[data-theme="dark"] tbody tr:hover {
    background: #20242c
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: #23272f;
    border-color: #333944
}

[data-theme="dark"] .links-tabs {
    background: #23272f
}

[data-theme="dark"] .links-tabs button.active {
    background: #2c313a
}

[data-theme="dark"] .btn.ghost {
    background: #23272f;
    border-color: #333944;
    color: #c9cfd9
}

[data-theme="dark"] .login-card {
    background: #1a1d24
}

@media (max-width: 1100px) {
    .sidebar {
        width: 168px
    }

    .main {
        margin-left: 168px;
        width: calc(100% - 168px);
        padding: 16px 18px 36px
    }
}

@media (max-width: 760px) {
    .sidebar {
        width: 232px;
        padding: 12px 10px
    }

    .main {
        margin-left: 0;
        width: 100%;
        padding: 14px 12px 32px
    }

    .panel {
        padding: 14px
    }

    .topbar h1 {
        font-size: 15px
    }
}

/* ============================================================
   统一视觉：把老页面拉到与广告管理页一致的观感
   只改颜色 / 圆角 / 间距 / 字体，不动布局与交互
   ============================================================ */

/* 面板 */
.panel {
  background: #fff;
  border: 1px solid #e8ebf0;
  border-radius: 10px;
  box-shadow: none;
}
.panel-head { padding: 14px 16px; border-bottom: 1px solid #e8ebf0; }
.panel-head h2 { font-size: 14px; font-weight: 600; color: #111827; margin: 0 0 2px; }
.panel-head p { font-size: 12px; color: #9ca3af; margin: 0; }

/* 指标卡 */
.dash-kpi, .stat-card {
  background: #fafbfc;
  border: 1px solid #eef1f6;
  border-radius: 8px;
}
.dash-kpi b, .stat-card b { font-size: 18px; font-weight: 600; color: #111827; }
.dash-kpi span, .stat-card span { font-size: 11px; color: #9ca3af; }

/* 表格 */
.table-wrap { border: none; }
.table-wrap table thead th {
  background: #f8fafc;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  padding: 9px 12px;
  border-bottom: 1px solid #e8ebf0;
  white-space: nowrap;
}
.table-wrap table tbody td {
  font-size: 12.5px;
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
}
.table-wrap table tbody tr:nth-child(even) { background: #fcfcfd; }
.table-wrap table tbody tr:hover { background: #eff6ff; }

/* 按钮 */
.btn { border-radius: 6px; font-size: 12.5px; border-color: #e2e6ee; }
.btn.primary, .btn.pri { background: #2563eb; border-color: #2563eb; }
.btn.ghost { border-color: #e2e6ee; }
.btn.small { height: 28px; font-size: 12px; }

/* 标签 / 徽标 */
.dash-chip, .chip {
  border-radius: 4px;
  font-size: 12px;
  background: #f1f5f9;
  color: #475569;
}

/* 标题与间距 */
.topbar h1 { font-size: 16px; font-weight: 600; }
.topbar-sub, .topbar p { font-size: 12px; color: #9ca3af; }
.empty { color: #9ca3af; font-size: 13px; }
