/* 电子资源管理页：沿用入口页的蔚蓝玻璃风格，信息密度更高，方便后台维护 */

:root {
    --bg-top: #e4f0ff;
    --bg-mid: #bfd9ff;
    --bg-bot: #9cc3ff;

    --ink: #0b1c39;
    --ink-dim: #33507d;
    --ink-faint: #4a6488;

    --line: rgba(37, 99, 235, 0.18);
    --line-strong: rgba(37, 99, 235, 0.34);

    --accent: #2563eb;
    --accent-deep: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, 0.12);

    --ok: #0b6b43;
    --ok-soft: rgba(16, 138, 88, 0.13);
    --ok-line: rgba(11, 107, 67, 0.24);
    --warn: #8a5300;
    --warn-soft: rgba(180, 110, 0, 0.14);
    --warn-line: rgba(138, 83, 0, 0.26);
    --info: #0f6b73;
    --info-soft: rgba(15, 107, 115, 0.12);
    --info-line: rgba(15, 107, 115, 0.26);
    --danger: #a32318;
    --danger-soft: rgba(163, 35, 24, 0.12);
    --danger-line: rgba(163, 35, 24, 0.28);
    --muted: #5b6b85;
    --muted-soft: rgba(91, 107, 133, 0.12);
    --muted-line: rgba(91, 107, 133, 0.26);

    --radius-card: 18px;
    --radius-field: 12px;
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);

    --font-sans: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Noto Sans SC", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

    color-scheme: light;
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    min-height: 100dvh;
    background: radial-gradient(ellipse 60% 50% at 12% 0%, rgba(255, 255, 255, 0.7), transparent 60%),
    radial-gradient(ellipse 56% 48% at 92% 90%, rgba(70, 128, 246, 0.5), transparent 64%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 48%, var(--bg-bot) 100%);
    color: var(--ink);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ---- 顶部 ---- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 26px 24px 6px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand__mark {
    flex: none;
    width: 34px;
    height: 34px;
    border-radius: 11px;
    background: linear-gradient(145deg, #3b82f6, #1d4ed8);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4),
    0 10px 18px -12px rgba(29, 78, 216, 0.9);
}

.brand__copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand__name {
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.brand__tagline {
    color: var(--ink-faint);
    font-size: 0.75rem;
    letter-spacing: 0.02em;
}

.topbar__nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
}

.back {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.62);
    color: var(--ink-dim);
    font-size: 0.8125rem;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.22s var(--ease), border-color 0.22s var(--ease), background-color 0.22s var(--ease);
}

.back:hover {
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.85);
    color: var(--accent-deep);
}

/* 后台导航当前页 */
.back.is-active {
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.92);
    color: var(--accent-deep);
    box-shadow: inset 0 1px 0 #fff;
}

.back__arrow {
    width: 7px;
    height: 7px;
    border-bottom: 1.6px solid currentColor;
    border-left: 1.6px solid currentColor;
    transform: rotate(45deg);
}

/* ---- 布局 ---- */

.layout {
    display: grid;
    grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
    gap: 20px;
    max-width: 1180px;
    margin: 20px auto 60px;
    padding: 0 24px;
    align-items: start;
}

.panel {
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: rgba(255, 255, 255, 0.82);
    -webkit-backdrop-filter: blur(16px) saturate(150%);
    backdrop-filter: blur(16px) saturate(150%);
    box-shadow: inset 0 1px 0 #fff,
    0 24px 48px -34px rgba(23, 63, 150, 0.6);
}

.panel__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 20px 0;
}

