@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;500;600;700&display=swap");

:root {
    --bg: #f4f8ff;
    --bg-strong: #eaf2ff;
    --panel: #ffffff;
    --panel-solid: #ffffff;
    --text: #101828;
    --muted: #5f6f84;
    --line: #d8e4f5;
    --line-soft: #edf3fb;
    --blue: #1d6fe9;
    --blue-strong: #0b56c2;
    --blue-soft: #e8f1ff;
    --cyan: #13a8d8;
    --danger: #cf2e2e;
    --success: #138a56;
    --shadow: 0 18px 55px rgba(23, 82, 150, 0.12);
    --shadow-soft: 0 10px 28px rgba(23, 82, 150, 0.08);
    --font-ui: "Noto Sans SC", "Microsoft YaHei UI", "HarmonyOS Sans SC", "MiSans", "PingFang SC", "Segoe UI Variable", "Segoe UI", Arial, sans-serif;
    --font-display: "Noto Sans SC", "Microsoft YaHei UI", "HarmonyOS Sans SC", "MiSans", "PingFang SC", "Segoe UI Variable Display", "Segoe UI", Arial, sans-serif;
    --font-mono: "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-height: 100%;
    margin: 0;
    background:
        radial-gradient(circle at 18% 0%, rgba(29, 111, 233, 0.14), transparent 34%),
        linear-gradient(180deg, #f7fbff 0%, var(--bg) 46%, #ffffff 100%);
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 400;
    line-height: 1.65;
    letter-spacing: 0;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--blue);
    text-decoration: none;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 68px;
    display: flex;
    align-items: center;
    gap: 28px;
    padding: 0 32px;
    border-bottom: 1px solid rgba(216, 228, 245, 0.82);
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(18px);
    box-shadow: 0 10px 30px rgba(31, 75, 130, 0.06);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    line-height: 1;
    white-space: nowrap;
}

.brand-mark {
    width: 36px;
    height: 36px;
    display: inline-grid;
    place-items: center;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--blue), var(--cyan));
    color: #fff;
    font-size: 12px;
    box-shadow: 0 10px 22px rgba(29, 111, 233, 0.26);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-links a {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 0 13px;
    border-radius: 8px;
    color: #42556d;
    font-weight: 600;
    line-height: 1;
    transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}

.nav-links a:hover {
    color: var(--blue);
    background: var(--blue-soft);
    transform: translateY(-1px);
}

.nav-links a.active {
    color: var(--blue-strong);
    background: #edf5ff;
}

.topbar-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    color: #34465c;
    font-weight: 600;
    line-height: 1;
}

.logout-link {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 8px;
    background: #f2f6fc;
    color: #4e6076;
    font-weight: 600;
    line-height: 1;
    transition: background 180ms ease, color 180ms ease;
}

.logout-link:hover {
    background: #e7f0ff;
    color: var(--blue);
}

.page-aura {
    height: 126px;
    margin-bottom: -126px;
    background: linear-gradient(90deg, rgba(29, 111, 233, 0.12), rgba(19, 168, 216, 0.08), transparent);
    pointer-events: none;
}

.shell {
    width: min(1220px, calc(100% - 40px));
    margin: 0 auto;
    padding: 30px 0 32px;
    animation: pageIn 420ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.site-footer {
    width: min(1220px, calc(100% - 40px));
    margin: 0 auto 28px;
    padding: 10px 0 0;
    color: #7890aa;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

.site-footer span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    padding: 0 12px;
    border: 1px solid rgba(216, 228, 245, 0.78);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.68);
    box-shadow: 0 10px 24px rgba(23, 82, 150, 0.06);
}

.page-title {
    margin-bottom: 20px;
}

.page-title p {
    margin: 0 0 6px;
    color: #0f65d8;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.4;
}

.page-title h1,
h1 {
    margin: 0 0 18px;
    color: #102a47;
    font-family: var(--font-display);
    font-size: 30px;
    font-weight: 700;
    line-height: 1.25;
}

.page-title + h1 {
    display: none;
}

h2 {
    margin: 0 0 16px;
    color: #173451;
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
}

.panel,
.stat {
    background: var(--panel);
    border: 1px solid rgba(216, 228, 245, 0.9);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
}

