/* ===== VARIABLES ===== */
:root {
  --primary: #7c7ff5;
  --primary-light: #1e2040;
  --primary-dark: #6366d6;
  --danger: #f87171;
  --danger-light: #2d1515;
  --success: #34d399;
  --success-light: #0d2d24;
  --bg: #0f1117;
  --card: #1a1d2e;
  --border: #2a2d3d;
  --text: #e8e9f0;
  --text-secondary: #cdd1e8;
  --text-muted: #b0b5ce;
  --nav-height: 68px;
  --header-height: 60px;
  --radius: 14px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.5);
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  direction: rtl;
  font-size: 16px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { cursor: pointer; font-family: inherit; border: none; background: none; }
input { font-family: inherit; }
a { text-decoration: none; color: inherit; }

.hidden { display: none !important; }

/* ===== APP LAYOUT ===== */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: relative;
  overflow: hidden;
}

#pages {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* ===== PAGES ===== */
.page {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  opacity: 1;
  transform: translateX(0);
  transition: opacity 0.25s ease, transform 0.25s ease;
  overflow: hidden;
}

.page.hidden {
  display: flex !important; /* keep in DOM for transitions */
  opacity: 0;
  pointer-events: none;
  transform: translateX(20px);
}

.page-header {
  background: var(--card);
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.page-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

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

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 16px);
}

/* ===== BOTTOM NAV ===== */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 100;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 500;
  transition: color 0.2s, transform 0.1s;
}

.nav-btn svg { transition: stroke 0.2s; }

.nav-btn.active {
  color: var(--primary);
}

.nav-btn.active svg { stroke: var(--primary); }

.nav-btn:active { transform: scale(0.92); }

/* ===== PERIOD PILLS ===== */
.period-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--border);
  color: var(--text-secondary);
  transition: all 0.2s;
  white-space: nowrap;
}

.pill.active {
  background: var(--primary);
  color: #fff;
}

.pill:active { transform: scale(0.95); }

/* ===== VIEW MODE BTN ===== */
.view-mode-btn {
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--primary-light);
  color: var(--primary);
  transition: all 0.2s;
}

.view-mode-btn:active { transform: scale(0.95); }
.view-mode-btn.average-mode {
  background: var(--primary);
  color: #fff;
}

/* ===== MONTH INPUT ===== */
.specific-month-wrap { display: flex; align-items: center; }

.month-input {
  padding: 6px 10px;
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  background: var(--card);
  color: var(--text);
  direction: ltr;
  color-scheme: dark;
}

/* ===== CHART ===== */
.chart-wrap {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.chart-wrap canvas {
  max-width: 260px;
  max-height: 260px;
}

.chart-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 1rem;
}

/* ===== CATEGORY LIST ===== */
.category-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cat-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.15s;
}

.cat-row {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 10px;
  cursor: pointer;
  transition: background 0.15s;
}

.cat-row:hover { background: var(--border); }
.cat-row:active { background: var(--primary-light); }

.cat-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-name {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
}

.cat-parent .cat-name { font-size: 1rem; font-weight: 700; }

.cat-amount {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  direction: ltr;
}

.cat-toggle-wrap {
  display: flex;
  align-items: center;
  margin-right: 4px;
}

.cat-expand-icon {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform 0.25s;
  margin-right: 6px;
  width: 12px;
  text-align: center;
}

.cat-expand-icon.expanded { transform: rotate(90deg); }

.cat-children {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.3s ease;
}

.cat-children.expanded { max-height: 400px; }

.cat-child-row {
  display: flex;
  align-items: center;
  padding: 11px 16px 11px 28px;
  gap: 10px;
  border-top: 1px solid var(--border);
  transition: background 0.15s;
}

.cat-child-row:hover { background: var(--border); }

/* ===== TOGGLE SWITCH ===== */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.toggle-input { display: none; }

.toggle-track {
  width: 38px;
  height: 22px;
  border-radius: 11px;
  background: #3a3d50;
  position: relative;
  transition: background 0.25s;
  flex-shrink: 0;
}

.toggle-input:checked + .toggle-track { background: var(--primary); }

.toggle-thumb {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e0e2f0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  transition: transform 0.25s;
}

.toggle-input:checked + .toggle-track .toggle-thumb {
  transform: translateX(-16px);
}

