/* ===== Petra Aroma Theme ===== */
:root {
  --brown: #3d2c1e;
  --brown-light: #5a4333;
  --sage: #9caf88;
  --sage-dark: #7d9466;
  --sage-light: #b8c9a8;
  --cream: #f9f8ec;
  --cream-dark: #f0eeda;
  --white: #ffffff;
  --red: #c0392b;
  --red-light: #e8d5d2;
  --green: #27ae60;
  --green-light: #d4edda;
  --text: #3d2c1e;
  --text-light: #6b5b4e;
  --border: #e0ddd0;
  --shadow: rgba(61,44,30,0.08);
}

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

body {
  font-family: 'Nunito Sans', sans-serif;
  background: var(--cream);
  color: var(--text);
  display: flex;
  min-height: 100vh;
}

h1, h2, h3, h4 { font-family: 'Lora', serif; font-weight: 600; }

/* ===== Sidebar ===== */
.sidebar {
  width: 240px;
  background: var(--brown);
  color: var(--cream);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  padding: 0 24px 24px;
  border-bottom: 1px solid var(--brown-light);
  margin-bottom: 16px;
  text-align: center;
}

.sidebar-logo {
  width: 160px;
  height: auto;
  filter: brightness(0) invert(1) sepia(0.15) brightness(0.95);
  margin: 0 auto 6px;
  display: block;
}

.sidebar-brand .subtitle {
  font-size: 0.75rem;
  color: var(--cream-dark);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.nav-links { list-style: none; }

.nav-links li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: var(--cream-dark);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 400;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.nav-links li a:hover {
  background: var(--brown-light);
  color: var(--white);
}

.nav-links li a.active {
  background: rgba(156,175,136,0.15);
  color: var(--sage-light);
  border-left-color: var(--sage);
  font-weight: 600;
}

.nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

/* ===== Main Content ===== */
.main-content {
  margin-left: 240px;
  flex: 1;
  padding: 24px 32px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#page-container {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* Fixed-layout pages: header/stats/filters stay visible, table scrolls internally */
#page-container.page-fixed {
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#page-container.page-fixed .table-card {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin-bottom: 0;
}

#page-container.page-fixed .page-header {
  flex-shrink: 0;
}

#page-container.page-fixed .card-grid {
  flex-shrink: 0;
}

#page-container.page-fixed .filters {
  flex-shrink: 0;
}

/* Sticky table headers inside scrollable table cards */
#page-container.page-fixed .table-card thead th {
  position: sticky;
  top: 0;
  background: var(--white);
  z-index: 1;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.page-header h2 { font-size: 1.6rem; color: var(--brown); }

/* ===== Cards ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px var(--shadow);
  border: 1px solid var(--border);
}

.card-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 8px;
}

.card-value {
  font-family: 'Lora', serif;
  font-size: 1.8rem;
  font-weight: 700;
}

.card-value.positive { color: var(--green); }
.card-value.negative { color: var(--red); }

.card-clickable {
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px var(--shadow);
  border-color: var(--sage);
}

/* ===== Charts ===== */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.chart-card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px var(--shadow);
  border: 1px solid var(--border);
}

.chart-card h3 {
  font-size: 1rem;
  margin-bottom: 16px;
  color: var(--brown);
}

.chart-card canvas { max-height: 280px; }

.chart-full {
  grid-column: 1 / -1;
}

/* ===== Tables ===== */
.table-card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 2px 8px var(--shadow);
  border: 1px solid var(--border);
  margin-bottom: 28px;
  overflow-x: auto;
}

.table-card h3 { margin-bottom: 16px; font-size: 1rem; color: var(--brown); }

table { width: 100%; border-collapse: collapse; }

th {
  text-align: left;
  padding: 10px 12px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  border-bottom: 2px solid var(--border);
}

td {
  padding: 10px 12px;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border);
}

tr:last-child td { border-bottom: none; }
tr:hover { background: var(--cream); }

.amount-positive { color: var(--green); font-weight: 600; }
.amount-negative { color: var(--red); font-weight: 600; }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: 8px;
  font-family: 'Nunito Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--sage);
  color: var(--white);
}
.btn-primary:hover { background: var(--sage-dark); }

.btn-secondary {
  background: var(--cream-dark);
  color: var(--brown);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
  background: var(--red-light);
  color: var(--red);
}
.btn-danger:hover { background: var(--red); color: var(--white); }

.btn-sm { padding: 5px 10px; font-size: 0.8rem; }

.btn-group { display: flex; gap: 8px; }

/* ===== Forms ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Nunito Sans', sans-serif;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--white);
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(156,175,136,0.2);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ===== Week Navigation ===== */
.week-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}

.week-nav .week-label {
  font-family: 'Lora', serif;
  font-size: 1.1rem;
  color: var(--brown);
  min-width: 220px;
  text-align: center;
}

.week-nav .btn { min-width: 40px; justify-content: center; }

/* ===== Filters ===== */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding: 16px;
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.filters select,
.filters input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: 'Nunito Sans', sans-serif;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--white);
}

