.app-page {
  padding-bottom: 80px;
}

.app-main {
  padding: 0 8vw 80px;
}

.app-page .nav {
  padding: 24px 8vw 12px;
}

.app-nav-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.app-user {
  font-weight: 600;
  color: var(--muted);
}

.app-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
  align-items: center;
  padding: 48px 0 24px;
}

.app-hero h1 {
  margin: 0 0 10px;
  font-size: clamp(2rem, 2.6vw + 1.4rem, 2.8rem);
}

.app-sub {
  color: var(--muted);
  max-width: 480px;
}

.app-status {
  display: grid;
  gap: 16px;
  background: var(--card);
  padding: 24px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: var(--shadow);
}

.app-grid .app-status {
  grid-column: 1 / -1;
}

.app-tabs {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.app-tab {
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: #fff;
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease,
    color 0.2s ease;
}

.app-tab.is-active {
  border-color: rgba(30, 99, 214, 0.4);
  color: var(--ink);
  box-shadow: 0 16px 24px -20px rgba(30, 99, 214, 0.4);
}

.app-tab:focus-visible {
  outline: 2px solid rgba(30, 99, 214, 0.5);
  outline-offset: 2px;
}

.app-tab-panels {
  margin-top: 16px;
}

.status-label {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.status-value {
  font-size: 1.1rem;
  font-weight: 600;
}

.app-grid {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 32px;
}

.app-panel[data-panel="dashboard"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.app-panel[data-panel="setup"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.setup-shell {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.setup-nav {
  background: var(--card);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 10px;
}

.setup-tab {
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--muted);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.2s ease, color 0.2s ease,
    box-shadow 0.2s ease, transform 0.2s ease;
}

.setup-tab:hover {
  border-color: rgba(15, 23, 42, 0.3);
  color: var(--ink);
}

.setup-tab.is-active {
  border-color: rgba(30, 99, 214, 0.4);
  color: var(--ink);
  box-shadow: 0 16px 24px -20px rgba(30, 99, 214, 0.4);
  transform: translateY(-1px);
}

.setup-panel {
  display: none;
  gap: 24px;
  grid-template-columns: 1fr;
}

.setup-panel.is-active {
  display: grid;
}

/* Settings navigation sidebar */
.setup-with-nav {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 24px;
}

.settings-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 24px;
  align-self: start;
}

.settings-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: transparent;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.settings-nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.settings-nav-item:hover {
  background: rgba(15, 23, 42, 0.04);
  color: var(--ink);
}

.settings-nav-item.is-active {
  background: rgba(30, 99, 214, 0.1);
  color: var(--brand);
}

.settings-section {
  display: none;
}

.settings-section.is-active {
  display: contents;
}

@media (max-width: 900px) {
  .setup-with-nav {
    grid-template-columns: 1fr;
  }

  .settings-nav {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    position: static;
  }

  .settings-nav-item {
    flex: 1 1 auto;
    justify-content: center;
    padding: 8px 12px;
  }

  .settings-nav-item svg {
    display: none;
  }
}

.app-panel[data-panel="reports"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.app-card {
  background: var(--card);
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow);
}

.dashboard-chart-card {
  grid-column: 1 / -1;
}

.dashboard-wide {
  grid-column: 1 / -1;
}

.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.dashboard-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.dashboard-toolbar {
  grid-column: 1 / -1;
  justify-content: flex-end;
}

.dashboard-actions .app-note {
  margin-top: 0;
}

.year-select-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.9);
  font-size: 0.75rem;
  color: var(--muted);
}

.year-label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  font-size: 0.65rem;
}

.year-select {
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink);
  padding: 2px 0;
}

.year-select:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.35);
  outline-offset: 2px;
}

