* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: linear-gradient(180deg, #f5f8ff 0, #eef4ff 42%, #f8fbff 100%);
    color: #0f172a;
}

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

.sidebar {
    width: 240px;
    background: linear-gradient(180deg, #0b1732 0, #131f40 100%);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 20px 14px;
    transition: width 0.22s ease, padding 0.22s ease;
}

.sidebar-brand {
    display: flex;
    gap: 14px;
    align-items: center;
    padding: 10px 12px 24px;
    min-height: 82px;
}

.brand-cube,
.brand-mark {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, #2dd4bf, #2563eb);
    box-shadow: 0 15px 35px rgba(37, 99, 235, 0.35);
}

.sidebar-brand strong {
    display: block;
    font-size: 17px;
}

.sidebar-brand span {
    display: block;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
}

.menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.menu-group {
    display: grid;
    gap: 6px;
}

.menu-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 28px;
    gap: 8px;
    align-items: center;
}

.menu-item,
.submenu-item,
.plain-link {
    color: inherit;
    text-decoration: none;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 14px;
    color: #dbeafe;
    font-size: 14px;
    transition: background 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.menu-item.active,
.menu-item:hover {
    background: linear-gradient(90deg, #2f73f6, #3d7af7);
    color: #fff;
    box-shadow: 0 12px 32px rgba(37, 99, 235, 0.28);
}

.menu-item.has-children:not(.active):hover {
    background: rgba(47, 115, 246, 0.16);
    box-shadow: none;
}

.menu-group.open > .menu-row .menu-item.has-children:not(.active) {
    background: rgba(255, 255, 255, 0.04);
}

.menu-group.open > .menu-row .menu-expand {
    color: #fff;
}

.menu-icon {
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 18px;
    color: currentColor;
    opacity: 0.96;
}

.menu-icon svg,
.menu-expand svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.menu-label {
    flex: 1;
    min-width: 0;
    transition: opacity 0.18s ease;
}

.menu-expand {
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: rgba(203, 213, 225, 0.92);
    cursor: pointer;
    border-radius: 10px;
    transition: color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.menu-expand:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}

.menu-expand.open svg {
    transform: rotate(180deg);
}

.submenu {
    display: grid;
    gap: 6px;
    padding: 0 0 0 26px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.22s ease, opacity 0.22s ease, padding-top 0.22s ease, padding-bottom 0.22s ease;
}

.submenu.open {
    max-height: 280px;
    opacity: 1;
    padding-top: 2px;
    padding-bottom: 6px;
}

.submenu-item {
    display: flex;
    align-items: center;
    min-height: 36px;
    padding: 0 12px;
    border-radius: 12px;
    color: #cbd5e1;
    font-size: 13px;
    transition: background 0.2s ease, color 0.2s ease;
}

.submenu-item.active,
.submenu-item:hover {
    background: rgba(37, 99, 235, 0.22);
    color: #fff;
}

.sidebar-user {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 18px 12px 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f8fafc, #60a5fa);
}

.sidebar-user strong {
    font-size: 15px;
}

.sidebar-user span {
    display: block;
    color: #94a3b8;
    font-size: 12px;
}

.content-shell {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 76px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid rgba(228, 236, 248, 0.95);
    box-shadow: 0 14px 36px rgba(16, 39, 77, 0.06);
}

.topbar-left {
    display: flex;
    gap: 18px;
    align-items: center;
}

.menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 14px;
    padding: 0;
    background: transparent;
    cursor: pointer;
    border-left: none;
    border-right: none;
    border-top: 2px solid #475569;
    border-bottom: 2px solid #475569;
    position: relative;
}

.menu-toggle:before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 5px;
    border-top: 2px solid #475569;
}

.menu-toggle:hover {
    border-top-color: #1e293b;
    border-bottom-color: #1e293b;
}

.menu-toggle:hover:before {
    border-top-color: #1e293b;
}

.sidebar-collapsed .sidebar {
    width: 88px;
    padding-left: 10px;
    padding-right: 10px;
}

.sidebar-collapsed .sidebar-brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar-collapsed .brand-cube {
    width: 44px;
    height: 44px;
}

.sidebar-collapsed .sidebar-brand > div:last-child,
.sidebar-collapsed .sidebar-user > div:last-child,
.sidebar-collapsed .menu-label,
.sidebar-collapsed .menu-expand,
.sidebar-collapsed .submenu {
    display: none;
}

.sidebar-collapsed .menu-row {
    grid-template-columns: 1fr;
}

