/* =====================================================
   GENERAL
===================================================== */

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

body {
  min-height: 100vh;
  padding: 32px 16px 60px;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Arial,
    sans-serif;

  background: #f4f6f8;

  color: #172033;
}

button,
input,
select {
  font-family: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}


/* =====================================================
   CONTAINER
===================================================== */

.container {
  width: 100%;
  max-width: 650px;
  margin: 0 auto;
}


/* =====================================================
   HEADER
===================================================== */

.header {
  text-align: center;
  margin-bottom: 28px;
}

.header h1 {
  margin-bottom: 7px;

  color: #111827;

  font-size: 30px;

  font-weight: 800;
}

.header p {
  color: #6b7280;
  font-size: 15px;
}


/* =====================================================
   PAGE TOP BAR
===================================================== */

.page-topbar {
  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 14px;

  margin-bottom: 28px;
}


/* =====================================================
   NAVIGATION
===================================================== */

.top-nav {
  display: flex;

  align-items: center;

  gap: 5px;

  padding: 5px;

  background: #e8edf2;

  border-radius: 14px;
}

.nav-link {
  min-width: 110px;

  padding: 10px 17px;

  border-radius: 10px;

  color: #64748b;

  text-align: center;

  text-decoration: none;

  font-size: 14px;

  font-weight: 700;
}

.nav-link.active {
  background: #ffffff;

  color: #111827;

  box-shadow:
    0 2px 8px
    rgba(15, 23, 42, 0.08);
}


/* =====================================================
   EXPORT
===================================================== */

.export-wrap {
  position: relative;
}

.export-btn {
  min-height: 44px;

  padding: 0 18px;

  border: 1px solid #d1d5db;

  border-radius: 12px;

  background: #ffffff;

  color: #374151;

  font-size: 14px;

  font-weight: 750;
}

.export-btn:hover {
  background: #f8fafc;
}

.export-menu {
  display: none;

  position: absolute;

  top: calc(100% + 8px);

  right: 0;

  z-index: 4000;

  width: 190px;

  padding: 7px;

  background: #ffffff;

  border: 1px solid #e5e7eb;

  border-radius: 13px;

  box-shadow:
    0 18px 45px
    rgba(15, 23, 42, 0.16);
}

.export-menu.show {
  display: block;
}

.export-menu button {
  width: 100%;

  min-height: 44px;

  padding: 9px 12px;

  border: none;

  border-radius: 9px;

  background: transparent;

  color: #374151;

  text-align: left;

  font-size: 14px;

  font-weight: 700;
}

.export-menu button:hover {
  background: #f1f5f9;
}


/* =====================================================
   BALANCE
===================================================== */

.balance-card {
  margin-bottom: 20px;

  padding: 36px 24px;

  background: #ffffff;

  border: 1px solid #e8ebef;

  border-radius: 24px;

  text-align: center;

  box-shadow:
    0 12px 35px
    rgba(15, 23, 42, 0.07);
}

.balance-title {
  margin-bottom: 10px;

  color: #6b7280;

  font-size: 13px;

  font-weight: 700;

  letter-spacing: 1.2px;
}

.balance-amount {
  color: #111827;

  font-size: 46px;

  font-weight: 800;
}

.negative-balance {
  color: #dc2626;
}


/* =====================================================
   ACTIONS
===================================================== */

.actions {
  display: grid;

  grid-template-columns:
    1fr 1fr;

  gap: 14px;

  margin-bottom: 28px;
}

.income-btn,
.expense-btn {
  min-height: 62px;

  border-radius: 16px;

  font-size: 17px;

  font-weight: 800;
}

.income-btn {
  border: 1px solid #86efac;

  background: #dcfce7;

  color: #166534;
}

.expense-btn {
  border: 1px solid #fca5a5;

  background: #fee2e2;

  color: #b91c1c;
}


/* =====================================================
   TRANSACTIONS
===================================================== */

.transactions {
  padding: 24px;

  background: #ffffff;

  border: 1px solid #e8ebef;

  border-radius: 24px;

  box-shadow:
    0 12px 35px
    rgba(15, 23, 42, 0.06);
}

.transactions h2 {
  margin-bottom: 20px;

  color: #111827;

  font-size: 20px;
}

.transaction-item {
  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 16px;

  min-height: 76px;

  margin-bottom: 12px;

  padding: 15px 16px;

  border-radius: 16px;

  border: 1px solid transparent;
}

.transaction-item:last-child {
  margin-bottom: 0;
}

.transaction-income {
  background: #f0fdf4;

  border-color: #bbf7d0;

  border-left:
    5px solid #22c55e;
}

