:root {
  --bg: #050505;
  --bg2: #111113;
  --panel: rgba(29,29,31,.86);
  --panel2: rgba(255,255,255,.07);
  --line: rgba(255,255,255,.14);
  --text: #f5f5f7;
  --muted: #a1a1a6;
  --blue: #2997ff;
  --green: #30d158;
  --amber: #ffd60a;
  --red: #ff453a;
  --button: rgba(255,255,255,.10);
  --button-text: #f5f5f7;
  --hover: rgba(255,255,255,.08);
  --table-head: rgba(255,255,255,.08);
  --login-shadow: rgba(0,0,0,.42);
  --glass: rgba(22,22,23,.72);
  --shadow: 0 28px 80px rgba(0,0,0,.36);
}

[data-theme="light"] {
  --bg: #f5f5f7;
  --bg2: #ffffff;
  --panel: #ffffff;
  --panel2: rgba(0,0,0,.045);
  --line: rgba(0,0,0,.12);
  --text: #1d1d1f;
  --muted: #6e6e73;
  --blue: #0066cc;
  --green: #248a3d;
  --amber: #b77900;
  --red: #d70015;
  --button: rgba(0,0,0,.055);
  --button-text: #1d1d1f;
  --hover: rgba(0,0,0,.045);
  --table-head: rgba(0,0,0,.045);
  --login-shadow: rgba(0,0,0,.14);
  --glass: rgba(255,255,255,.74);
  --shadow: 0 24px 70px rgba(0,0,0,.12);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -18rem, rgba(255,255,255,.18), transparent 34rem),
    linear-gradient(180deg, var(--bg2) 0, var(--bg) 34rem, var(--bg) 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.top {
  min-height: 108px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-end;
  padding: 18px 24px 12px;
  border-bottom: 0;
}

h1 {
  margin: 0;
  max-width: none;
  font-size: clamp(30px, 3vw, 46px);
  line-height: 1;
  letter-spacing: 0;
  font-weight: 850;
}
p { margin: 0; color: var(--muted); }

.summary {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: end;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: end;
}

.summary span, .badge {
  border: 1px solid var(--line);
  background: var(--glass);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 13px;
  font-weight: 700;
  backdrop-filter: blur(18px) saturate(1.3);
}

main {
  max-width: none;
  margin: 0;
  padding: 14px 24px 28px;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 6px;
  padding: 8px 24px;
  background: color-mix(in srgb, var(--glass) 92%, transparent);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(22px) saturate(1.35);
  overflow-x: auto;
}

.tab {
  width: auto;
  min-height: 36px;
  padding: 8px 14px;
  border-radius: 999px;
  background: transparent;
  border-color: transparent;
  white-space: nowrap;
}

.tab.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.hidden { display: none !important; }

.report-status {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
}

.report-status.error {
  color: var(--danger);
}

.pending-report-view {
  display: grid;
  gap: 10px;
}

.pending-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px;
}

.pending-summary article,
.pending-provider {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.pending-summary article {
  padding: 10px 12px;
  border-left: 4px solid var(--blue);
}

.pending-summary small,
.pending-provider small {
  display: block;
  color: var(--muted);
  font-weight: 700;
}

.pending-summary strong {
  display: block;
  margin-top: 2px;
  font-size: 20px;
}

.pending-provider {
  overflow: hidden;
  border-top: 0;
}

.pending-provider-head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 14px;
  background: var(--provider-color);
  color: #fff;
  align-items: center;
}

.pending-provider-head strong {
  font-size: 17px;
}

.pending-provider-head > div:last-child {
  text-align: right;
}

.pending-provider-head > div:last-child strong,
.pending-provider-head > div:last-child span {
  display: block;
}

.pending-provider-head small,
.pending-provider-head span {
  color: rgba(255,255,255,.78);
}

.pending-provider-body {
  display: grid;
  grid-template-columns: minmax(320px, .9fr) minmax(420px, 1.3fr);
  gap: 0;
}

.pending-table-title {
  padding: 8px 12px;
  color: var(--muted);
  background: var(--table-head);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.pending-product-table,
.pending-orders {
  display: grid;
}

.pending-product-table {
  border-right: 1px solid var(--line);
  align-content: start;
}

.pending-product-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 92px 84px;
  gap: 8px;
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  align-items: center;
  font-size: 13px;
}

.pending-product-row strong {
  text-align: right;
}

.pending-product-row > span {
  color: var(--muted);
  text-align: right;
}

