.ledger-bill-embed-frame {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  left: -9999px;
  top: -9999px;
}

.ledger-bill-embed-toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 12000;
  max-width: min(92vw, 420px);
  padding: 0.65rem 1rem;
  border-radius: 10px;
  background: rgba(20, 24, 32, 0.92);
  color: #fff;
  font-size: 0.875rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.ledger-bill-ledger-detail-row.is-selectable {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.5rem;
  align-items: center;
}

.ledger-bill-detail-row-del {
  border: none;
  background: transparent;
  color: #999;
  padding: 0.25rem 0.4rem;
  line-height: 1;
}

.ledger-bill-detail-row-del:hover {
  color: #dc3545;
}

.ledger-bill-detail-cat-btn {
  border: 1px solid rgba(91, 141, 239, 0.45);
  background: transparent;
  color: var(--accent-color, #5b8def);
  border-radius: 8px;
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
}

.ledger-bill-detail-cat-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ledger-bill-detail-cat-filters {
  display: block;
}

.ledger-bill-detail-cat-pills {
  width: 100%;
  -webkit-overflow-scrolling: touch;
}

.ledger-bill-detail-l2-btn.is-active {
  background: rgba(91, 141, 239, 0.14);
  border-color: var(--accent-color, #5b8def);
  color: var(--accent-color, #4f46e5);
  font-weight: 600;
}

.bill-ledger-l2-modal {
  position: fixed;
  inset: 0;
  z-index: 14100;
  display: none;
}

.bill-ledger-l2-modal.is-open {
  display: block;
}

.bill-ledger-l2-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(2px);
}

.bill-ledger-l2-modal__panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 440px);
  max-height: min(82vh, 560px);
  display: flex;
  flex-direction: column;
  padding: 1.1rem 1.1rem 1rem;
  border-radius: 16px;
  background: var(--card-bg, #fff);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
}

.bill-ledger-l2-modal__close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  border: none;
  background: transparent;
  color: #64748b;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
}

