:root {
  --ink: #211b16;
  --muted: #6e6259;
  --brown: #24180f;
  --brown-2: #372719;
  --gold: #b7792a;
  --gold-2: #965f1c;
  --gold-soft: #f3e4d1;
  --paper: #fbfaf8;
  --soft: #f8f2ec;
  --line: #e8d9ca;
  --white: #fff;
  --blue: #8eb2d8;
  --green: #9dad78;
  --red: #d89489;
  --shadow: 0 14px 34px rgba(42, 30, 20, 0.08);
  --radius: 8px;
  --sidebar: 270px;
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: "Segoe UI", Inter, Arial, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 32px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  color: var(--gold-2);
  font-size: 16px;
  text-transform: uppercase;
}

p,
small {
  color: var(--muted);
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: linear-gradient(145deg, var(--brown), #4a3523);
}

.login-card {
  display: grid;
  width: min(420px, 100%);
  gap: 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  padding: 30px;
  background: var(--white);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.25);
}

.login-brand,
.brand {
  display: grid;
  justify-items: center;
  gap: 10px;
}

.brand-logo {
  display: block;
  width: min(100%, 220px);
  height: auto;
  object-fit: contain;
}

.brand-logo-light {
  width: min(100%, 300px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #d3d0d0;
}

.brand-logo-dark {
  width: min(100%, 224px);
  border-radius: 6px;
}

.login-brand small,
.brand small {
  font-weight: 700;
  text-transform: uppercase;
}

.login-brand small {
  color: var(--brown);
}

.brand small {
  color: rgba(255, 255, 255, 0.7);
}

.login-error {
  border-radius: var(--radius);
  padding: 10px 12px;
  color: #8d2f28;
  background: #f6dddd;
  font-weight: 700;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  padding: 34px 18px 24px;
  background: linear-gradient(160deg, var(--brown), #1b130d);
}

.nav-list {
  display: grid;
  gap: 10px;
}

.nav-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 54px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 16px;
  color: rgba(255, 255, 255, 0.86);
  background: transparent;
  font-weight: 800;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  color: #fff;
  background: linear-gradient(135deg, #a86a22, #c38432);
}

.nav-item svg {
  width: 22px;
  height: 22px;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  min-height: 78px;
  border-bottom: 1px solid var(--line);
  padding: 14px 32px;
  background: rgba(251, 250, 248, 0.96);
}

.search-box {
  position: relative;
  display: block;
  width: min(330px, 100%);
}

.search-box span {
  position: absolute;
  left: 13px;
  top: 50%;
  color: var(--gold-2);
  transform: translateY(-50%);
}

.search-box input {
  padding-left: 42px;
}

.notification-button {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 0;
  background: transparent;
}

.notification-button b {
  position: absolute;
  right: 2px;
  top: 2px;
  display: grid;
  width: 18px;
  height: 18px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: #a84921;
  font-size: 11px;
}

.profile {
  display: grid;
  grid-template-columns: 44px minmax(110px, auto);
  align-items: center;
  gap: 12px;
}

.profile strong,
.profile small {
  display: block;
}

.avatar {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  color: var(--brown);
  background: #e9ded2;
  font-weight: 900;
}

.view {
  display: none;
  padding: 30px 38px;
}

.view.active {
  display: block;
}

.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 26px;
}

.page-heading p {
  margin-bottom: 0;
}

.date-chip {
  white-space: nowrap;
  font-weight: 600;
}

.surface,
.stat-card,
.quick-card,
.client-card,
.product-card,
.proposal-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--white);
  box-shadow: var(--shadow);
}

.surface {
  padding: 22px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1.45fr) minmax(390px, 0.95fr);
  gap: 22px;
  margin-bottom: 22px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1.1fr) minmax(430px, 0.95fr);
  gap: 22px;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(106px, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.quick-card {
  display: grid;
  min-height: 176px;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 16px 12px;
  text-align: center;
}

.quick-card > span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--gold-2);
  font-size: 30px;
  font-weight: 800;
}

.quick-card strong {
  font-size: 13px;
}

.quick-card small {
  line-height: 1.35;
}

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

.stat-card {
  display: grid;
  min-height: 139px;
  padding: 20px;
}