.transaction-expense {
  background: #fef2f2;

  border-color: #fecaca;

  border-left:
    5px solid #ef4444;
}

.transaction-opening {
  background: #eff6ff;

  border-color: #bfdbfe;

  border-left:
    5px solid #3b82f6;
}

.transaction-info {
  min-width: 0;
}

.transaction-info strong {
  display: block;

  margin-bottom: 5px;

  overflow-wrap: anywhere;

  color: #1f2937;

  font-size: 15px;
}

.transaction-info span {
  display: block;

  color: #6b7280;

  font-size: 13px;
}

.transaction-amount {
  flex-shrink: 0;

  white-space: nowrap;

  font-size: 16px;

  font-weight: 800;
}

.income-amount {
  color: #15803d;
}

.expense-amount {
  color: #dc2626;
}

.opening-amount {
  color: #2563eb;
}


/* =====================================================
   LOGIN
===================================================== */

.login-card {
  width: 100%;
  max-width: 480px;

  margin: 0 auto;

  padding: 32px;

  background: #ffffff;

  border: 1px solid #e8ebef;

  border-radius: 24px;

  box-shadow:
    0 12px 35px
    rgba(15, 23, 42, 0.07);
}

.login-card h2 {
  margin-bottom: 26px;

  text-align: center;
}

.login-card label,
.transaction-modal label {
  display: block;

  margin-bottom: 7px;

  color: #374151;

  font-size: 14px;

  font-weight: 700;
}

.login-card input {
  width: 100%;

  height: 52px;

  margin-bottom: 18px;

  padding: 0 14px;

  border: 1px solid #d1d5db;

  border-radius: 12px;

  font-size: 16px;
}

.login-btn {
  width: 100%;

  min-height: 54px;

  border: none;

  border-radius: 13px;

  background: #111827;

  color: #ffffff;

  font-size: 16px;

  font-weight: 800;
}

.error-message {
  margin-top: 15px;

  min-height: 20px;

  color: #dc2626;

  text-align: center;

  font-size: 14px;
}


/* =====================================================
   LOGOUT
===================================================== */

.logout-btn {
  width: 100%;

  min-height: 50px;

  margin-top: 20px;

  border: 1px solid #d1d5db;

  border-radius: 14px;

  background: #ffffff;

  color: #6b7280;

  font-size: 15px;

  font-weight: 700;
}


/* =====================================================
   TRANSACTION MODAL
===================================================== */

.modal-overlay {
  position: fixed;

  inset: 0;

  z-index: 5000;

  display: flex;

  align-items: center;

  justify-content: center;

  padding: 20px;

  background:
    rgba(15, 23, 42, 0.55);

  backdrop-filter:
    blur(4px);
}

.transaction-modal {
  width: 100%;
  max-width: 480px;

  max-height: 90vh;

  overflow-y: auto;

  padding: 28px;

  background: #ffffff;

  border-radius: 24px;

  box-shadow:
    0 25px 60px
    rgba(15, 23, 42, 0.25);
}

.modal-header {
  display: flex;

  align-items: flex-start;

  justify-content: space-between;

  gap: 20px;

  margin-bottom: 26px;
}

.modal-header h2 {
  margin-top: 6px;

  color: #111827;

  font-size: 24px;
}

.modal-type-label {
  display: inline-block;

  padding: 6px 10px;

  border-radius: 20px;

  font-size: 11px;

  font-weight: 800;
}

.income-label {
  background: #dcfce7;

  color: #15803d;
}

.expense-label {
  background: #fee2e2;

  color: #dc2626;
}

.close-modal-btn {
  width: 42px;

  height: 42px;

  flex-shrink: 0;

  border: none;

  border-radius: 50%;

  background: #f3f4f6;

  color: #4b5563;

  font-size: 26px;
}

.transaction-modal input,
.transaction-modal select {
  width: 100%;

  min-height: 52px;

  margin-bottom: 20px;

  padding: 0 14px;

  border: 1px solid #d1d5db;

  border-radius: 12px;

  background: #ffffff;

  font-size: 16px;
}

.optional-text {
  color: #9ca3af;

  font-size: 12px;

  font-weight: 400;
}

.amount-input-wrapper {
  position: relative;
}

.amount-input-wrapper input {
  padding-right: 60px;
}

.amount-input-wrapper span {
  position: absolute;

  top: 17px;

  right: 15px;

  color: #6b7280;

  font-size: 14px;

  font-weight: 700;
}

.save-transaction-btn {
  width: 100%;

  min-height: 56px;

  margin-top: 5px;

  border: none;

  border-radius: 14px;

  color: #ffffff;

  font-size: 16px;

  font-weight: 800;
}

.save-income {
  background: #16a34a;
}

