/* ============ BASE ============ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  background: #f4f6f9;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ============ VIEWS ============ */
.view {
  display: none;
  min-height: 100vh;
}

.view.active {
  display: block;
}

/* ============ AUTH ============ */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #075E54, #128C7E);
  padding: 20px;
}

.auth-card {
  background: white;
  padding: 40px;
  border-radius: 20px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.auth-logo {
  font-size: 32px;
  font-weight: bold;
  color: #075E54;
  text-align: center;
  margin-bottom: 10px;
}

.auth-card h2 {
  text-align: center;
  color: #1a1a2e;
  margin-bottom: 5px;
}

.auth-subtitle {
  text-align: center;
  color: #666;
  font-size: 14px;
  margin-bottom: 25px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #333;
  margin-bottom: 5px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 10px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #075E54;
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.btn-primary {
  background: #075E54;
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary:hover {
  background: #054740;
}

.btn-secondary {
  background: #e8e8e8;
  color: #333;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary:hover {
  background: #d0d0d0;
}

.btn-full {
  width: 100%;
}

.btn-small {
  background: #075E54;
  color: white;
  border: none;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

.btn-small:hover {
  background: #054740;
}

.btn-logout {
  background: #dc3545;
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-logout:hover {
  background: #c82333;
}

.btn-back {
  background: none;
  border: none;
  color: #075E54;
  font-size: 16px;
  cursor: pointer;
  padding: 8px 12px;
}

.btn-back:hover {
  text-decoration: underline;
}

.auth-switch {
  text-align: center;
  margin-top: 20px;
  font-size: 14px;
  color: #666;
}

.auth-switch a {
  color: #075E54;
  text-decoration: none;
  font-weight: 600;
}

.auth-switch a:hover {
  text-decoration: underline;
}

/* ============ DASHBOARD NAV ============ */
.dashboard-nav {
  background: #075E54;
  color: white;
  padding: 15px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 22px;
  font-weight: bold;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 15px;
}

.nav-user span {
  font-size: 14px;
}

.nav-role {
  background: rgba(255, 255, 255, 0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
}

/* ============ DASHBOARD CONTENT ============ */
.dashboard-content {
  padding: 25px 30px;
  max-width: 1400px;
  margin: 0 auto;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
  margin-bottom: 25px;
}

.dashboard-header h2 {
  font-size: 24px;
  color: #1a1a2e;
}

.header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============ STATS GRID ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 25px;
}

.stat-card {
  background: white;
  padding: 20px;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  text-align: center;
}

.stat-number {
  font-size: 28px;
  font-weight: bold;
  color: #075E54;
}

.stat-label {
  font-size: 13px;
  color: #666;
  margin-top: 4px;
}

/* ============ FILTERS BAR ============ */
.filters-bar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 15px;
  background: white;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.filters-bar input,
.filters-bar select {
  padding: 8px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  flex: 1;
  min-width: 150px;
}

.filters-bar input:focus,
.filters-bar select:focus {
  outline: none;
  border-color: #075E54;
}

/* ============ CLIENT GRID ============ */
.client-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.client-card {
  background: white;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.client-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.client-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.client-name {
  font-size: 18px;
  font-weight: 600;
}

.client-status {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 20px;
}

.status-open {
  background: #d4edda;
  color: #155724;
}

.status-closed {
  background: #f8d7da;
  color: #721c24;
}

.client-card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 10px;
}

.client-meta {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #555;
}

.client-card-footer {
  border-top: 1px solid #eee;
  padding-top: 10px;
  font-size: 12px;
  color: #999;
}

/* ============ CLIENT DETAIL ============ */
.client-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  background: white;
  padding: 20px;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-bottom: 20px;
}

.summary-item {
  text-align: center;
}

.summary-label {
  display: block;
  font-size: 12px;
  color: #999;
}

.summary-value {
  font-size: 18px;
  font-weight: 600;
  color: #1a1a2e;
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  gap: 5px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  background: white;
  padding: 10px;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.tab {
  padding: 8px 18px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
  color: #666;
}

.tab:hover {
  background: #f0f0f0;
}

.tab.active {
  background: #075E54;
  color: white;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ============ TRANSACTION LIST ============ */
.transaction-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.transaction-item {
  background: white;
  padding: 15px 20px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.tx-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.tx-number {
  font-weight: 600;
  color: #666;
  font-size: 13px;
}

.tx-category {
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.tx-category.income {
  background: #d4edda;
  color: #155724;
}

.tx-category.expense {
  background: #f8d7da;
  color: #721c24;
}

.tx-description {
  font-size: 15px;
}

.tx-details {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.tx-amount {
  font-size: 16px;
  font-weight: 600;
}

.tx-date {
  font-size: 12px;
  color: #999;
}

.income-text {
  color: #16a34a;
}

.expense-text {
  color: #dc2626;
}

/* ============ PAGINATION ============ */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  margin-top: 20px;
  padding: 15px;
}

.pagination button {
  background: #075E54;
  color: white;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  cursor: pointer;
}

.pagination button:hover {
  background: #054740;
}

.pagination span {
  font-size: 14px;
  color: #666;
}

/* ============ DEBTOR/CREDITOR GRID ============ */
.debtor-grid,
.creditor-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 15px;
}

.debtor-item,
.creditor-item {
  background: white;
  padding: 15px 20px;
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.debtor-name,
.creditor-name {
  font-size: 16px;
  font-weight: 600;
}

.debtor-amount,
.creditor-amount {
  font-size: 18px;
  font-weight: 700;
}

.debtor-summary,
.creditor-summary {
  background: white;
  padding: 15px 20px;
  border-radius: 10px;
  margin-bottom: 15px;
  font-size: 16px;
}

.status-paid {
  color: #16a34a;
}

.status-outstanding {
  color: #dc2626;
}

/* ============ RECONCILIATION ============ */
.reconciliation-table {
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.recon-header {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  background: #075E54;
  color: white;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
}

.recon-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  padding: 10px 16px;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}

.recon-balanced {
  background: #f8fff8;
}

.recon-unbalanced {
  background: #fff8f8;
}

/* ============ AUDIT TRAIL ============ */
.audit-table {
  background: white;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.audit-header {
  display: grid;
  grid-template-columns: 160px 100px 140px 1fr;
  background: #075E54;
  color: white;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 13px;
}

.audit-row {
  display: grid;
  grid-template-columns: 160px 100px 140px 1fr;
  padding: 10px 16px;
  border-bottom: 1px solid #eee;
  font-size: 13px;
  align-items: center;
}

.audit-time {
  font-size: 12px;
  color: #666;
}

.audit-action {
  font-weight: 600;
}

.audit-action.reclassify {
  color: #ff9800;
}

.audit-action.delete {
  color: #dc3545;
}

.audit-action.create {
  color: #16a34a;
}

.audit-details {
  font-size: 12px;
  color: #555;
}

/* ============ POPIA ============ */
.popia-card {
  background: white;
  padding: 25px;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.popia-card h4 {
  margin-bottom: 15px;
  color: #075E54;
}

.popia-field {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.popia-label {
  font-weight: 600;
  color: #555;
}

.popia-consent-text {
  margin-top: 15px;
  padding: 15px;
  background: #f0f8ff;
  border-radius: 8px;
}

.popia-consent-text p {
  margin-top: 5px;
  font-style: italic;
  color: #555;
}

.popia-footer {
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid #eee;
  color: #999;
  font-size: 12px;
}

/* ============ REPORTS ============ */
.reports-container {
  background: white;
  border-radius: 14px;
  padding: 25px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.report-controls {
  margin-bottom: 20px;
}

.report-controls h3 {
  margin-bottom: 12px;
}

.report-filters {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: end;
}

.report-filters input {
  padding: 8px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
}

.report-result {
  padding: 20px;
  background: #f8f9fa;
  border-radius: 10px;
}

.report-period {
  color: #666;
  margin-bottom: 15px;
}

.report-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.report-item {
  background: white;
  padding: 15px;
  border-radius: 8px;
  text-align: center;
}

.report-label {
  display: block;
  font-size: 12px;
  color: #999;
}

.report-value {
  font-size: 18px;
  font-weight: 600;
}

.report-categories {
  margin-top: 15px;
}

.category-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #eee;
}

.report-footer {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #999;
}

.report-placeholder {
  text-align: center;
  padding: 40px 20px;
  color: #999;
}

.report-actions {
  margin-top: 15px;
  display: flex;
  gap: 10px;
}

/* ============ EMPTY STATE ============ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 16px;
}

/* ============ MODAL ============ */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  overflow-y: auto;
}

.modal-content {
  background: white;
  margin: 5% auto;
  padding: 30px;
  border-radius: 20px;
  max-width: 500px;
  width: 95%;
  position: relative;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-close {
  position: absolute;
  right: 20px;
  top: 15px;
  font-size: 28px;
  cursor: pointer;
  color: #999;
}

.modal-close:hover {
  color: #333;
}

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 28px;
  border-radius: 10px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  z-index: 2000;
  display: none;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.toast.success {
  background: #16a34a;
}

.toast.error {
  background: #dc2626;
}

.toast.info {
  background: #075E54;
}

/* ============ ACCOUNTANT LIST (ADMIN) ============ */
.accountant-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
  gap: 20px;
  margin-top: 15px;
}

.accountant-card {
  background: white;
  padding: 20px;
  border-radius: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.accountant-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.accountant-name {
  font-size: 16px;
  font-weight: 600;
}

.accountant-email {
  font-size: 13px;
  color: #666;
}

.accountant-firm {
  font-size: 13px;
  color: #075E54;
}

.accountant-stats {
  display: flex;
  flex-direction: column;
  align-items: end;
  gap: 4px;
  font-size: 13px;
  color: #666;
}

.accountant-role {
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

.role-admin {
  background: #ff9800;
  color: white;
}

.role-accountant {
  background: #075E54;
  color: white;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .dashboard-nav {
    flex-direction: column;
    gap: 10px;
    padding: 12px 20px;
  }

  .dashboard-content {
    padding: 15px;
  }

  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
  }

  .header-actions {
    flex-wrap: wrap;
  }

  .filters-bar {
    flex-direction: column;
  }

  .filters-bar input,
  .filters-bar select {
    min-width: 100%;
  }

  .client-grid {
    grid-template-columns: 1fr;
  }

  .transaction-item {
    flex-direction: column;
    align-items: stretch;
  }

  .tx-details {
    justify-content: space-between;
  }

  .audit-header,
  .audit-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .recon-header,
  .recon-row {
    grid-template-columns: 1fr 1fr;
    gap: 4px;
    font-size: 12px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .client-summary {
    grid-template-columns: 1fr 1fr;
  }

  .modal-content {
    margin: 10% auto;
    padding: 20px;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .client-summary {
    grid-template-columns: 1fr;
  }

  .nav-user {
    flex-wrap: wrap;
    justify-content: center;
  }
}