.dashboard-metrics {
  margin-top: 16px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.metric {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(15, 23, 42, 0.08);
  display: grid;
  gap: 6px;
}

.metric-label {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.metric-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
}

.metric-sub {
  font-size: 0.85rem;
  color: var(--muted);
}

.metric-link {
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.metric-link:hover {
  background: rgba(15, 23, 42, 0.08);
  border-color: rgba(15, 23, 42, 0.16);
}

.metric-link:active {
  transform: scale(0.98);
}

.dashboard-details {
  margin-top: 12px;
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.dashboard-detail {
  min-width: 0;
}

.dashboard-detail h4 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.dashboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
  min-width: 0;
}

.dashboard-list li {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  min-width: 0;
  width: 100%;
  transition: background 0.15s, border-color 0.15s;
}

.dashboard-list-item:hover {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.16);
}

.dashboard-list-item:active {
  transform: scale(0.98);
}

.dashboard-list li span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-list li span:last-child {
  flex-shrink: 0;
}

.dashboard-foot {
  margin-top: 16px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.dashboard-foot-item {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(15, 23, 42, 0.04);
  display: grid;
  gap: 4px;
}

.dashboard-foot-link {
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.dashboard-foot-link:hover {
  background: rgba(15, 23, 42, 0.08);
  border-color: rgba(15, 23, 42, 0.16);
}

.dashboard-foot-link:active {
  transform: scale(0.98);
}

.dashboard-chart {
  margin-top: 16px;
  display: grid;
  gap: 10px;
}

.chart-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 80px;
  gap: 12px;
  align-items: center;
}

.chart-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.chart-bar {
  position: relative;
  height: 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(120deg, var(--brand), var(--brand-dark));
}

.chart-value {
  font-size: 0.85rem;
  text-align: right;
  color: var(--muted);
}

.dashboard-pie {
  margin-top: 16px;
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
  gap: 24px;
  align-items: center;
}

.pie-chart-wrap {
  position: relative;
  width: min(200px, 100%);
  aspect-ratio: 1;
  margin: 0 auto;
}

.pie-chart {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: conic-gradient(
    from 0deg,
    rgba(15, 23, 42, 0.08) 0deg 360deg
  );
}

.pie-chart.is-empty {
  background: conic-gradient(
    from 0deg,
    rgba(15, 23, 42, 0.08) 0deg 360deg
  );
}

.pie-center {
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid rgba(15, 23, 42, 0.08);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 6px;
}

.pie-label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.pie-value {
  font-size: 1rem;
  font-weight: 700;
}

.pie-legend {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.pie-legend li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.9rem;
  min-width: 0;
}

.pie-legend-item {
  padding: 6px 10px;
  margin: -6px -10px;
  border-radius: 8px;
  transition: background 0.15s;
}

.pie-legend-item:hover {
  background: rgba(15, 23, 42, 0.06);
}

.pie-legend-item:active {
  transform: scale(0.98);
}

.pie-legend-label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.pie-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--slice-color, var(--brand));
  flex-shrink: 0;
}

.pie-legend-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pie-legend-value {
  flex-shrink: 0;
  color: var(--muted);
}

.app-panel[data-panel="receipts"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.receipt-send-section {
  grid-column: 1 / -1;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.02);
}

.receipt-send-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.receipt-send-toggle::-webkit-details-marker {
  display: none;
}

.receipt-send-toggle-text {
  font-weight: 600;
  font-size: 0.95rem;
}

.receipt-send-toggle-sub {
  color: #64748b;
  font-size: 0.85rem;
}

.receipt-send-toggle-icon {
  width: 18px;
  height: 18px;
  margin-left: auto;
  color: #64748b;
  transition: transform 0.2s ease;
}

.receipt-send-section[open] .receipt-send-toggle-icon {
  transform: rotate(180deg);
}

.receipt-send-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  padding: 0 18px 18px;
}

.receipt-card {
  grid-column: auto;
}

@media (max-width: 900px) {
  .receipt-send-cards {
    grid-template-columns: 1fr;
  }
}

.receipt-history-card {
  grid-column: 1 / -1;
}

.report-catalog {
  display: flex;
  flex-direction: column;
}

.report-viewer {
  grid-column: span 2;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.report-list {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.report-option {
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.03);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  width: 100%;
  font-family: inherit;
}

.report-option h4 {
  margin: 0 0 4px;
  font-size: 0.98rem;
}

.report-option p {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.report-option.is-active {
  border-color: rgba(30, 99, 214, 0.6);
  box-shadow: 0 10px 24px -18px rgba(30, 99, 214, 0.6);
  background: rgba(30, 99, 214, 0.08);
}

.report-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.report-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.report-meta span {
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.08);
  color: var(--ink);
  font-weight: 600;
}

.report-table {
  display: grid;
  gap: 8px;
}

.report-row {
  display: grid;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, 0.85);
}

.report-row.is-header {
  background: rgba(15, 23, 42, 0.05);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.7rem;
  color: var(--muted);
}

.report-row-link {
  cursor: pointer;
  width: 100%;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.report-row-link:hover {
  background: rgba(15, 23, 42, 0.08);
  border-color: rgba(15, 23, 42, 0.16);
}

.report-row-link:active {
  transform: scale(0.99);
}

.report-cell {
  font-size: 0.9rem;
  color: var(--ink);
}

.report-empty {
  padding: 16px;
  border-radius: 14px;
  border: 1px dashed rgba(15, 23, 42, 0.15);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 8px;
}

.card-title h3 {
  margin: 0;
}

.card-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(30, 99, 214, 0.12);
  color: var(--brand);
}

.card-icon svg {
  width: 18px;
  height: 18px;
}

.receipt-cta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 30;
}

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

.modal-backdrop {
  position: absolute;
  inset: 0;
}

.modal-dialog {
  position: relative;
  width: min(520px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 24px 60px -40px rgba(15, 23, 42, 0.6);
  z-index: 1;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: rgba(15, 23, 42, 0.08);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}

.modal-sub {
  color: var(--muted);
  margin-top: 6px;
  margin-bottom: 16px;
  font-size: 0.9rem;
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: 20px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  box-shadow: 0 24px 60px -40px rgba(15, 23, 42, 0.6);
  z-index: 1;
}

/* Email Viewer Modal */
.email-modal-content {
  width: min(900px, 95vw);
  height: min(80vh, 700px);
  display: flex;
  flex-direction: column;
}

.email-modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
}

.email-modal-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.email-modal-body {
  flex: 1;
  overflow: hidden;
}

.email-modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

