*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #f6f5f4;
  color: #111827;
}

.app {
  max-width: 960px;
  margin: 40px auto;
  padding: 0 16px;
}

/* TOP NAV */

.top-nav {
  display: inline-flex;
  margin-bottom: 12px;
  border-radius: 999px;
  background-color: #e5e7eb;
  padding: 2px;
}

.top-nav-link {
  text-decoration: none;
  font-size: 13px;
  color: #4b5563;
  padding: 4px 12px;
  border-radius: 999px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.top-nav-link.active {
  background-color: #ffffff;
  color: #111827;
  box-shadow: 0 1px 2px rgba(15,23,42,0.15);
}

/* HEADER */

.app-header {
  margin-bottom: 16px;
}

.app-header h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
}

.app-header p {
  margin: 4px 0 24px;
  color: #6b7280;
  font-size: 14px;
}

.app-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-header-left {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.month-display {
  padding: 4px 10px;
  border-radius: 999px;
  background-color: #eef2ff;
  color: #3730a3;
  font-size: 13px;
  font-weight: 500;
}

.ghost-btn {
  border: 1px solid #d1d5db;
  background: #f9fafb;
  color: #4b5563;
  border-radius: 999px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.ghost-btn:hover {
  background-color: #e5e7eb;
  border-color: #9ca3af;
}

/* Toggle devise */

.currency-toggle {
  display: inline-flex;
  border-radius: 999px;
  padding: 2px;
  background-color: #e5e7eb;
}

.currency-btn {
  border: none;
  background: transparent;
  padding: 4px 12px;
  font-size: 12px;
  border-radius: 999px;
  cursor: pointer;
  color: #4b5563;
  min-width: 64px;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.currency-btn.active {
  background-color: #ffffff;
  color: #111827;
  box-shadow: 0 1px 2px rgba(15,23,42,0.15);
}

/* CARD GÉNÉRALE */

.card {
  background-color: #ffffff;
  border-radius: 16px;
  padding: 24px 24px 20px;
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06),
              0 18px 40px rgba(15, 23, 42, 0.08);
}

/* FORM (page 1) */

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-row-inline {
  flex-direction: row;
  gap: 16px;
}

.form-row-inline > div {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

label {
  font-size: 13px;
  color: #4b5563;
}

input[type="text"],
input[type="date"],
input[type="number"],
input[type="password"],
select {
  border-radius: 6px;
  border: 1px solid #d1d5db;
  padding: 8px 10px;
  font-size: 14px;
  background-color: #f9fafb;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: #6366f1;
  background-color: #ffffff;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.4);
}

.form-actions {
  margin-top: 8px;
  display: flex;
  justify-content: flex-end;
}

button {
  border: none;
  border-radius: 10px 10px 0px 0px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  background-color: #6366f1;
  color: white;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

button:hover {
  background-color: #4f46e538;
  border-radius: 10px 10px 0px 0px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.2);
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.18);
}

button:disabled {
  background-color: #9ca3af;
  cursor: not-allowed;
  opacity: 0.6;
}

.form-status {
  margin-top: 12px;
  font-size: 13px;
  color: #6b7280;
}

/* DASHBOARD (page 2) */

.dashboard {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

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

.summary-card {
  border-radius: 12px;
  padding: 12px 14px;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.summary-income {
  border-left: 3px solid #22c55e;
}

.summary-expense {
  border-left: 3px solid #ef4444;
}

.summary-balance {
  border-left: 3px solid #6366f1;
}

.summary-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6b7280;
}

.summary-value {
  font-size: 18px;
  font-weight: 600;
}

.categories h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
}

/* ACCORDIONS CATÉGORIES */

.category-item {
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background-color: #f9fafb;
  margin-bottom: 8px;
  overflow: hidden;
}

.category-item[open] {
  background-color: #ffffff;
}

.category-item summary {
  list-style: none;
  cursor: pointer;
}

.category-item summary::-webkit-details-marker {
  display: none;
}

.category-header {
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.category-name {
  font-weight: 500;
}

.category-amount {
  font-size: 14px;
  font-weight: 500;
}

.category-amount.negative {
  color: #b91c1c;
}

/* TABLE TRANSACTIONS */

.tx-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.tx-table th,
.tx-table td {
  padding: 6px 10px;
  border-top: 1px solid #e5e7eb;
}

.tx-table th {
  background-color: #f3f4f6;
  text-align: left;
  font-weight: 500;
  color: #4b5563;
}

.tx-table td {
  color: #374151;
}

/* RESPONSIVE */

@media (min-width: 800px) {
  .app-header-left {
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }
}

@media (max-width: 720px) {
  .app {
    margin: 20px auto;
    padding: 0 12px;
  }

  .card {
    padding: 20px 16px 16px;
    border-radius: 12px;
  }

  /* Top nav responsive */
  .top-nav {
    width: 100%;
    justify-content: center;
    margin-bottom: 16px;
  }

  .top-nav-link {
    flex: 0 0 auto;
    padding: 6px 16px;
  }

  /* Header tableau responsive */
  .app-header h1 {
    font-size: 24px;
  }

  .app-header p {
    font-size: 13px;
  }

  .app-header-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
  }

  .app-header-left {
    width: 100%;
    flex-direction: column;
    gap: 8px;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
  }

  .month-display {
    flex: 1;
    text-align: center;
  }

  .currency-toggle {
    align-self: flex-end;
    margin-top: 8px;
  }

  /* Formulaire */
  .form-row-inline {
    flex-direction: column;
    gap: 12px;
  }

  /* Dashboard */
  .summary-row {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .summary-value {
    font-size: 16px;
  }

  .categories h2 {
    font-size: 16px;
  }

  /* Table transactions responsive */
  .tx-table {
    font-size: 12px;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .tx-table thead,
  .tx-table tbody,
  .tx-table tr {
    display: table;
    width: 100%;
    table-layout: fixed;
  }

  .tx-table th,
  .tx-table td {
    padding: 8px 6px;
  }

  .tx-table th:nth-child(1),
  .tx-table td:nth-child(1) {
    width: 30%;
  }

  .tx-table th:nth-child(2),
  .tx-table td:nth-child(2) {
    width: 45%;
  }

  .tx-table th:nth-child(3),
  .tx-table td:nth-child(3) {
    width: 25%;
    text-align: right;
  }

  .category-header {
    padding: 12px 10px;
  }

  .category-name {
    font-size: 14px;
  }

  .category-amount {
    font-size: 13px;
  }
}

/* Très petits écrans (< 400px) */
@media (max-width: 400px) {
  .app {
    padding: 0 8px;
  }

  .card {
    padding: 16px 12px;
  }

  .ghost-btn {
    width: 28px;
    height: 28px;
    font-size: 14px;
  }

  .currency-btn {
    min-width: 56px;
    font-size: 11px;
    padding: 4px 8px;
  }

  .summary-value {
    font-size: 14px;
  }
}

/* ===== ACTIONS & MODAL ===== */

/* Actions au survol */
.actions { 
  display: none; 
  gap: 6px; 
}

tr:hover .actions { 
  display: flex !important; 
}

.btn-edit, .btn-delete { 
  background: none; 
  border: none; 
  cursor: pointer; 
  font-size: 16px; 
  padding: 4px 6px;
  transition: transform 0.1s;
  color: #6b7280;
}

.btn-edit:hover { 
  transform: scale(1.2); 
  color: #3b82f6; 
}

.btn-delete:hover { 
  transform: scale(1.2); 
  color: #ef4444; 
}

/* Modal */
.modal { 
  display: none; 
  position: fixed; 
  top: 0; 
  left: 0; 
  right: 0; 
  bottom: 0; 
  background: rgba(0, 0, 0, 0.5); 
  align-items: center; 
  justify-content: center; 
  z-index: 100; 
}

.modal.open { 
  display: flex; 
}

.modal-content { 
  background: white; 
  padding: 30px; 
  border-radius: 12px; 
  max-width: 500px; 
  width: 90%; 
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.06),
              0 18px 40px rgba(15, 23, 42, 0.12);
}

.modal-header { 
  font-size: 18px; 
  font-weight: 600; 
  margin-bottom: 20px; 
  color: #111827;
}

.form-group { 
  margin-bottom: 15px; 
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.form-group label { 
  font-size: 13px;
  color: #4b5563;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input, 
.form-group select { 
  border-radius: 6px;
  border: 1px solid #d1d5db;
  padding: 8px 10px;
  font-size: 14px;
  background-color: #f9fafb;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #6366f1;
  background-color: #ffffff;
  box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.4);
}

.modal-buttons { 
  display: flex; 
  gap: 10px; 
  margin-top: 20px; 
}

.modal-buttons button { 
  padding: 8px 16px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}

.btn-save { 
  background: #6366f1;
  color: white; 
  flex: 1;
}

.btn-save:hover {
  background: #4f46e5;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.2);
}

.btn-save:active {
  transform: translateY(1px);
}

.btn-cancel { 
  background: #e5e7eb; 
  color: #4b5563;
  flex: 0 0 auto;
}

.btn-cancel:hover {
  background: #d1d5db;
}

/* ===== ONGLETS ===== */

.tabs { 
  display: flex; 
  gap: 10px; 
  margin-bottom: 20px; 
  border-bottom: 2px solid #e5e7eb; 
}

.tab-btn { 
  padding: 8px 12px; 
  background: none; 
  border: none; 
  cursor: pointer; 
  color: #6b7280; 
  font-weight: 500;
  font-size: 14px;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  margin-bottom: -2px;
}

.tab-btn:hover {
  color: #4f46e538;
}

.tab-btn.active { 
  color: #111827; 
  border-bottom-color: #4f46e5; 
}

.tab-content { 
  display: none; 
}

.tab-content.active { 
  display: block; 
}

/* ===== RESPONSIF MODAL ===== */

@media (max-width: 720px) {
  .modal-content {
    max-width: 90%;
    padding: 24px 16px;
  }

  .modal-header {
    font-size: 16px;
  }

  .form-group input,
  .form-group select {
    padding: 10px 8px;
    font-size: 16px; /* Évite le zoom sur mobile */
  }

  .modal-buttons {
    flex-direction: column;
  }

  .btn-save,
  .btn-cancel {
    flex: 1;
  }

  .tabs {
    gap: 8px;
    margin-bottom: 16px;
  }

  .tab-btn {
    padding: 6px 10px;
    font-size: 13px;
  }
}

.pie-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.pie-left, .pie-right {
    flex: 1;
    min-width: 240px;
    text-align: center;
}

.pie-left canvas,
.pie-right canvas {
    max-width: 240px;
    max-height: 240px;
}

.pie-legend {
    min-width: 200px;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.pie-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.pie-color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}


