* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: #f8fafc;
  color: #0f172a;
  padding: 40px 20px;
  min-height: 100vh;
}

.container {
  max-width: 980px;
  margin: 0 auto;
}

/* Authentication Card & Modal Styles */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 80vh;
}

.auth-card {
  background: #ffffff;
  padding: 2rem;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  width: 100%;
  max-width: 380px;
}

.auth-tabs {
  display: flex;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid #f1f5f9;
}

.auth-tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  color: #64748b;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
}

.auth-tab:hover {
  color: #1e293b;
}

.auth-tab.active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

.auth-card form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.auth-card form h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0.25rem;
}

.auth-card .form-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}

.auth-card .form-group:last-of-type {
  margin-bottom: 0;
}

.auth-card .form-group input {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.auth-submit-btn {
  width: 100%;
  padding: 10px;
  background-color: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.auth-submit-btn:hover {
  background-color: #1d4ed8;
}

.auth-error-msg {
  color: #ef4444;
  font-size: 0.85rem;
  margin-top: 1rem;
  text-align: center;
  font-weight: 600;
  min-height: 1.2em;
}

/* Header & Control Bar */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1e293b;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-group label {
  font-weight: 600;
  font-size: 0.9rem;
  color: #475569;
}

.control-group input[type="month"] {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  font-size: 0.95rem;
}

.logout-btn {
  padding: 8px 14px;
  background-color: #ffffff;
  color: #475569;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.logout-btn:hover {
  background-color: #f1f5f9;
  color: #ef4444;
  border-color: #fca5a5;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #ffffff;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.stat-card p {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 700;
  text-transform: uppercase;
}

.stat-card h2 {
  font-size: 1.5rem;
  margin-top: 6px;
}

.stat-card.income h2 {
  color: #10b981;
}

.stat-card.expense h2 {
  color: #ef4444;
}

/* Card Containers */
.card {
  background: #ffffff;
  padding: 24px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  margin-bottom: 24px;
}

.card-title {
  font-size: 1.1rem;
  margin-bottom: 16px;
  font-weight: 700;
  color: #0f172a;
}

/* Form Inputs */
.form-inputs {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 2fr auto;
  gap: 10px;
  margin-bottom: 20px;
}

input[type="text"],
input[type="number"],
input[type="password"],
select {
  padding: 10px 12px;
  font-size: 0.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  outline: none;
  background: #ffffff;
}

input:focus,
select:focus {
  border-color: #2563eb;
}

.btn-group {
  display: flex;
  gap: 8px;
}

button.add-btn {
  background: #2563eb;
  color: #ffffff;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s ease;
}

button.add-btn:hover {
  background: #1d4ed8;
}

button.clear-btn {
  background: #e2e8f0;
  color: #475569;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.2s ease, color 0.2s ease;
}

button.clear-btn:hover {
  background: #cbd5e1;
  color: #0f172a;
}

/* Low-Profile Dropdown Controls */
.sub-control-group {
  position: relative;
  display: flex;
  flex-direction: column;
}

.sub-select-wrapper {
  display: flex;
  align-items: center;
  position: relative;
  width: 100%;
}

.sub-select-wrapper select {
  width: 100%;
  padding-right: 80px;
}

.sub-inline-actions {
  position: absolute;
  right: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  background: #ffffff;
  padding-left: 4px;
}

.icon-sub-btn {
  background: transparent;
  border: none;
  color: #64748b;
  font-size: 0.9rem;
  font-weight: bold;
  padding: 2px 5px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-sub-btn:hover {
  background: #f1f5f9;
  color: #2563eb;
}

.icon-sub-btn.del-sub-btn:hover {
  color: #ef4444;
}

.sub-action-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  gap: 6px;
  background: #ffffff;
  padding: 6px;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.sub-action-panel input {
  flex: 1;
  padding: 6px 8px;
  font-size: 0.85rem;
}

.sub-action-panel button {
  border: none;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

/* Calendar Grid Component */
.calendar-picker-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #475569;
  margin-bottom: 8px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.cal-header {
  font-size: 0.75rem;
  font-weight: 700;
  color: #64748b;
  text-align: center;
  padding-bottom: 4px;
}

.cal-day {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  min-height: 48px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cal-day:hover:not(.empty) {
  border-color: #2563eb;
  background: #eff6ff;
}

.cal-day.selected {
  background: #2563eb;
  border-color: #2563eb;
}

.cal-day.selected .day-num {
  color: #ffffff;
  font-weight: 700;
}

.cal-day.empty {
  background: transparent;
  border: none;
  cursor: default;
}

.day-num {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}

.dots {
  display: flex;
  gap: 3px;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.dot-income {
  background-color: #10b981;
}

.dot-expense {
  background-color: #ef4444;
}

.cal-day.selected .dot-income {
  background-color: #6ee7b7;
}

.cal-day.selected .dot-expense {
  background-color: #fca5a5;
}

/* Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 24px;
}

/* Chart Container Wrapper */
.chart-wrapper {
  position: relative;
  height: 270px;
  margin-bottom: 16px;
}

.color-legend-header {
  font-size: 0.8rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.color-legend-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  padding: 4px 8px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
}

.color-picker {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  background: none;
}

.color-picker::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker::-webkit-color-swatch {
  border: 1px solid #cbd5e1;
  border-radius: 50%;
}

.color-legend-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
}

.no-legend-text {
  font-size: 0.85rem;
  color: #94a3b8;
  font-style: italic;
}

/* Schedule Timeline List & Tags */
ul.timeline-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

li.schedule-item {
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  transition: all 0.2s ease;
}

.item-view {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.date-badge {
  background: #e2e8f0;
  color: #334155;
  font-weight: 700;
  font-size: 0.8rem;
  padding: 6px 10px;
  border-radius: 6px;
  text-align: center;
  min-width: 55px;
}

.schedule-info {
  flex: 1;
  margin: 0 16px;
}

.schedule-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: #0f172a;
}

.tag-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
}

.profile-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.subcategory-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.tag-expense {
  background: #fee2e2;
  color: #dc2626;
}

.tag-income {
  background: #d1fae5;
  color: #059669;
}

.schedule-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.amount {
  font-weight: 700;
  font-size: 0.95rem;
}

.edit-btn {
  background: none;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease;
}

.edit-btn:hover {
  color: #2563eb;
  background: #eff6ff;
}

.delete-btn {
  background: none;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  font-size: 1.2rem;
}

.delete-btn:hover {
  color: #ef4444;
}

.edit-panel {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #cbd5e1;
  width: 100%;
}

.edit-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 0.8fr 1fr 1fr 1.2fr;
  gap: 8px;
  margin-bottom: 10px;
}

.edit-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.save-btn {
  background: #10b981;
  color: #ffffff;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

.save-btn:hover {
  background: #059669;
}

.cancel-btn {
  background: #e2e8f0;
  color: #475569;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

.cancel-btn:hover {
  background: #cbd5e1;
}

@media (max-width: 820px) {

  .dashboard-grid,
  .form-inputs {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .edit-grid {
    grid-template-columns: 1fr;
  }
}

/* Danger Zone Card */
.danger-zone-card {
  border: 1px solid #fca5a5;
  background-color: #fff5f5;
}

.danger-title {
  color: #dc2626;
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.danger-desc {
  font-size: 0.85rem;
  color: #7f1d1d;
  margin-bottom: 16px;
}

.btn-danger {
  background-color: #ef4444;
  color: #ffffff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.btn-danger:hover {
  background-color: #dc2626;
}

/* Modal Overlay & Container */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.modal-overlay.hidden {
  display: none;
}

.modal-card {
  background: #ffffff;
  padding: 24px;
  border-radius: 12px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-card h2 {
  font-size: 1.25rem;
  color: #0f172a;
  margin-bottom: 8px;
}

.modal-card p {
  font-size: 0.9rem;
  color: #475569;
  margin-bottom: 16px;
  line-height: 1.4;
}

.modal-card .form-group {
  margin-bottom: 8px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

/* Account Profile Button in Header */
.btn-account {
  padding: 8px 14px;
  background-color: #2563eb;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  transition: background-color 0.2s ease;
}

.btn-account:hover {
  background-color: #1d4ed8;
}

/* Account Modal Overlay & Card Layout */
.account-modal-card {
  max-width: 480px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.close-btn {
  font-size: 1.5rem;
  font-weight: 700;
  color: #64748b;
  cursor: pointer;
  line-height: 1;
  transition: color 0.15s ease;
}

.close-btn:hover {
  color: #0f172a;
}

.account-stats-box {
  margin-bottom: 20px;
  padding: 12px 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  line-height: 1.6;
}

.account-stats-box p {
  color: #334155;
}

.form-group-modal {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.form-group-modal label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #475569;
}

.form-group-modal input {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.9rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
}

.account-divider {
  border: none;
  border-top: 1px solid #e2e8f0;
  margin: 20px 0;
}

.account-actions-section {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.account-actions-section button {
  flex: 1;
}

/* Ensure account deletion modal layers on top of profile modal */
#deleteProfileModal {
  z-index: 1100;
}