/* Image Modal */
.image-modal-content {
  width: min(600px, 95vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.image-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(15, 23, 42, 0.1);
  gap: 12px;
}

.image-modal-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-modal-body {
  flex: 1;
  overflow: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: #f8fafc;
}

.image-modal-body img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Sync Progress Modal */
.sync-modal-content {
  width: min(380px, 90vw);
  padding: 32px 24px;
  text-align: center;
}

.sync-modal-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  color: var(--primary, #2563eb);
}

.sync-modal-icon svg {
  width: 100%;
  height: 100%;
}

.sync-modal-icon .sync-spinner {
  animation: spin 1s linear infinite;
}

.sync-modal-icon.success {
  color: #22c55e;
}

.sync-modal-icon.error {
  color: #ef4444;
}

.sync-modal-content h3 {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 600;
}

.sync-modal-content p {
  margin: 0 0 20px;
  color: var(--muted, #64748b);
  font-size: 0.95rem;
  line-height: 1.5;
}

.sync-modal-progress {
  font-size: 0.85rem;
  color: var(--muted, #64748b);
  margin-bottom: 16px;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Account Selection Modal */
.account-select-content {
  width: min(440px, 90vw);
  padding: 28px 24px;
}

.account-select-content h3 {
  margin: 0 0 8px;
  font-size: 1.2rem;
  font-weight: 600;
}

.account-select-content > p {
  margin: 0 0 20px;
  color: var(--muted, #64748b);
  font-size: 0.9rem;
  line-height: 1.5;
}

.account-select-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
  max-height: 300px;
  overflow-y: auto;
}

.account-select-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 2px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.account-select-option:hover {
  border-color: rgba(30, 99, 214, 0.3);
  background: rgba(30, 99, 214, 0.02);
}

.account-select-option.is-selected {
  border-color: var(--brand, #1e63d6);
  background: rgba(30, 99, 214, 0.06);
}

.account-select-option input[type="radio"],
.account-select-option input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--brand, #1e63d6);
  flex-shrink: 0;
}

.account-select-info {
  flex: 1;
  min-width: 0;
}

.account-select-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 2px;
}

.account-select-meta {
  font-size: 0.85rem;
  color: var(--muted, #64748b);
}

.account-select-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Sync Toast Banner */
.sync-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
  max-width: 90vw;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.sync-toast-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.sync-toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--primary, #3b82f6);
}

.sync-toast-icon svg {
  width: 100%;
  height: 100%;
}

.sync-toast-icon .sync-spinner {
  animation: spin 1s linear infinite;
}

.sync-toast-icon.success {
  color: var(--success, #22c55e);
}

.sync-toast-icon.error {
  color: var(--danger, #ef4444);
}

.sync-toast-message {
  font-size: 0.9rem;
  color: var(--text, #1e293b);
}

.sync-toast-close {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: var(--muted, #64748b);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sync-toast-close:hover {
  background: var(--hover, #f1f5f9);
}

.sync-toast-close svg {
  width: 16px;
  height: 16px;
}

/* Receipt Edit Modal */
.receipt-edit-content {
  width: min(420px, 95vw);
  padding: 24px;
}

.receipt-edit-content h3 {
  margin: 0 0 20px;
}

.receipt-edit-form {
  display: grid;
  gap: 16px;
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #475569;
}

.form-field input,
.form-field textarea {
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
}

.form-field input:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.form-actions {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
}

/* Link field in receipt edit */
.link-field .link-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.04);
  border-radius: 10px;
  font-size: 0.9rem;
}

.link-field .link-status span {
  flex: 1;
  color: #475569;
}

.link-field .btn.small {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* Link Picker Modal */
.link-picker-content {
  width: min(480px, 95vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
}

.link-picker-content h3 {
  margin: 0 0 16px;
}

.link-picker-search {
  margin-bottom: 16px;
}

.link-picker-search input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: 12px;
  font-size: 0.95rem;
  font-family: inherit;
}

.link-picker-search input:focus {
  outline: none;
  border-color: var(--primary);
}

.link-picker-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 400px;
}

.link-picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}

.link-picker-item:hover {
  background: rgba(15, 23, 42, 0.06);
  border-color: rgba(15, 23, 42, 0.2);
}

.link-picker-item-info {
  flex: 1;
  min-width: 0;
}

.link-picker-item-merchant {
  font-weight: 500;
  color: #1e293b;
  margin-bottom: 2px;
}

.link-picker-item-meta {
  font-size: 0.85rem;
  color: #64748b;
}

.link-picker-empty {
  padding: 24px;
  text-align: center;
  color: #64748b;
}

.link-picker-status {
  margin-top: 12px;
  font-size: 0.85rem;
  color: #64748b;
}

.link-picker-status.is-error {
  color: #dc2626;
}

/* Receipt Item Actions */
.receipt-item-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.receipt-edit-btn,
.receipt-view-btn {
  background: none;
  border: none;
  padding: 6px;
  cursor: pointer;
  color: #64748b;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}

.receipt-edit-btn:hover,
.receipt-view-btn:hover {
  background: rgba(15, 23, 42, 0.08);
  color: #1e293b;
}

.receipt-edit-btn svg,
.receipt-view-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.btn.danger {
  background: linear-gradient(120deg, #dc2626, #b91c1c);
  color: #fff;
  box-shadow: 0 16px 30px -24px rgba(220, 38, 38, 0.7);
}

.btn.danger:hover {
  transform: translateY(-1px);
}

.btn.danger:disabled {
  opacity: 0.6;
  box-shadow: none;
  transform: none;
}

.sheet-gate {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.6);
  z-index: 40;
}

.sheet-gate.is-open {
  display: flex;
}

.sheet-gate.is-suspended {
  opacity: 0;
  pointer-events: none;
}

.sheet-gate-backdrop {
  position: absolute;
  inset: 0;
}

.sheet-gate-card {
  position: relative;
  width: min(560px, 100%);
  background: #fff;
  border-radius: 24px;
  padding: 28px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 32px 80px -48px rgba(15, 23, 42, 0.7);
  z-index: 1;
}

.sheet-gate-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.sheet-gate-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.sheet-gate-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
}

.disconnect-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 16px;
}

.disconnect-actions .app-note {
  margin-top: 0;
}

.sheet-note-danger {
  color: #b42318;
}

.onboarding-dialog {
  width: min(720px, 100%);
}

.onboarding-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}

.onboarding-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
}

.onboarding-progress {
  display: grid;
  gap: 8px;
  min-width: 160px;
  font-size: 0.8rem;
  color: var(--muted);
}

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.12);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: #1d4ed8;
  border-radius: inherit;
  transition: width 0.2s ease;
}

