:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #111827;
  background: #f4f6f9;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f6f9; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app-shell { min-height: 100vh; }
.topbar { height: 76px; display: flex; align-items: center; gap: 24px; padding: 0 24px; background: linear-gradient(90deg, #121722 0%, #0c1018 100%); color: white; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 14px rgba(15, 23, 42, .18); }
.brand { width: 250px; display: flex; align-items: center; gap: 12px; }
.brand-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: rgba(255,255,255,.1); }
.brand strong { display: block; font-size: 19px; }
.brand span { display: block; color: #aab3c1; font-size: 12px; margin-top: 2px; }
.tabs { height: 100%; display: flex; align-items: center; gap: 8px; flex: 1; }
.tabs button { height: 100%; border: 0; background: transparent; color: #c7ced8; display: flex; align-items: center; gap: 8px; padding: 0 22px; border-bottom: 3px solid transparent; font-weight: 700; }
.tabs button:hover, .tabs button.active { color: white; border-bottom-color: white; background: rgba(255,255,255,.03); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.compact-control { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: #dbe1ea; }
.compact-control select, .compact-control input { height: 38px; border-radius: 9px; border: 1px solid #3a4250; background: white; color: #111827; padding: 0 10px; }
.compact-control input { width: 112px; }
.icon-button { border: 0; background: transparent; display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 9px; color: #4b5563; font-size: 24px; }
.icon-button:hover { background: #eef2f7; }
.icon-button.dark { color: white; }
.icon-button.dark:hover { background: rgba(255,255,255,.1); }
.workspace { display: flex; gap: 16px; padding: 16px; min-height: calc(100vh - 76px); }
.workspace-single { display: block; }
.sidebar { width: 315px; flex: 0 0 315px; display: flex; flex-direction: column; gap: 12px; }
.content-area { flex: 1; min-width: 0; }
.single-page { width: 100%; max-width: 1600px; margin: 0 auto; }
.panel { background: white; border: 1px solid #e2e7ef; border-radius: 14px; box-shadow: 0 3px 12px rgba(15, 23, 42, .04); padding: 18px; }
.panel h2, .panel h3 { margin: 0; }
.panel h2 { font-size: 18px; }
.panel h3 { font-size: 15px; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.panel-title-row p { margin: 4px 0 0; color: #6b7280; font-size: 12px; }
.panel-padding { padding: 18px; }
.link-button { border: 0; background: none; color: #2457ee; font-weight: 700; }
.order-name { display: flex; align-items: center; gap: 10px; margin: 18px 0; }
.order-name strong { flex: 1; }
.tiny-product-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; background: #111827; color: white; }
.status-chip { display: inline-flex; align-items: center; justify-content: center; padding: 5px 9px; border-radius: 999px; background: #e8efff; color: #2457ee; font-size: 11px; font-weight: 800; white-space: nowrap; }
.status-green { background: #dcfce7; color: #16823f; }
.detail-list, .cost-list { display: grid; gap: 12px; margin: 0; }
.detail-list div, .cost-list div { display: flex; justify-content: space-between; gap: 14px; }
.detail-list dt, .cost-list dt { color: #6b7280; font-size: 12px; }
.detail-list dd, .cost-list dd { margin: 0; font-size: 12px; font-weight: 700; text-align: right; }
.total-row { border-top: 1px solid #e7ebf1; margin-top: 16px; padding-top: 16px; display: flex; justify-content: space-between; align-items: center; text-transform: uppercase; font-size: 12px; font-weight: 800; }
.total-row strong { font-size: 18px; }
.dropzone { margin-top: 14px; border: 1.5px dashed #cbd3df; border-radius: 12px; min-height: 100px; display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 5px; color: #5d6674; cursor: pointer; text-align: center; }
.dropzone:hover { background: #f8fafc; border-color: #8da1c2; }
.dropzone input { display: none; }
.dropzone span { font-size: 12px; font-weight: 700; }
.dropzone small { font-size: 11px; }
.attachment-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.attachment { position: relative; min-height: 78px; border: 1px solid #e3e7ed; border-radius: 9px; display: grid; place-items: center; overflow: hidden; background: #f9fafb; padding: 5px; }
.attachment img { width: 100%; height: 54px; object-fit: cover; }
.attachment span { width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 9px; }
.attachment button { position: absolute; right: 4px; top: 4px; border: 0; background: white; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.empty-mini { color: #8a93a0; font-size: 11px; grid-column: 1 / -1; }
.button { min-height: 40px; padding: 0 16px; border-radius: 9px; border: 1px solid transparent; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; font-size: 12px; }
.button-primary { background: #2457ee; color: white; box-shadow: 0 4px 10px rgba(36, 87, 238, .18); }
.button-primary:hover { background: #1849da; }
.button-secondary { background: white; border-color: #cfd6e1; color: #253044; }
.button-dark { background: #111827; color: white; }
.button-danger { background: #fee2e2; color: #b91c1c; border-color: #fecaca; }
.full-width { width: 100%; }
.page-heading { display: flex; justify-content: space-between; align-items: center; margin: 4px 0 18px; }
.page-heading h1 { margin: 0; font-size: 26px; }
.page-heading p { margin: 5px 0 0; color: #6b7280; font-size: 13px; }
.order-selector { position: relative; display: flex; align-items: center; gap: 6px; padding: 10px 12px; border: 1px solid #d8dee8; border-radius: 11px; background: white; font-size: 11px; font-weight: 700; }
.order-selector select { border: 0; background: transparent; font-weight: 700; outline: none; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.metric-card { min-height: 112px; background: white; border: 1px solid #e2e7ef; border-radius: 14px; display: flex; align-items: center; gap: 14px; padding: 18px; box-shadow: 0 3px 12px rgba(15, 23, 42, .04); }
.metric-card span, .metric-card small { display: block; color: #6b7280; }
.metric-card span { font-size: 12px; }
.metric-card small { font-size: 11px; margin-top: 5px; }
.metric-card strong { display: block; font-size: 18px; margin-top: 4px; }
.metric-icon { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; }
.metric-icon.blue { background: #e8efff; color: #2457ee; }
.metric-icon.green { background: #dcfce7; color: #16a34a; }
.metric-icon.orange { background: #ffedd5; color: #ea580c; }
.metric-icon.purple { background: #f3e8ff; color: #9333ea; }
.products-panel { padding: 0; overflow: hidden; }
.table-wrap { width: 100%; overflow-x: auto; }
.product-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.product-table th { background: #f8fafc; color: #4b5563; font-size: 10px; text-transform: uppercase; letter-spacing: .02em; text-align: left; padding: 11px 12px; border-top: 1px solid #e7ebf1; border-bottom: 1px solid #e7ebf1; white-space: nowrap; }
.product-table td { padding: 10px 12px; border-bottom: 1px solid #edf0f4; vertical-align: middle; white-space: nowrap; }
.product-table tbody tr:hover { background: #fbfcfe; }
.product-table td strong, .product-table td small { display: block; }
.product-table td small { margin-top: 3px; color: #7b8491; font-size: 10px; }
.product-thumb { width: 42px; height: 42px; object-fit: cover; border-radius: 8px; border: 1px solid #e4e7ec; }
.product-thumb.placeholder { display: grid; place-items: center; background: #f3f4f6; color: #87909d; }
.table-actions { display: flex; gap: 4px; }
.table-actions button { width: 32px; height: 32px; border: 0; background: transparent; color: #5f6977; border-radius: 7px; display: grid; place-items: center; }
.table-actions button:hover { background: #eef2f7; }
.empty-row { text-align: center; color: #7b8491; padding: 30px !important; }
.info-banner { margin-top: 14px; padding: 18px; display: grid; grid-template-columns: 1fr 1.35fr; gap: 22px; border: 1px solid #f0dfbf; border-radius: 14px; background: #fffaf0; }
.info-banner h3 { margin: 0; font-size: 14px; }
.info-banner p { color: #5f6670; font-size: 12px; line-height: 1.5; }
.pending-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-top: 10px; }
.pending-card { display: flex; align-items: center; gap: 9px; border: 1px solid #f2d7a7; border-radius: 10px; background: white; padding: 11px; color: #d97706; }
.pending-card.complete { border-color: #bbf7d0; color: #16823f; }
.pending-card strong, .pending-card span { display: block; }
.pending-card strong { color: #283142; font-size: 10px; }
.pending-card span { font-size: 9px; margin-top: 2px; }
.costs-layout { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; margin-bottom: 14px; }
.cost-editor-list { display: grid; gap: 12px; margin-top: 18px; }
.cost-editor-row { display: grid; grid-template-columns: 1fr 230px; gap: 12px; }
.cost-editor-row label, .field { display: flex; flex-direction: column; gap: 6px; }
.cost-editor-row span, .field span { font-size: 11px; font-weight: 800; color: #4b5563; }
.cost-editor-row input, .cost-editor-row select, .field input, .field select, .field textarea { width: 100%; border: 1px solid #d7dde6; border-radius: 9px; padding: 10px 11px; background: white; color: #111827; }
.cost-editor-row input:focus, .cost-editor-row select:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(36, 87, 238, .15); border-color: #2457ee; }
.mini-explanation { margin-top: 16px; border-radius: 10px; background: #f8fafc; padding: 13px; }
.mini-explanation p { margin: 5px 0 0; color: #6b7280; font-size: 11px; line-height: 1.45; }
.result-card { margin-top: 16px; border: 1px solid #dbe4f4; background: #f6f9ff; border-radius: 12px; padding: 15px; }
.result-card span, .result-card small { display: block; color: #647083; }
.result-card strong { display: block; margin: 5px 0; font-size: 22px; }
.summary-pill { background: white; border: 1px solid #dbe1e9; border-radius: 11px; padding: 9px 14px; }
.summary-pill span, .summary-pill strong { display: block; }
.summary-pill span { color: #6b7280; font-size: 10px; }
.summary-pill strong { margin-top: 2px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 100; background: rgba(15, 23, 42, .52); display: grid; place-items: center; padding: 22px; }
.modal { width: 620px; max-height: 92vh; overflow: hidden; background: white; border-radius: 16px; box-shadow: 0 30px 80px rgba(15, 23, 42, .28); }
.modal-wide { width: 850px; }
.modal-header { height: 64px; padding: 0 20px; border-bottom: 1px solid #e8ebf0; display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { margin: 0; font-size: 19px; }
.modal-body { padding: 20px; max-height: calc(92vh - 64px); overflow-y: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.image-uploader { display: flex; align-items: center; gap: 14px; }
.image-uploader img, .image-placeholder { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; border: 1px solid #dde2ea; }
.image-placeholder { display: grid; place-items: center; color: #8a93a0; background: #f6f7f9; }
.settings-stack { display: grid; gap: 12px; }
.settings-card { display: flex; align-items: center; justify-content: space-between; gap: 14px; border: 1px solid #e1e6ed; border-radius: 12px; padding: 15px; }
.settings-card p { margin: 4px 0 0; color: #6b7280; font-size: 11px; }
.settings-card.danger { border-color: #fecaca; background: #fffafa; }
@media (max-width: 1300px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .pending-grid { grid-template-columns: repeat(2, 1fr); }
  .info-banner { grid-template-columns: 1fr; }
}


.button-install { min-height: 36px; padding: 0 12px; background: rgba(255,255,255,.12); color: white; border-color: rgba(255,255,255,.18); }
.button-install:hover { background: rgba(255,255,255,.2); }

@media (max-width: 980px) {
  .topbar { height: auto; min-height: 68px; padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
  .brand { width: auto; flex: 1; }
  .brand span { display: none; }
  .tabs { order: 3; width: 100%; height: 48px; justify-content: space-around; }
  .tabs button { height: 48px; flex: 1; justify-content: center; padding: 0 8px; font-size: 12px; }
  .topbar-actions { gap: 8px; }
  .compact-control { font-size: 0; gap: 0; }
  .compact-control select, .compact-control input { height: 36px; font-size: 12px; }
  .compact-control input { width: 88px; }
  .workspace { display: block; padding: 12px; min-height: calc(100vh - 126px); }
  .sidebar { width: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 12px; }
  .sidebar > .button { grid-column: 1 / -1; }
  .costs-layout { grid-template-columns: 1fr; }
  .page-heading { align-items: flex-start; gap: 12px; }
  .page-heading h1 { font-size: 22px; }
}

@media (max-width: 700px) {
  body { padding-bottom: 68px; }
  .topbar { position: sticky; top: 0; padding: 9px 12px; min-height: 60px; }
  .brand-icon { width: 38px; height: 38px; }
  .brand strong { font-size: 17px; }
  .tabs { position: fixed; z-index: 50; bottom: 0; left: 0; right: 0; height: 64px; padding: 4px 6px max(4px, env(safe-area-inset-bottom)); background: #0d121b; box-shadow: 0 -4px 18px rgba(15,23,42,.22); }
  .tabs button { height: 56px; flex-direction: column; gap: 2px; border: 0; border-radius: 10px; font-size: 10px; }
  .tabs button.active { background: rgba(255,255,255,.1); border: 0; }
  .topbar-actions .compact-control:first-child { display: none; }
  .button-install { display: none; }
  .workspace { padding: 10px; min-height: calc(100vh - 60px); }
  .sidebar { display: flex; }
  .panel { border-radius: 12px; padding: 14px; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { min-height: 90px; padding: 12px; gap: 10px; }
  .metric-icon { width: 38px; height: 38px; }
  .metric-card strong { font-size: 15px; }
  .page-heading { flex-direction: column; margin-bottom: 12px; }
  .order-selector, .summary-pill { width: 100%; justify-content: space-between; }
  .panel-title-row { align-items: flex-start; flex-direction: column; }
  .panel-title-row .button { width: 100%; }
  .info-banner { padding: 14px; }
  .pending-grid { grid-template-columns: 1fr 1fr; }
  .cost-editor-row { grid-template-columns: 1fr; gap: 8px; border-bottom: 1px solid #edf0f4; padding-bottom: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .field-span-2 { grid-column: auto; }
  .modal-backdrop { padding: 0; align-items: end; }
  .modal, .modal-wide { width: 100%; max-height: 94vh; border-radius: 18px 18px 0 0; }
  .modal-body { padding: 16px; }
  .image-uploader { align-items: flex-start; flex-direction: column; }
  .settings-card { align-items: flex-start; flex-direction: column; }
  .settings-card .button { width: 100%; }

  .table-wrap { overflow: visible; }
  .product-table, .product-table tbody { display: block; width: 100%; }
  .product-table thead { display: none; }
  .product-table tr { display: grid; grid-template-columns: 64px 1fr; gap: 0 12px; margin: 10px; padding: 12px; border: 1px solid #e1e6ed; border-radius: 13px; background: white; box-shadow: 0 2px 8px rgba(15,23,42,.04); }
  .product-table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 7px 0; border: 0; white-space: normal; grid-column: 2; text-align: right; }
  .product-table td::before { content: attr(data-label); color: #7b8491; font-size: 10px; font-weight: 800; text-transform: uppercase; text-align: left; }
  .product-table td[data-label="Foto"] { grid-column: 1; grid-row: 1 / span 4; display: block; padding: 0; }
  .product-table td[data-label="Foto"]::before, .product-table td[data-label="Producto"]::before, .product-table td[data-label="Acciones"]::before { display: none; }
  .product-table td[data-label="Producto"] { justify-content: flex-start; text-align: left; padding-top: 0; }
  .product-table td[data-label="Acciones"] { justify-content: flex-end; border-top: 1px solid #edf0f4; margin-top: 4px; padding-top: 10px; }
  .product-thumb { width: 64px; height: 64px; border-radius: 10px; }
  .empty-row { display: block !important; margin: 12px !important; }
}

@media (max-width: 420px) {
  .topbar-actions .compact-control { display: none; }
  .metric-grid, .pending-grid { grid-template-columns: 1fr; }
  .metric-card { min-height: 78px; }
  .attachment-grid { grid-template-columns: repeat(2, 1fr); }
}
