html,
body {
  margin: 0;
  padding: 0;
  font-family: 'Roboto', sans-serif;
  min-height: 100vh;
  background: linear-gradient(to bottom right, #fff8e1, #ffe0b2);
  box-sizing: border-box;
}

@page {
  size: A4;
  margin: 20pt;
}

.hidden {
  display: none !important;
}

#authContainer {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}

.login-box {
  background: white;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-box h2 {
  color: #8b4513;
  margin-bottom: 2rem;
}

.login-box .form-group {
  margin-bottom: 1.5rem;
  text-align: left;
}

.login-box input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 1rem;
  box-sizing: border-box;
}

.login-box button {
  width: 100%;
  padding: 0.75rem;
  background-color: #d97706;
  color: white;
  border: none;
  border-radius: 0.375rem;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.login-box button:hover {
  background-color: #b45309;
}

#authError {
  color: #dc2626;
  margin-top: 1rem;
  font-size: 0.875rem;
  min-height: 1.25rem;
}

.app-wrapper {
  padding: 2rem;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

header.main-header {
  text-align: center;
  margin-bottom: 3rem;
  padding: 1rem;
  color: white;
  border-radius: 12px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

header.main-header h1 {
  color: #8b4513;
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

header.main-header p {
  color: #a0522d;
  font-size: 1.2rem;
  opacity: 0.9;
}

#main-nav {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.nav-button {
  background: #4b5563;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-button:hover {
  background: #374151;
}

.nav-button.active {
    background: #d97706;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}

.logout-button {
  background: #ef4444;
}

.logout-button:hover {
  background: #dc2626;
}

.budget-container {
  width: 210mm;
  margin: 0 auto;
}

.form-container,
.budget-container,
.budget-list-container,
.contract-container,
.shopping-list-container,
.watermark-container,
#dashboardContainer {
  background: white;
  border-radius: 0.75rem;
  padding: 2rem;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  margin-bottom: 2rem;
}

.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #4b5563;
  margin-bottom: 0.5rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 1rem;
  transition: all 0.2s;
  font-family: inherit;
  box-sizing: border-box;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

textarea {
  resize: vertical;
}

.section {
  margin-bottom: 2rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 1.5rem;
  cursor: move;
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-header .category-title {
  flex: 1;
  min-width: 200px;
}

.icon-select {
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  background: white;
  min-width: 150px;
}

.items-grid {
  display: grid;
  grid-template-columns: 2fr 3fr 1fr 1fr 1fr auto;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
  cursor: move;
  align-items: center;
}

.add-button {
  color: #d97706;
  background: none;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  transition: all 0.2s;
}

.add-button:hover {
  background: #fff8e1;
  color: #b45309;
}

.add-category-button {
  background: #f59e0b;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 0.375rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 2rem 0;
  transition: all 0.2s;
}

.add-category-button:hover {
  background: #d97706;
}

.generate-button {
  background-color: #d97706;
  color: white;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.375rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
  margin-right: 0.5rem;
  vertical-align: middle;
}

.generate-button:hover {
  background-color: #b45309;
}

.generate-button.edit-contract {
    background-color: #2563eb;
}
.generate-button.edit-contract:hover {
    background-color: #1d4ed8;
}

.remove-button {
  color: #ef4444;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.25rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}

.remove-button:hover {
  background: #fee2e2;
}

.drag-over {
  border: 2px dashed #f59e0b;
}

.budget-info {
  margin-top: 2rem;
}

.budget-info h3 {
  color: #8b4513;
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.budget-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.budget-item {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.budget-item-label {
  flex: 0 0 40%;
  font-weight: 500;
  color: #6b7280;
}

.budget-item-value {
  flex: 1;
}

.budget-section {
  border-top: 1px solid #e5e7eb;
  padding-top: 1rem;
  margin-top: 1rem;
  page-break-inside: avoid;
}

.budget-section .section-title {
  color: #8b4513;
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.budget-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.budget-row span:last-child {
  font-weight: bold;
  text-align: right;
}

.total-row {
  margin-top: 2rem;
  font-weight: bold;
  font-size: 1.25rem;
  color: #8b4513;
  display: flex;
  justify-content: space-between;
  padding-top: 1rem;
  border-top: 1px solid #e5e7eb;
}

.discount-row {
  font-weight: bold;
  color: #d97706;
}

.budget-footer {
  margin-top: 2rem;
  font-style: italic;
  color: #6b7280;
  font-size: 0.9rem;
}

.pdf-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.pdf-header h1 {
  color: #8b4513;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.pdf-header p {
  color: #a0522d;
  margin-bottom: 1rem;
}

.contract-container {
  max-width: 180mm;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  font-family: 'Times New Roman', serif;
  font-size: 11pt;
  line-height: 1.4;
  color: #333;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
}

.contract-container img {
  max-width: 100%;
  height: auto;
}

.contract-header,
.contract-section,
.contract-signatures {
  page-break-inside: avoid;
  margin-bottom: 20px;
}

.contract-header {
  text-align: center;
  margin-bottom: 30px;
  border-bottom: 2px solid #8b4513;
  padding-bottom: 20px;
}

.contract-title {
  font-size: 14pt;
  font-weight: bold;
  text-align: center;
  color: #8b4513;
  margin-bottom: 10px;
  text-transform: uppercase;
}

.contract-section p {
  margin: 10px 0;
  text-align: justify;
  word-break: break-word;
}

.contract-clause {
  margin: 15px 0;
}

.contract-clause-title {
  font-weight: bold;
  margin-bottom: 8px;
}

.contract-signatures {
  margin-top: 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  page-break-inside: avoid;
}

.signature-line {
  border-top: 1px solid #000;
  margin-top: 40px;
  padding-top: 10px;
  text-align: center;
}

.contract-footer {
  margin-top: 40px;
  text-align: center;
  font-size: 12px;
  color: #666;
}

.obligations-list {
  margin-left: 20px;
  position: relative;
}

.obligations-list li {
  margin-bottom: 8px;
  list-style: none;
  padding-left: 20px;
  text-indent: -20px;
  word-break: break-word;
}

.obligations-list li::before {
  content: '•';
  color: #8b4513;
  font-weight: bold;
  position: absolute;
  left: 0;
}

#budgetPopup,
#shoppingListPopup {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: rgba(255, 255, 255, 0.95);
  padding: 12px 18px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  z-index: 1000;
  display: none;
  font-size: 0.95rem;
  color: #333;
  min-width: 250px;
  line-height: 1.5;
}

#dashboardContainer h3 {
  color: #8b4513;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #ffe0b2;
  padding-bottom: 0.5rem;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
}

.dashboard-column {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.financial-kpis .kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background-color: #fff8e1;
  padding: 1.5rem;
  border-radius: 8px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.kpi-card h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: #a0522d;
}

.kpi-card p {
  margin: 0;
  font-size: 1.8rem;
  font-weight: 700;
  color: #8b4513;
}

.upcoming-events .events-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.event-card {
  background-color: #fafafa;
  border-left: 4px solid #f59e0b;
  padding: 1rem;
  border-radius: 4px;
}

.event-card h4 {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  color: #4b5563;
}

.event-card ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
  font-size: 0.9rem;
  max-height: 150px;
  overflow-y: auto;
}
.event-card ul li {
  margin-bottom: 0.5rem;
}

.financial-chart-container {
    position: relative;
    height: 400px;
    padding: 1rem;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

#calendar-container {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    height: 100%;
}

#calendar {
  height: 100%;
}

:root {
  --fc-border-color: #e5e7eb;
  --fc-daygrid-event-dot-width: 8px;
  --fc-list-event-dot-width: 10px;
  --fc-list-event-hover-bg-color: #fff8e1;
  --fc-event-bg-color: #d97706;
  --fc-event-border-color: #b45309;
  --fc-event-text-color: #fff;
  --fc-button-bg-color: #8b4513;
  --fc-button-text-color: #fff;
  --fc-button-border-color: #8b4513;
  --fc-button-hover-bg-color: #a0522d;
  --fc-button-hover-border-color: #a0522d;
  --fc-button-active-bg-color: #b45309;
  --fc-button-active-border-color: #b45309;
  --fc-today-bg-color: rgba(255, 248, 225, 0.7);
}
.fc-daygrid-day.fc-day-today {
    background-color: var(--fc-today-bg-color) !important;
}

.budget-list-card {
    border: 1px solid #e5e7eb;
    padding: 1.5rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
}

.budget-list-card p {
    margin: 0.25rem 0;
}

.budget-list-card strong {
    color: #4b5563;
}

.budget-actions {
    margin-top: 1rem;
    display:flex;
    gap:0.5rem;
    flex-wrap:wrap;
    align-items: center;
}

.status-controls {
    display: flex;
    gap: 0.5rem;
    border-left: 2px solid #d1d5db;
    padding-left: 1rem;
    margin-left: 0.5rem;
}
.status-btn {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    border-radius: 1rem;
    border: 1px solid transparent;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.status-btn.approved { background-color: #dcfce7; color: #166534; border-color: #16a34a; }
.status-btn.reproved { background-color: #fee2e2; color: #991b1b; border-color: #ef4444; }
.status-btn.pending { background-color: #fef9c3; color: #854d0e; border-color: #f59e0b; }

.status-btn:not(.active) {
    opacity: 0.6;
}
.status-btn:not(.active):hover {
    opacity: 1;
}

.status-tag {
    font-size: 0.8rem;
    padding: 0.2rem 0.6rem;
    border-radius: 1rem;
    font-weight: 500;
    color: white;
    margin-left: 1rem;
}
.status-tag.approved { background-color: #16a34a; }
.status-tag.reproved { background-color: #ef4444; }
.status-tag.pending { background-color: #f59e0b; }

.shopping-list-master-view h2,
.shopping-list-detail-view h2,
.shopping-list-detail-view h2 input {
  color: #8b4513;
  margin-bottom: 1.5rem;
}

.shopping-list-card {
  border: 1px solid #e5e7eb;
  padding: 1rem 1.5rem;
  margin-bottom: 1rem;
  border-radius: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.shopping-list-card .info p {
  margin: 0.25rem 0;
}

.shopping-list-card .info strong {
  color: #4b5563;
}

.shopping-list-card .info .associated-budget {
  font-size: 0.9rem;
  color: #6b7280;
}

.shopping-list-card .actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.shopping-list-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid #f3f4f6;
}

.shopping-list-item:last-child {
  border-bottom: none;
}

.shopping-list-item input[type="checkbox"] {
  width: auto;
  transform: scale(1.3);
  cursor: pointer;
  justify-self: center;
}

.shopping-list-item .item-details {
  flex-grow: 1;
  display: grid;
  grid-template-columns: 1fr 80px 100px 100px;
  gap: 0.75rem;
  align-items: center;
}

.shopping-list-item input,
.shopping-list-item select {
  padding: 0.4rem;
  font-size: 0.95rem;
}

.item-checked .item-details input,
.item-checked .item-details select {
  text-decoration: line-through;
  color: #9ca3af;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.modal-content {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
  margin-top: 0;
  color: #8b4513;
}

.modal-actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.watermark-container h2 {
    color: #8b4513;
    margin-bottom: 0.5rem;
}

.watermark-container p {
    color: #6b7280;
    margin-bottom: 2rem;
    max-width: 800px;
}

.upload-area {
  margin-bottom: 2rem;
}

.upload-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px dashed #d1d5db;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  color: #6b7280;
}

.upload-label:hover {
  border-color: #8b4513;
  background-color: #fff8e1;
  color: #8b4513;
}

.upload-label svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
}

.upload-label span {
  font-weight: 500;
}

.watermark-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}

.watermark-item {
  position: relative;
  border-radius: 0.5rem;
  overflow: hidden;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  border: 1px solid #e5e7eb;
}

.watermark-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.watermark-item .overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.watermark-item:hover .overlay {
  opacity: 1;
}

.watermark-item .download-btn {
  background-color: #d97706;
  color: white;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 0.375rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: background-color 0.2s;
}

.watermark-item .download-btn:hover {
  background-color: #b45309;
}

.watermark-item p {
    font-size: 0.8rem;
    margin-top: 0.5rem;
    text-align: center;
}

@media (min-width: 768px) {
  .grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 1200px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 767px) {
  .app-wrapper {
    padding: 1rem;
  }

  .form-container,
  .budget-container,
  .budget-list-container,
  .contract-container,
  .shopping-list-container,
  #dashboardContainer {
    padding: 1.5rem; 
    width: auto;
  }

  header.main-header h1 {
    font-size: 2rem;
  }

  header.main-header p {
    font-size: 1rem;
  }

  header.main-header div {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }

  .section-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
  }

  .icon-select {
    width: 100%;
  }

  .items-grid {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
  }

  .items-grid input {
    width: 100%;
  }

  .items-grid .remove-button {
    align-self: flex-end;
    margin-top: 0.5rem;
  }

  .items-grid .toggle-display,
  .items-grid .include-total {
    transform: scale(1.2);
    margin-right: 8px;
  }

  .budget-container .button-group {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  .budget-container .button-group .generate-button {
    width: 100%;
    margin-right: 0;
    justify-content: center;
  }

  .budget-grid {
    grid-template-columns: 1fr;
  }

  .budget-item-label {
    flex-basis: 120px;
    flex-shrink: 0;
  }

  .dashboard-grid {
    gap: 1.5rem; 
  }

  .kpi-card p {
    font-size: 1.5rem; 
  }

  .upcoming-events .events-grid {
    grid-template-columns: 1fr; 
  }
  
  .financial-chart-container {
    height: 300px; 
  }

  #calendar-container {
    padding: 0.5rem; 
    min-height: 550px; 
  }

  .fc .fc-toolbar.fc-header-toolbar {
    flex-direction: column; 
    align-items: stretch; 
    text-align: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem !important;
  }

  .fc .fc-toolbar-title {
    font-size: 1.25em !important; 
  }

  .fc .fc-button {
    font-size: 0.9em; 
    padding: .4em .6em;
  }
  
  .shopping-list-item {
    grid-template-columns: auto 1fr;
    gap: 0.5rem;
  }

  .shopping-list-item .item-details {
    grid-column: 1 / -1;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    margin-left: 30px;
  }

  .shopping-list-item .remove-button {
    grid-row: 1;
    grid-column: 3;
    justify-self: end;
  }
}


@media print {
  body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  #dashboardContainer,
  .form-container,
  .budget-list-container,
  .contract-container,
  .shopping-list-container,
  #main-nav,
  .add-category-button {
    display: none !important;
  }

  .generate-button {
    display: none !important;
  }

  .budget-container {
    box-shadow: none;
    padding: 0 !important;
    width: 100%;
    min-height: auto;
    display: block !important;
  }

  .budget-container .button-group {
    display: none !important;
  }
}