.stat-card span {
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.stat-card strong {
  margin: 14px 0 8px;
  font-size: 32px;
}

.good {
  color: #52710f;
  font-weight: 800;
}

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

.recent-list,
.client-list,
.proposal-list {
  display: grid;
  gap: 12px;
}

.recent-row {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) 100px 110px;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 8px 0 14px;
}

.recent-thumb,
.product-thumb {
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--soft);
  overflow: hidden;
}

.recent-thumb {
  width: 64px;
  height: 64px;
}

.recent-thumb img,
.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.status-pill {
  display: inline-flex;
  justify-content: center;
  min-width: 86px;
  border-radius: 7px;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.status-borrador { color: #58534e; background: #ece8e3; }
.status-enviada { color: #23527b; background: #e5f0fb; }
.status-aprobada { color: #536b20; background: #eaf0df; }
.status-rechazada { color: #9d372d; background: #f5dfdc; }
.status-en-produccion { color: #835819; background: #f1dfc3; }
.status-pendiente { color: #835819; background: #f1dfc3; }
.status-en-curso { color: #23527b; background: #e5f0fb; }
.status-hecha { color: #536b20; background: #eaf0df; }

.compact-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.danger {
  color: #9d372d !important;
  font-weight: 900;
}

.warn {
  color: #835819 !important;
  font-weight: 900;
}

.status-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: center;
  gap: 24px;
}

.donut {
  display: grid;
  width: 210px;
  height: 210px;
  place-items: center;
  border-radius: 50%;
  background: conic-gradient(#e8d3ba 0 30%, var(--blue) 30% 60%, var(--green) 60% 78%, var(--red) 78% 92%, #d39b4a 92% 100%);
  position: relative;
}

.donut::after {
  content: "";
  position: absolute;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  background: #fff;
}

.donut strong,
.donut small {
  position: relative;
  z-index: 1;
}

.donut strong {
  align-self: end;
  font-size: 30px;
}

.donut small {
  align-self: start;
}

.legend {
  display: grid;
  gap: 14px;
}

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

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.tip-card {
  margin-top: 22px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 22px;
  align-items: start;
}

.client-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
}

.client-avatar {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #806135, #2b2118);
  font-weight: 900;
}

.task-list {
  display: grid;
  gap: 12px;
}

.task-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px auto;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  background: #fff;
  box-shadow: var(--shadow);
}

.task-card.done {
  opacity: 0.72;
}

.task-card.done strong {
  text-decoration: line-through;
}

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.meta span {
  color: var(--muted);
  font-size: 13px;
}

.form-panel,
.settings-form {
  display: grid;
  gap: 14px;
}

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

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(183, 121, 42, 0.14);
}

.button-row,
.filter-row {
  display: flex;
  gap: 9px;
  flex-wrap: wrap;
}

.primary-button,
.ghost-button,
.outline-button,
.text-button,
.filter-row button,
.client-card button,
.task-card button,
.product-card button,
.user-card button,
.proposal-card button,
.pipeline-item,
.stage-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--gold);
  color: #fff;
  background: var(--gold);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

.ghost-button,
.filter-row button,
.client-card button,
.task-card button,
.product-card button,
.user-card button,
.proposal-card button,
.pipeline-item,
.stage-toolbar button {
  border: 1px solid var(--line);
  color: var(--brown);
  background: #fff;
}

.outline-button {
  width: 100%;
  border: 1px solid var(--gold);
  color: #fff;
  background: transparent;
  text-transform: uppercase;
}

.text-button {
  border: 0;
  color: var(--gold-2);
  background: transparent;
}

.danger-button {
  border-color: #e3b5ae !important;
  color: #9d372d !important;
  background: #fff7f6 !important;
}

.filter-row button.active {
  border-color: var(--gold);
  color: #fff;
  background: var(--gold);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 18px;
  color: var(--muted);
  background: var(--soft);
  font-weight: 700;
}

.image-fallback {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 82px;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.recent-thumb img + .image-fallback,
.product-thumb img + .image-fallback,
.image-preview img + .image-fallback {
  display: none;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(190px, 1fr));
  gap: 16px;
}

.catalog-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.catalog-layout .catalog-grid {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.product-card {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.product-thumb {
  height: 190px;
}

.proposals-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 22px;
}

.proposal-card {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.proposal-card.active {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(183, 121, 42, 0.14);
}

.pipeline-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(170px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.pipeline-column {
  display: grid;
  align-content: start;
  gap: 10px;
  min-width: 170px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: var(--soft);
}

.pipeline-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--gold-2);
}

.pipeline-head span {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--gold);
  font-weight: 900;
}

.pipeline-item {
  display: grid;
  min-height: auto;
  gap: 5px;
  padding: 11px;
  text-align: left;
  white-space: normal;
}

.pipeline-item span,
.pipeline-empty {
  color: var(--muted);
  font-size: 12px;
}

.pipeline-empty {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #fff;
}

.editor-layout {
  display: grid;
  grid-template-columns: 300px minmax(400px, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.stage-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.stage-toolbar button.active {
  color: #fff;
  background: var(--brown-2);
}

.garment-stage {
  position: relative;
  display: grid;
  aspect-ratio: 4 / 5;
  min-height: 500px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  overflow: hidden;
}

#garmentImage {
  width: 82%;
  height: 82%;
  object-fit: contain;
}

.logo-layer {
  position: absolute;
  left: 42%;
  top: 34%;
  display: grid;
  min-width: 130px;
  min-height: 68px;
  place-items: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
  font-weight: 900;
  transform: translate(-50%, -50%);
  transform-origin: center;
  touch-action: none;
}

.logo-layer img {
  display: none;
  max-width: 160px;
  max-height: 90px;
  object-fit: contain;
}

.logo-layer.has-image {
  background: transparent;
}

.logo-layer.has-image img {
  display: block;
}

.logo-layer.has-image span {
  display: none;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.report-block {
  margin-top: 22px;
}

.table-list,
.audit-list,
.user-list {
  display: grid;
  gap: 10px;
}

.table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 110px 130px;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
}

.table-row span {
  font-weight: 800;
}

.table-row strong,
.table-row em {
  font-style: normal;
  text-align: right;
}

.audit-row,
.user-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.audit-row {
  display: grid;
  gap: 5px;
  padding: 13px 14px;
}

.audit-row span,
.audit-row small {
  color: var(--muted);
}

.user-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 16px;
}

.settings-layout {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 18px;
  align-items: start;
}

.settings-actions {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
}

input[type="color"] {
  min-height: 44px;
  padding: 5px;
}

.check-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.permission-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: var(--soft);
}

.permission-preview span {
  border-radius: 999px;
  padding: 5px 9px;
  color: var(--brown);
  background: #fff;
  font-size: 12px;
  font-weight: 800;
}

.permission-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #fff;
}

.permission-check {
  border-radius: 7px;
  padding: 8px;
  background: var(--soft);
  font-size: 12px;
}

.image-preview {
  display: grid;
  min-height: 130px;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: var(--soft);
  overflow: hidden;
}

.image-preview img {
  max-width: 100%;
  max-height: 170px;
  object-fit: contain;
}

.density-compact .view {
  padding-top: 22px;
  padding-bottom: 22px;
}

.density-compact .surface,
.density-compact .stat-card,
.density-compact .client-card,
.density-compact .product-card,
.density-compact .proposal-card,
.density-compact .user-card {
  padding: 14px;
}

.density-compact .nav-item {
  min-height: 46px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 40;
  max-width: 360px;
  border-radius: var(--radius);
  padding: 14px 16px;
  color: #fff;
  background: var(--brown);
  opacity: 0;
  transform: translateY(8px);
  transition: 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

[data-icon] svg {
  width: 22px;
  height: 22px;
  stroke: currentColor;
}

@media (max-width: 1180px) {
  .dashboard-grid,
  .bottom-grid,
  .split-layout,
  .proposals-layout,
  .editor-layout,
  .catalog-layout,
  .settings-layout {
    grid-template-columns: 1fr;
  }

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

  .quick-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 820px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .topbar,
  .page-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .view {
    padding: 24px 18px;
  }

  .quick-grid,
  .stat-grid,
  .catalog-grid,
  .report-grid,
  .status-layout,
  .recent-row,
  .client-card,
  .task-card,
  .user-card,
  .table-row {
    grid-template-columns: 1fr;
  }

  .table-row strong,
  .table-row em {
    text-align: left;
  }
}
