@font-face {
  font-family: Montserrat;
  font-display: swap;
  font-style: normal;
  font-weight: 400;
  src: url("//www.sastreriagentleman.es/cdn/fonts/montserrat/montserrat_n4.81949fa0ac9fd2021e16436151e8eaa539321637.woff2") format("woff2");
}

@font-face {
  font-family: Montserrat;
  font-display: swap;
  font-style: normal;
  font-weight: 700;
  src: url("//www.sastreriagentleman.es/cdn/fonts/montserrat/montserrat_n7.3c434e22befd5c18a6b4afadb1e3d77c128c7939.woff2") format("woff2");
}

@font-face {
  font-family: Cormorant;
  font-display: swap;
  font-style: normal;
  font-weight: 700;
  src: url("//www.sastreriagentleman.es/cdn/fonts/cormorant/cormorant_n7.c51184f59f7d2caf4999bcef8df2fc4fc4444aec.woff2") format("woff2");
}

:root {
  --cream: #faf4e8;
  --sand: #ece2cc;
  --brown: #745d4a;
  --taupe: #a18167;
  --taupe-light: #c8b5a6;
  --charcoal: #292929;
  --ink: #262b2c;
  --muted: #556063;
  --line: rgba(116, 93, 74, 0.24);
  --panel: rgba(255, 255, 255, 0.88);
  --shadow: 0 18px 50px rgba(38, 43, 44, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Montserrat, sans-serif;
  background: var(--cream);
  letter-spacing: 0;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    linear-gradient(90deg, rgba(250, 244, 232, 0.88), rgba(250, 244, 232, 0.72)),
    url("/static/assets/hero-gentleman.jpg") center / cover no-repeat;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg, rgba(250, 244, 232, 0.9), rgba(236, 226, 204, 0.96) 45%, rgba(250, 244, 232, 1));
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.topbar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  padding: 10px 26px;
  color: var(--brown);
  background: var(--sand);
  font-size: 13px;
  text-align: center;
}

.topbar a,
.topbar span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  color: #fff;
  background: rgba(116, 93, 74, 0.96);
  box-shadow: 0 1px 0 rgba(250, 244, 232, 0.2);
  backdrop-filter: blur(12px);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1560px;
  min-height: 82px;
  margin: 0 auto;
  padding: 0 28px;
}

.brand-logo {
  width: 240px;
  height: auto;
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 26px;
  font-size: 13px;
  text-transform: uppercase;
}

.nav-links a,
.nav-button {
  border: 0;
  padding: 10px 0;
  color: inherit;
  background: transparent;
  text-decoration: none;
  text-transform: uppercase;
}

.nav-button.active {
  border-bottom: 1px solid var(--cream);
}

.logout-button {
  min-height: 36px;
  border: 1px solid rgba(250, 244, 232, 0.42);
  border-radius: 4px;
  padding: 0 12px;
  color: var(--cream);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.app-shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 30px 24px 44px;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
}

.hidden-media {
  display: none !important;
}

.records-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.records-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.88fr) minmax(520px, 1.12fr);
  gap: 18px;
  align-items: start;
}

.panel,
.clients-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.panel-title,
.section-heading {
  margin-bottom: 18px;
}

.panel-title.inline,
.section-heading.inline {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brown);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: Cormorant, serif;
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: 0;
}

h1 {
  font-size: 40px;
}

h2 {
  font-size: 32px;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 15px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 43px;
  border: 1px solid rgba(116, 93, 74, 0.32);
  border-radius: 4px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brown);
  box-shadow: 0 0 0 3px rgba(116, 93, 74, 0.16);
}

.field-grid {
  display: grid;
  gap: 12px;
}

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

.field-grid.three {
  grid-template-columns: 0.6fr 1.4fr;
}

.wide-field {
  min-width: 0;
}

.field-heading {
  margin: 0 0 9px;
  font-size: 13px;
  font-weight: 700;
}

.check-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 15px;
}

.check-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  margin: 0;
  border: 1px solid rgba(116, 93, 74, 0.24);
  border-radius: 6px;
  padding: 9px;
  background: rgba(250, 244, 232, 0.72);
  font-size: 12px;
  font-weight: 400;
}

.check-card input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--brown);
}

.check-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check-card strong {
  color: var(--brown);
  font-size: 12px;
}

.upload-box {
  display: grid;
  place-items: center;
  min-height: 132px;
  border: 1px dashed rgba(116, 93, 74, 0.55);
  border-radius: 6px;
  padding: 18px;
  text-align: center;
  background: rgba(236, 226, 204, 0.55);
}

.upload-box input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.upload-box span {
  color: var(--brown);
  text-transform: uppercase;
}

.upload-box strong {
  font-family: Cormorant, serif;
  font-size: 24px;
}

.upload-box small {
  max-width: 360px;
  color: var(--muted);
  font-weight: 400;
  line-height: 1.5;
}