.filters select:focus,
.filters input:focus {
  outline: none;
  border-color: var(--sage);
}

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(61,44,30,0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--white);
  border-radius: 16px;
  width: 90%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(61,44,30,0.2);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 { font-size: 1.1rem; }

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  line-height: 1;
}

.modal-body { padding: 24px; }

.modal.modal-wide { max-width: 900px; }

.modal-body .subtotal-row td {
  font-weight: 700;
  background: var(--cream);
  border-top: 2px solid var(--border);
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 4px 12px var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 360px;
}

.toast-success { background: var(--green-light); color: var(--green); }
.toast-error { background: var(--red-light); color: var(--red); }
.toast-info { background: var(--cream-dark); color: var(--brown); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Import ===== */
.import-section {
  background: var(--white);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

.import-section h3 {
  margin-bottom: 12px;
  font-size: 1rem;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  color: var(--text-light);
  margin: 12px 0;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-zone:hover {
  border-color: var(--sage);
  background: rgba(156,175,136,0.05);
}

.upload-zone input[type="file"] { display: none; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-revenue { background: var(--green-light); color: var(--green); }
.badge-expense { background: var(--red-light); color: var(--red); }
.badge-other_income { background: #e0f2f1; color: #00796b; }
.badge-shopify { background: #e8f5e9; color: #2e7d32; }
.badge-etsy { background: #fff3e0; color: #e65100; }
.badge-viator { background: #e3f2fd; color: #1565c0; }
.badge-ath_mobile { background: #f3e5f5; color: #7b1fa2; }
.badge-manual { background: var(--cream-dark); color: var(--text-light); }
.badge-bank { background: #e0e0e0; color: #424242; }
.badge-other { background: #f5f5f5; color: #757575; }
.badge-chase { background: #d9e8f5; color: #0060a9; }
.badge-banco_popular { background: #d4edda; color: #00703c; }
.badge-amazon { background: #fff3e0; color: #e67e00; }
.badge-paypal { background: #d6e4f0; color: #003087; }

/* ===== Loading ===== */
.loading {
  text-align: center;
  padding: 40px;
  color: var(--text-light);
}

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--sage);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state h3 {
  margin-bottom: 8px;
  color: var(--text-light);
}

/* ===== Reminder Banner ===== */
.reminder-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 12px;
  margin-bottom: 20px;
}

.reminder-icon {
  font-size: 1.5rem;
  color: #f9a825;
  flex-shrink: 0;
}

.reminder-content {
  flex: 1;
}

.reminder-content strong {
  display: block;
  margin-bottom: 6px;
  color: var(--brown);
  font-size: 0.95rem;
}

.reminder-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.reminder-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-light);
}

/* ===== Drag & Drop Reorder ===== */
.dashboard-section {
  position: relative;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.dashboard-section .drag-handle {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 16px;
  cursor: grab;
  opacity: 0;
  transition: opacity 0.2s;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-light);
  letter-spacing: 2px;
}

.dashboard-section .drag-handle::before {
  content: '\2261';
  font-size: 1.2rem;
}

.dashboard-section:hover .drag-handle {
  opacity: 0.6;
}

.dashboard-section .drag-handle:hover {
  opacity: 1;
}

.dashboard-section.dragging {
  opacity: 0.4;
  outline: 2px dashed var(--sage);
  outline-offset: 4px;
  cursor: grabbing;
}

.dashboard-section.drag-over-top {
  border-top: 3px solid var(--sage);
  padding-top: 4px;
}

.dashboard-section.drag-over-bottom {
  border-bottom: 3px solid var(--sage);
  padding-bottom: 4px;
}

/* ===== Categorize Page ===== */
.cat-btn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.cat-pill {
  padding: 8px 16px;
  border: 2px solid var(--pill-color, var(--sage));
  border-radius: 20px;
  background: var(--white);
  color: var(--text);
  font-family: 'Nunito Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.cat-pill:hover {
  background: var(--pill-color, var(--sage));
  color: var(--white);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ===== View Toggle Pills ===== */
.view-toggle {
  display: inline-flex;
  background: var(--cream-dark);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.view-toggle .toggle-pill {
  padding: 8px 20px;
  border: none;
  background: none;
  font-family: 'Nunito Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s;
}

.view-toggle .toggle-pill:hover {
  color: var(--text);
  background: var(--border);
}

.view-toggle .toggle-pill.active {
  background: var(--sage);
  color: var(--white);
}

/* ===== Month Picker ===== */
.month-picker {
  padding: 10px 16px;
  border: 2px solid var(--sage-light);
  border-radius: 10px;
  font-family: 'Nunito Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--brown);
  background: var(--white);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
  min-width: 160px;
}

.month-picker:focus {
  outline: none;
  border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(156,175,136,0.2);
}

/* ===== Overview Toolbar ===== */
.overview-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 24px;
  padding: 14px 20px;
  background: var(--white);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px var(--shadow);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-logo, .sidebar-brand .subtitle, .nav-links li a span:not(.nav-icon) { display: none; }
  .nav-links li a { justify-content: center; padding: 14px; }
  .main-content { margin-left: 60px; padding: 16px 16px; }
  .chart-row { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .card-grid { grid-template-columns: 1fr; }
}
