/*
 * BUILDX.mn дизайн систем — index.html загварын токен, классууд.
 * Tailwind preflight нь @layer base дотор тул энэ (layer-гүй) дүрмүүд давамгайлна.
 */
:root {
  --ink: #13253d;
  --orange: #ed5700;
  --orange-dark: #b44200;
  --orange-soft: #fff0e5;
  --bg: #f4f6f8;
  --line: #dde3e9;
  --field: #b9c5d0;
  --muted: #627184;
  --red: #b3261e;
  --red-soft: #fdecea;
  --green: #23663f;
  --green-soft: #e5f2eb;
  --focus: 0 0 0 3px rgba(237, 87, 0, .35);
}

* { box-sizing: border-box }
body { margin: 0; font: 16px/1.55 Arial, "Helvetica Neue", sans-serif; color: var(--ink); background: var(--bg); min-height: 100vh; display: flex; flex-direction: column }
a { color: inherit; text-decoration: none }
a:hover { color: var(--orange-dark) }
p a, .link, td a, li a { text-decoration: underline; text-underline-offset: 2px }
button, input, select, textarea { font: inherit }
img { max-width: 100%; height: auto }
:focus-visible { outline: 2px solid var(--orange); outline-offset: 2px }
[hidden] { display: none !important }

button, .btn { cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 10px 16px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; text-decoration: none; line-height: 1.2 }
button:hover, .btn:hover { border-color: var(--orange); color: var(--ink) }
/* Turbo нь маягт илгээх үед submit товчийг disabled болгодог. Rails-ийн f.submit нь
   <input type=submit> үүсгэдэг тул button:disabled дангаараа хүрэлцэхгүй. */