.photo-preview {
  display: none;
  width: 100%;
  max-height: 280px;
  object-fit: cover;
  border-radius: 6px;
  margin: -4px 0 16px;
}

.photo-preview.visible {
  display: block;
}

.zoomable {
  cursor: zoom-in;
}

.selected-fabrics-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(236, 226, 204, 0.45);
}

.selected-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.selected-list span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--cream);
  background: var(--brown);
  font-size: 11px;
  font-weight: 700;
}

.muted-text {
  color: var(--muted) !important;
  font-size: 13px;
}

.actions,
.result-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.primary-button,
.secondary-button,
.secondary-link,
.icon-button {
  min-height: 44px;
  border-radius: 4px;
  border: 1px solid transparent;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
}

.primary-button {
  color: var(--cream);
  background: var(--charcoal);
}

.secondary-button,
.secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--brown);
  border-color: rgba(116, 93, 74, 0.42);
  background: rgba(250, 244, 232, 0.8);
}

.icon-button {
  width: 44px;
  padding: 0;
  color: var(--cream);
  background: var(--brown);
  font-size: 24px;
  line-height: 1;
}

.status-line {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--brown);
  font-size: 13px;
  line-height: 1.5;
}

.fabric-form.hidden {
  display: none;
}

.fabric-form {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 18px;
  background: rgba(236, 226, 204, 0.45);
}

.fabric-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-height: 780px;
  overflow: auto;
  padding-right: 2px;
}

.fabric-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.fabric-card.selected {
  border-color: var(--charcoal);
  box-shadow: inset 0 0 0 2px var(--charcoal);
}

.fabric-card button {
  display: grid;
  grid-template-rows: 160px auto;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  text-align: left;
  background: transparent;
}

.fabric-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
}

.fabric-info {
  padding: 12px;
}

.fabric-info h3 {
  margin: 0 0 5px;
  font-family: Cormorant, serif;
  font-size: 22px;
  letter-spacing: 0;
}

.fabric-info p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.fabric-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.fabric-tags span,
.badge {
  display: inline-flex;
  align-items: center;
  min-height: 25px;
  border-radius: 999px;
  padding: 4px 9px;
  color: var(--brown);
  background: var(--sand);
  font-size: 11px;
  font-weight: 700;
}

.badge.ready {
  color: var(--cream);
  background: var(--charcoal);
}

.badge.demo {
  color: var(--cream);
  background: var(--brown);
}

.result-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 360px;
  border: 1px solid rgba(116, 93, 74, 0.22);
  border-radius: 8px;
  padding: 0;
  background: var(--charcoal);
  overflow: hidden;
}

.result-placeholder {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 360px;
  padding: 24px;
  color: var(--cream);
  text-align: center;
}

.result-placeholder strong {
  font-family: Cormorant, serif;
  font-size: 32px;
  line-height: 1;
}

.result-placeholder p {
  max-width: 420px;
  margin: 12px 0 0;
  color: #d8cab8;
  font-size: 13px;
  line-height: 1.5;
}

.result-frame img {
  width: 100%;
  height: auto;
  display: block;
}

.result-frame span {
  position: absolute;
  right: 14px;
  bottom: 14px;
  min-height: 30px;
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--cream);
  background: rgba(41, 41, 41, 0.8);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.result-meta {
  margin-top: 14px;
}

.result-meta.compact {
  margin-top: 0;
  justify-content: flex-end;
}

.generated-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.generated-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.78);
}

.generated-card button {
  display: grid;
  width: 100%;
  padding: 0;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
}

.generated-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}

.generated-card span {
  padding: 9px 10px;
  color: var(--brown);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.clients-section {
  margin-top: 18px;
  padding: 22px;
}

.client-history-section {
  background: rgba(250, 244, 232, 0.92);
}

.history-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 18px;
}

.history-grid h3 {
  margin: 0 0 12px;
  font-family: Cormorant, serif;
  font-size: 26px;
}

.history-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.history-grid section:nth-child(2) .history-list {
  grid-template-columns: 1fr;
}

.history-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.78);
}

.history-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 6px;
  object-fit: cover;
  margin-bottom: 10px;
  cursor: zoom-in;
}

.history-card div {
  display: grid;
  gap: 4px;
  margin-bottom: 10px;
}

.history-card strong {
  font-family: Cormorant, serif;
  font-size: 22px;
}

.history-card span {
  color: var(--muted);
  font-size: 12px;
}

.invoice-history-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.invoice-history-card div {
  margin-bottom: 0;
}

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

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.client-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.76);
}

.client-card h3 {
  margin: 0 0 6px;
  font-family: Cormorant, serif;
  font-size: 24px;
}

.client-card p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.client-card img {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 6px;
  object-fit: cover;
  margin-top: 8px;
}

.module-panel {
  max-width: 1420px;
  margin: 0 auto;
}

.fabric-grid-module {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  max-height: none;
}

