@import url("https://fonts.googleapis.com/css2?family=Mulish:wght@400;500;600;700;800;900&display=swap");

:root {
    --wine: #9b2a2b;
    --teal: #569c91;
    --pink: #d8457a;
    --blue: #4261a4;
    --green: #60b250;
    --gold: #e6b530;
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-soft: #fbfdff;
    --text: #132136;
    --muted: #5e6b80;
    --line: #dce4eb;
    --line-strong: #b8c6d4;
    --focus: rgba(66, 97, 164, .2);
    --radius-card: 8px;
    --radius-hero: 16px;
    --shadow-soft: 0 16px 40px rgba(14, 23, 38, .08);
    --shadow-card: 0 10px 28px rgba(15, 23, 42, .07);
    --font-body: Mulish, "Segoe UI", Tahoma, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    color: var(--text);
    font-family: var(--font-body);
    background:
        radial-gradient(900px 380px at -5% -8%, rgba(86, 156, 145, .16), transparent 52%),
        radial-gradient(780px 340px at 104% 7%, rgba(230, 181, 48, .16), transparent 57%),
        linear-gradient(180deg, #fbfcfe 0%, var(--bg) 100%);
}
h1, h2, h3, h4 { margin: 0; font-family: var(--font-body); letter-spacing: 0; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font-family: inherit; }

.shell {
    max-width: 1540px;
    margin: 0 auto;
    padding: 24px 22px 34px;
}

.hero {
    background: linear-gradient(132deg, rgba(155, 42, 43, .97), rgba(66, 97, 164, .95));
    color: #fff;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: var(--radius-hero);
    padding: 55px 30px;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}
.hero-brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    min-width: 0;
    max-width: 760px;
}
.hero-logo {
    width: 76px;
    height: auto;
    display: block;
}
.hero-title {
    margin: 0;
    font-size: clamp(32px, 4vw, 50px);
    line-height: 1.06;
    font-weight: 900;
    color: #fff;
}
.hero-summary {
    max-width: 720px;
    font-size: 15px;
    line-height: 1.5;
    color: rgba(255, 255, 255, .88);
}
.hero-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
}

.btn {
    border: 1px solid transparent;
    border-radius: var(--radius-card);
    padding: 11px 15px;
    min-height: 38px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease, border-color .16s ease, color .16s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn:hover { transform: translateY(-1px); }
.btn:focus-visible,
.mini-btn:focus-visible,
.preset:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px var(--focus);
}
.btn-primary {
    background: #fff;
    color: var(--wine);
    border-color: rgba(255, 255, 255, .75);
    box-shadow: 0 12px 20px rgba(18, 24, 40, .18);
}
.btn-ghost {
    background: rgba(255, 255, 255, .14);
    border-color: rgba(255, 255, 255, .28);
    color: #fff;
}
.btn-ghost:hover { background: rgba(255, 255, 255, .22); }
.btn-outline {
    background: #fff;
    border-color: var(--line);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--line-strong); background: #f8fbff; }
.btn-success {
    background: linear-gradient(135deg, rgba(86, 156, 145, .95), rgba(96, 178, 80, .95));
    color: #fff;
    box-shadow: 0 10px 18px rgba(86, 156, 145, .22);
}
.btn-danger,
.danger {
    border-color: #fecdd3;
    background: #fff1f2;
    color: #b42318;
}

.metrics {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}
.metric {
    border-radius: var(--radius-card);
    background: var(--surface);
    border: 1px solid var(--line);
    padding: 18px;
    box-shadow: var(--shadow-card);
}
.metric .label {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
}
.metric .value {
    margin-top: 8px;
    font-size: 30px;
    line-height: 1.1;
    font-weight: 800;
    color: #0f172a;
}
.metric-detail {
    display: block;
    margin-top: 7px;
    font-size: 12px;
    font-weight: 700;
    color: var(--muted);
}
.metric.teal { border-top: 4px solid var(--teal); }
.metric.pink { border-top: 4px solid var(--pink); }
.metric.green { border-top: 4px solid var(--green); }
.metric.gold { border-top: 4px solid var(--gold); }

