.gmail-settings { margin-top: 1rem; }
.gmail-settings h2 { margin: 0 0 .35rem; }
.gmail-settings summary { cursor: pointer; padding: .65rem 0; font-weight: 650; }
.gmail-settings p, .gmail-source p { overflow-wrap: anywhere; }
.gmail-permission-note { font-size: .85rem; color: var(--muted, #64748b); }
.gmail-form { display: grid; gap: .85rem; margin: .5rem 0 1rem; }
.gmail-form label { display: grid; gap: .35rem; min-width: 0; }
.gmail-form input:not([type="checkbox"]) { width: 100%; min-height: 44px; box-sizing: border-box; padding: .6rem .75rem; color: var(--text, #18243b); background: var(--card, white); border: 1px solid var(--border, #d0d6e0); border-radius: .55rem; font: inherit; }
.gmail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.gmail-form .gmail-check { display: flex; align-items: center; gap: .5rem; }
.gmail-check input { width: 20px; height: 20px; flex: 0 0 auto; }
.gmail-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.gmail-actions button, .gmail-form button { min-height: 44px; }
.gmail-connection { border: 1px solid var(--border, #d0d6e0); padding: 1rem; border-radius: .85rem; margin: .8rem 0; }
.gmail-connection-head { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.gmail-connection-head strong { overflow-wrap: anywhere; }
.gmail-origin-badge { display: inline-block; padding: .2rem .55rem; margin-top: .35rem; border: 1px solid var(--border, #d0d6e0); border-radius: 999px; color: var(--brand, #375bad); font-size: .78rem; }
.gmail-source { border: 1px solid var(--border, #d0d6e0); border-left: 4px solid var(--brand, #375bad); border-radius: .7rem; padding: .85rem 1rem; margin-bottom: 1rem; background: var(--soft, #f6f8fc); }
.gmail-source p { margin: .35rem 0; font-size: .85rem; }
.gmail-source a { color: var(--brand, #375bad); }
.gmail-history-row { padding: .75rem 0; border-bottom: 1px solid var(--border, #d0d6e0); font-size: .85rem; overflow-wrap: anywhere; }
.gmail-error { color: var(--danger, #b42318); }
@media (max-width: 650px) { .gmail-grid { grid-template-columns: 1fr; } .gmail-actions button { flex: 1 1 110px; } }

/* Gmail import v1.1: friendly search explanation and real worker progress. */
.gmail-plain-search {
  padding: .8rem 1rem;
  border: 1px solid var(--border, #d0d6e0);
  border-radius: .75rem;
  background: var(--soft, rgba(80, 120, 200, .06));
  line-height: 1.5;
}
.gmail-plain-search strong { display: block; margin-bottom: .25rem; }
.gmail-plain-search p { margin: .25rem 0; font-size: .88rem; color: var(--muted, #64748b); }
.gmail-sync-region { margin-top: .85rem; }
.gmail-sync-feedback {
  border: 1px solid var(--border, #d0d6e0);
  padding: .8rem .9rem;
  border-radius: .75rem;
  line-height: 1.5;
  font-size: .88rem;
  overflow-wrap: anywhere;
}
.gmail-sync-feedback strong { display: block; font-weight: 700; }
.gmail-sync-feedback p { margin: .4rem 0 0; }
.gmail-feedback-active { background: var(--soft, rgba(53, 109, 232, .07)); }
.gmail-feedback-success { background: rgba(38, 159, 92, .08); border-color: rgba(32, 159, 87, .38); }
.gmail-feedback-error { background: rgba(206, 53, 53, .06); border-color: rgba(209, 71, 71, .38); }
.gmail-feedback-success a { color: var(--brand, #4c80f1); font-weight: 650; }
.gmail-progress-track {
  position: relative;
  height: 9px;
  margin-top: .7rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border, #d0d6e0);
}
.gmail-progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 42%;
  border-radius: 999px;
  background: var(--brand, #4c80f1);
  animation: gmail-sync-indeterminate 1.8s cubic-bezier(.4, 0, .2, 1) infinite;
}
.gmail-progress-complete .gmail-progress-fill { width: 100%; animation: none; background: #27a562; }
.gmail-sync-counts { font-variant-numeric: tabular-nums; }
.gmail-progress-note { color: var(--muted, #64748b); font-size: .76rem; }
.gmail-retry-message { color: var(--danger, #b42318); }
.gmail-actions button:disabled,
.gmail-save button:disabled {
  opacity: .5;
  cursor: not-allowed;
}
@keyframes gmail-sync-indeterminate {
  0% { transform: translateX(-110%); }
  55% { transform: translateX(160%); }
  100% { transform: translateX(260%); }
}
@media (prefers-reduced-motion: reduce) {
  .gmail-progress-fill { animation: none; }
}

/* v1.2: readable Gmail source, without loading arbitrary email HTML. */
.gmail-original-file { margin-top: .65rem; font-size: .86rem; }
.gmail-original-file summary { cursor: pointer; }
.receipt-image-wrap.gmail-has-reader { display: block; padding: 0; min-height: 200px; background: var(--card, #fff); }
.gmail-inline-reader, .gmail-reader-host { min-width: 0; width: 100%; }
.gmail-reader-toolbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 10px; border-bottom: 1px solid var(--border, #d4dce8); background: var(--soft, #f1f5fb); }
.gmail-reader-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gmail-reader-button { min-height: 42px; padding: 8px 11px; font: inherit; font-size: 13px; white-space: nowrap; }
.gmail-reader-button[aria-pressed="true"] { background: var(--brand-soft, #eaf1ff); border-color: var(--brand, #356df0); color: var(--brand, #356df0); }
.gmail-reader-button:focus-visible, .gmail-reader-dialog a:focus-visible { outline: 3px solid var(--brand, #356df0); outline-offset: 2px; }
.gmail-reader-zoom, .gmail-reader-page-label { font-size: 13px; font-variant-numeric: tabular-nums; color: var(--text, #15243a); }
.gmail-reader-zoom { min-width: 39px; text-align: center; }
.gmail-reader-message { margin: 0; padding: 10px 14px; color: var(--muted, #65758a); font-size: 12px; line-height: 1.5; overflow-wrap: anywhere; }
.gmail-reader-viewport { background: #e9eef5; padding: 15px; max-height: 450px; overflow: auto; overscroll-behavior: contain; border-radius: 0 0 10px 10px; }
.gmail-reader-paper { box-sizing: border-box; margin: 0 auto; padding: 22px; width: 100%; max-width: 870px; color: #17243a; background: #fff; box-shadow: 0 2px 10px #1b355314; border: 1px solid #dce3ec; border-radius: 7px; font: 16px/1.65 system-ui, sans-serif; overflow-wrap: anywhere; text-align: left; }
.gmail-reader-paper p { margin: .5em 0; color: #17243a; line-height: 1.65; font-size: inherit; }
.gmail-reader-paper p:first-child { margin-top: 0; }
.gmail-reader-plain { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; color: #17243a; font: inherit; background: none; border: 0; }
.gmail-reader-table-wrap { overflow-x: auto; margin: .7em 0; max-width: 100%; }
.gmail-reader-table { width: 100%; border-collapse: collapse; color: #17243a; font-size: inherit; table-layout: auto; }
.gmail-reader-table td { border: 1px solid #dce3ec; padding: 8px 10px; vertical-align: top; min-width: 70px; font-size: inherit; }
.gmail-reader-table tr:nth-child(even) { background: #f4f7fb; }
.gmail-reader-page { display: block; max-width: 100%; width: 100%; height: auto; }
.gmail-reader-limit { color: var(--muted, #65758a); font-size: .82rem; padding: 12px; }
.gmail-reader-dialog { box-sizing: border-box; width: min(1120px, calc(100vw - 38px)); max-width: none; height: min(92dvh, 1000px); max-height: 96dvh; padding: 0; margin: auto; color: var(--text, #17243a); background: var(--card, #fff); border: 1px solid var(--border, #ced9e6); border-radius: 18px; box-shadow: 0 25px 90px #0007; overflow: hidden; }
.gmail-reader-dialog[open] { display: flex; flex-direction: column; }
.gmail-reader-dialog::backdrop { background: rgba(4, 12, 25, .75); backdrop-filter: blur(4px); }
.gmail-reader-heading { display: flex; align-items: flex-start; gap: 20px; justify-content: space-between; padding: 20px 23px 14px; border-bottom: 1px solid var(--border, #ced9e6); flex: 0 0 auto; }
.gmail-reader-titles { min-width: 0; }
.gmail-reader-heading h2 { font-size: clamp(17px, 2vw, 23px); margin: 3px 0 7px; overflow-wrap: anywhere; line-height: 1.35; }
.gmail-reader-eyebrow { font-size: 11px; letter-spacing: .13em; color: var(--brand, #356df0); margin: 0; }
.gmail-reader-sender, .gmail-reader-date { font-size: 12px; line-height: 1.4; color: var(--muted, #65758a); margin: 3px 0; overflow-wrap: anywhere; }
.gmail-reader-document-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 23px; }
.gmail-reader-document-actions a { color: var(--brand, #356df0); font-size: 13px; }
.gmail-reader-hint { font-size: 12px; color: var(--muted, #65758a); }
.gmail-reader-dialog .gmail-reader-host { min-height: 0; display: flex; flex-direction: column; flex: 1; }
.gmail-reader-dialog .gmail-reader-viewport { max-height: none; flex: 1; min-height: 0; border-radius: 0; }
.gmail-reader-dialog .gmail-reader-toolbar { padding: 10px 23px; }
@media (max-width: 650px) {
  .gmail-reader-dialog { width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; }
  .gmail-reader-heading { padding: 15px; gap: 10px; }
  .gmail-reader-document-actions { padding: 8px 15px; }
  .gmail-reader-hint { display: none; }
  .gmail-reader-dialog .gmail-reader-toolbar { padding: 10px 15px; }
  .gmail-reader-paper { padding: 16px; }
  .gmail-reader-viewport { padding: 9px; }
  .gmail-reader-toolbar { gap: 8px; }
  .gmail-reader-heading h2 { max-height: 4.1em; overflow: auto; }
}