.toggle-text {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

/* Small toggle for category rows */
.cat-toggle .toggle-track {
  width: 32px;
  height: 18px;
}

.cat-toggle .toggle-thumb {
  width: 14px;
  height: 14px;
}

.cat-toggle .toggle-input:checked + .toggle-track .toggle-thumb {
  transform: translateX(-14px);
}

/* ===== DATA TABLE ===== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.data-table thead th {
  padding: 10px 12px;
  text-align: right;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
}

.data-table tbody tr:hover { background: var(--primary-light); }
.data-table tbody tr:active { background: #252840; }

.data-table tbody tr.row-hidden {
  opacity: 0.35;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 4px,
    rgba(255,255,255,0.02) 4px,
    rgba(255,255,255,0.02) 8px
  );
}

.data-table tbody td {
  padding: 10px 12px;
  vertical-align: middle;
}

.data-table .col-date { white-space: nowrap; color: var(--text-secondary); font-size: 0.8rem; }
.data-table .col-desc { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.data-table .col-cat { white-space: nowrap; }
.data-table .col-amount { font-weight: 700; text-align: left; direction: ltr; white-space: nowrap; }

.cat-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
  background: var(--primary-light);
  color: var(--primary);
}

.cat-badge.uncat {
  background: rgba(251,191,36,0.12);
  color: #fbbf24;
  border-color: rgba(251,191,36,0.25);
}

.table-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.table-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* ===== BUTTONS ===== */
.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.15s;
  white-space: nowrap;
}

.primary-btn:hover { background: var(--primary-dark); }
.primary-btn:active { transform: scale(0.96); }

.secondary-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  transition: all 0.15s;
}

.secondary-btn:hover { background: #343748; }
.secondary-btn:active { transform: scale(0.96); }

.danger-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  background: var(--danger-light);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  border: 1.5px solid rgba(248,113,113,0.3);
  transition: all 0.15s;
}

.danger-btn:hover { background: var(--danger); color: white; }
.danger-btn:active { transform: scale(0.96); }

.danger-btn-sm {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  background: var(--danger-light);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  border: 1.5px solid rgba(248,113,113,0.3);
  transition: all 0.15s;
  white-space: nowrap;
}

.danger-btn-sm:hover { background: var(--danger); color: white; }
.danger-btn-sm:active { transform: scale(0.95); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--border);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
  transition: all 0.15s;
}

.icon-btn:hover { background: #343748; }
.icon-btn:active { transform: scale(0.92); }
.icon-btn.active { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* ===== SORTING OVERLAY ===== */
.full-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(5, 5, 15, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.full-overlay.hidden {
  display: none !important;
}

.sorting-content {
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: slideUp 0.3s ease;
}

.sorting-progress {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
}

.sorting-date {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
}

.sorting-desc {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  line-height: 1.4;
}

.sorting-amount {
  font-size: 1.5rem;
  font-weight: 800;
  text-align: center;
  color: var(--primary);
  direction: ltr;
}

.sorting-cat-buttons {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.sort-cat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 6px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--border);
  color: var(--text-secondary);
  border: 2px solid transparent;
  transition: all 0.15s;
  text-align: center;
}

.sort-cat-btn:hover { background: var(--primary-light); color: var(--primary); }
.sort-cat-btn:active { transform: scale(0.94); }

.sort-cat-btn.selected {
  background: var(--primary);
  color: white;
  border-color: var(--primary-dark);
  transform: scale(1.03);
}

.sorting-controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
}

.sorting-nav-row {
  display: flex;
  gap: 10px;
}

.sorting-nav-row .primary-btn,
.sorting-nav-row .secondary-btn {
  flex: 1;
  justify-content: center;
}

/* ===== MODAL ===== */
.modal-box {
  background: var(--card);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 24px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0));
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}

.modal-box.fullscreen {
  min-height: 100%;
  max-height: 100%;
  border-radius: 0;
  display: flex;
  flex-direction: column;
}

.modal-box.fullscreen #modal-body {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.modal-box.fullscreen .modal-actions-split {
  margin-top: auto;
  padding-top: 16px;
}

#modal-overlay:has(.modal-box.fullscreen) {
  align-items: stretch;
}

.modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 16px;
  color: var(--text);
}

.modal-field {
  margin-bottom: 14px;
}

.modal-field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.modal-field .field-value {
  font-size: 0.95rem;
  color: var(--text);
}

.modal-cat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.modal-cat-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 4px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--border);
  color: var(--text-secondary);
  border: 2px solid transparent;
  transition: all 0.15s;
  text-align: center;
}

.modal-cat-btn.selected {
  /* color/border/bg applied via inline style using category color */
}