.pending-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border: 1px solid rgba(0,0,0,.25);
  border-radius: 3px;
  vertical-align: -1px;
}

.pending-orders {
  align-content: start;
}

.pending-order-row {
  display: grid;
  grid-template-columns: minmax(170px, .8fr) minmax(220px, 1.2fr) 92px;
  gap: 10px;
  padding: 7px 12px;
  border-top: 1px solid var(--line);
  align-items: center;
  font-size: 13px;
}

.pending-order-main strong {
  display: block;
}

.pending-order-materials {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.pending-material-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255,255,255,.04);
  color: var(--text);
  white-space: nowrap;
}

.pending-material-chip strong {
  color: var(--muted);
}

.pending-order-total {
  text-align: right;
}

.pending-order-total strong {
  display: block;
}

@media (max-width: 980px) {
  .pending-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pending-provider-body {
    grid-template-columns: 1fr;
  }

  .pending-product-table {
    border-right: 0;
  }

  .pending-order-row {
    grid-template-columns: 1fr;
  }

  .pending-order-total {
    text-align: left;
  }
}

.filters {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) repeat(3, minmax(130px, .8fr)) repeat(2, 135px) repeat(2, 100px) 82px;
  gap: 10px;
  margin-bottom: 16px;
}

.compact-filters {
  grid-template-columns: minmax(280px, 520px);
  margin-bottom: 14px;
}

input, select, button {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  backdrop-filter: blur(18px) saturate(1.2);
}

button {
  cursor: pointer;
  background: var(--button);
  color: var(--button-text);
  font-weight: 800;
}

.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--button-text);
  background: var(--button);
  font-weight: 800;
  text-decoration: none;
}

.logout-btn, .theme-btn, .report-btn {
  width: auto;
  min-width: 72px;
}

.report-btn {
  min-width: 128px;
}

.theme-btn {
  min-width: 42px;
  padding: 0 12px;
  font-size: 18px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.25);
}

.user-chip strong,
.user-chip small {
  display: block;
  line-height: 1.2;
}

.user-chip small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% -12rem, rgba(255,255,255,.28), transparent 30rem),
    linear-gradient(180deg, var(--bg2), var(--bg)),
    var(--bg);
}

.login-shell {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  position: relative;
}

.login-theme-btn {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 2;
}

.login-panel {
  display: grid;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 34px;
  box-shadow: 0 22px 70px var(--login-shadow);
  backdrop-filter: blur(22px) saturate(1.25);
}

.login-panel h1 {
  margin-top: 4px;
  font-size: 46px;
  line-height: .96;
}

.login-panel label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.login-kicker {
  font-size: 13px;
  font-weight: 900;
  color: var(--blue);
}

.login-error {
  min-height: 20px;
  color: var(--red);
  font-weight: 800;
}

.icon-btn {
  width: 38px;
  padding: 0;
  font-size: 22px;
}

.fab {
  position: fixed;
  right: 26px;
  bottom: 26px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 0;
  background: var(--green);
  color: #07110c;
  font-size: 34px;
  box-shadow: 0 14px 38px rgba(0,0,0,.35);
  z-index: 20;
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(510px, 1.05fr);
  gap: 16px;
  align-items: start;
}

.list, .detail {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.2);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0;
}

.panel-head button {
  width: auto;
}

.table-list {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.2);
}

.dashboard-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 220px));
  gap: 10px;
  margin-bottom: 12px;
}

.dashboard-layout {
  display: grid;
  grid-template-columns: minmax(520px, .95fr) minmax(560px, 1.25fr);
  gap: 14px;
  align-items: start;
}

.dash-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px) saturate(1.2);
}

.dash-panel .panel-head {
  margin-bottom: 8px;
}

.dash-panel .panel-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.color-panel {
  min-height: 520px;
}

.chart-wrap {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 300px;
}

.chart-wrap canvas {
  width: min(300px, 100%);
  aspect-ratio: 1;
}

.chart-center {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  align-content: center;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: inset 0 0 30px rgba(255,255,255,.04);
}

.chart-center strong {
  font-size: 20px;
}

.chart-center small {
  color: var(--muted);
  font-weight: 800;
}

.legend-list {
  display: grid;
  gap: 6px;
}

.legend-list div {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 34px;
  padding: 6px 8px;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.legend-list i {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,.25);
}

.dash-side {
  display: grid;
  gap: 10px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.kpi {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  box-shadow: var(--shadow);
}

.kpi small {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 800;
}

.kpi strong {
  font-size: 22px;
}

.status-list {
  display: grid;
  gap: 6px;
}

.status-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  text-align: left;
  background: var(--panel2);
  border-radius: 8px;
}

