:root {
    --bg: #f5f7fb;
    --panel: #fff;
    --panel-soft: #f9fafb;
    --text: #111827;
    --muted: #6b7280;
    --subtle: #9ca3af;
    --line: #e5e7eb;
    --line-strong: #d1d5db;
    --primary: #2563eb;
    --primary-soft: #eff6ff;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --shadow: 0 18px 45px rgba(15, 23, 42, .08);
    --radius: 8px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    letter-spacing: 0;
}
button, input, select, textarea {
    font: inherit;
    letter-spacing: 0;
}
button { cursor: pointer; }
a { color: inherit; }

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 244px minmax(0, 1fr);
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 18px 14px;
    display: flex;
    flex-direction: column;
    z-index: 40;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 8px 18px;
    border-bottom: 1px solid var(--line);
}
.brand-icon {
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: var(--radius);
    background: #111827;
    color: #fff;
}
.brand strong { display: block; font-size: 15px; }
.brand small { display: block; color: var(--muted); margin-top: 2px; font-size: 12px; }
.nav-list {
    display: grid;
    gap: 4px;
    padding-top: 18px;
}
.nav-item {
    width: 100%;
    min-height: 40px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius);
    color: #4b5563;
    background: transparent;
    text-align: left;
}
.nav-item i { width: 18px; color: #9ca3af; }
.nav-item:hover { background: #f3f4f6; color: var(--text); }
.nav-item.active {
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 700;
}
.nav-item.active i { color: var(--primary); }
.sidebar-foot {
    margin-top: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 12px;
    padding: 12px 8px 2px;
}
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 4px rgba(22, 163, 74, .12);
}

.main-shell {
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.topbar {
    min-height: 72px;
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 14px 28px;
    background: rgba(245, 247, 251, .86);
    border-bottom: 1px solid rgba(229, 231, 235, .75);
    backdrop-filter: blur(14px);
}
.page-kicker {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}
h1, h2, h3 { margin: 0; letter-spacing: 0; }
#pageTitle { margin-top: 4px; font-size: 22px; line-height: 1.25; }
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.content {
    width: min(1440px, 100%);
    padding: 24px 28px 54px;
}

.mobile-menu { display: none !important; }
.icon-btn, .ghost-btn, .primary-btn, .danger-btn, .soft-btn, .file-btn {
    min-height: 36px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
    color: #374151;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 12px;
    text-decoration: none;
}
.icon-btn {
    width: 36px;
    padding: 0;
}
.ghost-btn:hover, .icon-btn:hover, .soft-btn:hover, .file-btn:hover { border-color: var(--line-strong); background: #f9fafb; }
.primary-btn {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    font-weight: 700;
}
.primary-btn:hover { background: #1d4ed8; border-color: #1d4ed8; }
.danger-btn, .ghost-btn.danger {
    color: var(--danger);
}
.danger-btn {
    background: var(--danger-soft);
    border-color: #fecaca;
}
.icon-btn:disabled, .ghost-btn:disabled, .primary-btn:disabled, .danger-btn:disabled, .soft-btn:disabled {
    cursor: not-allowed;
    opacity: .45;
    background: #f9fafb;
    border-color: var(--line);
    color: var(--muted);
}
.soft-btn {
    background: var(--panel-soft);
}
.user-pill {
    height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: #4b5563;
    white-space: nowrap;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.toolbar-left, .toolbar-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}
.search-field {
    position: relative;
    min-width: 240px;
}
.search-field i {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--subtle);
}
.search-field input {
    width: 100%;
    height: 36px;
    padding-left: 34px;
}

input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    outline: none;
}
input, select { height: 36px; padding: 0 10px; }
textarea { min-height: 92px; padding: 10px; line-height: 1.65; resize: vertical; }
input:focus, select:focus, textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
label.field-label {
    display: block;
    color: #374151;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 7px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.form-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-full { grid-column: 1 / -1; }
.field-help {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.6;
}
.rich-editor {
    min-width: 0;
}
.rich-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 8px;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: var(--radius) var(--radius) 0 0;
    background: #f9fafb;
}
.rich-toolbar .icon-btn {
    width: 32px;
    min-height: 32px;
}
.rich-toolbar .soft-btn {
    min-height: 32px;
    padding: 0 10px;
}
.rich-toolbar select {
    width: auto;
    min-width: 82px;
    height: 32px;
    font-size: 12px;
}
.rich-color {
    width: 36px;
    height: 32px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: #374151;
    display: inline-grid;
    place-items: center;
    position: relative;
    cursor: pointer;
}
.rich-color input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.rich-editor-surface,
.rich-editor-source {
    width: 100%;
    min-height: 240px;
    max-height: 520px;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 0 0 var(--radius) var(--radius);
    background: #fff;
    color: var(--text);
    padding: 14px;
    line-height: 1.8;
    outline: none;
}
.rich-editor-surface:focus,
.rich-editor-source:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.rich-editor-surface p {
    margin: 0 0 10px;
}
.rich-editor-surface h3 {
    margin: 14px 0 8px;
    font-size: 18px;
    line-height: 1.55;
}
.rich-editor-surface blockquote {
    margin: 10px 0;
    padding: 8px 12px;
    border-left: 3px solid var(--primary);
    background: var(--primary-soft);
    color: #374151;
}
.rich-editor-surface ul,
.rich-editor-surface ol {
    margin: 8px 0 10px 22px;
    padding: 0;
}
.rich-editor-source {
    display: none;
    resize: vertical;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
}
.rich-editor[data-mode="html"] .rich-editor-surface {
    display: none;
}
.rich-editor[data-mode="html"] .rich-editor-source {
    display: block;
}
.rich-editor[data-mode="html"] .rich-toggle-html {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

.panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 1px 0 rgba(15, 23, 42, .02);
}
.panel + .panel { margin-top: 16px; }
.panel-head {
    min-height: 54px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.panel-title {
    display: flex;
    align-items: center;
    gap: 9px;
    font-weight: 800;
}
.panel-title i { color: var(--primary); }
.panel-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.panel-body { padding: 16px; }

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.metric {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
}
.metric .num {
    display: block;
    font-size: 26px;
    font-weight: 800;
    margin: 10px 0 4px;
}
.metric .label { color: var(--muted); font-size: 12px; }
.metric i { color: var(--primary); }

.split-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, .8fr);
    gap: 16px;
}
.card-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}
.quick-card {
    min-height: 112px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    text-decoration: none;
}
.quick-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.quick-card i { color: var(--primary); }
.quick-card strong { display: block; margin-top: 12px; }
.quick-card span { color: var(--muted); font-size: 12px; line-height: 1.6; }