.invoice-layout {
  display: grid;
  grid-template-columns: minmax(340px, 0.82fr) minmax(520px, 1.18fr);
  gap: 18px;
  align-items: start;
}

.invoice-preview {
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}

.invoice-preview.empty {
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.68);
}

.invoice-paper {
  color: var(--ink);
}

.invoice-header,
.invoice-parties {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
  margin-bottom: 18px;
}

.invoice-header img {
  width: 230px;
  height: auto;
  object-fit: contain;
}

.invoice-header div {
  display: grid;
  justify-items: end;
  align-content: center;
  gap: 6px;
}

.invoice-header strong {
  font-family: Cormorant, serif;
  font-size: 30px;
}

.invoice-header span {
  color: var(--brown);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.invoice-parties h3 {
  margin: 0 0 6px;
  font-family: Cormorant, serif;
  font-size: 28px;
}

.invoice-parties p {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 13px;
}

.invoice-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 18px;
  font-size: 13px;
}

.invoice-table th,
.invoice-table td {
  border-bottom: 1px solid rgba(116, 93, 74, 0.18);
  padding: 11px 8px;
  text-align: left;
}

.invoice-table th:nth-child(n + 2),
.invoice-table td:nth-child(n + 2) {
  text-align: right;
}

.invoice-totals {
  display: grid;
  justify-content: end;
  gap: 8px;
}

.invoice-totals div {
  display: grid;
  grid-template-columns: 150px 130px;
  gap: 20px;
}

.invoice-totals span {
  color: var(--muted);
}

.invoice-totals strong {
  text-align: right;
}

.invoice-totals .grand-total {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  color: var(--charcoal);
  font-size: 20px;
}

.invoice-notes {
  border-top: 1px solid var(--line);
  margin: 20px 0 0;
  padding-top: 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.image-dialog {
  width: min(96vw, 1500px);
  max-width: none;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
}

.image-dialog::backdrop {
  background: rgba(18, 16, 14, 0.82);
}

.image-dialog img {
  width: 100%;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 8px;
  background: var(--charcoal);
}

.dialog-close {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 2;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(250, 244, 232, 0.4);
  border-radius: 999px;
  color: var(--cream);
  background: rgba(41, 41, 41, 0.82);
  font-size: 28px;
  line-height: 1;
}

.login-page::before {
  background:
    linear-gradient(90deg, rgba(41, 41, 41, 0.72), rgba(116, 93, 74, 0.42)),
    url("/static/assets/hero-gentleman.jpg") center / cover no-repeat;
}

.login-page::after {
  background: rgba(41, 41, 41, 0.25);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  border: 1px solid rgba(250, 244, 232, 0.28);
  border-radius: 8px;
  padding: 28px;
  color: var(--cream);
  background: rgba(41, 41, 41, 0.88);
  box-shadow: var(--shadow);
}

.login-card img {
  width: 260px;
  max-width: 100%;
  margin-bottom: 24px;
}

.login-card input {
  color: var(--ink);
}

.login-card .status-line.error {
  color: #f0b1a7 !important;
}

@media print {
  body::before,
  body::after,
  .topbar,
  .site-header,
  .invoice-builder,
  .clients-section,
  .panel-title .result-meta,
  .dialog-close {
    display: none !important;
  }

  .app-shell {
    max-width: none;
    padding: 0;
  }

  .view-section {
    display: none !important;
  }

  [data-view-section="facturas"] {
    display: block !important;
  }

  .invoice-layout {
    display: block;
  }

  .panel,
  .invoice-preview {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}

@media (max-width: 1260px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .result-panel,
  .invoice-preview-panel {
    grid-column: 1 / -1;
  }

  .clients-list,
  .fabric-grid-module {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .invoice-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 4px;
    font-size: 12px;
  }

  .header-inner {
    min-height: auto;
    flex-direction: column;
    gap: 12px;
    padding: 14px 18px 16px;
  }

  .brand-logo {
    width: min(260px, 82vw);
  }

  .nav-links {
    width: 100%;
    justify-content: center;
    gap: 15px;
    font-size: 11px;
  }

  .app-shell {
    padding: 18px 12px 28px;
  }

  .workspace,
  .field-grid.two,
  .field-grid.three,
  .check-grid,
  .fabric-grid,
  .fabric-grid-module,
  .invoice-layout,
  .clients-list {
    grid-template-columns: 1fr;
  }

  .selected-fabrics-bar,
  .records-hero,
  .section-heading.inline,
  .invoice-header,
  .invoice-parties {
    flex-direction: column;
  }

  .invoice-header div {
    justify-items: start;
  }

  .invoice-totals div {
    grid-template-columns: 1fr auto;
  }

  .history-grid,
  .history-list,
  .generated-gallery {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 17px;
  }

  h1 {
    font-size: 34px;
  }

  h2 {
    font-size: 29px;
  }
}
