/* Rush Total Budget – Apple HIG style, flat, minimal */

:root {
  --bg: #FFFFFF;
  --primary: #23A5FF;
  --secondary: #FE5700;
  --highlight: #FFD800;
  --positive: #3E9C1C;
  --dark: #0040DF;
  --radius: 12px;
  --radius-lg: 16px;
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  color: var(--dark);
  background: var(--bg);
  background-image: url('bg.png');
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  -webkit-overflow-scrolling: touch;
}

.app-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 72px;
}

.main-content {
  flex: 1;
  position: relative;
}

/* Screens: one visible at a time */
.screen {
  display: none;
  min-height: 200vh;
  padding: 16px 16px 24px;
  scroll-behavior: smooth;
}

.screen.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Section header with sprite logo */
.section-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.section-logo {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.section-header h1 {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 1.5rem;
  color: var(--dark);
  margin: 0;
}

.section-header-with-actions {
  justify-content: space-between;
}

.section-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-info {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--primary);
  background: var(--bg);
  color: var(--primary);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-add {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  background: var(--bg);
  color: var(--primary);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  margin-top: 12px;
}

.section-actions {
  padding: 0 0 16px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 64, 223, 0.25);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
  overflow-y: auto;
}

.modal-overlay.is-open {
  display: flex;
}

.modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  max-width: 420px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(0, 64, 223, 0.12);
}

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--dark);
  margin: 0;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--dark);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 20px;
  font-size: 0.9rem;
  color: var(--dark);
  line-height: 1.5;
}

.modal-body p { margin: 0 0 12px; }
.modal-body ul { margin: 0 0 12px; padding-left: 20px; }
.modal-body li { margin-bottom: 8px; }

/* Edit modal form */
.form-row {
  margin-bottom: 12px;
}

.form-row label {
  display: block;
  font-weight: 500;
  margin-bottom: 4px;
  font-size: 0.9rem;
}

.form-row input,
.form-row textarea,
.form-row select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(0, 64, 223, 0.2);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.form-actions button {
  flex: 1;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
}

.form-actions .btn-save {
  background: var(--primary);
  color: var(--bg);
}

.form-actions .btn-cancel {
  background: transparent;
  color: var(--dark);
  border: 2px solid rgba(0, 64, 223, 0.3);
}

/* Row actions (edit/delete in tables and cards) */
.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.row-actions button {
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  cursor: pointer;
  background: rgba(0, 64, 223, 0.1);
  color: var(--dark);
}

.row-actions button.btn-delete {
  background: rgba(254, 87, 0, 0.15);
  color: var(--secondary);
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.card-actions button {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  cursor: pointer;
}

.card-actions .btn-edit {
  background: rgba(35, 165, 255, 0.15);
  color: var(--primary);
}

.card-actions .btn-delete {
  background: rgba(254, 87, 0, 0.15);
  color: var(--secondary);
}

.chart-balance {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark);
  margin-bottom: 8px;
}

/* ----- Dashboard ----- */
.dashboard-chart-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.donut-chart {
  position: relative;
  width: 200px;
  height: 200px;
}

.donut-chart svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--dark);
}

.table-wrap {
  background: var(--bg);
  border-radius: var(--radius-lg);
  overflow-x: auto;
  margin-bottom: 32px;
}

.categories-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.categories-table th,
.categories-table td {
  padding: 14px 16px;
  text-align: left;
  border-bottom: 1px solid rgba(0, 64, 223, 0.1);
}

.categories-table th {
  font-weight: 600;
  color: var(--dark);
  background: rgba(35, 165, 255, 0.08);
}

.categories-table td {
  color: var(--dark);
}

.status-done { color: var(--positive); font-weight: 500; }
.status-progress { color: var(--highlight); font-weight: 500; }
.status-pending { color: var(--dark); opacity: 0.8; }

/* Spacer to ensure 200% height */
.dashboard .table-wrap::after,
.timeline .timeline-vertical::after,
.inventory .inventory-grid::after,
.cashflow .transactions-list::after,
.gallery .gallery-feed::after,
.team .team-list::after {
  content: '';
  display: block;
  height: 80vh;
}

/* ----- Timeline ----- */
.calendar-wrap {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 24px;
}

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

.cal-month {
  font-weight: 600;
  color: var(--dark);
}

.cal-nav {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--bg);
  font-size: 1rem;
  cursor: pointer;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  font-size: 0.85rem;
}

.cal-weekday {
  text-align: center;
  font-weight: 600;
  color: var(--dark);
  padding: 6px 0;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--dark);
}