.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    border-collapse: collapse;
    min-width: 720px;
}
th, td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}
th {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    background: #f9fafb;
}
tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: #fbfdff; }
.row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: #f3f4f6;
    color: #4b5563;
}
.badge.green { background: #ecfdf5; color: #047857; }
.badge.orange { background: #fff7ed; color: #c2410c; }
.badge.blue { background: #eff6ff; color: #1d4ed8; }

.tabs, .section-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.tab-btn {
    min-height: 34px;
    border: 1px solid var(--line);
    background: #fff;
    color: #4b5563;
    border-radius: var(--radius);
    padding: 0 12px;
}
.tab-btn.active {
    background: #111827;
    color: #fff;
    border-color: #111827;
}
.editor-layout {
    display: grid;
    grid-template-columns: 190px minmax(0, 1fr);
    gap: 16px;
}
.editor-nav {
    position: sticky;
    top: 92px;
    display: grid;
    gap: 6px;
    align-self: start;
}
.editor-nav button {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: var(--radius);
    min-height: 36px;
    text-align: left;
    padding: 0 10px;
}
.editor-nav button:hover { border-color: var(--primary); color: var(--primary); }
.section-block { scroll-margin-top: 100px; }

.array-list {
    display: grid;
    gap: 10px;
}
.array-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: start;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
    background: #fff;
}
.array-row.multi {
    grid-template-columns: repeat(3, minmax(0, 1fr)) auto;
}
.array-row.two {
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
}
.array-row.image-row {
    grid-template-columns: 56px minmax(0, 1fr) auto auto;
    align-items: center;
}
.img-thumb {
    width: 56px;
    height: 42px;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #f3f4f6;
}
.chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.check-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 10px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
    color: #374151;
}
.check-chip.active {
    background: var(--primary-soft);
    color: var(--primary);
    border-color: #bfdbfe;
    font-weight: 700;
}

.image-input {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}
.image-input img {
    width: 72px;
    height: 50px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #f3f4f6;
}

.svg-icon {
    width: 20px;
    height: 20px;
    display: inline-block;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-control {
    min-width: 0;
    width: 36px;
    display: inline-grid;
    align-items: center;
}
.icon-preview {
    width: 36px;
    height: 36px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--primary);
    display: grid;
    place-items: center;
    cursor: pointer;
}
.icon-preview i {
    font-size: 18px;
}
.icon-preview .svg-icon {
    width: 20px;
    height: 20px;
}
.icon-row {
    grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1.5fr) auto;
}
.array-row.two.icon-row {
    grid-template-columns: 44px minmax(0, 1fr) auto;
}
.vehicle-row.icon-row {
    grid-template-columns: 44px minmax(80px, .45fr) minmax(0, 1fr) minmax(0, 1fr) auto;
}
.icon-picker-tools {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) auto;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}
.current-icon {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    color: #374151;
    background: #fff;
}
.current-icon span {
    color: var(--muted);
    font-size: 12px;
}
.current-icon strong {
    font-size: 12px;
}
.current-icon .svg-icon {
    width: 20px;
    height: 20px;
}
.icon-category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 14px;
}
.icon-category-tab {
    min-height: 32px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: #374151;
    padding: 0 12px;
    font-weight: 700;
    cursor: pointer;
}
.icon-category-tab:hover {
    border-color: var(--line-strong);
    background: #f9fafb;
}
.icon-category-tab.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}
.svg-icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 10px;
    max-height: min(58vh, 560px);
    overflow: auto;
    padding-right: 2px;
}
.svg-icon-option {
    min-height: 74px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: #374151;
    display: grid;
    place-items: center;
    gap: 8px;
    padding: 12px 8px;
}
.svg-icon-option:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}
.svg-icon-option .svg-icon {
    width: 24px;
    height: 24px;
}
.svg-icon-option span {
    font-size: 12px;
    font-weight: 700;
}

