:root {
    --green: #07984f;
    --green-dark: #087443;
    --green-soft: #e9f8ef;
    --orange: #fb922c;
    --blue: #1f6feb;
    --purple: #7c4dcb;
    --ink: #111827;
    --muted: #667085;
    --line: #e8eaef;
    --bg: #f6f8fb;
    --card: #fff;
    --shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body.listing-create-page {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

/* create_listing.php no longer uses its own topbar (unified with the shared
   Design System header in Phase 15), but edit_listing.php still renders this
   same reference topbar markup and depends on these rules. */
.create-topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    display: flex;
    min-height: 74px;
    align-items: center;
    gap: 18px;
    padding: 0 32px;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(14px);
}

.create-topbar--reference {
    min-height: 64px;
    gap: 24px;
    padding: 0 30px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 28px;
    font-weight: 800;
}

.create-topbar--reference .brand {
    flex: 0 0 auto;
}

.create-back-top {
    display: inline-flex;
    min-height: 42px;
    align-items: center;
    gap: 10px;
    padding: 0 18px;
    color: #111827;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-weight: 700;
    text-decoration: none;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
    white-space: nowrap;
}

.create-back-top:hover {
    color: var(--green-dark);
    border-color: #bfd9cb;
}

.brand-mark {
    display: grid;
    width: 36px;
    height: 36px;
    place-items: center;
    color: #fff;
    background: var(--green);
    border-radius: 50%;
    font-weight: 800;
}

.topbar-spacer {
    flex: 1;
}

.user-chip {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.avatar {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    color: #fff;
    background: #23715f;
    border-radius: 50%;
    font-weight: 800;
}

.create-nav {
    display: flex;
    min-width: 0;
    flex: 1;
    align-items: center;
    gap: 6px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.create-nav a {
    flex: 0 0 auto;
    padding: 9px 11px;
    color: #475467;
    border-radius: 9px;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.create-nav a:hover,
.create-nav a.active {
    color: var(--green-dark);
    background: var(--green-soft);
}

.back-btn {
    min-width: 172px;
}

.create-shell {
    /* Нүүр хуудасны .eb-page-shell-тэй яг ижил max-width/padding загвар
       (width-хасалт биш, padding-инсет), 1496px+ өргөнд header-тэй
       яг нэг шугамд байлгахын тулд. */
    max-width: 1440px;
    margin: 24px auto 36px;
    padding: 0 28px;
}

.create-page-heading {
    display: none;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.create-page-heading h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0;
}

.create-page-heading p {
    margin: 8px 0 0;
    color: var(--muted);
}

.create-layout {
    display: grid;
    grid-template-columns: 275px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

.create-sidebar,
.form-section {
    /* Нүүр хуудасны .eb-listing-card-тэй ижил radius/shadow. */
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(23, 27, 38, 0.04);
}

.create-sidebar {
    position: sticky;
    top: 98px;
    overflow: hidden;
}

.create-sidebar h1 {
    margin: 0;
    padding: 28px 24px 4px;
    font-size: 22px;
    font-weight: 600;
}

.create-sidebar > p {
    margin: 0;
    padding: 0 24px 24px;
    color: var(--muted);
    font-weight: 600;
}

.stepper {
    position: relative;
    display: grid;
    gap: 22px;
    margin: 0;
    padding: 26px 24px;
    border-top: 1px solid var(--line);
    list-style: none;
}

.stepper::before {
    content: "";
    position: absolute;
    top: 48px;
    bottom: 48px;
    left: 43px;
    width: 2px;
    background: #d9dee8;
}

.stepper li {
    position: relative;
    display: flex;
    gap: 16px;
}

.stepper span {
    display: grid;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    place-items: center;
    color: #fff;
    background: #aab2bd;
    border-radius: 50%;
    font-weight: 800;
}

.stepper li.active span {
    background: var(--green);
}

.stepper strong {
    display: block;
    margin-bottom: 4px;
}

.stepper li.active strong {
    color: var(--green);
}

.stepper small {
    display: block;
    color: var(--muted);
    line-height: 1.45;
}

.safety-box {
    margin: 0 18px 18px;
    padding: 18px;
    background: #f0fbf4;
    border: 1px solid #d7f0df;
    border-radius: 10px;
}

.safety-box i {
    color: var(--green);
    font-size: 20px;
}

.safety-box strong {
    display: block;
    margin: 8px 0;
    color: #147242;
}

.safety-box p {
    margin: 0;
    color: #4b6358;
    font-size: 13px;
    line-height: 1.6;
}

.create-form {
    display: grid;
    gap: 18px;
}

.form-section {
    padding: 24px;
}

.listing-dynamic-field {
    min-width: 0;
}

.listing-dynamic-field .form-label {
    display: inline-flex;
    max-width: 100%;
    align-items: baseline;
    gap: 2px;
    overflow-wrap: anywhere;
}

.listing-dynamic-field .form-control,
.listing-dynamic-field .form-select,
.listing-dynamic-field textarea {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.listing-dynamic-field .input-group {
    flex-wrap: nowrap;
    max-width: 100%;
    min-width: 0;
}

.listing-dynamic-field .input-group > .form-control,
.listing-dynamic-field .input-group > .form-select {
    min-width: 0;
}

.listing-dynamic-field .input-group-text {
    flex: 0 0 auto;
    white-space: nowrap;
}

.dynamic-checkbox-group {
    display: grid;
    gap: 8px;
}

.dynamic-check-line {
    margin: 0;
    min-width: 0;
}

.dynamic-check-line span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 22px;
}

.section-title h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.section-title p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.section-index,
.section-icon {
    display: grid;
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    place-items: center;
    color: #fff;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 800;
}

.section-corner-icon {
    display: grid;
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
    place-items: center;
    margin-left: auto;
    color: var(--green);
    background: var(--green-soft);
    border-radius: 50%;
    font-size: 26px;
}

.section-icon {
    margin-left: auto;
    color: var(--green);
    background: var(--green-soft);
    border-radius: 50%;
}

.section-green,
.form-section--green {
    border-color: #cfeadd;
}

.section-green .section-index,
.form-section--green .section-index {
    background: var(--green);
}

.section-green h2,
.form-section--green h2 {
    color: var(--green);
}

.section-orange,
.form-section--orange {
    border-color: #fed7aa;
}

.section-orange .section-index,
.form-section--orange .section-index {
    background: var(--orange);
}

.section-orange h2,
.form-section--orange h2 {
    color: #c96710;
}

.section-blue,
.form-section--blue {
    border-color: #cfe0ff;
}

.section-blue .section-index,
.form-section--blue .section-index,
.wanted-number {
    background: var(--blue);
}

.section-blue h2,
.form-section--blue h2 {
    color: var(--blue);
}

.section-purple,
.form-section--purple {
    border-color: #e1d6ff;
}

.section-purple .section-index,
.form-section--purple .section-index {
    background: var(--purple);
}

.section-purple h2,
.form-section--purple h2 {
    color: var(--purple);
}

.form-label {
    color: #1f2937;
    font-size: 13px;
    font-weight: 800;
}

.form-label b {
    color: #ef4444;
}

.form-control,
.form-select {
    /* Нүүр хуудасны auth-input-тэй ойролцоо өндөр/radius. */
    min-height: 44px;
    border-color: #d9e1ec;
    border-radius: 10px;
    font-size: 14px;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--green);
    box-shadow: 0 0 0 0.18rem rgba(7, 152, 79, 0.15);
}

.dynamic-title {
    margin-top: 8px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
    color: var(--green);
    font-size: 15px;
    font-weight: 800;
}

.input-counter {
    position: relative;
}

.input-counter span {
    position: absolute;
    right: 14px;
    bottom: 10px;
    color: #98a2b3;
    font-size: 11px;
    font-weight: 700;
}

.textarea-counter span {
    bottom: 10px;
}

.textarea-counter textarea {
    padding-bottom: 28px;
}

.upload-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(120px, 1fr));
    gap: 14px;
}

.upload-grid--strip {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
}

.upload-box,
.preview-card {
    position: relative;
    display: grid;
    min-height: 116px;
    place-items: center;
    overflow: hidden;
    background: #f8fafc;
    border: 1px dashed #b9d8c6;
    border-radius: 10px;
}

.upload-box {
    gap: 4px;
    padding: 12px;
    cursor: pointer;
    text-align: center;
}

.upload-box input {
    display: none;
}

.upload-box i {
    font-size: 22px;
    color: var(--green);
}

.upload-box span {
    color: var(--green);
    font-size: 13px;
    font-weight: 700;
}

.upload-box small {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 500;
    line-height: 1.4;
}

.preview-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preview-card button {
    position: absolute;
    top: 8px;
    right: 8px;
    display: grid;
    width: 28px;
    height: 28px;
    place-items: center;
    background: #fff;
    border: 0;
    border-radius: 50%;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.16);
}

.preview-card--existing {
    display: block;
}

.preview-card--existing img {
    display: block;
}

.preview-card--existing .existing-image-delete {
    position: absolute;
    inset: auto 0 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 4px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    cursor: pointer;
    background: rgba(15, 23, 42, 0.72);
}

.preview-card--existing .existing-image-delete input {
    margin: 0;
}

.preview-card--existing.is-marked-for-delete {
    opacity: 0.4;
}

.preview-card--existing.is-marked-for-delete .existing-image-delete {
    background: #d63d4b;
}

.barter-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.option-card {
    display: flex;
    min-height: 128px;
    gap: 14px;
    padding: 22px;
    border: 1px solid #dfe5ef;
    border-radius: 10px;
    cursor: pointer;
}

.option-card.active {
    background: #fffaf3;
    border-color: var(--orange);
}

.option-card input[type="radio"] {
    display: none;
}

.option-card > span {
    display: grid;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    place-items: center;
    margin-top: 2px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
}

.option-card.active > span {
    border: 5px solid var(--orange);
}

.option-card strong,
.option-card small {
    display: block;
}

.option-card small {
    margin-top: 6px;
    color: var(--muted);
}

.wanted-list {
    display: grid;
    gap: 12px;
}

.wanted-row {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr) minmax(180px, 230px);
    gap: 12px;
    align-items: center;
}