.bill-ledger-l2-modal__title {
  margin: 0 2rem 0.35rem 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.bill-ledger-l2-modal__desc {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--muted-color, #64748b);
}

.bill-ledger-l2-modal__pills {
  flex: 1;
  min-height: 0;
  max-height: 42vh;
  overflow-x: auto;
  overflow-y: auto;
  flex-wrap: wrap;
  align-content: flex-start;
  padding-bottom: 0.35rem;
}

.bill-ledger-l2-count {
  opacity: 0.72;
  font-size: 0.75em;
  margin-left: 0.15rem;
}

.bill-ledger-l2-modal__empty {
  font-size: 0.875rem;
  color: var(--muted-color, #64748b);
  padding: 0.5rem 0;
}

.bill-ledger-l2-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: 0.85rem;
}

.bill-ledger-l2-modal__btn {
  border-radius: 10px;
  padding: 0.55rem 0.95rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
}

.bill-ledger-l2-modal__btn.is-secondary {
  background: rgba(148, 163, 184, 0.18);
  color: inherit;
}

.bill-ledger-l2-modal__btn.is-primary {
  background: var(--accent-color, #5b8def);
  color: #fff;
}

body.dark-theme .bill-ledger-l2-modal__panel {
  background: var(--card-bg, #1e1e1e);
}

.ledger-bill-cat-tag {
  border: 1px solid rgba(79, 70, 229, 0.24);
  background: #eef2ff;
  color: #3730a3;
  border-radius: 999px;
  padding: 0.12rem 0.58rem;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.35;
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-font-smoothing: antialiased;
}

.ledger-bill-cat-tag:hover {
  filter: brightness(0.97);
}

.ledger-bill-cat-tag.is-uncat {
  border-color: rgba(234, 88, 12, 0.35);
  background: #ffedd5;
  color: #9a3412;
}

.ledger-bill-cat-tag.is-cat-food {
  border-color: rgba(234, 88, 12, 0.32);
  background: #ffedd5;
  color: #9a3412;
}

.ledger-bill-cat-tag.is-cat-wear {
  border-color: rgba(219, 39, 119, 0.28);
  background: #fce7f3;
  color: #9d174d;
}

.ledger-bill-cat-tag.is-cat-home {
  border-color: rgba(22, 163, 74, 0.28);
  background: #dcfce7;
  color: #166534;
}

.ledger-bill-cat-tag.is-cat-trans {
  border-color: rgba(37, 99, 235, 0.3);
  background: #dbeafe;
  color: #1e40af;
}

.ledger-bill-cat-tag.is-cat-edu {
  border-color: rgba(109, 40, 217, 0.28);
  background: #ede9fe;
  color: #5b21b6;
}

.ledger-bill-cat-tag.is-cat-fun {
  border-color: rgba(162, 28, 175, 0.28);
  background: #fae8ff;
  color: #86198f;
}

.ledger-bill-cat-tag.is-cat-ins {
  border-color: rgba(14, 116, 144, 0.28);
  background: #cffafe;
  color: #0e7490;
}

.ledger-bill-cat-tag.is-cat-med {
  border-color: rgba(220, 38, 38, 0.28);
  background: #fee2e2;
  color: #b91c1c;
}

.ledger-bill-cat-tag.is-cat-shop {
  border-color: rgba(202, 138, 4, 0.32);
  background: #fef9c3;
  color: #854d0e;
}

.ledger-bill-cat-tag.is-cat-donate {
  border-color: rgba(219, 39, 119, 0.28);
  background: #fce7f3;
  color: #9d174d;
}

.ledger-bill-cat-tag.is-cat-other {
  border-color: rgba(100, 116, 139, 0.32);
  background: #e2e8f0;
  color: #334155;
}

body.dark-theme .ledger-bill-cat-tag {
  border-color: rgba(129, 140, 248, 0.4);
  background: rgba(79, 70, 229, 0.22);
  color: #e0e7ff;
  font-weight: 700;
}

body.dark-theme .ledger-bill-cat-tag.is-uncat,
body.dark-theme .ledger-bill-cat-tag.is-cat-food {
  border-color: rgba(251, 146, 60, 0.4);
  background: rgba(234, 88, 12, 0.2);
  color: #fdba74;
}

body.dark-theme .ledger-bill-cat-tag.is-cat-wear {
  border-color: rgba(244, 114, 182, 0.35);
  background: rgba(219, 39, 119, 0.18);
  color: #f9a8d4;
}

body.dark-theme .ledger-bill-cat-tag.is-cat-home {
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(22, 163, 74, 0.18);
  color: #86efac;
}

body.dark-theme .ledger-bill-cat-tag.is-cat-trans {
  border-color: rgba(96, 165, 250, 0.35);
  background: rgba(37, 99, 235, 0.2);
  color: #93c5fd;
}

body.dark-theme .ledger-bill-cat-tag.is-cat-edu {
  border-color: rgba(167, 139, 250, 0.35);
  background: rgba(109, 40, 217, 0.2);
  color: #c4b5fd;
}

body.dark-theme .ledger-bill-cat-tag.is-cat-fun {
  border-color: rgba(232, 121, 249, 0.35);
  background: rgba(162, 28, 175, 0.2);
  color: #e879f9;
}

body.dark-theme .ledger-bill-cat-tag.is-cat-ins {
  border-color: rgba(34, 211, 238, 0.35);
  background: rgba(14, 116, 144, 0.2);
  color: #67e8f9;
}

body.dark-theme .ledger-bill-cat-tag.is-cat-med {
  border-color: rgba(248, 113, 113, 0.35);
  background: rgba(220, 38, 38, 0.2);
  color: #fca5a5;
}

body.dark-theme .ledger-bill-cat-tag.is-cat-shop {
  border-color: rgba(250, 204, 21, 0.35);
  background: rgba(202, 138, 4, 0.2);
  color: #fde047;
}

body.dark-theme .ledger-bill-cat-tag.is-cat-donate {
  border-color: rgba(244, 114, 182, 0.35);
  background: rgba(190, 24, 93, 0.2);
  color: #f9a8d4;
}

body.dark-theme .ledger-bill-cat-tag.is-cat-other {
  border-color: rgba(148, 163, 184, 0.35);
  background: rgba(100, 116, 139, 0.22);
  color: #cbd5e1;
}

.ledger-bill-ledger-detail-meta-sep {
  margin: 0 0.2rem;
  opacity: 0.55;
}

.ledger-bill-uncat-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  border: 1px solid rgba(234, 88, 12, 0.25);
  background: rgba(255, 247, 237, 0.9);
}

.ledger-bill-uncat-banner__text {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.875rem;
  color: #9a3412;
}

.ledger-bill-uncat-banner__btn {
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.8125rem;
  font-weight: 600;
  background: #ea580c;
  color: #fff;
  white-space: nowrap;
}

.bill-ledger-cat-modal {
  position: fixed;
  inset: 0;
  z-index: 14000;
  display: none;
}

.bill-ledger-cat-modal.is-open {
  display: block;
}

.bill-ledger-cat-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(2px);
}

.bill-ledger-cat-modal__panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 420px);
  padding: 1.1rem 1.1rem 1rem;
  border-radius: 16px;
  background: var(--card-bg, #fff);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
}

.bill-ledger-cat-modal__close {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  border: none;
  background: transparent;
  color: #64748b;
  width: 2rem;
  height: 2rem;
  border-radius: 999px;
}