.modal-cat-btn:hover { background: var(--primary-light); color: var(--primary); }

.modal-actions-split {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.modal-actions-right {
  display: flex;
  gap: 8px;
}

.modal-trash-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--danger);
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.modal-trash-btn:hover { background: rgba(231, 76, 60, 0.1); border-color: var(--danger); }

/* ===== RULES LIST ===== */
.rules-empty {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.rule-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}

.rule-item:last-child { border-bottom: none; }
.rule-item:hover { background: var(--primary-light); }
.rule-item:active { background: #252840; }

.rule-text {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rule-arrow {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.rule-category {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--primary);
}

/* ===== RULE EDIT MODAL ===== */
.rule-input {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s;
  direction: rtl;
}

.rule-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--bg);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: #2a2d3d;
  color: var(--text);
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 999;
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
  opacity: 0;
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
  border: 1px solid var(--border);
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ===== ERROR BANNER ===== */
.error-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--danger-light);
  border-bottom: 2px solid var(--danger);
  z-index: 9999;
  padding: 12px 16px;
  max-height: 200px;
  overflow-y: auto;
}

.error-banner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  color: var(--danger);
  margin-bottom: 8px;
}

.error-banner-header button {
  font-size: 1.1rem;
  color: var(--danger);
  padding: 0 4px;
}

#error-text {
  font-size: 0.78rem;
  color: #fca5a5;
  font-family: monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { transform: translateY(60px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes popIn {
  0% { transform: scale(0.85); opacity: 0; }
  70% { transform: scale(1.04); }
  100% { transform: scale(1); opacity: 1; }
}

.pop-in { animation: popIn 0.25s ease forwards; }

/* ===== PAGE TITLE ROW ===== */
.page-title-row {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.last-upload-info {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* ===== DATA FILTER BAR ===== */
.data-filter-bar {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.data-filter-bar::-webkit-scrollbar { display: none; }

.filter-pill {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--border);
  color: var(--text-secondary);
  border: 1.5px solid transparent;
  white-space: nowrap;
  transition: all 0.15s;
  flex-shrink: 0;
}
.filter-pill.active {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}
.filter-pill:active { transform: scale(0.95); }

/* ===== FONT SIZE FAB ===== */
.font-fab {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 150;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.font-fab-main {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--card);
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  transition: all 0.2s;
  line-height: 1;
}
.font-fab-main:hover { background: var(--border); color: var(--text); }
.font-fab-main:active { transform: scale(0.92); }
.font-fab.open .font-fab-main {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

.font-fab-subs {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  pointer-events: none;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}
.font-fab.open .font-fab-subs {
  max-height: 100px;
  opacity: 1;
  pointer-events: auto;
}

.font-fab-sub {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--card);
  color: var(--text);
  font-size: 0.72rem;
  font-weight: 700;
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
  transition: all 0.15s;
  line-height: 1;
}
.font-fab-sub:hover { background: var(--border); }
.font-fab-sub:active { transform: scale(0.92); }

/* ===== MOBILE TABLE ===== */
@media (max-width: 480px) {
  .data-table thead { display: none; }
  .data-table,
  .data-table tbody { display: block; width: 100%; }
  .data-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
    column-gap: 8px;
    row-gap: 3px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
  }
  .data-table tbody tr.row-hidden { opacity: 0.35; }
  .data-table tbody td { padding: 0; border: none; vertical-align: top; }
  .data-table .col-desc {
    grid-column: 1; grid-row: 1;
    font-weight: 600;
    font-size: 0.9rem;
    max-width: none;
  }
  .data-table .col-amount {
    grid-column: 2; grid-row: 1;
    font-size: 0.9rem;
    font-weight: 700;
  }
  .data-table .col-date {
    grid-column: 1; grid-row: 2;
    font-size: 0.72rem;
  }
  .data-table .col-cat {
    grid-column: 2; grid-row: 2;
    text-align: left;
  }
}

/* ===== DESKTOP ===== */
@media (min-width: 600px) {
  #app { max-width: 600px; margin: 0 auto; }
  #bottom-nav { max-width: 600px; left: 50%; transform: translateX(-50%); }
  #sorting-overlay, #modal-overlay { align-items: center; }
  .sorting-content, .modal-box {
    border-radius: var(--radius);
    margin-bottom: 0;
    max-height: 85vh;
  }

  .page-content { padding-bottom: calc(var(--nav-height) + 24px); }
}

@media (min-width: 600px) {
  #app { box-shadow: var(--shadow-md); }
}