.save-expense {
  background: #dc2626;
}


/* =====================================================
   CONTEXT MENU
===================================================== */

.transaction-item:not(
  .transaction-opening
) {
  cursor: context-menu;

  user-select: none;

  -webkit-user-select: none;

  -webkit-touch-callout: none;
}

.transaction-context-menu {
  display: none;

  position: fixed;

  z-index: 6000;

  width: 205px;

  padding: 7px;

  background: #ffffff;

  border: 1px solid #e5e7eb;

  border-radius: 14px;

  box-shadow:
    0 18px 45px
    rgba(15, 23, 42, 0.18);
}

.transaction-context-menu button {
  display: flex;

  align-items: center;

  gap: 10px;

  width: 100%;

  min-height: 45px;

  padding: 10px 12px;

  border: none;

  border-radius: 10px;

  background: transparent;

  text-align: left;

  font-size: 14px;

  font-weight: 700;
}

.context-menu-icon {
  width: 22px;

  text-align: center;
}

.context-menu-edit {
  color: #2563eb;
}

.context-menu-duplicate {
  color: #374151;
}

.context-menu-delete {
  color: #dc2626;
}

.context-menu-edit:hover {
  background: #eff6ff;
}

.context-menu-duplicate:hover {
  background: #f3f4f6;
}

.context-menu-delete:hover {
  background: #fef2f2;
}


/* =====================================================
   STATES
===================================================== */

.loading,
.empty-state {
  padding: 26px 10px;

  color: #6b7280;

  text-align: center;

  font-size: 14px;
}


/* =====================================================
   DASHBOARD
===================================================== */

.dashboard-container {
  width: 100%;

  max-width: 1100px;

  margin: 0 auto;

  padding-bottom: 50px;
}

.dashboard-header {
  display: flex;

  align-items: center;

  justify-content: space-between;

  gap: 20px;

  margin-bottom: 24px;
}

.dashboard-header h1 {
  margin-bottom: 5px;

  color: #111827;

  font-size: 30px;
}

.dashboard-header p {
  color: #6b7280;

  font-size: 14px;
}

.dashboard-logout-btn {
  padding: 11px 18px;

  border: 1px solid #d1d5db;

  border-radius: 12px;

  background: #ffffff;

  color: #6b7280;

  font-weight: 700;
}


/* =====================================================
   DASHBOARD FILTERS
===================================================== */

.dashboard-filters {
  display: flex;

  flex-wrap: wrap;

  gap: 14px;

  margin-bottom: 20px;
}

.filter-group {
  min-width: 190px;
}

.filter-group label {
  display: block;

  margin-bottom: 6px;

  color: #64748b;

  font-size: 12px;

  font-weight: 700;
}

.filter-group select {
  width: 100%;

  min-height: 46px;

  padding: 0 12px;

  border: 1px solid #d1d5db;

  border-radius: 11px;

  background: #ffffff;

  font-size: 15px;
}


/* =====================================================
   KPI
===================================================== */

.dashboard-kpis {
  display: grid;

  grid-template-columns:
    repeat(4, 1fr);

  gap: 14px;

  margin-bottom: 22px;
}

.kpi-card {
  min-width: 0;

  padding: 20px;

  background: #ffffff;

  border: 1px solid #e5e7eb;

  border-radius: 18px;

  box-shadow:
    0 8px 25px
    rgba(15, 23, 42, 0.05);
}

.kpi-label {
  display: block;

  margin-bottom: 9px;

  color: #6b7280;

  font-size: 12px;

  font-weight: 700;
}

.kpi-card strong {
  display: block;

  color: #111827;

  font-size: 22px;
}

.balance-kpi {
  border-top:
    4px solid #3b82f6;
}

.income-kpi {
  border-top:
    4px solid #22c55e;
}

.income-kpi strong {
  color: #15803d;
}

.expense-kpi {
  border-top:
    4px solid #ef4444;
}

.expense-kpi strong {
  color: #dc2626;
}

.net-kpi {
  border-top:
    4px solid #64748b;
}

.dashboard-positive {
  color: #15803d !important;
}

.dashboard-negative {
  color: #dc2626 !important;
}


/* =====================================================
   DASHBOARD PANELS
===================================================== */

.dashboard-panel {
  margin-bottom: 20px;

  padding: 24px;

  background: #ffffff;

  border: 1px solid #e5e7eb;

  border-radius: 20px;

  box-shadow:
    0 8px 25px
    rgba(15, 23, 42, 0.05);
}

.panel-header {
  margin-bottom: 20px;
}

.panel-header h2 {
  margin-bottom: 4px;

  color: #111827;

  font-size: 19px;
}

.panel-header p {
  color: #6b7280;

  font-size: 13px;
}