button:disabled, input:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; border-color: var(--line) }
.primary, button.primary, .btn.primary { background: var(--orange); color: #fff; border-color: var(--orange) }
.primary:hover { background: #d44e00; color: #fff }
.primary:disabled { border-color: var(--orange) }
.danger { color: var(--red); border-color: #efc2be }
.danger:hover { border-color: var(--red) }
.link-button { background: none; border: 0; padding: 0; min-height: 0; color: inherit; text-decoration: underline; text-underline-offset: 2px }
.button_to { display: inline }

input, select, textarea { width: 100%; padding: 12px; border: 1px solid var(--field); border-radius: 7px; background: #fff; color: var(--ink); min-height: 46px }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; accent-color: var(--orange) }
input[type=file] { padding: 9px }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: var(--focus) }
textarea { min-height: 110px; resize: vertical }
label { display: block; font-weight: 600; margin-bottom: 16px }
label input, label select, label textarea { margin-top: 7px; font-weight: 400 }
label.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400 }
label.check input { margin-top: 4px }
.rich-field { margin-bottom: 16px }
.rich-field > label { margin-bottom: 7px }
.check-list { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 16px }
.check-list label.check { width: auto }
.hint { display: block; font-size: 13px; color: var(--muted); font-weight: 400; margin-top: 4px }
.field_with_errors { display: contents }
.field_with_errors input, .field_with_errors select, .field_with_errors textarea { border-color: var(--red) }
.field-error { display: block; color: var(--red); font-size: 14px; font-weight: 400; margin-top: 5px }
/* Tom Select — бичиж шүүдэг select. tom-select.min.css дараа ачаалагддаг тул сонгогчийг нарийвчилсан. */
.ts-wrapper.single { margin-top: 7px; font-weight: 400 }
.ts-wrapper.single .ts-control { min-height: 46px; padding: 11px 36px 11px 12px; border: 1px solid var(--field); border-radius: 7px; background: #fff; color: var(--ink); font-size: 16px; line-height: 1.4 }
.ts-wrapper.single .ts-control { flex-wrap: nowrap }
.ts-wrapper.single .ts-control > .item { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.ts-wrapper.single.has-items .ts-control > input { min-width: 1px !important }
.ts-wrapper.single.has-query .ts-control > .item { display: none }
.ts-wrapper.single.focus .ts-control { border-color: var(--orange); box-shadow: var(--focus) }
.ts-wrapper.single.invalid .ts-control, .field_with_errors .ts-wrapper.single .ts-control { border-color: var(--red) }
.ts-wrapper.single .ts-control::after { border-color: var(--muted) transparent transparent; right: 14px }
.ts-wrapper.single.dropdown-active .ts-control::after { border-color: transparent transparent var(--muted) }
.ts-dropdown { margin-top: 4px; border: 1px solid var(--field); border-radius: 7px; box-shadow: 0 8px 24px rgba(19, 37, 61, .14); color: var(--ink); font-size: 15px; font-weight: 400; overflow: hidden; z-index: 60 }
.ts-dropdown .ts-dropdown-content { max-height: min(320px, 50vh) }
.ts-dropdown .option, .ts-dropdown .no-results { padding: 9px 12px }
.ts-dropdown .optgroup-header { padding: 8px 12px 4px; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .02em }
.ts-dropdown .optgroup + .optgroup { border-top: 1px solid var(--line) }
.ts-dropdown .active { background: var(--orange-soft); color: var(--ink) }
.ts-dropdown .selected { font-weight: 700 }
.ts-dropdown .highlight { background: rgba(237, 87, 0, .18); border-radius: 2px }
select.tomselected { min-height: 0; height: 1px; margin: 0 }

fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px 4px; margin: 0 0 18px }
legend { font-weight: 700; padding: 0 6px }

header { background: #fff; border-bottom: 1px solid var(--line) }
.top, .nav, main, .foot { max-width: 1280px; margin: 0 auto; padding: 18px 24px; width: 100% }
main { flex: 1 }
main:focus { outline: none }
.top { display: flex; align-items: center; gap: 16px }
.logo { font-size: 30px; font-weight: 900; white-space: nowrap; letter-spacing: -1.5px; line-height: 1 }
.logo b { color: var(--orange); font-size: 37px }
.logo small { font-size: 21px }
.search { display: flex; gap: 8px; flex: 1; min-width: 0 }
.icon-link { font-size: 23px; position: relative; padding: 6px; min-width: 44px; text-align: center }
.dot { position: absolute; top: 0; right: 0; background: var(--orange); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 5px; font-weight: 700 }
.nav { display: flex; gap: 27px; padding-top: 0; flex-wrap: wrap; font-size: 14px; font-weight: 600 }
.nav a.active { color: var(--orange) }
.skip { position: absolute; left: -9999px; top: 8px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 6px; z-index: 50 }
.skip:focus { left: 8px }
.grow { flex: 1 }

.menu { position: relative }
.menu summary { list-style: none }
.menu summary::-webkit-details-marker { display: none }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(19, 37, 61, .12); min-width: 210px; padding: 6px; z-index: 30 }
.menu-list a, .menu-list .link-button { display: block; padding: 10px 12px; border-radius: 6px; text-decoration: none; width: 100%; text-align: left }
.menu-list a:hover, .menu-list .link-button:hover { background: var(--bg) }
.menu-list form { display: block; border-top: 1px solid var(--line); margin-top: 4px; padding-top: 4px }

/* Энгийн мөрөн жагсаалт (миний зарууд, мессеж, гишүүд, хавсралт г.м.).
   .menu-list бол зөвхөн толгой хэсгийн унждаг цэсний самбар — position: absolute
   тул энд хэрэглэвэл жагсаалт хуудаснаас мултарч хаячихна. */
.list { list-style: none; margin: 0 0 20px; padding: 0; background: #fff; border: 1px solid var(--line); border-radius: 12px }
.list > li { padding: 14px 16px; border-top: 1px solid var(--line) }
.list > li:first-child { border-top: 0 }

h1 { font-size: 32px; line-height: 1.25; margin: 14px 0 }
h2 { font-size: 23px; line-height: 1.3; margin: 0 0 16px }
h3 { font-size: 18px; line-height: 1.35; margin: 0 0 8px }
p { margin: 8px 0 18px }
ul { padding-left: 22px }
.muted, .meta { color: var(--muted) }
.meta { font-size: 14px }
.small { font-size: 13px }
.bread { font-size: 14px; color: var(--muted); margin-bottom: 14px }
.bread a { text-decoration: none }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap }
.row.tight { gap: 6px }
.row.center { justify-content: center }
.row.end { justify-content: flex-end }
.between { justify-content: space-between }
.stack > * + * { margin-top: 10px }
/* Нэвтрэх г.м. auth хуудсуудын доод холбоосуудын жагсаалт (.stack > a) — анкер нь
   үндсэндээ inline тул display:block өгөхгүй бол мөр таслалгүй нэг мөрөнд наалддаг. */
.stack > a { display: block; color: var(--muted); font-size: 14px }
.stack > a:hover { color: var(--orange-dark); text-decoration: underline; text-underline-offset: 2px }
.min0 { min-width: 0 }
.mt0 { margin-top: 0 }
.mb0 { margin-bottom: 0 }
.mt { margin-top: 24px }
.nowrap { white-space: nowrap }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden }
.pre { white-space: pre-line; overflow-wrap: anywhere }

.layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; margin-top: 26px }
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px }
.panel { padding: 24px; border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-bottom: 20px; display: block }
a.panel:hover { border-color: var(--orange); color: inherit }
.side { align-self: start }
.side nav a, .side > a { display: block; padding: 11px; border-radius: 6px; text-decoration: none }
.side nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px }
.nav-count { background: var(--orange); color: #fff; font-size: 12px; font-weight: 700; line-height: 18px; min-width: 20px; padding: 0 6px; border-radius: 999px; text-align: center; flex: none }
.nav-count.warn { background: var(--red); cursor: help }
.side nav a.active { background: #fff0e6; color: var(--orange-dark) }
.side nav .nav-group { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); margin: 14px 0 2px; padding: 0 11px }
.side nav a.sub { padding-left: 24px; font-size: 14px }
.sticky { position: sticky; top: 16px }
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px }
.grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)) }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px }
.price-range { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px }
.three { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 20px }

