* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  /* Updated to minimalist grayscale palette */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #ebebeb;
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --border-color: #d9d9d9;
  --accent-color: #999999;
  --accent-light: #f0f0f0;

  /* Material Design colors for action buttons */
  --btn-add: #4caf50;
  --btn-add-hover: #45a049;
  /* Changed edit button color to Material Design Light Blue */
  --btn-edit: #64b5f6;
  --btn-edit-hover: #42a5f5;
  --btn-delete: #f44336;
  --btn-delete-hover: #da190b;
  --btn-warning: #ff9800;
  --btn-warning-hover: #e68900;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: linear-gradient(135deg, #f9f9f9 0%, #f0f0f0 100%);
  color: var(--text-primary);
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

header {
  text-align: center;
  margin-bottom: 40px;
  padding: 20px 0;
  border-bottom: 1px solid var(--border-color);
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  color: var(--text-primary);
  font-weight: 700;
}

header .subtitle {
  font-size: 1.1rem;
  color: var(--text-secondary);
  font-weight: 400;
}

main {
  display: flex;
  flex-direction: column;
  gap: 40px;
}

/* Control Panel */
.control-panel {
  background: rgba(255, 255, 255, 0.95);
  padding: 24px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 20px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.12);
  position: relative;
  overflow: hidden;
}

.control-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.05) 100%);
  pointer-events: none;
  z-index: 0;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  z-index: 1;
  justify-content: center;
}

.control-group label {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.control-group input[type="number"],
.control-group input[type="text"],
.control-group select {
  padding: 10px 12px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
}

.control-group input[type="number"]:focus,
.control-group input[type="text"]:focus,
.control-group select:focus {
  outline: none;
  border-color: rgba(100, 181, 246, 0.8);
  box-shadow: 0 8px 24px rgba(100, 181, 246, 0.15);
  background: rgba(100, 181, 246, 0.08);
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--text-primary);
}

.checkbox-group label {
  margin: 0;
  cursor: pointer;
  font-weight: 500;
}

.price-input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.info-text {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-style: italic;
}

/* Sections */
.section {
  background: rgba(255, 255, 255, 0.95);
  padding: 24px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.12);
  position: relative;
  overflow: hidden;
}

.section::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.05) 100%);
  pointer-events: none;
  z-index: 0;
}

.section-header,
.section h2,
.table-container {
  position: relative;
  z-index: 1;
}

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

.section h2 {
  margin-bottom: 15px;
  color: var(--text-primary);
  font-size: 1.5rem;
  font-weight: 700;
}

.section-header h2 {
  margin-bottom: 0;
}

.rounding-notice {
  background: rgba(200, 200, 200, 0.2);
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 15px;
  font-size: 0.95rem;
  color: var(--text-primary);
  border-left: 4px solid var(--text-secondary);
}

/* Tables */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  overflow: hidden;
}

thead {
  background: rgba(255, 255, 255, 0.7);
  position: relative;
}

thead::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, 
    rgba(255, 255, 255, 0.6) 0%, 
    rgba(255, 255, 255, 0.8) 50%, 
    rgba(255, 255, 255, 0.6) 100%
  );
}

th {
  padding: 14px 12px;
  text-align: left;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
  background: transparent;
  position: relative;
}

th:first-child {
  border-top-left-radius: 12px;
}

th:last-child {
  border-top-right-radius: 12px;
}