.wanted-number {
    display: grid;
    width: 32px;
    height: 32px;
    place-items: center;
    color: #fff;
    border-radius: 50%;
    font-weight: 800;
}

.match-count {
    display: grid;
    min-height: 58px;
    place-items: center;
    padding: 8px;
    color: var(--blue);
    background: #f8fbff;
    border: 1px solid #dce8ff;
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
}

.match-card-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    min-width: 0;
}

.match-count--exact {
    color: #0f766e;
    background: #f0fdfa;
    border-color: #ccfbf1;
}

.match-count.is-disabled {
    color: #94a3b8;
    background: #f8fafc;
    border-color: #e2e8f0;
    cursor: default;
    pointer-events: none;
}

.duplicate-warning {
    grid-column: 2 / -1;
    color: #b42318;
    font-size: 12px;
    font-weight: 700;
}

.auth-modal-note {
    margin: 12px 0 0;
    color: #667085;
    font-size: 13px;
    line-height: 1.5;
}

.match-count strong {
    line-height: 1;
    font-size: 20px;
}

.match-count span {
    color: var(--muted);
    font-size: 11px;
}

.match-count em {
    color: var(--muted);
    font-size: 11px;
    font-style: normal;
}

.final-info-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.publish-summary {
    padding: 18px;
    border: 1px solid #e1d6ff;
    border-radius: 10px;
    background: #fbf9ff;
}