.cal-day.empty {
  visibility: hidden;
}

.timeline-vertical {
  position: relative;
  padding-left: 24px;
}

.timeline-line {
  position: absolute;
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--primary);
  border-radius: 1px;
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-dot {
  position: absolute;
  left: -24px;
  top: 8px;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
}

.timeline-card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-left: 8px;
}

.timeline-card time {
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 500;
}

.timeline-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark);
  margin: 4px 0 6px;
}

.timeline-card p {
  font-size: 0.9rem;
  color: var(--dark);
  opacity: 0.9;
  margin: 0;
}

/* ----- Inventory ----- */
.inventory-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.inventory-card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.inventory-card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--dark);
  margin: 0 0 4px;
}

.inventory-card .price {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 500;
  margin: 0 0 12px;
}

.photo-upload {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px;
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  background: rgba(35, 165, 255, 0.06);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--primary);
}

.photo-upload input[type="file"] {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.photo-upload:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ----- Cashflow ----- */
.line-chart-wrap {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 20px;
}

.line-chart {
  width: 100%;
  height: 120px;
  display: block;
}

.chart-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--dark);
  opacity: 0.8;
  margin-top: 8px;
}

.transactions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tx-item {
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  font-size: 0.9rem;
}

.tx-item .row-actions {
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.tx-date {
  color: var(--dark);
  opacity: 0.8;
}

.tx-desc {
  color: var(--dark);
}

.tx-amount {
  font-weight: 600;
}

.tx-item.income .tx-amount { color: var(--positive); }
.tx-item.expense .tx-amount { color: var(--secondary); }

/* ----- Gallery ----- */
.gallery-upload-wrap {
  margin-bottom: 20px;
}

.gallery-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 56px;
  background: var(--primary);
  color: var(--bg);
  border-radius: var(--radius-lg);
  font-weight: 600;
  cursor: pointer;
}

.gallery-upload-btn input[type="file"] {
  position: absolute;
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  z-index: -1;
}

.gallery-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.gallery-post {
  background: var(--bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.gallery-post time {
  display: block;
  padding: 12px 16px 0;
  font-size: 0.8rem;
  color: var(--primary);
  font-weight: 500;
}

.post-image {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  margin-top: 8px;
  display: block;
}

.post-image.placeholder {
  background: rgba(0, 64, 223, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dark);
  opacity: 0.6;
  font-size: 0.9rem;
}

.inventory-card .photo-preview {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 8px;
  margin-bottom: 8px;
  display: block;
}

.gallery-post p {
  padding: 12px 16px 16px;
  margin: 0;
  font-size: 0.95rem;
  color: var(--dark);
}

/* ----- Team ----- */
.team-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.team-card {
  background: var(--bg);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.team-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--dark);
  margin: 0 0 4px;
}

.team-card .role {
  font-size: 0.85rem;
  color: var(--primary);
  margin: 0 0 6px;
}

.team-card .phone {
  font-size: 0.9rem;
  color: var(--dark);
  margin: 0 0 10px;
}

.team-card .notes {
  width: 100%;
  min-height: 60px;
  padding: 10px 12px;
  border: 1px solid rgba(0, 64, 223, 0.2);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--dark);
  resize: vertical;
  margin-bottom: 10px;
}

.team-card .notes::placeholder {
  color: var(--dark);
  opacity: 0.5;
}

/* Rating with digit sprites 0-9.png */
.rating-digits {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.rating-digits img {
  height: 24px;
  width: auto;
  object-fit: contain;
}

.rating-sep {
  font-size: 0.9rem;
  color: var(--dark);
  opacity: 0.7;
  margin: 0 2px;
}

/* Tab bar – fixed bottom */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--bg);
  border-top: 1px solid rgba(0, 64, 223, 0.12);
  padding: 8px 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 100;
}

.tab-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  max-width: 72px;
  padding: 6px 4px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: rgba(0, 64, 223, 0.35);
  font-family: inherit;
  font-size: 0.7rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.tab-btn .tab-icon {
  display: flex;
  align-items: center;
  justify-content: center;
}

.tab-btn .tab-icon-svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
}

.tab-btn.active {
  background: rgba(35, 165, 255, 0.12);
  color: var(--primary);
  font-weight: 600;
}

/* Buttons – delete/secondary */
button.danger,
.btn-danger {
  background: var(--secondary);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
}

/* Smooth scroll for all scroll containers */
.main-content,
.screen {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 480px) {
  .inventory-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
