:root {
    --ink: #142033;
    --muted: #6f7b8f;
    --line: #e5e9f0;
    --surface: #ffffff;
    --canvas: #f4f6f9;
    --nav: #101a2b;
    --nav-soft: #1a2740;
    --blue: #2f6fec;
    --blue-dark: #1c4fb0;
    --gold: #d79b42;
    --green: #2c9b73;
    --danger: #d84b4b;
    --shadow: 0 12px 34px rgba(25, 39, 69, .08);
    font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; color: var(--ink); background: var(--canvas); }
body { font-size: 14px; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.cell-input {
    width: 112px;
    min-width: 90px;
    padding: 8px 9px;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fff;
}

.wide-input { width: 190px; }

.button-small {
    min-height: 34px;
    padding: 7px 13px;
    white-space: nowrap;
}

.data-table .hidden-column { display: none; }

.data-table .frozen-column {
    position: sticky;
    left: var(--frozen-left);
    z-index: 2;
    background: #fff;
    box-shadow: 1px 0 0 var(--border);
}

.data-table thead .frozen-column {
    z-index: 4;
    background: #f7f8fa;
}

.view-fields {
    margin: 4px 0 18px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
}

.view-fields legend { padding: 0 6px; color: var(--muted); }

.view-fields div {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 14px;
    max-height: 260px;
    overflow: auto;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px 1fr; }
.sidebar {
    position: sticky; top: 0; height: 100vh; padding: 26px 18px 18px;
    color: #d7deea; background:
        radial-gradient(circle at 0 0, rgba(47,111,236,.22), transparent 36%),
        var(--nav); display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 28px; color: #fff; }
.brand-mark {
    width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px;
    color: #0f1a2d; background: linear-gradient(145deg, #f6c97c, #d89437);
    font-size: 22px; font-weight: 900; box-shadow: 0 10px 24px rgba(215,155,66,.25);
}
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; letter-spacing: .02em; }
.brand small { color: #8d9ab1; margin-top: 3px; font-size: 11px; }
.nav-list { display: grid; gap: 4px; }
.nav-list a {
    padding: 11px 12px; display: flex; align-items: center; gap: 11px;
    border-radius: 9px; color: #aeb8c9; transition: .2s ease;
}
.nav-list a span { width: 18px; text-align: center; font-size: 16px; }
.nav-list a:hover { color: #fff; background: rgba(255,255,255,.06); }
.nav-list a.active { color: #fff; background: var(--nav-soft); box-shadow: inset 3px 0 var(--gold); }
.nav-caption {
    margin: 20px 12px 7px; color: #65748e; font-size: 10px; font-weight: 800;
    letter-spacing: .16em; text-transform: uppercase;
}
.sidebar-foot {
    margin-top: auto; padding: 13px 11px; display: flex; align-items: center; gap: 9px;
    border-top: 1px solid rgba(255,255,255,.08); color: #8390a5; font-size: 11px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #39c98d; box-shadow: 0 0 0 4px rgba(57,201,141,.13); }

.main-content { min-width: 0; }
.topbar {
    height: 100px; padding: 20px 34px; display: flex; align-items: center; justify-content: space-between;
    background: rgba(255,255,255,.86); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px);
}
.topbar h1 { margin: 4px 0 0; font-size: 24px; letter-spacing: -.03em; }
.eyebrow { color: var(--gold); font-size: 10px; font-weight: 900; letter-spacing: .16em; }
.eyebrow.light { color: #a9c8ff; }
.date-chip { padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); background: #fff; }
.page-body { padding: 28px 34px 44px; max-width: 1540px; margin: 0 auto; }

.panel {
    background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
    box-shadow: var(--shadow);
}
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 22px 24px; border-bottom: 1px solid var(--line); }
.panel-heading h3, .data-toolbar h3 { margin: 4px 0 0; font-size: 18px; }
.panel-heading > a { color: var(--blue); font-weight: 700; }
.pill { display: inline-flex; padding: 6px 10px; border-radius: 999px; background: #edf3ff; color: var(--blue-dark); font-size: 11px; font-weight: 800; }
.pill-dark { background: rgba(255,255,255,.13); color: #fff; }

.hero-card {
    min-height: 250px; padding: 34px 40px; display: flex; justify-content: space-between; align-items: end; gap: 30px;
    color: #fff; border-radius: 18px; overflow: hidden;
    background:
        radial-gradient(circle at 85% 20%, rgba(74,136,255,.55), transparent 30%),
        linear-gradient(135deg, #111d31 0%, #172944 55%, #243d63 100%);
    box-shadow: 0 20px 44px rgba(15,31,57,.18);
}
.hero-card h2 { margin: 18px 0 10px; font-size: clamp(28px, 3vw, 42px); line-height: 1.2; letter-spacing: -.04em; }
.hero-card p { max-width: 650px; margin: 0; color: #b7c3d6; line-height: 1.8; }
.hero-actions { display: flex; flex-direction: column; gap: 10px; min-width: 165px; }
.button {
    border: 0; border-radius: 9px; padding: 11px 16px; display: inline-flex;
    justify-content: center; align-items: center; gap: 8px; font-weight: 800;
}
.button-primary { color: #fff; background: var(--blue); box-shadow: 0 7px 16px rgba(47,111,236,.24); }
.button-primary:hover { background: var(--blue-dark); }
.button-primary:disabled { opacity: .45; cursor: not-allowed; }
.button-ghost { color: var(--ink); background: #eef1f5; }
.hero-card .button-ghost { color: #fff; background: rgba(255,255,255,.1); }

.stat-grid { margin: 22px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card { padding: 20px 22px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.stat-card span, .stat-card small { display: block; color: var(--muted); }
.stat-card strong { display: block; margin: 6px 0 2px; font-size: 30px; letter-spacing: -.04em; }
.stat-card small { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }
.section-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(310px, .75fr); gap: 20px; }
.quote-type-grid { padding: 20px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.quote-type-card { min-height: 178px; padding: 20px; border: 1px solid var(--line); border-radius: 13px; transition: .2s ease; }
.quote-type-card:hover { transform: translateY(-3px); box-shadow: 0 12px 24px rgba(22,37,65,.1); }
.quote-type-card .type-icon { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; font-size: 22px; }
.quote-type-card strong, .quote-type-card small, .quote-type-card b { display: block; }
.quote-type-card strong { margin-top: 20px; font-size: 16px; }
.quote-type-card small { margin: 6px 0 20px; color: var(--muted); min-height: 34px; line-height: 1.5; }
.quote-type-card b { color: var(--blue); font-size: 12px; }
.accent-gold .type-icon { color: #a76c18; background: #fff4df; }
.accent-blue .type-icon { color: var(--blue); background: #eaf1ff; }
.accent-green .type-icon { color: var(--green); background: #e5f7f0; }
.recent-list { padding: 10px 20px 18px; }
.recent-row { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.recent-row:last-child { border-bottom: 0; }
.recent-row span strong, .recent-row span small { display: block; }
.recent-row span small { margin-top: 3px; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 190px; }
.recent-row > b { color: var(--blue-dark); }
.mini-badge { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 8px; font-weight: 900; }
.mini-badge.pendant { background: #fff2dd; color: #aa6a0a; }
.mini-badge.ring { background: #e9f1ff; color: var(--blue); }
.mini-badge.chain { background: #e4f7ef; color: var(--green); }

.quote-layout { display: grid; grid-template-columns: minmax(600px, 1.4fr) minmax(330px, .65fr); gap: 22px; align-items: start; }
.form-panel form { padding: 8px 24px 26px; }
.form-section-title { display: flex; align-items: center; gap: 10px; margin: 24px 0 15px; font-weight: 900; }
.form-section-title span { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; color: var(--blue); background: #eaf1ff; font-size: 11px; }
.form-grid { display: grid; gap: 15px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; }
.field > span { font-weight: 800; font-size: 12px; }
.field em { color: var(--muted); margin-left: 5px; font-style: normal; font-weight: 500; }
.field i { color: var(--danger); margin-left: 3px; }
.field input, .field select, .field textarea, .toolbar-actions input, .toolbar-actions select {
    width: 100%; border: 1px solid #dce2eb; border-radius: 8px; padding: 10px 11px;
    outline: 0; color: var(--ink); background: #fff; transition: .15s ease;
}
.field input:focus, .field select:focus, .field textarea:focus, .toolbar-actions input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(47,111,236,.1); }
.field small { color: var(--muted); font-size: 10px; }
.field textarea { resize: vertical; }
.multi-select { min-height: 112px; }
.multi-select option { padding: 7px; }
.file-field input { background: #f8f9fb; }
.form-actions { margin-top: 24px; display: flex; justify-content: flex-end; gap: 10px; }
.result-panel, .detail-result {
    position: sticky; top: 124px; min-height: 520px; padding: 28px;
    color: #fff; border-radius: 17px; overflow: hidden;
    background:
        radial-gradient(circle at 80% 0, rgba(58,126,255,.42), transparent 30%),
        linear-gradient(150deg, #14233b, #0d1728 75%);
    box-shadow: 0 18px 40px rgba(16,28,48,.22);
}
.result-placeholder { min-height: 455px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; color: #9ba9be; }
.result-placeholder h3 { color: #fff; margin: 18px 0 7px; }
.result-placeholder p { max-width: 270px; line-height: 1.7; }
.result-orbit { width: 86px; height: 86px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.18); border-radius: 50%; font-size: 32px; color: var(--gold); box-shadow: 0 0 0 13px rgba(255,255,255,.03), 0 0 0 26px rgba(255,255,255,.02); }
.final-price { margin-top: 28px; padding-bottom: 24px; border-bottom: 1px solid rgba(255,255,255,.12); }
.final-price small, .final-price em { display: block; color: #9eabc0; font-style: normal; }
.final-price strong { display: block; margin: 6px 0 0; font-size: 56px; letter-spacing: -.06em; }
.final-price sup { font-size: 22px; margin-right: 5px; color: var(--gold); }
.weight-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 22px 0; }
.weight-grid > div { padding: 14px; border-radius: 11px; background: rgba(255,255,255,.07); }
.weight-grid small { display: block; color: #9eabc0; }
.weight-grid strong { display: inline-block; margin-top: 8px; font-size: 22px; }
.weight-grid span { margin-left: 4px; color: #aeb8c8; }
.breakdown { display: grid; gap: 0; }
.breakdown > div { display: flex; justify-content: space-between; padding: 11px 2px; border-bottom: 1px solid rgba(255,255,255,.09); }
.breakdown span { color: #aeb8c8; }
.trace-note { display: flex; align-items: center; gap: 10px; margin-top: 22px; color: #9eabc0; font-size: 11px; }

.data-panel { overflow: hidden; }
.data-toolbar { padding: 22px 24px; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.data-toolbar p { margin: 6px 0 0; color: var(--muted); }
.toolbar-actions { display: flex; gap: 10px; align-items: center; }
.toolbar-actions input { min-width: 240px; }
.dataset-tabs { display: flex; gap: 0; padding: 0 18px; overflow-x: auto; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.dataset-tabs button { padding: 13px 15px; border: 0; border-bottom: 2px solid transparent; white-space: nowrap; color: var(--muted); background: transparent; font-weight: 700; }
.dataset-tabs button.active { color: var(--blue); border-bottom-color: var(--blue); }
.grid-meta { padding: 11px 20px; display: flex; gap: 14px; color: var(--muted); background: #fafbfc; border-bottom: 1px solid var(--line); font-size: 11px; }
.grid-meta #grid-title { color: var(--ink); font-weight: 800; }
.grid-help { margin-left: auto; }
.data-table-wrap { width: 100%; overflow: auto; max-height: calc(100vh - 290px); }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; font-size: 12px; }
.data-table th { position: sticky; top: 0; z-index: 2; padding: 12px 14px; text-align: left; color: #566176; background: #f6f8fb; border-bottom: 1px solid var(--line); }
.data-table td { min-width: 130px; max-width: 360px; padding: 11px 14px; border-bottom: 1px solid #edf0f4; overflow: hidden; text-overflow: ellipsis; background: #fff; }
.data-table tbody tr:hover td { background: #fbfcff; }
.data-table td[contenteditable="true"] { background: #fffdf5; outline: 0; }
.data-table td[contenteditable="true"]:focus { box-shadow: inset 0 0 0 2px var(--blue); background: #fff; }
.data-table tr.dirty td { background: #fffaf0; }
.data-table .actions { position: sticky; right: 0; min-width: 90px; text-align: center; background: #fff; box-shadow: -8px 0 14px rgba(20,32,51,.04); }
.row-save { padding: 6px 9px; border: 0; border-radius: 7px; color: #fff; background: var(--blue); font-size: 11px; }
.row-save:disabled { color: #9aa5b6; background: #edf0f4; }
.cell-boolean { min-width: 74px !important; text-align: center; }
.history-table td:first-child a, .data-table a { color: var(--blue); font-weight: 800; }

.detail-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 22px; }
.detail-list { padding: 8px 24px 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.detail-list div { padding: 15px 0; border-bottom: 1px solid var(--line); }
.detail-list dt { color: var(--muted); font-size: 11px; }
.detail-list dd { margin: 6px 0 0; font-weight: 800; }
.detail-result { position: static; min-height: 480px; }
.attachment-grid { padding: 0 24px 24px; display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.attachment-grid a { padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.attachment-grid span, .attachment-grid strong { display: block; }
.attachment-grid span { color: var(--muted); font-size: 10px; }
.attachment-grid strong { margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.modal { width: min(460px, calc(100% - 30px)); border: 0; border-radius: 14px; padding: 0; box-shadow: 0 26px 80px rgba(15,25,42,.3); }
.modal::backdrop { background: rgba(12,20,34,.55); backdrop-filter: blur(3px); }
.modal form { padding: 22px; display: grid; gap: 14px; }
.modal-heading { display: flex; justify-content: space-between; align-items: center; }
.modal-heading h3 { margin: 0; }
.modal-heading button { border: 0; background: transparent; font-size: 24px; }
.toast { position: fixed; z-index: 100; left: 50%; bottom: 28px; transform: translate(-50%, 20px); padding: 11px 18px; border-radius: 9px; color: #fff; background: #16233a; opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #a63131; }
.empty-state { padding: 42px; text-align: center; color: var(--muted); }

@media (max-width: 1100px) {
    .app-shell { grid-template-columns: 82px 1fr; }
    .sidebar { padding: 22px 12px; }
    .brand { justify-content: center; padding-inline: 0; }
    .brand > span:last-child, .nav-list a:not(.active) { }
    .brand strong, .brand small, .nav-list a { font-size: 0; }
    .nav-list a { justify-content: center; }
    .nav-list a span { font-size: 18px; }
    .nav-caption, .sidebar-foot span:last-child { display: none; }
    .sidebar-foot { justify-content: center; }
    .quote-layout, .detail-grid { grid-template-columns: 1fr; }
    .result-panel { position: static; min-height: 420px; }
    .section-grid { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: static; width: 100%; height: auto; padding: 12px; flex-direction: row; align-items: center; overflow-x: auto; }
    .brand { padding: 0 10px 0 0; }
    .brand-mark { width: 34px; height: 34px; }
    .nav-list { display: flex; }
    .nav-list a { min-width: 44px; padding: 9px; }
    .nav-caption, .sidebar-foot { display: none; }
    .topbar { height: 78px; padding: 15px 18px; }
    .topbar h1 { font-size: 20px; }
    .date-chip { display: none; }
    .page-body { padding: 18px; }
    .hero-card { padding: 26px; align-items: start; flex-direction: column; }
    .hero-actions { width: 100%; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .quote-type-grid { grid-template-columns: 1fr; }
    .two-columns, .detail-list { grid-template-columns: 1fr; }
    .quote-layout { display: block; }
    .result-panel { margin-top: 18px; }
    .data-toolbar { align-items: stretch; flex-direction: column; }
    .toolbar-actions { align-items: stretch; flex-direction: column; }
    .toolbar-actions input { min-width: 0; }
}