.panel {
    padding: 22px;
    margin-bottom: 18px;
}

.auth-panel {
    max-width: 430px;
    margin: 40px auto 0;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 18px;
}

.stat {
    position: relative;
    overflow: hidden;
    padding: 20px;
    color: #52647a;
    line-height: 1.5;
}

.stat::after {
    content: "";
    position: absolute;
    inset: auto 18px 0;
    height: 3px;
    border-radius: 99px 99px 0 0;
    background: linear-gradient(90deg, var(--blue), var(--cyan));
}

.stat strong {
    display: block;
    margin-top: 8px;
    color: #12355a;
    font-family: var(--font-display);
    font-size: 28px;
    font-weight: 700;
    line-height: 1.1;
}

.stat span {
    display: block;
    margin-top: 8px;
    color: #6b7f98;
    font-size: 12px;
    font-weight: 600;
}

label {
    display: block;
    margin: 12px 0 7px;
    color: #34465c;
    font-weight: 600;
    line-height: 1.45;
}

input,
textarea,
select {
    width: 100%;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px 12px;
    background: #fff;
    color: var(--text);
    font: inherit;
    line-height: 1.45;
    outline: none;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:focus,
textarea:focus,
select:focus {
    border-color: rgba(29, 111, 233, 0.72);
    box-shadow: 0 0 0 4px rgba(29, 111, 233, 0.12);
}

input[type="password"] {
    font-family: "Segoe UI", Arial, sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

textarea {
    min-height: 136px;
    font-family: var(--font-mono);
    line-height: 1.55;
}

.row {
    display: flex;
    gap: 12px;
    align-items: end;
}

.row > * {
    flex: 1;
}

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

.section-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.section-heading h2 {
    margin-bottom: 4px;
}

.section-heading p {
    margin: 0;
}

.compact-heading {
    margin-top: 20px;
}

.field {
    min-width: 0;
}

.field-large {
    grid-column: 1 / -1;
}

.field label span {
    display: block;
    margin-top: 2px;
    color: #7a8ba0;
    font-size: 12px;
    font-weight: 500;
}

.field-large textarea {
    min-height: 190px;
}

.json-source-collapsed {
    display: none;
}

.json-source-visible {
    margin-top: 12px;
}

.json-editor {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
    overflow: hidden;
}

.json-editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line-soft);
    background: #f6f9ff;
}

.json-editor-toolbar span {
    color: #40536b;
    font-size: 13px;
    font-weight: 700;
}

.json-toggle {
    min-height: 32px;
    padding: 0 10px;
    font-size: 12px;
}

.json-editor-body {
    padding: 12px;
}

.json-editor-group {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: #fff;
}

.json-editor-group + .json-editor-group {
    margin-top: 10px;
}

.json-editor-group summary {
    cursor: pointer;
    padding: 10px 12px;
    color: #173451;
    font-weight: 700;
}

.json-editor-content {
    padding: 0 12px 12px;
}

.json-editor-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.json-editor-item {
    margin: 0;
}

.json-editor-item span {
    display: block;
    margin-bottom: 5px;
    color: #5f6f84;
    font-size: 12px;
    font-weight: 600;
}

.json-editor-item input,
.json-editor-item select {
    min-height: 38px;
    padding: 8px 10px;
}

.json-empty {
    margin: 0;
    color: var(--muted);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin: 20px 0 0;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 16px;
}

.pagination span {
    color: #52647a;
    font-weight: 600;
}

.subnav {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 4px 0 18px;
    padding: 6px;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    background: #f6f9ff;
}

.subnav a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 14px;
    border-radius: 8px;
    color: #41556d;
    font-weight: 700;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.subnav a:hover {
    background: #eaf3ff;
    color: var(--blue-strong);
    transform: translateY(-1px);
}

.subnav a.active {
    background: #fff;
    color: var(--blue-strong);
    box-shadow: 0 8px 18px rgba(29, 111, 233, 0.10);
}

.log-filter {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) minmax(190px, 230px) minmax(190px, 230px) auto auto;
    align-items: end;
    gap: 12px;
}

.button,
button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 0;
    border-radius: 8px;
    padding: 0 16px;
    background: linear-gradient(135deg, var(--blue), var(--blue-strong));
    color: #fff;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 12px 24px rgba(29, 111, 233, 0.22);
    transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.button:hover,
button:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 28px rgba(29, 111, 233, 0.28);
    filter: brightness(1.03);
}

.button-secondary {
    background: #eef5ff;
    color: var(--blue-strong);
    box-shadow: none;
}

.button.disabled {
    pointer-events: none;
    opacity: 0.48;
}

.button-danger {
    background: var(--danger);
}

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    border-radius: 8px;
    padding: 0 10px;
    background: #eef5ff;
    color: var(--blue-strong);
    font-size: 12px;
    font-weight: 700;
}

.badge-success {
    background: #ecf9f3;
    color: var(--success);
}

.badge-muted {
    background: #f1f5f9;
    color: #64748b;
}

.permission-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.permission-tags span {
    border-radius: 8px;
    padding: 3px 8px;
    background: #f2f7ff;
    color: #315d95;
    font-size: 12px;
    font-weight: 600;
}

.table-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-actions form {
    margin: 0;
}

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

.permission-option,
.toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfdff;
    color: #1f3044;
}

.permission-option input,
.toggle-row input {
    width: 16px;
    min-height: 16px;
    margin: 0;
}

.permission-option span,
.toggle-row span {
    font-weight: 700;
}

form > .toggle-row {
    margin-top: 18px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

thead {
    background: #f6f9ff;
}

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

tbody tr {
    transition: background 160ms ease;
}

tbody tr:hover {
    background: #f7fbff;
}

th {
    color: #40536b;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
    white-space: nowrap;
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: inherit;
    font-weight: 700;
}

.sort-link:hover,
.sort-link.active {
    color: var(--blue-strong);
}

.sort-indicator {
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    border-radius: 6px;
    background: #e8f1ff;
    color: var(--blue-strong);
    font-size: 12px;
    line-height: 1;
}

td {
    max-width: 260px;
    color: #1f3044;
    line-height: 1.65;
    overflow-wrap: break-word;
}

td:first-child,
th:first-child {
    width: 84px;
}

.dashboard-audit-table td:first-child,
.dashboard-audit-table th:first-child {
    width: 180px;
    white-space: nowrap;
}

.flash {
    border-radius: 8px;
    padding: 13px 15px;
    margin-bottom: 16px;
    border: 1px solid transparent;
    animation: riseIn 260ms ease both;
}

.flash-success {
    background: #ecf9f3;
    border-color: #cceede;
    color: var(--success);
}

.flash-error {
    background: #fff0f0;
    border-color: #ffd5d5;
    color: var(--danger);
}

.muted {
    color: var(--muted);
    line-height: 1.75;
}

.is-leaving {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 170ms ease, transform 170ms ease;
}

@keyframes pageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes riseIn {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 1ms !important;
        scroll-behavior: auto !important;
        transition-duration: 1ms !important;
    }
}

@media (max-width: 760px) {
    .topbar {
        position: static;
        align-items: flex-start;
        flex-direction: column;
        padding: 16px;
        gap: 14px;
    }

    .nav-links {
        width: 100%;
        overflow-x: auto;
    }

    .topbar-actions {
        width: 100%;
        margin-left: 0;
        justify-content: space-between;
    }

    .shell {
        width: min(100% - 28px, 1220px);
        padding-top: 22px;
    }

    .row {
        display: block;
    }

    .log-filter {
        grid-template-columns: 1fr;
    }

    .table-wrap {
        margin-right: -8px;
        padding-bottom: 4px;
    }

    .table-wrap table {
        min-width: 860px;
    }

    .table-wrap th,
    .table-wrap td {
        white-space: nowrap;
        overflow-wrap: normal;
        word-break: normal;
    }

    .table-wrap td {
        max-width: none;
    }

    .table-wrap td:nth-child(2),
    .table-wrap td:nth-child(3),
    .table-wrap td:nth-child(4) {
        max-width: 240px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .field-grid {
        grid-template-columns: 1fr;
    }

    .json-editor-grid {
        grid-template-columns: 1fr;
    }

    .section-heading,
    .form-actions {
        flex-direction: column;
    }

    .pagination {
        justify-content: stretch;
        flex-wrap: wrap;
    }

    .row button {
        width: 100%;
        margin-top: 12px;
    }
}