.publish-summary h3 {
    margin: 0 0 12px;
    color: var(--purple);
    font-size: 17px;
    font-weight: 800;
}

.publish-summary ul {
    display: grid;
    gap: 10px;
    margin: 0 0 14px;
    padding: 0;
    list-style: none;
}

.publish-summary li {
    display: flex;
    gap: 8px;
    align-items: center;
    color: #334155;
    font-weight: 700;
}

.publish-summary p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.55;
}

.check-line {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    font-weight: 700;
}

.check-line input {
    width: 17px;
    height: 17px;
    accent-color: var(--green);
}

.guest-lock {
    width: min(100%, 300px);
    justify-self: end;
    margin-top: -42px;
    margin-right: 120px;
    padding: 22px;
    text-align: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.guest-lock i {
    color: #4b5563;
    font-size: 26px;
}

.guest-lock strong {
    display: block;
    margin-top: 10px;
}

.guest-lock p {
    margin: 8px 0 14px;
    color: var(--muted);
    font-size: 13px;
}

.create-actions {
    display: grid;
    grid-template-columns: 150px 170px minmax(180px, 310px);
    justify-content: end;
    gap: 14px;
}

.publish-btn {
    background: var(--green);
    border-color: var(--green);
    font-weight: 800;
}

.publish-btn:hover {
    background: var(--green-dark);
    border-color: var(--green-dark);
}

.auth-modal {
    border: 0;
    border-radius: 12px;
}

.auth-modal-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

    .create-sidebar {
        position: static;
    }

    .stepper {
        grid-template-columns: repeat(4, 1fr);
        gap: 12px;
    }

    .stepper::before {
        display: none;
    }
}