.chart {
    height: 220px;
    display: flex;
    align-items: end;
    gap: 10px;
    padding: 14px 4px 28px;
}
.bar {
    flex: 1;
    min-width: 24px;
    border-radius: 8px 8px 0 0;
    background: linear-gradient(180deg, #60a5fa, #2563eb);
    position: relative;
}
.bar small {
    position: absolute;
    left: 50%;
    bottom: -22px;
    transform: translateX(-50%);
    white-space: nowrap;
    color: var(--muted);
    font-size: 11px;
}
.bar b {
    position: absolute;
    left: 50%;
    top: -22px;
    transform: translateX(-50%);
    font-size: 12px;
}

.toast-wrap {
    position: fixed;
    right: 18px;
    bottom: 18px;
    display: grid;
    gap: 10px;
    z-index: 120;
}
.toast {
    width: min(360px, calc(100vw - 32px));
    background: #111827;
    color: #fff;
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 10px;
}
.toast.success i { color: #86efac; }
.toast.error i { color: #fca5a5; }

.modal-layer, .image-picker {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    padding: 20px;
    background: rgba(15, 23, 42, .42);
    z-index: 100;
}
.modal-layer.show, .image-picker.show { display: grid; }
.modal-card, .image-picker-card {
    width: min(720px, 100%);
    max-height: min(840px, calc(100vh - 40px));
    overflow: hidden;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}
.image-picker-card { width: min(980px, 100%); }
.modal-head {
    padding: 16px;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
}
.modal-head h2 { margin-top: 3px; font-size: 20px; }
.modal-body {
    padding: 16px;
    overflow: auto;
}
.modal-actions {
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}
.image-picker-tools {
    padding: 14px 16px;
    display: flex;
    gap: 10px;
    border-bottom: 1px solid var(--line);
}
.file-btn {
    position: relative;
    overflow: hidden;
    white-space: nowrap;
}
.file-btn input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.image-grid {
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 12px;
    overflow: auto;
}
.image-tile {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    overflow: hidden;
    text-align: left;
}
.image-tile img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    background: #f3f4f6;
}
.image-tile span {
    display: block;
    padding: 8px;
    font-size: 12px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pager {
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    display: flex;
    justify-content: center;
    gap: 8px;
}
.loading-panel, .empty-state {
    min-height: 260px;
    display: grid;
    place-items: center;
    gap: 12px;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.empty-state { text-align: center; padding: 32px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

@media (max-width: 1100px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split-grid, .editor-layout { grid-template-columns: 1fr; }
    .editor-nav { position: static; display: flex; flex-wrap: wrap; }
}
@media (max-width: 760px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
        transition: transform .2s ease;
        box-shadow: var(--shadow);
    }
    .sidebar.show { transform: translateX(0); }
    .mobile-menu { display: inline-flex !important; }
    .topbar {
        padding: 12px 14px;
        align-items: flex-start;
    }
    #pageTitle { font-size: 18px; }
    .topbar-actions {
        margin-left: auto;
        gap: 6px;
    }
    .topbar-actions .ghost-btn span, .user-pill span { display: none; }
    .content { padding: 16px 14px 40px; }
    .form-grid, .form-grid.three, .card-grid, .metric-grid { grid-template-columns: 1fr; }
    .toolbar, .toolbar-left, .toolbar-right { align-items: stretch; }
    .toolbar-left, .toolbar-right, .search-field { width: 100%; }
    .array-row, .array-row.multi, .array-row.two, .array-row.image-row, .image-input {
        grid-template-columns: 1fr;
    }
    .array-row.image-row .img-thumb, .image-input img {
        width: 100%;
        height: 140px;
    }
    .icon-row,
    .array-row.two.icon-row,
    .icon-picker-tools {
        grid-template-columns: 1fr;
    }
    .image-picker-tools { flex-direction: column; }
}