.sidebar-collapsed .menu-item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    min-height: 46px;
}

.sidebar-collapsed .menu-item.active,
.sidebar-collapsed .menu-item:hover {
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.24);
}

.sidebar-collapsed .sidebar-user {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.topbar h1 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.topbar-right {
    display: flex;
    gap: 18px;
    align-items: center;
}

.plain-link {
    color: #475569;
    font-size: 13px;
}

.workspace {
    padding: 24px;
}

.hero-card {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: center;
    background: #fff;
    border: 1px solid rgba(228, 236, 248, 0.95);
    border-radius: 20px;
    padding: 28px;
    box-shadow: 0 14px 36px rgba(16, 39, 77, 0.06);
}

.hero-card h2 {
    margin: 0 0 12px;
    font-size: 21px;
    font-weight: 700;
}

.hero-card p {
    margin: 0;
    color: #64748b;
    max-width: 720px;
    line-height: 1.8;
    font-size: 13px;
}

.hero-meta {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    margin-top: 18px;
    color: #94a3b8;
    font-size: 11px;
}

.hero-art {
    width: 280px;
    height: 190px;
    border-radius: 24px;
    background: radial-gradient(circle at 30% 30%, rgba(147, 197, 253, 0.95), rgba(99, 102, 241, 0.75) 45%, rgba(255, 255, 255, 0) 60%), linear-gradient(135deg, #eff6ff, #dbeafe);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 16px;
    margin-top: 18px;
}

.compact-stats {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 16px;
}

.stat-card {
    padding: 20px;
    border-radius: 20px;
    background: #fff;
    border: 1px solid rgba(228, 236, 248, 0.95);
    box-shadow: 0 14px 36px rgba(16, 39, 77, 0.06);
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.stat-card:after {
    content: "";
    position: absolute;
    width: 96px;
    height: 96px;
    border-radius: 50%;
    right: -20px;
    top: -20px;
    opacity: 0.14;
}

.stat-card span {
    display: block;
    color: #64748b;
    font-size: 13px;
}

.stat-card strong {
    display: block;
    font-size: 20px;
    font-weight: 700;
    margin-top: 12px;
}

.stat-card.blue:after {
    background: #2563eb;
}

.stat-card.green:after {
    background: #10b981;
}

.stat-card.violet:after {
    background: #6366f1;
}

.stat-card.amber:after {
    background: #f59e0b;
}

.stat-card.cyan:after {
    background: #0ea5e9;
}

.stat-card.pink:after {
    background: #ec4899;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1.2fr 1.2fr;
    gap: 18px;
    margin-top: 18px;
}

.panel {
    background: #fff;
    border: 1px solid rgba(228, 236, 248, 0.95);
    border-radius: 20px;
    padding: 24px;
    box-shadow: 0 14px 36px rgba(16, 39, 77, 0.06);
}

.panel.large {
    grid-column: span 1;
}

.panel.nested {
    margin-top: 18px;
    box-shadow: none;
    background: #f8fbff;
}

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

.panel-head h3,
.panel-head h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
}

.panel-head span,
.panel-sub {
    font-size: 11px;
    color: #94a3b8;
}

.panel-head.split {
    align-items: flex-start;
}

.fake-chart {
    height: 260px;
    display: flex;
    align-items: flex-end;
    gap: 14px;
    padding-top: 16px;
}

.bar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.bar-item span {
    font-size: 11px;
    color: #94a3b8;
}

.bar {
    width: 100%;
    max-width: 48px;
    border-radius: 18px 18px 6px 6px;
    background: linear-gradient(180deg, #60a5fa, #2563eb);
}

.info-list {
    display: grid;
    gap: 12px;
    margin: 0;
}

.info-list div {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eef2ff;
}

.info-list dt {
    color: #64748b;
    font-size: 12px;
}

.info-list dd {
    margin: 0;
    font-weight: 600;
    font-size: 12px;
}

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

.quick-grid a {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 82px;
    border-radius: 18px;
    background: #f8fbff;
    color: #1e40af;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid #e5edff;
}

.list-stack {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-item {
    padding: 14px;
    border-radius: 16px;
    background: #f8fbff;
}

.list-item strong {
    display: block;
    font-size: 12px;
}

.list-item span {
    display: block;
    margin-top: 6px;
    color: #94a3b8;
    font-size: 11px;
}

.list-item p {
    margin: 8px 0 0;
    color: #475569;
    font-size: 12px;
    line-height: 1.7;
}

.list-item.compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.toolbar input,
.toolbar select,
.form-grid input,
.form-grid textarea,
.form-grid select {
    height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid #dbe4ff;
    background: #fff;
    font: inherit;
    font-size: 13px;
}

.form-grid textarea {
    height: auto;
    padding: 12px;
}

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

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

.form-grid section {
    display: grid;
    gap: 14px;
}

.form-grid label {
    display: grid;
    gap: 8px;
    color: #334155;
    font-size: 12px;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.table-wrap {
    overflow: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 860px;
}

.admin-table th,
.admin-table td {
    padding: 14px 16px;
    border-bottom: 1px solid #eef2ff;
    text-align: left;
    vertical-align: middle;
    font-size: 12px;
}

.admin-table thead th {
    color: #64748b;
    background: #fbfdff;
    font-weight: 700;
}

.admin-table tbody tr:hover {
    background: #f8fbff;
}

.badge {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
}

.badge.success {
    background: #dcfce7;
    color: #166534;
}

.badge.muted {
    background: #e2e8f0;
    color: #475569;
}

.action-cell {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.tiny-btn,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: none;
    cursor: pointer;
    font: inherit;
}

.tiny-btn {
    height: 30px;
    padding: 0 12px;
    border-radius: 10px;
    background: #f8fafc;
    color: #334155;
    font-size: 12px;
}

.tiny-btn.primary {
    background: #2f73f6;
    color: #fff;
}

.tiny-btn.warn {
    background: #fff7ed;
    color: #ea580c;
}

.btn {
    height: 34px;
    padding: 0 16px;
    border-radius: 10px;
    font-size: 13px;
}

.btn.primary {
    background: linear-gradient(90deg, #2f73f6, #3d7af7);
    color: #fff;
}

.btn.secondary {
    background: #fff;
    color: #0f172a;
    border: 1px solid #dbe4ff;
}

.btn.fill {
    width: 100%;
}

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

.tabs a {
    padding: 10px 4px;
    color: #64748b;
    text-decoration: none;
    border-bottom: 2px solid transparent;
    font-size: 12px;
}

.tabs a.active {
    color: #2f73f6;
    border-color: #2f73f6;
}

.template-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}

.template-card {
    background: #f8fbff;
    border: 1px solid #e5edff;
    border-radius: 20px;
    padding: 18px;
}

.template-card.active {
    border-color: #2563eb;
    box-shadow: 0 18px 34px rgba(37, 99, 235, 0.12);
}

.template-preview {
    height: 170px;
    border-radius: 20px;
    background: linear-gradient(135deg, #dbeafe, #eff6ff 40%, #e9d5ff);
}

.template-card h4 {
    margin: 16px 0 10px;
    font-size: 15px;
    font-weight: 700;
}

.template-card p {
    margin: 0;
    color: #64748b;
    line-height: 1.7;
    min-height: 48px;
    font-size: 12px;
}

.template-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: #94a3b8;
    font-size: 11px;
    margin: 14px 0;
}

.inline-form {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-top: 20px;
}

.inline-form input {
    flex: 1;
    min-width: 240px;
    height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid #dbe4ff;
    font-size: 13px;
}

.inline-form input[type="file"] {
    padding: 6px 0;
    border: none;
    background: transparent;
    min-width: 200px;
}

.json-box {
    padding: 18px;
    border-radius: 18px;
    background: #0f172a;
    color: #dbeafe;
    overflow: auto;
    font-size: 12px;
}

.notice {
    padding: 14px 16px;
    border-radius: 16px;
    margin-bottom: 16px;
    font-size: 13px;
}

.notice.success {
    background: #ecfdf5;
    color: #166534;
}

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

.table-empty {
    padding: 28px 16px;
    text-align: center;
    color: #94a3b8;
    font-size: 12px;
}

.card-empty {
    grid-column: 1 / -1;
    background: #fff;
    border: 1px dashed #dbe4ff;
    border-radius: 18px;
}

.admin-pagination {
    margin-top: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.admin-pagination.single {
    justify-content: flex-end;
}

.page-summary {
    color: #64748b;
    font-size: 12px;
}

.page-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.page-link,
.page-ellipsis {
    min-width: 34px;
    height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.page-link {
    text-decoration: none;
    color: #334155;
    background: #fff;
    border: 1px solid #dbe4ff;
    transition: all 0.2s ease;
}

.page-link:hover {
    border-color: #93c5fd;
    color: #1d4ed8;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.08);
}

.page-link.active {
    color: #fff;
    border-color: transparent;
    background: linear-gradient(90deg, #2f73f6, #3d7af7);
    box-shadow: 0 12px 26px rgba(37, 99, 235, 0.18);
}

.page-link.disabled {
    pointer-events: none;
    color: #94a3b8;
    background: #f8fbff;
}

.page-ellipsis {
    color: #94a3b8;
}

.detail-grid {
    display: grid;
    gap: 12px;
}

.detail-row {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid #eef2ff;
}

.detail-row strong {
    font-size: 12px;
}

.detail-row span {
    font-size: 12px;
    color: #475569;
}

.detail-row-rich {
    align-items: start;
}

.detail-value-block {
    display: grid;
    gap: 10px;
    min-width: 0;
}

.detail-muted-text {
    color: #94a3b8;
    word-break: break-all;
}

.admin-detail-image,
.admin-detail-gallery-item {
    overflow: hidden;
    border-radius: 16px;
    border: 1px solid #dbe4ff;
    background: #f8fbff;
}

.admin-detail-image {
    max-width: 360px;
}

.admin-detail-image img,
.admin-detail-gallery-item img {
    display: block;
    width: 100%;
    height: auto;
}

.admin-detail-gallery {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    max-width: 760px;
}

.admin-detail-link {
    color: #1d4ed8;
    text-decoration: none;
    word-break: break-all;
}

.admin-detail-link:hover {
    text-decoration: underline;
}

.content-preview {
    line-height: 1.8;
    color: #334155;
    white-space: normal;
    word-break: break-word;
    font-size: 13px;
}

.dynamic-fields-wrap {
    margin-top: -4px;
}

.dynamic-field-group {
    display: none;
}

.dynamic-field-group.active {
    display: block;
}

.dynamic-fields-grid {
    display: grid;
    gap: 14px;
}

.field-empty {
    padding: 18px;
    border-radius: 16px;
    background: #f8fbff;
    color: #64748b;
    font-size: 12px;
}

.field-hint {
    color: #94a3b8;
    font-size: 11px;
    line-height: 1.6;
}

.media-field-stack {
    display: grid;
    gap: 10px;
}

.inline-image-preview {
    display: none;
    width: min(320px, 100%);
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid #dbe4ff;
    background: #f8fbff;
}

.inline-image-preview.has-image {
    display: block;
}

.inline-image-preview img {
    display: block;
    width: 100%;
    height: auto;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
    margin-top: 18px;
}

.media-card {
    background: #fff;
    border: 1px solid #e5edff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 14px 36px rgba(16, 39, 77, 0.06);
}

.media-preview {
    aspect-ratio: 16 / 10;
    background: #f8fbff;
    border-bottom: 1px solid #e5edff;
}

.media-preview img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-card-body {
    display: grid;
    gap: 6px;
    padding: 16px 16px 0;
}

.media-card-body strong {
    font-size: 13px;
}

.media-card-body span {
    color: #64748b;
    font-size: 11px;
}

.media-url {
    padding: 10px 12px;
    border-radius: 12px;
    background: #f8fbff;
    color: #475569;
    font-size: 11px;
    word-break: break-all;
}

.media-card .action-cell {
    padding: 14px 16px 16px;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #2563eb 0, #0f172a 50%, #020617 100%);
}

.login-card {
    width: min(460px, 100% - 32px);
    background: #fff;
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 26px 70px rgba(15, 23, 42, 0.28);
}

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

.brand h1 {
    margin: 0;
    font-size: 17px;
}

.brand p {
    margin: 6px 0 0;
    color: #64748b;
    font-size: 12px;
}

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

.login-card label {
    display: grid;
    gap: 8px;
    color: #334155;
    font-size: 12px;
}

.login-card input {
    height: 34px;
    padding: 0 12px;
    border-radius: 10px;
    border: 1px solid #dbe4ff;
    font-size: 13px;
}

.hint {
    color: #64748b;
    font-size: 11px;
}

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

    .template-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .stats-grid {
        overflow-x: auto;
        grid-template-columns: repeat(6, 180px);
    }

    .admin-pagination {
        align-items: flex-start;
    }
}

@media (max-width: 980px) {
    .admin-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .dashboard-grid,
    .template-grid,
    .media-grid,
    .quick-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .hero-card {
        flex-direction: column;
        align-items: flex-start;
    }

    .detail-row {
        grid-template-columns: 1fr;
    }

    .admin-detail-gallery {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        overflow-x: auto;
        grid-template-columns: repeat(6, 180px);
    }
}