.panel__title {
    font-size: 0.9375rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.panel__hint {
    color: var(--ink-faint);
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

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

.form-panel {
    position: sticky;
    top: 20px;
}

.form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px 20px 20px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field__label {
    color: var(--ink-dim);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius-field);
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.5;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.field input,
.field select {
    height: 40px;
    padding: 0 12px;
}

.field textarea {
    padding: 10px 12px;
    resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
    color: #8aa0c0;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

/* 多选状态标签：去掉 fieldset 默认边框，改成一格一格的勾选项 */
.field--tags {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.field--tags legend {
    margin-bottom: 6px;
}

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

.tag-option {
    display: flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink-dim);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.tag-option:hover {
    border-color: var(--line-strong);
}

.tag-option:has(input:checked) {
    border-color: rgba(37, 99, 235, 0.38);
    background: var(--accent-soft);
    color: var(--accent-deep);
}

.tag-option input {
    flex: none;
    width: 15px;
    height: 15px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    accent-color: var(--accent-deep);
    cursor: pointer;
}

.tag-option:focus-within {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.form__actions {
    display: flex;
    gap: 10px;
    margin-top: 2px;
}

.btn {
    height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    transition: transform 0.2s var(--ease), background-color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.btn:active {
    transform: translateY(1px);
}

.btn--primary {
    background: linear-gradient(140deg, var(--accent-deep), var(--accent));
    color: #fff;
    box-shadow: 0 10px 20px -12px rgba(29, 78, 216, 0.9);
}

.btn--primary:hover {
    background: linear-gradient(140deg, #1e40af, var(--accent-deep));
}

.btn--ghost {
    border-color: var(--line-strong);
    background: transparent;
    color: var(--ink-dim);
}

.btn--ghost:hover {
    background: rgba(255, 255, 255, 0.7);
    color: var(--accent-deep);
}

.btn:focus-visible,
.link-btn:focus-visible,
.back:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

/* ---- 列表 ---- */

.list-panel {
    min-width: 0;
}

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 14px 20px 0;
}

.filter {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.filter__label {
    color: var(--ink-faint);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.filter select {
    height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.filter select:hover {
    border-color: var(--line-strong);
}

.filter select:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.filter__reset {
    padding: 5px 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--accent-deep);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s var(--ease);
}

.filter__reset:hover {
    background: rgba(37, 99, 235, 0.1);
}

.filter__reset:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.table-wrap {
    padding: 10px 20px 20px;
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.table th {
    padding: 10px 10px;
    color: var(--ink-faint);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-align: left;
    white-space: nowrap;
}

.table td {
    padding: 12px 10px;
    border-top: 1px solid var(--line);
    vertical-align: middle;
}

.table tbody tr {
    transition: background-color 0.2s var(--ease);
}

.table tbody tr:hover {
    background: rgba(37, 99, 235, 0.05);
}

.cell-name {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 130px;
}

.cell-name__title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--ink);
}

.cell-name__desc {
    color: var(--ink-faint);
    font-size: 0.75rem;
    line-height: 1.4;
}

.cell-url {
    display: block;
    max-width: 260px;
    overflow: hidden;
    color: var(--ink-dim);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.cell-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 220px;
}

.cell-lang {
    white-space: nowrap;
}

/* ---- 排序 ---- */

.cell-sort {
    width: 86px;
    white-space: nowrap;
}

.sort-cell {
    display: flex;
    align-items: center;
    gap: 5px;
}

.sort-handle {
    color: var(--ink-faint);
    font-size: 0.9375rem;
    line-height: 1;
    cursor: grab;
    user-select: none;
}

.sort-handle:hover {
    color: var(--accent-deep);
}

.sort-cell.is-disabled .sort-handle {
    color: var(--line-strong);
    cursor: not-allowed;
}

.sort-input {
    width: 46px;
    height: 30px;
    padding: 0 4px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.8125rem;
    text-align: center;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.sort-input:hover:not(:disabled) {
    border-color: var(--line-strong);
}

.sort-input:focus-visible {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.sort-input:disabled {
    border-style: dashed;
    background: transparent;
    color: var(--ink-faint);
    cursor: not-allowed;
}

/* 拖拽中的行与目标插入位置 */
.table tbody tr.is-dragging {
    opacity: 0.45;
}

.table tbody tr.is-drop-before td {
    box-shadow: inset 0 2px 0 var(--accent);
}

.table tbody tr.is-drop-after td {
    box-shadow: inset 0 -2px 0 var(--accent);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border: 1px solid transparent;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge--verifying {
    border-color: rgba(37, 99, 235, 0.3);
    background: var(--accent-soft);
    color: var(--accent-deep);
}

.badge--rough {
    border-color: var(--info-line);
    background: var(--info-soft);
    color: var(--info);
}

.badge--verified {
    border-color: var(--ok-line);
    background: var(--ok-soft);
    color: var(--ok);
}

.badge--pending {
    border-color: var(--warn-line);
    background: var(--warn-soft);
    color: var(--warn);
}

.badge--major {
    border-color: var(--danger-line);
    background: var(--danger-soft);
    color: var(--danger);
}

.badge--deferred {
    border-color: var(--muted-line);
    background: var(--muted-soft);
    color: var(--muted);
}

.badge--unmarked {
    border-color: var(--line);
    background: rgba(255, 255, 255, 0.7);
    color: var(--ink-faint);
}

.cell-actions {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    white-space: nowrap;
}

.link-btn {
    padding: 4px 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--accent-deep);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.link-btn:hover {
    background: rgba(37, 99, 235, 0.1);
}

.link-btn--danger {
    color: var(--danger);
}

.link-btn--danger:hover {
    background: rgba(163, 35, 24, 0.1);
}

/* ---- 分组 ---- */

.groups {
    max-width: 1180px;
    margin: 18px auto 0;
    padding: 16px 20px 18px;
}

.groups > .panel__head {
    padding: 0;
}

.group-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.group-tab {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 36px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.7);
    color: var(--ink-dim);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s var(--ease), border-color 0.2s var(--ease), background-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}

.group-tab:hover {
    border-color: var(--line-strong);
    background: rgba(255, 255, 255, 0.92);
}

.group-tab.is-selected {
    border-color: rgba(37, 99, 235, 0.42);
    background: rgba(255, 255, 255, 0.98);
    color: var(--accent-deep);
    box-shadow: inset 0 1px 0 #fff, 0 10px 18px -14px rgba(29, 78, 216, 0.9);
}

.group-tab:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.group-tab__name {
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-tab__flag {
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--muted-soft);
    color: var(--muted);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.group-tab__flag--active {
    background: var(--ok-soft);
    color: var(--ok);
}

.group-tab__count {
    min-width: 21px;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-deep);
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    text-align: center;
}

.group-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
}

.group-form {
    display: flex;
    gap: 8px;
}

.group-form input {
    width: 200px;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.8125rem;
    transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.group-form input::placeholder {
    color: #8aa0c0;
}

.group-form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.group-toolbar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.group-delete {
    color: var(--danger);
    border-color: var(--danger-line);
}

.group-delete:hover:not(:disabled) {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: var(--danger-line);
}

.btn--sm {
    height: 34px;
    padding: 0 14px;
    font-size: 0.75rem;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn:disabled:active {
    transform: none;
}

/* ---- 导入弹窗 ---- */

.modal {
    /* 全局 reset 清掉了 dialog 的 margin:auto，这里显式补回来才能居中 */
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(680px, calc(100vw - 32px));
    max-height: min(86vh, 720px);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: rgba(250, 253, 255, 0.98);
    color: var(--ink);
    box-shadow: 0 30px 80px -30px rgba(23, 63, 150, 0.55);
}

.modal::backdrop {
    background: rgba(11, 28, 57, 0.45);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.modal__form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 20px;
}

.modal__head {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.modal__title {
    font-size: 1rem;
    font-weight: 700;
}

.modal__hint {
    color: var(--ink-faint);
    font-size: 0.8125rem;
    line-height: 1.5;
}

.modal__hint span {
    color: var(--accent-deep);
    font-weight: 600;
}

.modal textarea {
    min-height: 220px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    line-height: 1.6;
}

.modal__error {
    color: var(--danger);
    font-size: 0.8125rem;
    line-height: 1.5;
}

.modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.empty {
    padding: 34px 20px 40px;
    color: var(--ink-faint);
    font-size: 0.8125rem;
    text-align: center;
}

/* ---- 提示 ---- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 30px;
    max-width: min(90vw, 460px);
    padding: 10px 18px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(11, 28, 57, 0.9);
    color: #fff;
    font-size: 0.8125rem;
    line-height: 1.5;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px);
    transition: opacity 0.24s var(--ease), transform 0.24s var(--ease);
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.toast.is-error {
    background: rgba(163, 35, 24, 0.94);
}

@media (max-width: 900px) {
    .layout {
        grid-template-columns: 1fr;
    }

    .form-panel {
        position: static;
    }
}

@media (max-width: 560px) {
    .topbar {
        padding: 20px 16px 4px;
    }

    .layout {
        gap: 14px;
        margin-top: 14px;
        padding: 0 16px;
    }

    .brand__tagline {
        display: none;
    }

    .topbar__nav .back:first-child {
        display: none;
    }

    .panel__head {
        padding: 16px 16px 0;
    }

    .form {
        padding: 14px 16px 18px;
    }

    .table-wrap {
        padding: 8px 12px 16px;
    }

    .filters {
        padding: 12px 16px 0;
    }

    .cell-url {
        max-width: 150px;
    }

    .groups {
        margin-top: 14px;
        padding: 14px 16px 16px;
    }

    .groups > .panel__head {
        padding: 0;
    }

    .group-form {
        flex: 1 1 100%;
    }

    .group-form input {
        flex: 1;
        width: auto;
        min-width: 0;
    }

    .group-toolbar__actions {
        width: 100%;
    }

    .modal__form {
        padding: 16px;
    }
}
