/* MercadilloGeek 2.6 · adaptación táctil y centro de copias */

html { min-width: 320px; }
body.mg-marketplace-page { margin: 0; min-width: 320px; overflow-x: hidden; }
body.mg-marketplace-page .mg-app {
  display: block !important;
  min-height: 100vh;
  opacity: 1 !important;
  overflow: hidden;
  visibility: visible !important;
  width: 100% !important;
}
.mg-app *, .mg-app *::before, .mg-app *::after { box-sizing: border-box; }
.mg-app img, .mg-app video, .mg-app iframe { max-width: 100%; }
.mg-app input, .mg-app select, .mg-app textarea, .mg-app button { font: inherit; max-width: 100%; }
.mg-shell, .mg-app section, .mg-app article, .mg-app div { min-width: 0; }

/* Centro de copias */
.mg-backup-center { min-height: 760px; padding-bottom: 90px; }
.mg-backup-hero {
  align-items: center;
  background: radial-gradient(circle at 82% 18%, #6277f555, transparent 30%), linear-gradient(135deg, #101522, #080b12);
  border: 1px solid #2c3852;
  border-radius: 24px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  margin-bottom: 24px;
  overflow: hidden;
  padding: 42px 48px;
  position: relative;
}
.mg-backup-hero::before { background-image: linear-gradient(#79f0ae13 1px, transparent 1px), linear-gradient(90deg, #79f0ae13 1px, transparent 1px); background-size: 28px 28px; content: ""; inset: 0; pointer-events: none; position: absolute; }
.mg-backup-hero > * { position: relative; z-index: 1; }
.mg-backup-hero h1 { font-size: clamp(36px, 5vw, 58px); letter-spacing: -3px; line-height: 1; margin: 16px 0 10px; }
.mg-backup-hero p { color: #afb8ca; font-size: 13px; line-height: 1.6; margin: 0; max-width: 690px; }
.mg-backup-shield { align-items: center; background: linear-gradient(145deg, #596ef0, #3443a7); border: 4px solid #8291ed; border-radius: 24px; box-shadow: 0 18px 50px #0006; display: flex; flex: 0 0 126px; font-size: 57px; height: 126px; justify-content: center; position: relative; transform: rotate(4deg); }
.mg-backup-shield i { align-items: center; background: #79f0ae; border: 4px solid #101522; border-radius: 50%; bottom: -12px; color: #0b3422; display: flex; font-size: 18px; font-style: normal; height: 40px; justify-content: center; position: absolute; right: -12px; width: 40px; }
.mg-backup-grid { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }
.mg-backup-grid > article, .mg-restore-card { border: 1px solid var(--mg-line); border-radius: 17px; box-shadow: 0 14px 40px #1118270b; padding: 26px; }
.mg-backup-grid article > small, .mg-restore-card small { color: #5869d0; display: block; font: 850 8px monospace; letter-spacing: .8px; margin-top: 14px; }
.mg-backup-grid h2, .mg-restore-card h2 { font-size: 24px; letter-spacing: -1px; margin: 6px 0; }
.mg-backup-grid p, .mg-restore-card p { color: #777c87; font-size: 11px; line-height: 1.6; min-height: 53px; }
.mg-backup-icon { align-items: center; border-radius: 13px; display: flex; font-size: 22px; font-style: normal; font-weight: 900; height: 50px; justify-content: center; width: 50px; }
.mg-backup-icon.local { background: #e6f9ed; color: #16824a; }
.mg-backup-icon.drive { background: linear-gradient(135deg, #fff2d9, #eaf4ff); color: #3970cf; }
.mg-backup-icon.restore { background: #fff0df; color: #c66a1b; }
.mg-backup-grid form { margin: 0; }
.mg-backup-disconnect { color: #8a8e97; display: block; font-size: 9px; margin-top: 11px; text-align: center; }
.mg-backup-mini, .mg-backup-alert { background: #fff7e8; border: 1px solid #f2d39d; border-radius: 10px; color: #85511c; font-size: 10px; line-height: 1.55; padding: 11px; }
.mg-backup-alert { margin-bottom: 18px; }
.mg-backup-alert p { margin: 4px 0 0; }
.mg-backup-last { background: #f6f7fa; border-radius: 10px; display: flex; flex-wrap: wrap; gap: 5px 10px; margin-top: 15px; padding: 11px; }
.mg-backup-last b, .mg-backup-last span { font-size: 9px; }
.mg-backup-last small { color: #8b8f97 !important; flex-basis: 100%; font-size: 8px !important; margin: 0 !important; overflow-wrap: anywhere; }
.mg-restore-card { align-items: center; background: linear-gradient(135deg, #fffaf3, #fff); display: grid; gap: 30px; grid-template-columns: 1fr 1fr; margin-top: 18px; }
.mg-restore-card p { min-height: 0; }
.mg-restore-card form { display: grid; gap: 12px; }
.mg-backup-file { background: #fff; border: 2px dashed #d8dbe5; border-radius: 11px; display: grid; font-size: 10px; font-weight: 800; gap: 9px; padding: 15px; }
.mg-backup-file input { font-size: 10px; width: 100%; }
.mg-backup-confirm { align-items: flex-start; display: flex; font-size: 9px; gap: 8px; line-height: 1.45; }
.mg-backup-confirm input { accent-color: #cc711f; margin-top: 1px; }
.mg-restore-button { background: linear-gradient(135deg, #dc7620, #ad4e14); border: 0; border-radius: 10px; color: #fff; cursor: pointer; font-weight: 850; min-height: 44px; padding: 12px 17px; }
.mg-backup-scope { align-items: center; background: #f6f7fa; border-radius: 13px; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; padding: 15px; }
.mg-backup-scope b { font-size: 10px; margin-right: 3px; }
.mg-backup-scope span { background: #fff; border: 1px solid #e2e4e9; border-radius: 999px; font-size: 8px; padding: 7px 9px; }
.mg-backup-scope em { color: #7f838c; flex-basis: 100%; font-size: 8px; font-style: normal; }
.mg-admin-title-actions { align-items: center; display: flex; gap: 8px; }
.mg-admin-shortcuts { grid-template-columns: auto repeat(3, 1fr); }

/* Tablet horizontal y iPad */
@media (max-width: 1100px) {
  .mg-shell { width: min(100% - 36px, 940px); }
  .mg-topbar { gap: 14px; padding-inline: 18px; }
  .mg-topbar nav { gap: 8px; min-width: 0; overflow-x: auto; scrollbar-width: none; }
  .mg-topbar nav::-webkit-scrollbar { display: none; }
  .mg-topbar nav > a { flex: 0 0 auto; }
  .mg-account > span { display: none; }
  .mg-brand b { white-space: nowrap; }
  .mg-hero { gap: 32px; grid-template-columns: 1fr; min-height: 0; }
  .mg-hero > div:first-child { max-width: 760px; }
  .mg-hero h1 { font-size: clamp(46px, 7vw, 62px); }
  .mg-hero-art, .mg-hero-cover { height: min(52vw, 440px); margin-top: 0; }
  .mg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mg-detail-grid { gap: 28px; grid-template-columns: 1fr; }
  .mg-gallery { aspect-ratio: 4 / 3; min-height: 0; }
  .mg-dashboard-grid, .mg-public-profile-grid, .mg-admin-report-grid { grid-template-columns: 1fr; }
  .mg-dashboard-grid aside, .mg-public-profile-grid aside { border-left: 0; border-top: 1px solid var(--mg-line); padding-left: 0; padding-top: 24px; }
  .mg-messages-layout { grid-template-columns: minmax(260px, 34%) 1fr; }
  .mg-admin-shortcuts { grid-template-columns: 1fr 1fr; }
  .mg-admin-shortcuts > span { grid-column: 1 / -1; }
  .mg-admin-title { align-items: flex-start; }
  .mg-backup-hero { padding: 36px; }
}

/* Tablet vertical y teléfonos grandes */
@media (max-width: 820px) {
  body.mg-marketplace-page { -webkit-text-size-adjust: 100%; }
  .mg-shell { width: calc(100% - 28px); }
  .mg-topbar { align-content: center; flex-wrap: wrap; height: auto; min-height: 72px; padding-block: 10px; position: sticky; }
  .mg-topbar .mg-search { display: flex; flex: 1 0 100%; max-width: none; order: 3; }
  .mg-topbar nav { margin-left: auto; max-width: calc(100% - 175px); }
  .mg-users-nav, .mg-sold-nav { font-size: 0 !important; height: 38px; justify-content: center; padding: 0 !important; width: 38px; }
  .mg-users-nav::before { content: "⌨"; font-size: 16px; }
  .mg-sold-nav::before { content: "✓"; font-size: 16px; }
  .mg-publish-button { align-items: center; display: inline-flex; min-height: 38px; }
  .mg-categories > .mg-shell { justify-content: flex-start; overscroll-behavior-x: contain; padding-block: 9px; scroll-snap-type: x proximity; }
  .mg-categories a { scroll-snap-align: start; }
  .mg-hero { padding-block: 38px; }
  .mg-hero-art, .mg-hero-cover { border-radius: 22px; height: min(65vw, 430px); }
  .mg-products { padding-block: 52px; }
  .mg-manifesto { padding: 38px 30px; }
  .mg-profile-head { flex-wrap: wrap; }
  .mg-avatar-form { margin-left: 0; width: 100%; }
  .mg-profile-stats-votes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mg-profile-stats-votes > div { border: 1px solid var(--mg-line) !important; }
  .mg-dashboard-shortcuts, .mg-public-stats, .mg-report-stats, .mg-order-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mg-transaction { grid-template-columns: 48px 1fr auto; }
  .mg-rate-form { grid-column: 1 / -1; }
  .mg-messages-layout { display: block; min-height: 0; }
  .mg-thread-list { border-bottom: 1px solid var(--mg-line); max-height: 280px; overflow-y: auto; }
  .mg-message-stream { max-height: 52vh; }
  .mg-user-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mg-admin-title { flex-direction: column; gap: 14px; }
  .mg-admin-title-actions { flex-wrap: wrap; width: 100%; }
  .mg-admin-title-actions a { flex: 1 1 210px; text-align: center; }
  .mg-admin-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mg-daily-chart { min-width: 650px; }
  .mg-evolution { overflow-x: auto; }
  .mg-report-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .mg-report-table { min-width: 720px; }
  .mg-backup-grid, .mg-restore-card { grid-template-columns: 1fr; }
  .mg-backup-grid p { min-height: 0; }
}

/* Teléfonos */
@media (max-width: 620px) {
  .mg-shell { width: calc(100% - 24px); }
  .mg-topbar { gap: 8px; padding-inline: 12px; }
  .mg-brand { flex: 0 0 auto; }
  .mg-brand b { font-size: 15px; }
  .mg-brand > i { height: 34px; width: 34px; }
  .mg-topbar nav { gap: 5px; max-width: calc(100% - 146px); }
  .mg-topbar .mg-search { height: 42px; }
  .mg-topbar .mg-search button { min-width: 62px; padding-inline: 8px; }
  .mg-message-nav, .mg-account { flex: 0 0 38px; height: 38px; justify-content: center; padding: 0 !important; width: 38px; }
  .mg-account .mg-avatar { --mg-avatar-size: 32px !important; }
  .mg-login, .mg-signup { font-size: 10px; padding: 8px 5px; }
  .mg-signup { display: none; }
  .mg-publish-button { font-size: 0; min-width: 38px; padding: 9px 11px; }
  .mg-publish-button::before { content: "＋"; font-size: 20px; }
  .mg-categories > div { height: auto; }
  .mg-hero { padding-block: 32px; }
  .mg-hero h1 { font-size: clamp(38px, 12vw, 48px); letter-spacing: -2.8px; }
  .mg-hero > div > p { font-size: 14px; }
  .mg-actions { align-items: stretch; flex-direction: column; }
  .mg-actions a { text-align: center; width: 100%; }
  .mg-trust { align-items: flex-start; flex-direction: column; }
  .mg-hero-art, .mg-hero-cover { height: 67vw; min-height: 250px; }
  .mg-grid, .mg-user-grid { grid-template-columns: 1fr; }
  .mg-card-info { padding: 16px; }
  .mg-section-head { align-items: flex-start; flex-direction: column; gap: 7px; }
  .mg-section-head h2 { font-size: 30px; }
  .mg-manifesto { border-radius: 18px; margin-bottom: 50px; padding: 30px 20px; }
  .mg-detail { padding-bottom: 55px; }
  .mg-gallery { border-radius: 15px; }
  .mg-detail-copy { padding-top: 18px; }
  .mg-detail-copy h1 { font-size: 31px; }
  .mg-detail-copy > strong { font-size: 29px; }
  .mg-thumbnails { padding-bottom: 5px; scroll-snap-type: x mandatory; }
  .mg-thumbnail-button { scroll-snap-align: start; }
  .mg-share-actions a, .mg-share-actions button { min-height: 44px; }
  .mg-form-card { padding: 24px 16px; }
  .mg-form-card h1 { font-size: 32px; }
  .mg-form-card input, .mg-form-card select, .mg-form-card textarea, .mg-register-card input, .mg-login-card input { font-size: 16px !important; min-height: 46px; }
  .mg-form-row, .mg-register-row, .mg-register-card fieldset { grid-template-columns: 1fr; }
  .mg-register, .mg-login-page { padding-block: 20px 50px; }
  .mg-register-visual, .mg-login-visual { min-height: 0; padding: 30px 21px; }
  .mg-register-visual h1, .mg-login-visual h1 { font-size: 32px; }
  .mg-register-card, .mg-login-card { padding: 28px 18px; }
  .mg-profile-head h1 { font-size: 27px; overflow-wrap: anywhere; }
  .mg-avatar-form { align-items: stretch; display: grid; grid-template-columns: 1fr auto; }
  .mg-avatar-form label, .mg-avatar-form button { min-height: 44px; text-align: center; }
  .mg-dashboard-shortcuts, .mg-profile-stats-votes, .mg-public-stats, .mg-report-stats, .mg-order-summary, .mg-admin-kpis { grid-template-columns: 1fr; }
  .mg-dashboard-shortcuts > a, .mg-admin-shortcuts > a { min-height: 82px; }
  .mg-transaction { align-items: start; grid-template-columns: 44px 1fr; }
  .mg-transaction > strong, .mg-transaction > button, .mg-transaction > .mg-rated { grid-column: 2; justify-self: start; }
  .mg-transaction > strong { font-size: 15px; }
  .mg-rate-form { grid-column: 1 / -1; }
  .mg-order-list > a { grid-template-columns: 44px 1fr; }
  .mg-order-list > a > strong, .mg-order-list > a > .mg-status { grid-column: 2; justify-self: start; }
  .mg-manage-list > article { grid-template-columns: 58px 1fr; }
  .mg-manage-list > article > strong { grid-column: 2; }
  .mg-manage-actions { grid-column: 1 / -1; width: 100%; }
  .mg-manage-actions a { flex: 1; min-height: 42px; text-align: center; }
  .mg-user-card { grid-template-columns: 58px 1fr auto; padding: 15px; }
  .mg-user-card .mg-avatar { --mg-avatar-size: 58px !important; }
  .mg-user-search { margin-inline: 0; width: 100%; }
  .mg-user-search button { min-height: 44px; }
  .mg-public-profile-head { align-items: flex-start; }
  .mg-reputation-medal { margin-left: 0; }
  .mg-public-trades > a { grid-template-columns: 42px 1fr; }
  .mg-public-trades > a > i { grid-column: 2; }
  .mg-messages-head h1 { font-size: 31px; }
  .mg-thread-list { max-height: 235px; }
  .mg-message-stream { padding: 14px; }
  .mg-message-stream article { max-width: 92%; }
  .mg-reply-form { grid-template-columns: 1fr; padding: 13px; }
  .mg-reply-form textarea { font-size: 16px; min-height: 86px; }
  .mg-reply-form button { min-height: 44px; }
  .mg-evolution { padding: 15px; }
  .mg-evolution > header { align-items: flex-start; flex-direction: column; gap: 10px; }
  .mg-admin-shortcuts { grid-template-columns: 1fr; }
  .mg-admin-shortcuts > span { grid-column: auto; }
  .mg-admin-title-actions a { flex-basis: 100%; }
  .mg-backup-center { padding-bottom: 55px; }
  .mg-backup-hero { align-items: flex-start; padding: 27px 20px; }
  .mg-backup-hero h1 { font-size: 38px; letter-spacing: -2px; }
  .mg-backup-shield { display: none; }
  .mg-backup-grid > article, .mg-restore-card { padding: 20px 17px; }
  .mg-backup-grid .mg-full, .mg-restore-card button { min-height: 46px; text-align: center; width: 100%; }
  .mg-backup-scope { align-items: flex-start; flex-direction: column; }
  .mg-footer { padding-block: 28px; }
  .mg-footer .mg-shell { align-items: flex-start; flex-direction: column; gap: 12px; }
}

@media (max-width: 390px) {
  .mg-brand b { font-size: 13px; }
  .mg-brand > i { height: 32px; width: 32px; }
  .mg-topbar nav { max-width: calc(100% - 126px); }
  .mg-users-nav, .mg-sold-nav { display: none !important; }
  .mg-hero h1 { font-size: 37px; }
  .mg-user-card { grid-template-columns: 52px 1fr; }
  .mg-user-card > .mg-user-drive { grid-column: 1 / -1; align-items: center; flex-direction: row; gap: 8px; }
}

@media (pointer: coarse) {
  .mg-app a, .mg-app button, .mg-app input[type="file"], .mg-app select { touch-action: manipulation; }
  .mg-categories a, .mg-manage-actions a, .mg-share-actions a, .mg-share-actions button { min-height: 42px; }
  .mg-app button:active, .mg-app a:active { transform: scale(.98); }
}

@media (prefers-reduced-motion: reduce) {
  .mg-app *, .mg-app *::before, .mg-app *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