.card { background: #fff; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; position: relative; display: flex; flex-direction: column }
.card:hover { border-color: #c8d2dc }
.card-link { display: flex; flex-direction: column; flex: 1; color: inherit; text-decoration: none }
.card-link:hover { color: inherit }
.card-link:hover h3 { color: var(--orange-dark) }
.card .body { padding: 18px }
.thumb { height: 155px; background: #e8edf2; display: flex; align-items: center; justify-content: center; font-size: 54px; overflow: hidden }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block }
.card:nth-child(3n+2) .thumb { background: #f2e8df }
.card:nth-child(3n+3) .thumb { background: #e3eceb }
.thumb-icon { line-height: 1 }
.badge { font-size: 12px; background: #edf3f8; border-radius: 5px; padding: 4px 8px; display: inline-block; font-weight: 600; line-height: 1.3; white-space: nowrap }
.badge.orange { background: var(--orange-soft); color: #ab3d00 }
.badge.green { background: var(--green-soft); color: var(--green) }
.badge.red { background: var(--red-soft); color: var(--red) }
.badge.gray { background: #eceff2; color: #4c5968 }
.price { font-size: 22px; font-weight: 700; margin: 8px 0 }
.price.big { font-size: 30px }
.fav-wrap form { display: contents }
.heart { position: absolute; right: 10px; top: 10px; border-radius: 50%; padding: 6px 12px; font-size: 23px; z-index: 2; min-width: 44px }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 20px 0 }
.chip { display: inline-flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 20px; padding: 6px 12px; font-size: 14px; min-height: 36px; text-decoration: none }
.chip:hover { border-color: var(--orange) }
.chip .x { font-size: 17px; line-height: 1; color: var(--muted) }
.chips .selected, .chip.selected { background: var(--ink); color: #fff; border-color: var(--ink) }
.catgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px }
.category { padding: 20px; background: #fff; border: 1px solid var(--line); border-radius: 9px; display: block }
.category:hover { border-color: var(--orange); color: inherit }
.category > span { font-size: 27px; display: block; margin-bottom: 7px; line-height: 1.2 }
.category .sub a { text-decoration: none }
.category .sub a:hover { text-decoration: underline }
.banner { background: var(--ink); color: #fff; padding: 30px; border-radius: 12px; margin: 24px 0 }
.banner .meta, .banner .muted { color: #c3cfdc }
.banner .btn:not(.primary) { color: var(--ink) }
.banner-logo { width: 88px; height: 88px; border-radius: 12px; background: #fff; object-fit: contain; padding: 6px }
.tabline { display: flex; gap: 8px; border-bottom: 1px solid var(--line); padding-bottom: 0; margin: 24px 0; overflow-x: auto }
.tabline a { padding: 8px 14px 12px; white-space: nowrap; text-decoration: none; border-bottom: 2px solid transparent }
.tabline .active { color: var(--orange); border-bottom-color: var(--orange) }
.wide { width: 100% }
.stat { font-size: 30px; font-weight: 700 }
.tablewrap { overflow: auto }
table { width: 100%; border-collapse: collapse; text-align: left }
th, td { padding: 14px 10px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top }
th { background: #f5f7f9 }
table.spec td:first-child { color: var(--muted); width: 42% }
.steps { display: flex; gap: 8px; margin: 24px 0; list-style: none; padding: 0 }
.steps li, .steps span { flex: 1; padding: 10px; border-bottom: 3px solid var(--line); font-size: 14px }
.steps .on { border-color: var(--orange); color: var(--orange) }
.steps a { text-decoration: none }
.notice { background: #fff4e9; border-left: 3px solid var(--orange); padding: 15px; margin: 18px 0; border-radius: 0 6px 6px 0 }
.notice.error { background: var(--red-soft); border-left-color: var(--red) }
.notice.ok { background: var(--green-soft); border-left-color: var(--green) }
.notice.info { background: #edf3f8; border-left-color: var(--ink) }
.notice ul { margin: 6px 0 0 }
.notice:focus { outline: none }
.empty { text-align: center; padding: 60px 20px }
.hero-icon { font-size: 110px; background: #e8edf2; text-align: center; padding: 50px; border-radius: 9px }

.toasts { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 40; display: flex; flex-direction: column; gap: 8px; width: max-content; max-width: 90vw }
.toast { background: var(--ink); color: #fff; padding: 12px 12px 12px 20px; border-radius: 10px; display: flex; align-items: center; gap: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18) }
.toast.alert { background: var(--red) }
.toast-close { background: transparent; color: #fff; border: 0; font-size: 22px; min-height: 32px; padding: 0 8px }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin: 28px 0 }
.pagination .page { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; border: 1px solid var(--line); background: #fff; border-radius: 8px; text-decoration: none }
.pagination a.page:hover { border-color: var(--orange) }
.pagination .current { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 700 }
.pagination .gap { border: 0; background: none }

.filters summary { display: none }
.filters .filter-body { display: block }

.gallery-main { background: #e8edf2; border-radius: 9px; overflow: hidden; aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; position: relative }
.gallery-main img { width: 100%; height: 100%; object-fit: contain; cursor: zoom-in }
.gallery-main .thumb-icon { font-size: 110px }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 10px; overflow-x: auto; padding-bottom: 4px }
.gallery-thumbs button { padding: 0; width: 76px; height: 60px; flex: 0 0 auto; overflow: hidden; min-height: 0 }
.gallery-thumbs button[aria-current=true] { border: 2px solid var(--orange) }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block }
dialog { border: 0; border-radius: 12px; padding: 0; max-width: min(640px, 94vw); width: 100%; color: var(--ink) }
dialog::backdrop { background: rgba(19, 37, 61, .55) }
dialog .dialog-body { padding: 24px }

.uploads { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 10px }
.upload-item { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 9px; padding: 8px; background: #fff }
.upload-item img, .upload-item .ph { width: 72px; height: 56px; object-fit: cover; border-radius: 6px; background: #e8edf2; display: flex; align-items: center; justify-content: center }
.upload-item.error { border-color: var(--red) }
.upload-item .actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end }
.upload-item .actions button { min-height: 36px; padding: 4px 10px; font-size: 13px }
.progress { height: 6px; background: var(--line); border-radius: 4px; overflow: hidden; margin-top: 6px }
.progress > span { display: block; height: 100%; background: var(--orange); width: 0; transition: width .2s }
.dropzone { border: 2px dashed var(--field); border-radius: 10px; padding: 22px; text-align: center; background: #fafbfc; margin-bottom: 14px }
.dropzone.over { border-color: var(--orange); background: var(--orange-soft) }

/* Хавсаргасан зургийн жижиг урьдчилсан харагдац. .thumb дангаараа зарын картын
   өргөн зурган талбар (155px өндөр) тул энд хэмжээг нь тогтмол болгоно. */
.thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 16px }
.thumbs .thumb { position: relative; width: 150px; height: 112px; flex: none; border: 1px solid var(--line); border-radius: 8px }
.thumbs .thumb img { border-radius: 7px }
.thumb.sm { width: 60px; height: 45px; flex: none; border-radius: 6px }
.thumbs .thumb .meta { padding: 8px; font-size: 12px; text-align: center; overflow-wrap: anywhere }
.thumbs .thumb .check { position: absolute; left: 0; right: 0; bottom: 0; margin: 0; display: flex; gap: 6px; align-items: center; justify-content: center; padding: 4px; font-size: 12px; background: rgba(255,255,255,.92); border-radius: 0 0 7px 7px; cursor: pointer }
.thumbs .thumb .check input { margin: 0 }
/* GLightbox-оор томруулах холбоос — зургийг бүтэн дүүргэнэ. */
.zoom { display: block; width: 100%; height: 100%; cursor: zoom-in }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px }
.photo-grid .zoom { aspect-ratio: 4 / 3; border-radius: 8px; overflow: hidden; background: #e8edf2 }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block }

.conversation { min-height: 330px; max-height: 60vh; overflow-y: auto; margin: 8px 0 20px }
.bubble { background: #edf2f6; border-radius: 12px; padding: 16px; margin: 12px 0; max-width: 85%; overflow-wrap: anywhere }
.bubble.mine { background: var(--orange-soft); margin-left: auto }
.bubble .text { white-space: pre-line }
.bubble .meta { font-size: 12px; margin-top: 4px }
.composer { display: flex; gap: 12px; align-items: center }
.composer input { flex: 1; min-width: 0 }

.foot { font-size: 14px; border-top: 1px solid var(--line); margin-top: 40px; display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap }
.foot nav a { text-decoration: none }
.spec li { margin-bottom: 10px }
.mobilebar { display: none }
.contactbar { display: none }
.trix-content { overflow-wrap: anywhere }
.article-body img { border-radius: 8px }
.auth { max-width: 500px; margin: 30px auto }
.recaptcha-wrap { margin-bottom: 16px }

@media (max-width: 950px) {
  .grid, .grid.four { grid-template-columns: repeat(2, minmax(0, 1fr)) }
  .detail { grid-template-columns: minmax(0, 1fr) }
  .top { flex-wrap: wrap }
  .search { order: 3; flex-basis: 100% }
  .catgrid { grid-template-columns: repeat(3, 1fr) }
  .three { grid-template-columns: 1fr 1fr }
  .sticky { position: static }
}

@media (max-width: 640px) {
  main { padding: 18px 14px }
  .top { padding: 14px; gap: 8px }
  .logo { font-size: 25px }
  .logo b { font-size: 30px }
  .top > .btn, .menu summary { padding: 8px; font-size: 14px }
  .hide-sm { display: none !important }
  .nav { padding: 0 14px 14px; gap: 16px; overflow-x: auto; flex-wrap: nowrap; white-space: nowrap }
  .layout { grid-template-columns: minmax(0, 1fr); margin-top: 16px }
  .side { margin-bottom: 0 }
  .grid, .grid.four, .two, .three { grid-template-columns: minmax(0, 1fr) }
  .catgrid { grid-template-columns: 1fr 1fr }
  .panel { padding: 18px }
  h1 { font-size: 27px }
  .steps li, .steps span { font-size: 12px; padding: 6px }
  .thumb { height: 190px }
  .foot { padding-bottom: 80px }
  .mobilebar { display: flex; position: sticky; bottom: 0; background: #fff; justify-content: space-around; padding: 8px; border-top: 1px solid var(--line); font-size: 13px; z-index: 20 }
  .mobilebar a { padding: 8px; min-height: 44px; display: flex; align-items: center; text-decoration: none }
  .mobilebar a.active { color: var(--orange) }
  .contactbar { display: flex; gap: 8px; position: sticky; bottom: 0; background: #fff; padding: 10px 14px; border-top: 1px solid var(--line); z-index: 20 }
  .contactbar > * { flex: 1 }
  .filters summary { display: flex; justify-content: space-between; align-items: center; cursor: pointer; font-weight: 700; list-style: none; min-height: 44px }
  .filters summary::-webkit-details-marker { display: none }
  .filters:not([open]) .filter-body { display: none }
  .filters[open] .filter-body { margin-top: 14px }
  .upload-item { grid-template-columns: 56px minmax(0, 1fr) }
  .upload-item .actions { grid-column: 1 / -1; justify-content: flex-start }
  .toasts { bottom: 76px }
}