.status-item strong,
.status-item small {
  display: block;
}

.status-item small {
  color: var(--muted);
  margin-top: 3px;
  font-weight: 600;
}

.empty.compact {
  padding: 12px;
}

.table-row {
  display: grid;
  grid-template-columns: 64px 1.2fr 1fr 1fr 120px 132px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.table-row:last-child { border-bottom: 0; }
.table-row strong { display: block; }
.table-row small { color: var(--muted); display: block; }

.tarifa-row {
  grid-template-columns: 64px minmax(130px, 1.15fr) minmax(110px, .95fr) minmax(110px, .95fr) minmax(130px, 1fr) 110px 110px 132px;
}

.obsolete-row {
  opacity: .82;
}

.table-head {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--table-head);
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.sort-button {
  width: auto;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  text-transform: uppercase;
}

.sort-button.active {
  color: var(--blue);
}

.sort-button span {
  margin-left: 4px;
}

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--panel2);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 900;
}

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

.avatar-image {
  width: 100%;
  height: 100%;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: inherit;
  background: transparent;
  cursor: zoom-in;
  overflow: hidden;
}

.avatar-image:focus-visible {
  outline: 3px solid rgba(111,180,255,.35);
  outline-offset: 2px;
}

.small-avatar {
  width: 30px;
  height: 30px;
  font-size: 13px;
}

.order {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) 110px 130px 42px;
  gap: 12px;
  align-items: center;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}

.order:hover, .order.active { background: var(--hover); }
.order strong { display: block; font-size: 14px; }
.order small { color: var(--muted); }

.order-identity {
  min-width: 0;
}