@media (max-width: 860px) {
    .create-topbar {
        flex-wrap: wrap;
        height: auto;
        padding: 14px 18px;
    }

    .create-topbar--reference {
        gap: 12px;
    }

    .create-back-top {
        order: 3;
        width: 100%;
        justify-content: center;
    }

    .brand {
        font-size: 23px;
    }

    .back-btn {
        order: 3;
        width: 100%;
    }

    .create-nav {
        order: 4;
        width: 100%;
        flex-basis: 100%;
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .create-page-heading {
        display: grid;
    }

    .create-shell {
        /* Нүүр хуудасны header-ийн ≤800px inset (padding:0 18px)-тэй нэг
           шугамд байлгах зорилгоор яг тэр хэмжээгээр тохируулав. */
        padding: 0 18px;
    }

    .stepper,
    .barter-options,
    .wanted-row,
    .final-info-grid,
    .create-actions {
        grid-template-columns: 1fr;
    }

    .match-card-group {
        grid-template-columns: 1fr 1fr;
    }

    .duplicate-warning {
        grid-column: auto;
    }

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

    .guest-lock {
        justify-self: stretch;
        width: 100%;
        margin: 0;
    }
}

@media (max-width: 575.98px) {
    .form-section {
        padding: 18px;
    }

    .listing-dynamic-field .input-group > .form-select {
        flex: 0 1 118px;
    }

    .listing-dynamic-field .input-group-text {
        max-width: 42%;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

.preview-card {
    position: relative;
    overflow: hidden;
}

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

.preview-card .cover-label {
    position: absolute;
    left: 8px;
    bottom: 8px;
    padding: 5px 9px;
    border-radius: 7px;
    background: rgba(5, 150, 105, 0.92);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
}

.preview-card .remove-image {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(17, 24, 39, 0.75);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.preview-card .remove-image:hover {
    background: rgba(220, 38, 38, 0.92);
}

.preview-card{
    cursor:grab;
    transition:.2s;
}

.preview-card:active{
    cursor:grabbing;
}

.preview-card.dragging{
    opacity:.45;
}

.preview-card.drag-over{
    border:2px dashed #07984f;
}

/* CHANGE 3B (UX round 2026-08) -- small order-number chip, top-left, kept
   clear of .cover-label (bottom-left) and .remove-image (top-right) so all
   three can show on the same card without overlapping. */
.preview-card .order-badge {
    position: absolute;
    top: 7px;
    left: 7px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: rgba(17, 24, 39, 0.72);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
    pointer-events: none;
}

.preview-card.touch-dragging {
    opacity: .55;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.28);
    z-index: 5;
}

.match-summary-list {
    display: grid;
    gap: 10px;
}

.match-summary-list > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid #e5e9f0;
    border-radius: 9px;
}

.match-summary-list span {
    color: #667085;
    font-size: 13px;
    font-weight: 600;
}

.match-summary-list strong {
    color: #111827;
    font-size: 18px;
    font-weight: 800;
}