td {
  padding: 12px;
  border-bottom: 1px solid rgba(217, 217, 217, 0.3);
  background: rgba(255, 255, 255, 0.5);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:last-child td:first-child {
  border-bottom-left-radius: 12px;
}

tbody tr:last-child td:last-child {
  border-bottom-right-radius: 12px;
}

tr:hover td {
  background: rgba(245, 245, 245, 0.6);
}

td input[type="number"] {
  width: 100%;
  padding: 8px 10px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  transition: all 0.2s ease;
}

td input[type="number"]:focus {
  outline: none;
  border-color: rgba(100, 181, 246, 0.8);
  box-shadow: 0 8px 24px rgba(100, 181, 246, 0.15);
  background: rgba(100, 181, 246, 0.08);
}

/* Buttons - Liquid Glass Style */
.btn {
  padding: 10px 16px;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

/* Add button - Green tinted liquid glass */
.btn-add {
  background: rgba(76, 175, 80, 0.12);
  color: rgb(46, 125, 50);
  box-shadow: 
    0 0 0 1px rgba(76, 175, 80, 0.6),
    0 8px 32px rgba(76, 175, 80, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn-add::before {
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.3) 0%, rgba(76, 175, 80, 0.1) 100%);
}

.btn-add:hover {
  color: rgb(27, 94, 32);
  box-shadow: 
    0 0 0 2px rgba(76, 175, 80, 0.8),
    0 16px 48px rgba(76, 175, 80, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Edit button - Blue tinted liquid glass */
.btn-edit {
  background: rgba(100, 181, 246, 0.12);
  color: rgb(25, 118, 210);
  padding: 6px 10px;
  font-size: 0.9rem;
  box-shadow: 
    0 0 0 1px rgba(100, 181, 246, 0.6),
    0 8px 32px rgba(100, 181, 246, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn-edit::before {
  background: linear-gradient(135deg, rgba(100, 181, 246, 0.3) 0%, rgba(100, 181, 246, 0.1) 100%);
}

.btn-edit:hover {
  color: rgb(13, 71, 161);
  box-shadow: 
    0 0 0 2px rgba(100, 181, 246, 0.8),
    0 16px 48px rgba(100, 181, 246, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Delete button - Red tinted liquid glass */
.btn-delete {
  background: rgba(244, 67, 54, 0.12);
  color: rgb(198, 40, 40);
  padding: 6px 10px;
  font-size: 0.9rem;
  box-shadow: 
    0 0 0 1px rgba(244, 67, 54, 0.6),
    0 8px 32px rgba(244, 67, 54, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn-delete::before {
  background: linear-gradient(135deg, rgba(244, 67, 54, 0.3) 0%, rgba(244, 67, 54, 0.1) 100%);
}

.btn-delete:hover {
  color: rgb(183, 28, 28);
  box-shadow: 
    0 0 0 2px rgba(244, 67, 54, 0.8),
    0 16px 48px rgba(244, 67, 54, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Secondary button - Gray tinted liquid glass */
.btn-secondary {
  background: rgba(128, 128, 128, 0.12);
  color: rgb(66, 66, 66);
  box-shadow: 
    0 0 0 1px rgba(128, 128, 128, 0.6),
    0 8px 32px rgba(128, 128, 128, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn-secondary::before {
  background: linear-gradient(135deg, rgba(128, 128, 128, 0.3) 0%, rgba(128, 128, 128, 0.1) 100%);
}

.btn-secondary:hover {
  color: rgb(33, 33, 33);
  box-shadow: 
    0 0 0 2px rgba(128, 128, 128, 0.8),
    0 16px 48px rgba(128, 128, 128, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

/* Warning button - Orange tinted liquid glass */
.btn-warning {
  background: rgba(255, 152, 0, 0.12);
  color: rgb(230, 81, 0);
  box-shadow: 
    0 0 0 1px rgba(255, 152, 0, 0.6),
    0 8px 32px rgba(255, 152, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.btn-warning::before {
  background: linear-gradient(135deg, rgba(255, 152, 0, 0.3) 0%, rgba(255, 152, 0, 0.1) 100%);
}

.btn-warning:hover {
  color: rgb(191, 54, 12);
  box-shadow: 
    0 0 0 2px rgba(255, 152, 0, 0.8),
    0 16px 48px rgba(255, 152, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.btn-small {
  padding: 8px 12px;
  font-size: 0.9rem;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
  background: rgb(255, 255, 255);
  margin: 5% auto;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid rgba(200, 200, 200, 0.5);
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.modal-content .btn {
  margin-top: 20px;
}

.close {
  color: var(--text-secondary);
  float: right;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s ease;
}

.close:hover {
  color: var(--text-primary);
}

.modal h3 {
  margin-bottom: 15px;
  color: var(--text-primary);
  font-weight: 700;
}

#assignmentCheckboxes {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-bottom: 15px;
}

.assignment-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 4px;
  background: var(--bg-secondary);
}

.assignment-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--text-primary);
}

/* Actions */
.actions {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
  justify-content: center;
}

/* Responsive */
/* Space chips for person assignments */
.spaces-cell {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.shared-payments-cell {
  /* Removed display: flex to maintain table-cell layout */
}

.shared-payments-cell > * {
  display: inline-flex;
  margin: 2px;
}

.space-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.space-chip.assigned {
  background: rgba(76, 175, 80, 0.12);
  color: rgb(27, 94, 32);
  box-shadow: 
    0 0 0 1px rgba(76, 175, 80, 0.6),
    0 4px 16px rgba(76, 175, 80, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

.space-chip.assigned:hover {
  transform: translateY(-1px);
  color: rgb(27, 94, 32);
  box-shadow: 
    0 0 0 2px rgba(76, 175, 80, 0.8),
    0 6px 20px rgba(76, 175, 80, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.space-chip.unassigned {
  background: rgba(158, 158, 158, 0.08);
  color: rgba(102, 102, 102, 0.6);
  box-shadow: 
    0 0 0 1px rgba(158, 158, 158, 0.4),
    0 4px 16px rgba(158, 158, 158, 0.1),
    inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.space-chip.unassigned:hover {
  transform: translateY(-1px);
  color: rgba(102, 102, 102, 0.8);
  box-shadow: 
    0 0 0 2px rgba(158, 158, 158, 0.6),
    0 6px 20px rgba(158, 158, 158, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

/* Shared Payment Chips */
.shared-payment-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  margin: 2px;
  transition: all 0.2s ease;
  color: white;
  position: relative;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.shared-payment-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Tooltip para chips */
.shared-payment-tooltip {
  position: absolute;
  background: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 1001;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-5px);
  margin-bottom: 5px;
}

.shared-payment-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: rgba(0, 0, 0, 0.9);
}

.shared-payment-chip:hover .shared-payment-tooltip {
  opacity: 1;
}

/* Modal ancho para multi-paso */
.modal-wide {
  max-width: 700px;
}

/* System description */
.system-description {
  background: rgba(100, 181, 246, 0.08);
  border: 2px solid rgba(100, 181, 246, 0.3);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 25px;
}

.system-description h4 {
  color: var(--text-primary);
  font-size: 1.1rem;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.system-description h4 i {
  color: #64B5F6;
}

.system-description p {
  color: var(--text-primary);
  line-height: 1.6;
  margin-bottom: 15px;
}

.description-example {
  background: white;
  border-radius: 8px;
  padding: 15px;
  margin-top: 15px;
}

.description-example h5 {
  color: #64B5F6;
  font-size: 0.95rem;
  margin-bottom: 10px;
  font-weight: 600;
}

.description-example p {
  margin-bottom: 10px;
  font-size: 0.9rem;
}

.description-example ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}

.description-example li {
  padding: 6px 0;
  padding-left: 24px;
  position: relative;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.description-example li::before {
  content: '•';
  position: absolute;
  left: 8px;
  color: #64B5F6;
  font-weight: bold;
}

/* Step indicator */
.step-indicator {
  display: flex;
  justify-content: space-between;
  margin-bottom: 30px;
  padding: 0 20px;
  position: relative;
}

.step-indicator::before {
  content: '';
  position: absolute;
  top: 20px;
  left: 60px;
  right: 60px;
  height: 2px;
  background: var(--border-color);
  z-index: 0;
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  position: relative;
  z-index: 1;
}

.step::before {
  content: '';
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-secondary);
  border: 2px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
}

.step.active {
  color: var(--text-primary);
}

.step.active::before {
  background: #64B5F6;
  border-color: #64B5F6;
}

.step.completed::before {
  background: #81C784;
  border-color: #81C784;
}

/* Modal steps */
.modal-step {
  min-height: 300px;
}

.step-description {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 0.95rem;
}

/* Checkbox container */
.checkbox-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  max-height: 400px;
  overflow-y: auto;
  padding: 10px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.checkbox-container label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  background: white;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 2px solid transparent;
}

.checkbox-container label:hover {
  border-color: #64B5F6;
  background: rgba(100, 181, 246, 0.05);
}

.checkbox-container input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: #64B5F6;
}

.checkbox-container input[type="checkbox"]:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.space-disabled-info {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-left: 26px;
}

/* Income inputs */
.income-inputs-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
  margin-bottom: 20px;
}

.income-input-group {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg-secondary);
  border-radius: 8px;
}

.income-input-group label {
  flex: 1;
  font-weight: 600;
  color: var(--text-primary);
}

.income-input-group input {
  flex: 1;
  padding: 8px 12px;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-size: 1rem;
}

.income-input-group input:focus {
  outline: none;
  border-color: #64B5F6;
}

/* Percentage preview */
.percentage-preview {
  background: rgba(100, 181, 246, 0.1);
  border: 2px solid rgba(100, 181, 246, 0.3);
  border-radius: 8px;
  padding: 15px;
  margin-bottom: 20px;
}

.percentage-preview h4 {
  margin-bottom: 12px;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.percentage-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(100, 181, 246, 0.2);
}

.percentage-item:last-child {
  border-bottom: none;
}

.percentage-bar {
  flex: 1;
  height: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
  margin: 0 12px;
  overflow: hidden;
}

.percentage-fill {
  height: 100%;
  background: #64B5F6;
  transition: width 0.3s ease;
}

/* Modal buttons */
.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

/* Shared payment details */
.shared-payment-details {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-section {
  background: var(--bg-secondary);
  padding: 15px;
  border-radius: 8px;
}

.detail-section h4 {
  margin-bottom: 10px;
  color: var(--text-primary);
  font-size: 1rem;
}

.detail-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-chip {
  padding: 6px 12px;
  background: white;
  border-radius: 6px;
  font-size: 0.85rem;
  border: 1px solid var(--border-color);
}

.cost-breakdown {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cost-item {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  background: white;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.cost-item-name {
  font-weight: 600;
}

.cost-item-amount {
  color: #64B5F6;
  font-weight: 700;
}

@media (max-width: 768px) {
  header h1 {
    font-size: 2rem;
  }

  .control-panel {
    grid-template-columns: 1fr;
  }

  .section-header {
    flex-direction: column;
    align-items: stretch;
  }

  .section-header .btn {
    width: 100%;
    justify-content: center;
  }

  .section-header > div {
    flex-direction: column;
    width: 100%;
  }

  .actions {
    flex-direction: column;
  }

  .actions .btn {
    width: 100%;
    justify-content: center;
  }

  table {
    font-size: 0.9rem;
  }

  th,
  td {
    padding: 8px;
  }

  .spaces-cell {
    max-width: 250px;
  }

  .space-chip {
    font-size: 0.75rem;
    padding: 4px 8px;
  }

  .step-indicator {
    padding: 0 10px;
  }

  .step {
    font-size: 0.75rem;
  }

  .step::before {
    width: 30px;
    height: 30px;
  }

  .checkbox-container {
    grid-template-columns: 1fr;
  }

  .modal-wide {
    max-width: 95%;
  }
}