.order-id {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.order-client-line {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin-top: 3px;
}

.order-client {
  flex: 0 1 auto;
  min-width: 0;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-work-chip {
  flex: 0 1 auto;
  min-width: 0;
  width: fit-content;
  max-width: min(420px, 100%);
  padding: 4px 8px;
  border-radius: 999px;
  color: #dbeafe;
  background: rgba(42, 91, 140, .42);
  border: 1px solid rgba(111, 180, 255, .28);
  font-size: 13px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-city {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.mobile-order-detail {
  display: none;
}

.status-Pendiente { color: var(--amber); }
.status-Pedido { color: var(--blue); }
.status-En-almacen { color: var(--green); }
.status-En-Obra { color: var(--green); }
.status-Terminado { color: var(--muted); }

.detail {
  padding: 18px;
  min-width: 510px;
}
.detail h2 { margin: 0 0 4px; font-size: 22px; }
.meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 6px;
  margin: 10px 0 8px;
}
.meta div, .material, .event {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}
.meta div {
  min-width: 0;
  padding: 7px 9px;
}
.meta small, .material small, .event small {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}
.meta small {
  margin-bottom: 2px;
  font-size: 11px;
  line-height: 1.15;
}
.meta strong {
  font-size: 13px;
  line-height: 1.2;
}

.material, .event { margin-top: 8px; }
.material-grid {
  display: grid;
  grid-template-columns: 52px minmax(170px, 1.6fr) 95px minmax(120px, 1fr) 42px;
  gap: 10px;
  align-items: center;
}

.kg-breakdown {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.kg-breakdown span {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 6px;
  align-items: baseline;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel2);
}

.kg-breakdown small {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.kg-breakdown strong {
  font-size: 13px;
}

.plan-buttons {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.plan-btn {
  width: auto;
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 6px;
  background: rgba(41,151,255,.14);
  border-color: rgba(41,151,255,.42);
  color: var(--text);
  font-size: 12px;
  text-transform: uppercase;
}

.detail-plans {
  margin: 8px 0 12px;
}

.drum-chip {
  grid-column: 1 / -1;
  justify-self: start;
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 7px;
  align-items: baseline;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(111,180,255,.12);
}

.drum-chip small {
  color: var(--muted);
  font-weight: 900;
  text-transform: uppercase;
}

.drum-chip strong {
  color: var(--blue);
  font-size: 13px;
}

.drum-note {
  color: var(--blue) !important;
  font-weight: 900;
  margin-top: 4px;
}

.material-attachments {
  grid-column: 1 / -1;
}

.attachments, .upload-zone {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}

.attachment {
  width: 92px;
  min-height: 92px;
  display: grid;
  grid-template-rows: 66px auto;
  gap: 5px;
  align-items: center;
  justify-items: center;
  color: var(--text);
  text-decoration: none;
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
  padding: 5px;
}

.attachment img {
  width: 100%;
  height: 66px;
  object-fit: cover;
  border-radius: 4px;
}

.attachment span {
  display: grid;
  place-items: center;
  width: 100%;
  height: 66px;
  background: #2b333c;
  border-radius: 4px;
  font-weight: 900;
}

.attachment small {
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
  text-align: center;
}

.upload-btn {
  width: auto;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--button);
  color: var(--text);
  padding: 8px 10px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.upload-btn.small {
  min-height: 34px;
  padding: 7px 9px;
}

.upload-btn input {
  display: none;
}
.empty {
  color: var(--muted);
  padding: 30px;
  text-align: center;
}

.edit-btn {
  min-height: 34px;
  padding: 0;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: end;
}

.row-actions .edit-btn {
  width: 38px;
  flex: 0 0 38px;
}

.row-attachments {
  grid-column: 2 / -1;
}

.attachment-delete {
  width: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 50%;
  background: #4a2227;
  border-color: #7a333b;
  color: #ffd8dd;
  font-size: 18px;
  line-height: 1;
}

.danger {
  background: #4a2227;
  border-color: #7a333b;
  color: #ffd8dd;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.62);
  display: grid;
  place-items: center;
  z-index: 40;
  padding: 18px;
}
.modal.hidden { display: none; }
.modal-box {
  width: min(940px, 100%);
  max-height: 92vh;
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
}
.modal-head, .modal-subhead, .modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.modal h2, .modal h3 { margin: 0; }
.form-grid, .material-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.form-grid label, .material-row label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.form-grid .wide { grid-column: span 2; }
.toggle-label {
  min-height: 38px;
  display: flex !important;
  flex-direction: row;
  gap: 8px !important;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel2);
}

.toggle-label input {
  width: auto;
  min-height: 0;
}
.modal-section {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.material-row {
  grid-template-columns: 1fr 1fr 120px 42px 42px;
  align-items: end;
}
.modal-actions {
  margin-top: 18px;
}
#modal-status {
  color: var(--muted);
  font-weight: 700;
}

.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 18px;
}

.image-viewer.hidden { display: none; }

.image-viewer-backdrop {
  position: absolute;
  inset: 0;
  min-height: 0;
  border: 0;
  border-radius: 0;
  background: rgba(0,0,0,.76);
}

.image-viewer-box {
  position: relative;
  width: min(980px, 96vw);
  max-height: 94vh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 70px rgba(0,0,0,.42);
}

.image-viewer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.image-viewer-box img,
.image-viewer-box iframe {
  max-width: 100%;
  max-height: calc(94vh - 74px);
  border-radius: 6px;
  background: var(--panel2);
}

.image-viewer-box img {
  object-fit: contain;
}

.image-viewer-box iframe {
  width: min(900px, 92vw);
  height: calc(94vh - 74px);
  border: 0;
}

@media (max-width: 980px) {
  body {
    padding-bottom: calc(78px + env(safe-area-inset-bottom));
  }
  .top { align-items: start; flex-direction: column; }
  .tabs {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 80;
    overflow-x: auto;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    background: #111113 !important;
    border-top: 1px solid rgba(255,255,255,.16);
    border-bottom: 0;
    box-shadow: 0 -18px 40px rgba(0,0,0,.42);
    backdrop-filter: blur(20px) saturate(1.25);
    gap: 4px;
    justify-content: space-between;
  }
  .tab {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    padding: 10px 4px;
    font-size: 0;
    color: #f5f5f7;
    background: #1d1d1f;
    border-color: rgba(255,255,255,.14);
    text-align: center;
  }
  .tab::after {
    content: attr(data-mobile-label);
    font-size: 12px;
    font-weight: 850;
    line-height: 1;
  }
  .tab.active {
    color: #fff;
    background: #0a84ff;
    border-color: #0a84ff;
  }
  .filters { grid-template-columns: 1fr 1fr; }
  .dashboard-filters { grid-template-columns: 1fr; }
  .dashboard-layout { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .layout { grid-template-columns: 1fr; }
  .layout > .detail,
  #detail.detail {
    display: none !important;
  }
  .detail { min-width: 0; }
  .meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .order { grid-template-columns: 1fr; }
  .order > .plan-buttons,
  .order > .kg-breakdown {
    display: none;
  }
  .mobile-order-detail {
    display: block;
    grid-column: 1 / -1;
    margin-top: 8px;
    padding: 10px;
    border: 1px solid rgba(255,255,255,.16);
    border-radius: 8px;
    background: #1d1d1f;
    color: #f5f5f7;
    box-shadow: 0 14px 34px rgba(0,0,0,.32);
  }
  .mobile-order-detail > .plan-buttons {
    display: flex;
  }
  .mobile-order-detail * {
    color: inherit;
  }
  .mobile-order-detail small,
  .mobile-order-detail .meta small,
  .mobile-order-detail .material small {
    color: #a1a1a6;
  }
  .mobile-order-detail .meta div,
  .mobile-order-detail .material,
  .mobile-order-detail .event {
    background: #2c2c2e;
    border-color: rgba(255,255,255,.16);
  }
  .mobile-order-detail .plan-btn {
    background: rgba(41,151,255,.18);
    border-color: rgba(41,151,255,.46);
    color: #f5f5f7;
  }
  .mobile-detail-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: flex-start;
    margin-bottom: 8px;
  }
  .mobile-detail-head > div { min-width: 0; }
  .mobile-detail-head span {
    flex: 0 0 auto;
    font-size: 13px;
    font-weight: 900;
  }
  .mobile-detail-meta {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 8px 0;
  }
  .mobile-detail-meta div {
    padding: 8px;
  }
  .mobile-material-head {
    margin-top: 8px;
    margin-bottom: 4px;
  }
  .mobile-material-grid {
    grid-template-columns: 48px 1fr;
    gap: 8px;
    padding: 8px;
    margin-top: 6px;
  }
  .mobile-material-grid > div:nth-child(n+3) {
    grid-column: 2;
  }
  .table-row { grid-template-columns: 48px 1fr; }
  .tarifa-row { grid-template-columns: 48px 1fr; }
  .table-head { display: none; }
}

.alfred-chat {
  position: fixed;
  right: 18px;
  bottom: 92px;
  z-index: 80;
  font-family: inherit;
}

.alfred-chat-toggle {
  min-width: 96px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid rgba(102, 212, 140, .55);
  border-radius: 999px;
  color: #f5f5f7;
  background: #11161b;
  box-shadow: 0 16px 38px rgba(0,0,0,.28);
  font-weight: 800;
}

.alfred-chat-panel {
  position: absolute;
  right: 0;
  bottom: 58px;
  display: none;
  width: min(380px, calc(100vw - 28px));
  height: min(760px, calc(100vh - 130px));
  max-height: min(760px, calc(100vh - 130px));
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px;
  background: #161a20;
  color: #f5f5f7;
  box-shadow: 0 24px 70px rgba(0,0,0,.42);
}

.alfred-chat.open .alfred-chat-panel {
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto auto;
}

.alfred-chat-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid rgba(255,255,255,.10);
}

.alfred-chat-panel header small,
.alfred-chat-message small {
  color: #a1a1a6;
}

.alfred-chat-close {
  width: 34px;
  min-height: 34px;
  border-radius: 999px;
  color: #f5f5f7;
  background: rgba(255,255,255,.08);
}

.alfred-chat-messages {
  display: grid;
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 14px;
}

.alfred-chat-message {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.45;
}

.alfred-chat-message.is-user {
  justify-self: end;
  background: #2997ff;
  color: #fff;
}

.alfred-chat-message.is-alfred {
  justify-self: start;
  background: rgba(255,255,255,.08);
  color: #f5f5f7;
}

.alfred-chat-suggestions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 14px 12px;
}

.alfred-chat-suggestions button {
  flex: 0 0 auto;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  color: #dce7f5;
  background: rgba(255,255,255,.08);
}

.alfred-chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.10);
}

.alfred-chat-form textarea {
  width: 100%;
  min-height: 42px;
  max-height: 120px;
  resize: none;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.16);
  padding: 11px 12px;
  color: #f5f5f7;
  background: rgba(255,255,255,.08);
}

.alfred-chat-form button {
  min-height: 42px;
  border-radius: 8px;
  color: #11161b;
  background: #66d48c;
  font-weight: 900;
}

@media (max-width: 760px) {
  .alfred-chat {
    right: 12px;
    bottom: calc(138px + env(safe-area-inset-bottom));
  }
  .alfred-chat-panel {
    right: -4px;
    bottom: 56px;
    width: calc(100vw - 16px);
    height: calc(100vh - 210px);
    max-height: calc(100vh - 210px);
  }
}