.workspace {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    align-items: start;
}
.workspace > .history-panel {
    grid-column: span 1;
}
.workspace > .panel:not(.history-panel) {
    grid-column: span 3;
    min-width: 0;
}
.panel,
.service-card {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: var(--shadow-card);
    border: 1px solid var(--line);
    overflow: hidden;
}
.panel-header {
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
}
.panel-title { font-size: 22px; font-weight: 900; }
.panel-subtitle {
    margin-top: 6px;
    font-size: 14px;
    color: var(--muted);
    line-height: 1.4;
}
.panel-body {
    padding: 18px;
    background: linear-gradient(180deg, #fff 0%, #fcfdff 100%);
}

label {
    display: block;
    margin-bottom: 7px;
    color: #3d4d63;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .03em;
}
input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    border-radius: 12px;
    border: 1px solid var(--line);
    padding: 11px 12px;
    font-size: 14px;
    color: var(--text);
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
textarea {
    min-height: 108px;
    resize: vertical;
    line-height: 1.5;
}
input:hover,
select:hover,
textarea:hover { border-color: var(--line-strong); }
input:focus,
select:focus,
textarea:focus {
    border-color: rgba(66, 97, 164, .54);
    background: #fff;
}

.history-panel {
    position: sticky;
    top: 14px;
    max-height: calc(100vh - 28px);
    display: grid;
    grid-template-rows: auto 1fr;
}
.search-wrap { margin-top: 12px; }
.search-field { position: relative; }
.search-field .search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--blue);
    pointer-events: none;
}
.search-field input {
    padding-left: 34px;
    background: #fbfcff;
}
.history-meta {
    margin-top: 10px;
    font-size: 12px;
    color: var(--muted);
}
.history-list {
    overflow: auto;
    padding: 14px;
    display: grid;
    gap: 10px;
    align-content: start;
    background: linear-gradient(180deg, #fbfdff 0%, #f8fbff 100%);
}
.history-item {
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: 12px;
    background: #fff;
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.history-item:hover {
    transform: translateY(-1px);
    border-color: #bac9da;
    box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
}
.history-item[data-active="true"] {
    border-color: rgba(66, 97, 164, .55);
    box-shadow: inset 0 0 0 1px rgba(66, 97, 164, .14);
    background: linear-gradient(135deg, #fff 0%, #f3f7ff 100%);
}
.history-compact {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.history-main { min-width: 0; }
.history-number { font-size: 14px; font-weight: 800; color: #0f172a; }
.history-name {
    margin-top: 4px;
    color: #1e293b;
    font-size: 13px;
    font-weight: 700;
}
.history-actions {
    display: flex;
    gap: 6px;
    margin-top: 0;
    flex-wrap: nowrap;
    flex-shrink: 0;
}
.history-actions form { margin: 0; }
.history-load-more-wrap {
    margin-top: 2px;
    display: flex;
}
.history-load-more {
    width: 100%;
    justify-content: center;
}
.history-load-more[aria-busy="true"] {
    opacity: .74;
    pointer-events: none;
}
.mini-btn {
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: 7px 9px;
    min-height: 31px;
    font-size: 11px;
    font-weight: 800;
    background: #fff;
    cursor: pointer;
}
.icon-btn {
    width: 31px;
    min-width: 31px;
    height: 31px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.icon-btn svg {
    width: 15px;
    height: 15px;
    fill: none;
    stroke: #334155;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.icon-btn:hover {
    background: #f8fbff;
    border-color: #c8d5e3;
}
.icon-btn.icon-btn-danger {
    border-color: #fecdd3;
    background: #fff1f2;
}
.icon-btn.icon-btn-danger svg { stroke: #b42318; }

.stack { display: grid; gap: 12px; }
.section-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: 14px;
    background: var(--surface);
}
.section-title {
    font-size: 17px;
    font-weight: 900;
    margin-bottom: 3px;
}
.section-subtitle {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 12px;
}
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.form-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.preset-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}
.preset {
    border: 1px solid rgba(66, 97, 164, .28);
    background: #f5f8ff;
    color: #2f4674;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}
.preset:hover { background: #eaf1ff; border-color: rgba(66, 97, 164, .44); }
.plan-picker {
    margin-top: 10px;
    border: 1px solid #cdd9e8;
    border-radius: var(--radius-card);
    background: linear-gradient(180deg, #fbfdff 0%, #f7faff 100%);
    padding: 12px;
}
.plan-picker-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.plan-picker-head strong {
    display: block;
    font-size: 15px;
    font-weight: 900;
}
.plan-picker-head span {
    display: block;
    margin-top: 3px;
    font-size: 12px;
    color: var(--muted);
}
.plan-options {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}
.plan-option {
    min-height: 112px;
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    background: #fff;
    padding: 12px;
    text-align: left;
    cursor: pointer;
    display: grid;
    gap: 7px;
    align-content: start;
    color: var(--text);
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.plan-option:hover {
    transform: translateY(-1px);
    border-color: rgba(66, 97, 164, .45);
    box-shadow: 0 8px 18px rgba(15, 23, 42, .08);
}
.plan-option-title {
    font-size: 14px;
    line-height: 1.25;
    font-weight: 900;
}
.plan-option-desc {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}
.plan-option-price {
    margin-top: auto;
    color: #811f20;
    font-size: 15px;
    font-weight: 900;
}
.plan-option-billing {
    color: #506078;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.service-direct-option {
    border-color: rgba(86, 156, 145, .45);
    background: #f7fffc;
}
.section-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.markup-tools {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
}
.markup-tools .field-inline {
    min-width: 150px;
    max-width: 170px;
}

.item-card {
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: 12px;
    margin-top: 10px;
    background: linear-gradient(180deg, #fff 0%, #fbfcff 100%);
}
.item-card.is-dragging { opacity: .55; }
.item-head {
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}
.item-head-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.drag-handle {
    border: 1px solid #cbd8e6;
    border-radius: var(--radius-card);
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    color: #52657d;
    cursor: grab;
}
.drag-handle:active { cursor: grabbing; }
.drag-handle svg { width: 18px; height: 18px; }
.item-index {
    font-size: 14px;
    font-weight: 800;
    color: #1f2a44;
}
.item-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
    gap: 10px;
}
.item-hint {
    margin-top: 8px;
    font-size: 12px;
    color: #5f6f84;
}

.rich-source {
    display: none;
}
.rich-shell {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.rich-shell:focus-within {
    border-color: rgba(66, 97, 164, .54);
    box-shadow: 0 0 0 4px var(--focus);
}
.rich-shell .ql-toolbar.ql-snow {
    border: 0;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(180deg, #fbfdff 0%, #f5f8fc 100%);
    padding: 8px 10px;
    border-radius: 12px 12px 0 0;
}
.rich-shell .ql-container.ql-snow {
    border: 0;
    min-height: 130px;
    font-family: var(--font-body);
    font-size: 14px;
    border-radius: 0 0 12px 12px;
}
.item-card .rich-shell .ql-container.ql-snow {
    min-height: 112px;
}
.rich-shell .ql-editor {
    min-height: 130px;
    padding: 12px 14px;
    line-height: 1.55;
}
.item-card .rich-shell .ql-editor {
    min-height: 112px;
}
.rich-shell .ql-editor p,
.rich-shell .ql-editor ul,
.rich-shell .ql-editor ol {
    margin-bottom: 8px;
}
.rich-shell .ql-picker-label,
.rich-shell .ql-picker-options {
    border-color: var(--line);
}
.rich-shell .ql-formats {
    margin-right: 12px;
}
.rich-shell .ql-picker {
    color: #344256;
}
.rich-content {
    line-height: 1.5;
}
.rich-content p,
.rich-content ul,
.rich-content ol {
    margin: 0 0 8px;
}
.rich-content ul,
.rich-content ol {
    padding-left: 20px;
}

.totals {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.total-card {
    border: 1px solid #d0ddec;
    border-radius: var(--radius-card);
    background: #fff;
    padding: 13px;
    min-height: 96px;
    display: grid;
    align-content: start;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}
.total-card .label {
    color: var(--muted);
    font-size: 12px;
}
.total-card .value {
    font-size: 24px;
    line-height: 1.08;
    font-weight: 900;
    color: #142337;
    font-variant-numeric: tabular-nums;
    min-width: 0;
    overflow-wrap: anywhere;
}
.total-card.highlight {
    border-color: rgba(155, 42, 43, .4);
    background:
        radial-gradient(190px 110px at 86% 10%, rgba(216, 69, 122, .2), transparent 58%),
        linear-gradient(135deg, rgba(155, 42, 43, .1), rgba(216, 69, 122, .15));
}
.total-card.monthly {
    border-color: rgba(66, 97, 164, .35);
    background:
        radial-gradient(180px 110px at 88% 8%, rgba(66, 97, 164, .14), transparent 58%),
        linear-gradient(135deg, rgba(86, 156, 145, .08), rgba(66, 97, 164, .1));
}
.total-detail {
    display: block;
    color: #6f1f35;
    font-size: 11px;
    line-height: 1.3;
    font-weight: 700;
    min-width: 0;
    overflow-wrap: anywhere;
}
.total-card.highlight .total-detail:first-of-type {
    margin-top: 2px;
}
.form-actions {
    position: sticky;
    bottom: -1px;
    margin-top: 6px;
    padding-top: 14px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0), #fff 22%);
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-top: 1px dashed #d6e1eb;
}

.services-grid {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}
.services-manager {
    align-items: start;
}
.service-card { padding: 18px; }
.service-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}
.service-card h2 {
    font-size: 28px;
    line-height: 1.1;
    font-weight: 900;
}
.service-card-subtitle {
    margin-top: 6px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.4;
}
.catalog-count {
    border: 1px solid #d7e2ee;
    border-radius: 999px;
    background: #f8fbff;
    color: #40536b;
    padding: 6px 9px;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}
.catalog-form {
    display: grid;
    gap: 9px;
    margin-top: 0;
    border: 1px solid #dce6f0;
    border-radius: var(--radius-card);
    padding: 12px;
    background: linear-gradient(180deg, #fff 0%, #fbfdff 100%);
}
.catalog-library-head {
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px dashed #d6e1eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.catalog-library-head strong {
    font-size: 14px;
    font-weight: 900;
}
.catalog-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
    overflow: visible;
}
.catalog-item {
    border: 1px solid var(--line);
    border-radius: var(--radius-card);
    padding: 14px;
    background: #fbfdff;
}
.catalog-item h3 { font-size: 18px; font-weight: 900; }
.catalog-group {
    display: grid;
    gap: 10px;
}
.catalog-group + .catalog-group {
    padding-top: 10px;
    border-top: 1px dashed var(--line);
}
.catalog-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 2px 2px 0;
}
.catalog-group-title strong {
    font-size: 15px;
    font-weight: 900;
}
.catalog-group-title span {
    font-size: 12px;
    color: var(--muted);
}
.catalog-meta {
    margin-top: 4px;
    font-size: 13px;
    color: #4a5f7a;
}
.catalog-desc {
    margin-top: 7px;
    color: #1e293b;
    line-height: 1.45;
}
.catalog-actions {
    margin-top: 8px;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
}
.catalog-actions form { margin: 0; }
.catalog-form-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.catalog-form-actions .btn {
    flex: 1 1 180px;
}

@media (max-width: 1290px) {
    .hero { flex-direction: column; align-items: flex-start; }
    .hero-actions { width: 100%; justify-content: flex-start; }
    .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .workspace { grid-template-columns: 1fr; }
    .workspace > .history-panel,
    .workspace > .panel:not(.history-panel) { grid-column: auto; }
    .history-panel { position: static; max-height: none; }
}
@media (max-width: 920px) {
    .form-grid,
    .form-grid-2,
    .item-grid,
    .totals,
    .plan-options,
    .services-grid { grid-template-columns: 1fr; }
}
@media (max-width: 680px) {
    .shell { padding: 14px; }
    .hero { padding: 42px 22px; border-radius: 12px; }
    .hero-logo { width: 52px; }
    .hero-title { font-size: 34px; }
    .metrics { grid-template-columns: 1fr; }
    .service-card-head {
        flex-direction: column;
        align-items: flex-start;
    }
    .panel-header,
    .panel-body,
    .service-card { padding: 14px; }
    .form-actions {
        position: static;
        background: transparent;
        border-top: 0;
        padding-top: 0;
    }
}