.onboarding-description {
  margin-top: 8px;
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
}

.onboarding-steps {
  margin-top: 12px;
}

.onboarding-business-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.onboarding-input-row {
  display: grid;
  gap: 4px;
}

.onboarding-input-row label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

.onboarding-input-row input {
  padding: 10px 12px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 8px;
  font-size: 0.95rem;
  background: #fff;
}

.onboarding-input-row input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.onboarding-step {
  display: none;
}

.onboarding-step.is-active {
  display: block;
}

.onboarding-step h4 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.onboarding-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
  display: grid;
  gap: 6px;
}

.onboarding-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(15, 23, 42, 0.04);
  color: var(--muted);
  font-size: 0.9rem;
}

.onboarding-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.onboarding-receipt-actions .btn {
  flex: 0 0 auto;
}

.onboarding-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.onboarding-footer {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.onboarding-nav {
  display: flex;
  align-items: center;
  gap: 10px;
}

body.modal-open {
  overflow: hidden;
}

body.sheet-gate-open {
  overflow: hidden;
}

body.picker-open {
  overflow: auto;
}

.receipt-history-card {
  grid-column: 1 / -1;
}

.receipt-history-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.receipt-history-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.receipt-history-actions .app-note {
  margin-top: 0;
}

.receipt-history-summary {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.receipt-history-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 10px;
}

.receipt-item {
  display: flex;
  flex-direction: column;
  gap: 0;
  align-items: stretch;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(15, 23, 42, 0.04);
  overflow-x: hidden;
  max-width: 100%;
  box-sizing: border-box;
}

.receipt-item.is-expandable {
  cursor: pointer;
}

.receipt-item.is-expanded {
  border-color: rgba(30, 99, 214, 0.2);
  background: rgba(30, 99, 214, 0.06);
}

.receipt-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
}

.receipt-info {
  display: grid;
  gap: 2px;
  flex: 1;
  min-width: 0;
  text-align: left;
}

.receipt-merchant {
  font-weight: 600;
  text-align: left;
}

.receipt-sub {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: left;
}

.receipt-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  justify-content: flex-start;
  margin-left: auto;
}

.receipt-detail {
  flex-basis: 100%;
  width: 100%;
  max-width: 100%;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(15, 23, 42, 0.08);
  display: none;
  box-sizing: border-box;
  overflow-x: auto;
}

.receipt-item.is-expanded .receipt-detail {
  display: grid;
}

.receipt-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}

@media (max-width: 480px) {
  .receipt-detail-grid {
    grid-template-columns: 1fr 1fr;
  }

  .receipt-detail-item:first-child {
    grid-column: 1 / -1;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.08);
    margin-bottom: 4px;
  }
}

.receipt-detail-item {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.receipt-detail-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.receipt-detail-value {
  font-size: 0.85rem;
  color: var(--ink);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.receipt-detail-item.is-note {
  grid-column: 1 / -1;
}

.receipt-link {
  font-size: 0.85rem;
  color: var(--brand);
  font-weight: 600;
  overflow-wrap: anywhere;
  white-space: nowrap;
}

.receipt-actions .btn {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.receipt-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.08);
  color: var(--ink);
}

.receipt-chip.is-alert {
  background: rgba(244, 63, 94, 0.12);
  color: #9f1239;
}

.receipt-history-empty {
  margin-top: 12px;
  padding: 16px;
  border-radius: 14px;
  border: 1px dashed rgba(15, 23, 42, 0.15);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
}

.receipt-thumb {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: #fff;
}

.transaction-card {
  grid-column: 1 / -1;
}

.transaction-card-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  align-items: flex-start;
}

.transaction-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.icon-btn {
  padding: 8px 12px;
}

.icon-btn .icon {
  width: 18px;
  height: 18px;
  display: block;
}

.transaction-actions .app-note {
  margin-top: 0;
}