.chart-container {
  position: relative;

  width: 100%;

  height: 360px;
}

.category-chart-container {
  min-height: 340px;
}


/* =====================================================
   CATEGORY TABLE
===================================================== */

.category-table-wrapper {
  width: 100%;

  overflow-x: auto;
}

.category-table {
  width: 100%;

  min-width: 620px;

  border-collapse: collapse;
}

.category-table th {
  padding: 12px;

  border-bottom:
    1px solid #e5e7eb;

  color: #6b7280;

  text-align: right;

  font-size: 12px;
}

.category-table th:first-child {
  text-align: left;
}

.category-table td {
  padding: 14px 12px;

  border-bottom:
    1px solid #f1f5f9;

  color: #374151;

  text-align: right;

  font-size: 14px;
}

.category-table td:first-child {
  color: #111827;

  text-align: left;

  font-weight: 700;
}

.table-income {
  color: #15803d !important;

  font-weight: 700;
}

.table-expense {
  color: #dc2626 !important;

  font-weight: 700;
}


/* =====================================================
   TABLET
===================================================== */

@media (
  max-width: 850px
) {

  .dashboard-kpis {
    grid-template-columns:
      repeat(2, 1fr);
  }

}


/* =====================================================
   MOBILE
===================================================== */

@media (
  max-width: 600px
) {

  body {
    padding:
      22px 12px 45px;
  }


  .page-topbar {
    flex-direction: column;

    align-items: stretch;
  }


  .top-nav {
    width: 100%;
  }


  .nav-link {
    flex: 1;

    min-width: 0;
  }


  .export-wrap {
    width: 100%;
  }


  .export-btn {
    width: 100%;
  }


  .export-menu {
    left: 0;

    right: 0;

    width: 100%;
  }


  .balance-card {
    padding:
      30px 15px;
  }


  .balance-amount {
    font-size: 37px;
  }


  .actions {
    gap: 10px;
  }


  .transactions {
    padding: 17px;
  }


  .transaction-item {
    padding: 14px;

    gap: 10px;
  }


  .transaction-amount {
    font-size: 14px;
  }


  .login-card {
    padding:
      24px 18px;
  }


  .transaction-modal {
    padding:
      22px 18px;
  }


  .dashboard-header {
    align-items: flex-start;
  }


  .dashboard-header h1 {
    font-size: 25px;
  }


  .dashboard-filters {
    display: grid;

    grid-template-columns:
      1fr 1fr;
  }


  .filter-group {
    min-width: 0;
  }


  .dashboard-kpis {
    grid-template-columns:
      1fr 1fr;

    gap: 10px;
  }


  .kpi-card {
    padding: 16px;
  }


  .kpi-card strong {
    font-size: 17px;
  }


  .dashboard-panel {
    padding: 17px;
  }


  .chart-container {
    height: 300px;
  }

}


/* =====================================================
   VERY SMALL MOBILE
===================================================== */

@media (
  max-width: 370px
) {

  .actions {
    grid-template-columns:
      1fr;
  }


  .dashboard-filters {
    grid-template-columns:
      1fr;
  }


  .dashboard-kpis {
    grid-template-columns:
      1fr;
  }


  .transaction-item {
    align-items: flex-start;

    flex-direction: column;
  }


  .transaction-amount {
    align-self: flex-end;
  }

}
/* =====================================================
   LOGIN / REGISTER TABS
===================================================== */

.auth-tabs {
  display: grid;

  grid-template-columns:
    1fr 1fr;

  gap: 5px;

  margin-bottom: 28px;

  padding: 5px;

  background: #eef2f6;

  border-radius: 13px;
}


.auth-tab {
  min-height: 44px;

  border: none;

  border-radius: 9px;

  background: transparent;

  color: #64748b;

  font-size: 14px;

  font-weight: 700;
}


.auth-tab.active {
  background: #ffffff;

  color: #111827;

  box-shadow:
    0 2px 8px
    rgba(15, 23, 42, 0.08);
}


/* =====================================================
   REGISTER BUTTON
===================================================== */

.register-btn {
  width: 100%;

  min-height: 54px;

  margin-top: 5px;

  border: none;

  border-radius: 13px;

  background: #2563eb;

  color: #ffffff;

  font-size: 16px;

  font-weight: 800;
}


.register-btn:hover {
  background: #1d4ed8;
}


/* =====================================================
   REGISTER MESSAGE
===================================================== */

.register-message {
  min-height: 20px;

  margin-top: 15px;

  text-align: center;

  font-size: 14px;

  font-weight: 600;
}


.register-error {
  color: #dc2626;
}


.register-success {
  color: #15803d;
}