.bill-ledger-cat-modal__title {
  margin: 0 2rem 0.35rem 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.bill-ledger-cat-modal__desc {
  margin: 0 0 0.85rem;
  font-size: 0.875rem;
  color: var(--muted-color, #64748b);
  word-break: break-word;
}

.bill-ledger-cat-modal__field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  font-size: 0.8125rem;
}

.bill-ledger-cat-modal__input {
  width: 100%;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 10px;
  padding: 0.5rem 0.65rem;
  font-size: 0.9375rem;
  background: var(--card-bg, #fff);
  color: inherit;
}

.bill-ledger-cat-modal__remember {
  display: flex;
  align-items: flex-start;
  gap: 0.45rem;
  margin: 0.2rem 0 0.95rem;
  font-size: 0.8125rem;
  color: var(--muted-color, #64748b);
}

.bill-ledger-cat-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.bill-ledger-cat-modal__btn {
  border-radius: 10px;
  padding: 0.55rem 0.95rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
}

.bill-ledger-cat-modal__btn.is-secondary {
  background: rgba(148, 163, 184, 0.18);
  color: inherit;
}

.bill-ledger-cat-modal__btn.is-primary {
  background: var(--accent-color, #5b8def);
  color: #fff;
}

body.dark-theme .ledger-bill-uncat-banner {
  background: rgba(124, 45, 18, 0.22);
  border-color: rgba(251, 146, 60, 0.28);
}

body.dark-theme .ledger-bill-uncat-banner__text {
  color: #fdba74;
}

body.dark-theme .bill-ledger-cat-modal__panel {
  background: var(--card-bg, #1e1e1e);
}

.ledger-bill-pdf-chip .chip-dot {
  background: var(--accent-color, #5b8def) !important;
}

.ledger-bill-pdf-chip.active {
  border-color: var(--accent-color, #5b8def);
}

/* Gmail sync progress modal */
.bill-sync-progress-modal {
  position: fixed;
  inset: 0;
  z-index: 13000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.bill-sync-progress-modal.is-open {
  display: flex;
}

.bill-sync-progress-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.bill-sync-progress-panel {
  position: relative;
  width: min(92vw, 440px);
  max-height: min(88vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem 2.5rem 1rem 1.25rem;
  border-radius: 16px;
  background: var(--card-bg, #fff);
  color: var(--text-color, #1a1a1a);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
}

.bill-sync-progress-close-btn {
  position: absolute;
  top: 0.65rem;
  right: 0.65rem;
  z-index: 2;
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: #94a3b8;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.bill-sync-progress-close-btn:hover {
  background: rgba(148, 163, 184, 0.16);
  color: #64748b;
}

.bill-sync-progress-close-btn.is-hidden {
  display: none;
}

body.dark-theme .bill-sync-progress-close-btn {
  color: #94a3b8;
}

body.dark-theme .bill-sync-progress-close-btn:hover {
  background: rgba(148, 163, 184, 0.14);
  color: #e2e8f0;
}

body.dark-theme .bill-sync-progress-panel {
  background: var(--card-bg, #1e1e1e);
  color: var(--text-color, #f0f0f0);
}

.bill-sync-progress-head {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}

.bill-sync-progress-icon {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(91, 141, 239, 0.15);
  color: var(--accent-color, #5b8def);
  font-size: 1.15rem;
  flex-shrink: 0;
}

.bill-sync-progress-title {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.bill-sync-progress-warning {
  margin: 0;
  font-size: 0.8125rem;
  color: #e67e22;
  font-weight: 600;
}

.bill-sync-progress-warning i {
  margin-right: 0.25rem;
}

.bill-sync-progress-bar-wrap {
  height: 8px;
  border-radius: 999px;
  background: rgba(128, 128, 128, 0.2);
  overflow: hidden;
}

.bill-sync-progress-bar-wrap.is-indeterminate .bill-sync-progress-bar {
  width: 35% !important;
  animation: billSyncProgressIndeterminate 1.2s ease-in-out infinite;
}

@keyframes billSyncProgressIndeterminate {
  0% { transform: translateX(-120%); }
  100% { transform: translateX(320%); }
}

.bill-sync-progress-bar {
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-color, #5b8def), #7eb0ff);
  transition: width 0.35s ease;
}

.bill-sync-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8125rem;
  color: var(--muted-color, #666);
}

.bill-sync-progress-status {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.45;
  min-height: 1.4em;
}

.bill-sync-progress-status.is-active {
  animation: billSyncStatusPulse 0.45s ease;
}

@keyframes billSyncStatusPulse {
  0% { opacity: 0.55; }
  100% { opacity: 1; }
}

.bill-sync-progress-log-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: none;
  background: transparent;
  color: var(--accent-color, #5b8def);
  font-size: 0.8125rem;
  padding: 0.25rem 0;
  cursor: pointer;
  align-self: flex-start;
}

.bill-sync-log-chevron {
  transition: transform 0.2s ease;
  font-size: 0.7rem;
}

.bill-sync-log-chevron.is-open {
  transform: rotate(90deg);
}

.bill-sync-progress-log-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.bill-sync-progress-log-wrap.is-collapsed {
  display: none;
}

.bill-sync-progress-log {
  margin: 0;
  max-height: 220px;
  overflow: auto;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.06);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.6875rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

body.dark-theme .bill-sync-progress-log {
  background: rgba(255, 255, 255, 0.06);
}

.bill-sync-progress-done-btn {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  font-size: 0.9375rem;
  font-weight: 600;
  background: var(--accent-color, #5b8def);
  color: #fff;
  cursor: pointer;
}

.bill-sync-progress-done-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.bill-sync-progress-done-btn.is-success {
  background: #2ecc71;
}

.bill-sync-progress-modal.is-paused-for-prompt {
  visibility: hidden;
  pointer-events: none;
}

.bill-sync-progress-modal.is-paused-for-prompt .bill-sync-progress-panel {
  opacity: 0;
}