.transaction-filters-header {
  display: none;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
}

.transaction-filters-panel {
  margin-top: 16px;
}

.transaction-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.transaction-filters input,
.transaction-filters select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  font-family: inherit;
  font-size: 0.9rem;
  background: #fff;
}

.transaction-summary {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.transaction-table {
  margin-top: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.7);
}

.transaction-row {
  display: grid;
  grid-template-columns: 110px minmax(0, 1.6fr) 110px 110px 120px;
  gap: 12px;
  align-items: center;
  padding: 12px 16px;
}

.transaction-head {
  background: rgba(15, 23, 42, 0.04);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.transaction-head .sort-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  background: transparent;
  padding: 0;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  color: inherit;
  cursor: pointer;
}

.transaction-head .sort-btn:focus-visible {
  outline: 2px solid rgba(30, 99, 214, 0.5);
  outline-offset: 2px;
  border-radius: 6px;
}

.transaction-head .sort-btn.align-right {
  justify-content: flex-end;
}

.transaction-head .sort-arrow {
  width: 8px;
  height: 8px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  display: inline-block;
  transform: rotate(45deg);
  opacity: 0.35;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.transaction-head .sort-btn.is-active .sort-arrow {
  opacity: 0.9;
}

.transaction-head .sort-btn[data-direction="asc"] .sort-arrow {
  transform: rotate(-135deg);
}

.transaction-list .transaction-row {
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
}

.transaction-row.is-expandable {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.transaction-row.is-expandable:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 18px -16px rgba(15, 23, 42, 0.3);
}

.transaction-row.is-review {
  background: rgba(255, 239, 239, 0.7);
}

.transaction-merchant {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.transaction-merchant-name {
  font-weight: 600;
}

.transaction-meta {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.transaction-meta-receipt {
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease;
  display: inline-block;
}

.transaction-meta-receipt:hover {
  transform: scale(1.2);
}

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

.align-right {
  text-align: right;
}

.transaction-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.08);
  color: var(--ink);
  white-space: nowrap;
}

.transaction-chip.is-alert {
  background: rgba(244, 63, 94, 0.12);
  color: #9f1239;
}

.transaction-chip.is-ok {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.transaction-chip.is-muted {
  background: rgba(15, 23, 42, 0.08);
  color: var(--muted);
}

.transaction-chip.is-business {
  background: rgba(30, 99, 214, 0.12);
  color: var(--brand);
}

.transaction-chip.is-personal {
  background: rgba(15, 23, 42, 0.08);
  color: var(--muted);
}

.transaction-chip.is-mixed {
  background: rgba(245, 158, 11, 0.16);
  color: #b45309;
}

.transaction-detail {
  grid-column: 1 / -1;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.04);
  border: 1px solid rgba(15, 23, 42, 0.08);
  display: none;
  gap: 12px;
}

.transaction-row.is-expanded .transaction-detail {
  display: grid;
}

.transaction-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.transaction-detail-item {
  display: grid;
  gap: 2px;
}

.transaction-detail-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.transaction-detail-value {
  font-size: 0.85rem;
  color: var(--ink);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.transaction-detail-item.is-note {
  grid-column: 1 / -1;
}

.transaction-detail-item.is-receipt {
  grid-column: 1 / -1;
}

.transaction-edit {
  padding-bottom: 12px;
  border-bottom: 1px dashed rgba(15, 23, 42, 0.12);
  display: grid;
  gap: 10px;
}

.transaction-edit-fields {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.transaction-edit-field {
  display: grid;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 0;
}

.transaction-edit-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.transaction-edit-select {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  font-family: inherit;
  background: #fff;
  font-size: 0.9rem;
  width: 100%;
  max-width: 100%;
}

.transaction-edit-status {
  font-size: 0.85rem;
  color: var(--muted);
}

.transaction-edit-status.is-error {
  color: #b42318;
}

.transaction-edit-clear {
  justify-self: flex-start;
  border: 1px solid rgba(15, 23, 42, 0.15);
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
}

.transaction-edit-clear:disabled {
  opacity: 0.6;
  cursor: wait;
}

.transaction-receipt {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.transaction-receipt-thumb {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  object-fit: cover;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: #fff;
}

.transaction-receipt-meta {
  display: grid;
  gap: 2px;
}

.transaction-receipt-title {
  font-weight: 600;
}

.transaction-receipt-details {
  font-size: 0.85rem;
  color: var(--muted);
}
.transaction-empty {
  margin-top: 12px;
  padding: 16px;
  border-radius: 14px;
  border: 1px dashed rgba(15, 23, 42, 0.15);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.7);
}

.receipt-form {
  display: grid;
  gap: 12px;
  margin-top: 12px;
}

.receipt-inputs {
  display: grid;
  gap: 12px;
}

.receipt-inputs input[type="file"] {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  font-family: inherit;
  font-size: 0.9rem;
  background: #fff;
}

.receipt-inputs textarea {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 72px;
}

.receipt-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.app-note.is-error {
  color: #b42318;
}

.app-actions {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.initial-sync-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
}

.initial-sync-option select {
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
}

.sync-status-message {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

.sync-status-message.syncing {
  background: #fef3cd;
  border-color: #ffc107;
  color: #856404;
}

.sync-status-message.success {
  background: #d4edda;
  border-color: #28a745;
  color: #155724;
}

.sync-status-message.error {
  background: #f8d7da;
  border-color: #dc3545;
  color: #721c24;
}

.input-row {
  display: grid;
  gap: 12px;
}

.input-row input {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  font-family: inherit;
  font-size: 0.95rem;
}

.input-row textarea {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  font-family: inherit;
  font-size: 0.95rem;
  resize: vertical;
  min-height: 72px;
}

.categorization-setting {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.categorization-slider {
  width: 100%;
  accent-color: var(--brand);
}

.categorization-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.app-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.9rem;
}

.app-note.is-loading {
  font-weight: 600;
}

.app-note.is-loading::after {
  content: "...";
  display: inline-block;
  width: 0;
  margin-left: 4px;
  overflow: hidden;
  vertical-align: bottom;
  animation: dots 1.2s steps(4, end) infinite;
}

@keyframes dots {
  to {
    width: 1.2em;
  }
}

.app-warning {
  margin-top: 12px;
  color: #8b5a2b;
  font-size: 0.9rem;
  background: #fff5e6;
  border: 1px solid rgba(139, 90, 43, 0.25);
  padding: 10px 12px;
  border-radius: 12px;
}

.app-warning[hidden] {
  display: none;
}

.sheet-details {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px dashed rgba(15, 23, 42, 0.2);
  background: rgba(15, 23, 42, 0.03);
}

.sheet-danger {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(220, 38, 38, 0.25);
  background: rgba(220, 38, 38, 0.06);
  display: grid;
  gap: 10px;
}

.sheet-danger-title {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: #b42318;
}

.sheet-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  list-style: none;
}

.sheet-details summary::-webkit-details-marker {
  display: none;
}

.sheet-details[open] summary {
  margin-bottom: 8px;
}

.sheet-actions {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.sheet-note {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--muted);
}

.connection-stack {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.connection-label {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.connection-id {
  font-size: 0.85rem;
  color: var(--muted);
  word-break: break-all;
}

.account-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.app-loading .skeleton {
  color: transparent;
  background: linear-gradient(110deg, #e6edf6 0%, #f5f9ff 45%, #e6edf6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.25s linear infinite;
  border-radius: 999px;
}

.app-loading .status-value.skeleton,
.app-loading .app-user.skeleton {
  min-width: 140px;
}

.app-loading .status-value.skeleton {
  min-height: 22px;
}

.app-loading .app-user.skeleton {
  min-height: 18px;
}

.account-skeleton {
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: linear-gradient(110deg, #e6edf6 0%, #f5f9ff 45%, #e6edf6 75%);
  background-size: 200% 100%;
  animation: shimmer 1.25s linear infinite;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.bank-group-title {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 8px;
}

.bank-group-title:first-child {
  margin-top: 0;
}

.account-item,
.account-empty {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(15, 23, 42, 0.04);
}

.account-toggle {
  padding: 0;
  border: none;
  background: transparent;
}

.account-toggle-btn {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.16);
  background: rgba(255, 255, 255, 0.8);
  color: var(--brand);
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
}

.account-toggle-btn:hover {
  background: rgba(30, 99, 214, 0.08);
}

.account-item {
  display: flex;
  justify-content: flex-start;
  gap: 8px 12px;
  align-items: center;
  flex-wrap: wrap;
  font-weight: 600;
}

.account-name,
.account-meta {
  min-width: 0;
}

.account-meta {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.usage-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  margin-left: auto;
  flex-wrap: wrap;
  max-width: 100%;
  min-width: 0;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.6);
}

.usage-btn {
  border: none;
  background: transparent;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.usage-btn.is-active {
  background: rgba(30, 99, 214, 0.14);
  color: var(--brand);
}

.usage-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.account-disconnect {
  font-size: 0.75rem;
  color: var(--muted);
  margin-left: 4px;
}

.account-disconnect:hover {
  color: #c53030;
}

@media (max-width: 1100px) {
  .app-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }

  .account-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .usage-toggle {
    align-self: flex-start;
    justify-content: flex-start;
    margin-left: 0;
  }

  .usage-btn {
    padding: 6px 8px;
    font-size: 0.7rem;
  }
}

@media (max-width: 720px) {
  .account-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .usage-toggle {
    align-self: stretch;
    justify-content: space-between;
    margin-left: 0;
  }
}

.account-mask {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.sync-details {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.sync-history {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  display: grid;
  gap: 8px;
}

.sync-item,
.sync-empty {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: rgba(15, 23, 42, 0.04);
}

.sync-item {
  display: grid;
  gap: 4px;
}

.sync-metrics {
  font-weight: 600;
}

.sync-time {
  color: var(--muted);
  font-size: 0.85rem;
}

.sync-setting {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.email-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.email-setting .usage-toggle {
  margin-left: auto;
}

.telegram-connect {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.telegram-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.telegram-action-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.telegram-disconnect {
  align-self: flex-start;
}

.btn-link {
  border: none;
  background: transparent;
  color: var(--brand);
  font-weight: 600;
  padding: 0;
  cursor: pointer;
}

.btn-link:hover {
  text-decoration: underline;
}

.btn-link:disabled {
  opacity: 0.6;
  cursor: wait;
}

.telegram-link {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.85);
  display: none;
}

.telegram-link a {
  display: inline-flex;
  margin-top: 6px;
  color: var(--brand);
  font-weight: 600;
  word-break: break-all;
}

.sync-resync {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: rgba(255, 255, 255, 0.85);
}

.sync-resync summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
  list-style: none;
}

.sync-resync summary::-webkit-details-marker {
  display: none;
}

.sync-resync[open] summary {
  margin-bottom: 8px;
}

.resync-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 10px;
  margin-top: 8px;
  align-items: center;
}

@media (max-width: 480px) {
  .resync-row {
    grid-template-columns: 1fr 1fr;
  }
  .resync-row input {
    grid-column: 1 / -1;
  }
}

.resync-row input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.15);
  font-family: inherit;
  font-size: 0.95rem;
}

.resync-note {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--muted);
}

@media (max-width: 900px) {
  .app-main {
    padding: 0 6vw 80px;
  }

  .app-hero {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 28px 0 16px;
  }

  .app-hero .eyebrow {
    display: none;
  }

  .app-hero h1,
  .app-hero .app-sub {
    display: none;
  }

  .app-hero h1 {
    font-size: clamp(1.6rem, 4vw + 1rem, 2.2rem);
    margin-bottom: 6px;
  }

  .app-tabs {
    margin-top: 12px;
  }

  .app-tab {
    padding: 6px 12px;
    font-size: 0.78rem;
  }

  .app-nav-actions .btn {
    padding: 6px 12px;
    font-size: 0.78rem;
  }

  .transaction-filters-header {
    display: flex;
  }

  .transaction-filters-panel {
    display: none;
    margin-top: 12px;
  }

  .transaction-filters-panel.is-open {
    display: block;
  }

  .transaction-filters {
    grid-template-columns: 1fr;
    margin-top: 0;
  }

  .transaction-table {
    border: none;
    background: transparent;
  }

  .transaction-head {
    display: none;
  }

  .transaction-list {
    display: grid;
    gap: 12px;
  }

  .transaction-row {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "date amount"
      "merchant merchant"
      "business review";
    border: 1px solid rgba(15, 23, 42, 0.1);
    border-radius: 16px;
  }

  .transaction-list .transaction-row {
    border-top: none;
  }

  .transaction-date {
    grid-area: date;
  }

  .transaction-amount {
    grid-area: amount;
    justify-self: end;
  }

  .transaction-merchant {
    grid-area: merchant;
  }

  .transaction-business {
    grid-area: business;
  }

  .transaction-review {
    grid-area: review;
    justify-self: end;
  }

  .receipt-item {
    align-items: flex-start;
  }

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

  .receipt-actions {
    flex-wrap: wrap;
    margin-left: 0;
  }

  .chart-row {
    grid-template-columns: 60px minmax(0, 1fr) 60px;
  }

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

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

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

  .dashboard-list li {
    flex-direction: column;
    align-items: flex-start;
  }

  .dashboard-list li span:last-child {
    align-self: flex-end;
  }

  .dashboard-list li span:first-child {
    white-space: normal;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: anywhere;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

@media (max-width: 1100px) {
  .app-panel[data-panel="dashboard"] {
    grid-template-columns: 1fr;
  }

  .app-panel[data-panel="receipts"] {
    grid-template-columns: 1fr;
  }

  .app-panel[data-panel="reports"] {
    grid-template-columns: 1fr;
  }

  .report-viewer {
    grid-column: auto;
  }

  .app-panel[data-panel="setup"] {
    grid-template-columns: 1fr;
  }

  .setup-shell {
    grid-template-columns: 1fr;
  }

  .setup-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }

  .setup-tab {
    flex: 1 1 160px;
    text-align: center;
  }
}

.app-tab-panels .app-panel {
  display: none;
}

.app-tab-panels .app-panel.is-active {
  display: grid;
}

@media (max-width: 640px) {
  .app-page .nav {
    flex-direction: row;
    align-items: center;
  }

  .app-nav-actions {
    width: auto;
    flex-wrap: nowrap;
  }

  .app-page .btn {
    width: auto;
  }

  .app-actions .btn {
    width: 100%;
  }

  .setup-panel {
    grid-template-columns: 1fr;
  }

  .app-user {
    display: none;
  }

  .app-tabs {
    margin-top: 6px;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app-tab {
    white-space: nowrap;
    flex: 0 0 auto;
  }

  .app-tab-panels {
    margin-top: 8px;
  }

  .year-select-wrap {
    padding: 4px 8px;
    gap: 6px;
  }

  .year-label {
    font-size: 0.55rem;
  }

  .year-select {
    font-size: 0.8rem;
  }

  .receipt-detail {
    max-width: 100%;
  }

  .receipt-detail-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-toolbar {
    justify-content: flex-start;
  }

  .onboarding-dialog {
    padding: 20px;
  }

  .onboarding-progress {
    width: 100%;
  }

  .onboarding-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .onboarding-nav {
    width: 100%;
    justify-content: space-between;
  }

  .onboarding-actions .btn {
    width: 100%;
  }
}

/* Subscription UI */

.subscription-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 12px 24px;
  background: var(--surface-2, #f5f5f5);
  border-bottom: 1px solid var(--border, #e0e0e0);
  font-size: 14px;
}

.subscription-banner.warning {
  background: #fff3cd;
  border-color: #ffc107;
}

.subscription-banner.error {
  background: #f8d7da;
  border-color: #dc3545;
}

.subscription-banner .btn.small {
  padding: 6px 12px;
  font-size: 13px;
}

.plan-badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
  background: var(--surface-2, #e8e8e8);
  color: var(--text-2, #666);
}

.plan-badge.solo {
  background: #e3f2fd;
  color: #1565c0;
}

.plan-badge.pro {
  background: #fff3e0;
  color: #ef6c00;
}

.billing-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
}

/* Pricing Modal */

.pricing-modal {
  max-width: 640px;
}

.pricing-toggle {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 20px 0;
  padding: 4px;
  background: var(--surface-2, #f5f5f5);
  border-radius: 8px;
}

.pricing-toggle .toggle-btn {
  padding: 8px 20px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pricing-toggle .toggle-btn.active {
  background: white;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pricing-toggle .save-badge {
  font-size: 11px;
  padding: 2px 6px;
  background: #4caf50;
  color: white;
  border-radius: 4px;
  margin-left: 6px;
}

.pricing-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 20px;
}

.pricing-card {
  padding: 24px;
  border: 1px solid var(--border, #e0e0e0);
  border-radius: 12px;
  text-align: center;
  position: relative;
}

.pricing-card.featured {
  border-color: var(--primary, #2563eb);
  border-width: 2px;
}

.pricing-card h4 {
  font-size: 18px;
  font-weight: 600;
  margin: 0 0 12px;
}

.pricing-card .price {
  margin-bottom: 16px;
}

.pricing-card .price .amount {
  font-size: 36px;
  font-weight: 700;
}

.pricing-card .price .interval {
  font-size: 14px;
  color: var(--text-2, #666);
}

.pricing-card .features {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  text-align: left;
}

.pricing-card .features li {
  padding: 6px 0;
  font-size: 14px;
  padding-left: 24px;
  position: relative;
}

.pricing-card .features li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  color: #4caf50;
  font-weight: bold;
}

.pricing-card .popular-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary, #2563eb);
  color: white;
  border-radius: 12px;
  text-transform: uppercase;
}

.pricing-card .btn {
  width: 100%;
}

@media (max-width: 600px) {
  .pricing-cards {
    grid-template-columns: 1fr;
  }
}

/* Subscription Gate */
.subscription-gate {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.75);
  z-index: 50;
}

.subscription-gate.is-open {
  display: flex;
}

.subscription-gate-backdrop {
  position: absolute;
  inset: 0;
}

.subscription-gate-card {
  position: relative;
  width: min(680px, 100%);
  background: #fff;
  border-radius: 24px;
  padding: 32px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  box-shadow: 0 32px 80px -48px rgba(15, 23, 42, 0.7);
  z-index: 1;
  text-align: center;
}

.subscription-gate-eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.subscription-gate-card h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
}

.subscription-gate-sub {
  color: var(--muted);
  margin: 0 0 24px;
}

.subscription-gate-toggle {
  display: inline-flex;
  gap: 4px;
  background: rgba(15, 23, 42, 0.06);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 24px;
}

.subscription-gate-toggle .toggle-btn {
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.subscription-gate-toggle .toggle-btn.active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.subscription-gate-toggle .save-badge {
  font-size: 11px;
  background: #dcfce7;
  color: #15803d;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

.subscription-gate-plans {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.gate-plan-card {
  position: relative;
  background: #fff;
  border: 2px solid rgba(15, 23, 42, 0.1);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  transition: border-color 0.2s;
}

.gate-plan-card:hover {
  border-color: rgba(15, 23, 42, 0.2);
}

.gate-plan-card.featured {
  border-color: var(--primary, #2563eb);
}

.gate-plan-card h4 {
  margin: 0 0 12px;
  font-size: 1.25rem;
}

.gate-plan-price {
  margin-bottom: 16px;
}

.gate-plan-price .amount {
  font-size: 2rem;
  font-weight: 700;
}

.gate-plan-price .interval {
  font-size: 14px;
  color: var(--muted);
}

.gate-plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  text-align: left;
}

.gate-plan-features li {
  padding: 6px 0;
  font-size: 14px;
  padding-left: 24px;
  position: relative;
}

.gate-plan-features li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  color: #4caf50;
  font-weight: bold;
}

.gate-plan-card .popular-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  font-size: 11px;
  font-weight: 600;
  background: var(--primary, #2563eb);
  color: white;
  border-radius: 12px;
  text-transform: uppercase;
}

.gate-plan-card .btn {
  width: 100%;
}

body.subscription-gate-open {
  overflow: hidden;
}

@media (max-width: 600px) {
  .subscription-gate-plans {
    grid-template-columns: 1fr;
  }

  .subscription-gate-card {
    padding: 24px;
  }
}

.btn.is-disabled {
  opacity: 0.65;
  cursor: not-allowed;
  text-decoration: none;
}
