/*
 * Receipt Runner's look, carried over from the Electron app (app/src/styles/variables.less) and receiptrunner.com:
 * a navy sidebar, Receipt Runner blue for actions, green for receipts that are done, Lato throughout.
 */
:root {
  --navy: #0e2749;
  --navy-line: #3c506c;
  --navy-muted: #aab4c8;
  --blue: #1f56a0;
  --blue-soft: #e8eef8;
  --green: #40ad36;
  --green-text: #2b7a23;
  --green-badge: #2b8224;
  --green-soft: #e8f5e7;
  --red: #c23434;
  --red-soft: #fbeaea;
  --grey: #f2f4f8;
  --grey-shade: #e4e8f0;
  --line: #d8dee8;
  --ink: #242a33;
  --muted: #626a77;
  --surface: #ffffff;
  --font: "Lato", system-ui, -apple-system, "Segoe UI", sans-serif;
  --sidebar: 220px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--grey);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
}

a { color: var(--blue); }
a:hover { color: var(--navy); }
h1 { font-size: 28px; margin: 0 0 8px; }
h2 { font-size: 20px; margin: 0 0 8px; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
svg.icon-fill { fill: currentColor; stroke: none; }

.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons: Receipt Runner's hard shadow. */
.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  background: var(--blue);
  box-shadow: 0 4px 0 var(--navy);
  color: #ffffff;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.button:hover { color: #ffffff; background: #1a4b8c; }
.button:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--navy); }
.button--secondary, .button--outline { background: var(--surface); color: var(--blue); border: 1px solid #cfd6e6; box-shadow: 0 3px 0 #cfd6e6; font-weight: 400; }
.button--secondary:hover, .button--outline:hover { background: var(--surface); color: var(--navy); }
.button--card { padding: 7px 14px; background: var(--surface); color: var(--blue); border: 1px solid var(--surface); box-shadow: 0 2px 0 #cfd6e6; font-weight: 400; font-size: 15px; }
.button--card:hover { background: var(--surface); color: var(--navy); }
.button--choice { width: 100%; justify-content: center; padding: 9px 8px; background: var(--surface); color: var(--blue); border: 1px solid #cfd6e6; box-shadow: 0 2px 0 #cfd6e6; font-weight: 700; font-size: 14px; }
.button--choice:hover { background: var(--blue-soft); color: var(--navy); }
.button--choice.is-selected { background: var(--blue); color: #ffffff; border-color: var(--blue); box-shadow: 0 2px 0 var(--navy); }
.button--choice:disabled { opacity: 0.45; cursor: default; }
.button--small { padding: 6px 12px; font-size: 14px; box-shadow: 0 2px 0 var(--navy); }

.link-button { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; padding: 0; color: var(--blue); font: inherit; cursor: pointer; text-align: left; }
.link-button:hover { color: var(--navy); }
form.button_to { display: inline; }

.flash { padding: 10px 16px; background: var(--blue-soft); color: var(--navy); border-bottom: 1px solid var(--line); }
.flash--alert { background: var(--red-soft); color: var(--red); }

/* The app: navy sidebar, everything else beside it. */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); height: 100vh; }
.app__main { overflow-y: auto; padding: 32px 40px; }
.app__main:has(.review) { display: flex; flex-direction: column; padding: 0; overflow: hidden; }

.sidebar { display: flex; flex-direction: column; background: var(--navy); color: #ffffff; overflow-y: auto; }
.sidebar__logo { display: block; padding: 22px 20px 0; }
.sidebar__logo img { display: block; width: 172px; height: auto; }
.sidebar__search { position: relative; display: block; margin: 28px 16px 0; }
.sidebar__search input { width: 100%; height: 38px; padding: 0 36px 0 12px; border: none; border-radius: 0; font: inherit; color: var(--ink); background: #ffffff; }
.sidebar__search svg { position: absolute; right: 10px; top: 11px; color: var(--ink); }
.sidebar__heading { margin: 0; padding: 32px 20px 10px; font-style: italic; color: var(--navy-muted); border-bottom: 1px solid var(--navy-line); }
.sidebar__account { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px 20px; border-bottom: 1px solid var(--navy-line); }
.sidebar__account.is-current { background: #c4cbd5; color: var(--navy); }
.sidebar__account-name { font-size: 18px; }
.sidebar__account--other { width: 100%; border: none; border-bottom: 1px solid var(--navy-line); background: none; color: #ffffff; font: inherit; font-size: 18px; text-align: left; cursor: pointer; }
.sidebar__account--other:hover { background: #1a3560; }
.sidebar .button_to { display: block; }
.sidebar__account .button_to { display: inline; }
.sidebar__add { display: inline-flex; align-items: center; gap: 8px; padding: 16px 20px; color: var(--navy-muted); font-size: 18px; text-decoration: none; }
.sidebar__add:hover { color: #ffffff; }
.sidebar__link { display: inline-flex; align-items: center; gap: 8px; padding: 0; border: none; background: none; color: inherit; font: inherit; text-decoration: none; cursor: pointer; }
.sidebar__link:hover { color: var(--blue); }
.sidebar__footer { margin-top: auto; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 0 20px 20px; font-size: 13px; }
.sidebar__footer .sidebar__heading { padding: 24px 0 6px; margin-bottom: 4px; width: 100%; font-size: 14px; }
.sidebar__mailbox { color: #ffffff; overflow-wrap: anywhere; }
.sidebar__quiet-link { padding: 0; border: none; background: none; color: var(--navy-muted); font: inherit; text-decoration: none; cursor: pointer; }
.sidebar__quiet-link:hover { color: #ffffff; }

/* The period ("Find receipts for:") and its picker. */
.period { position: relative; border-bottom: 1px solid var(--navy-line); }
.period__current { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 2px 10px; padding: 16px 20px; font-size: 18px; line-height: 1.3; cursor: pointer; list-style: none; }
.period__current::-webkit-details-marker { display: none; }
.period__current svg { width: 20px; height: 20px; stroke-width: 1.8; margin-bottom: 3px; }
.period__term { grid-column: 1 / -1; font-size: 13px; opacity: 0.8; }
.period[open] .period__current { background: #c4cbd5; color: var(--navy); }
.period__popover { position: fixed; left: calc(var(--sidebar) + 12px); top: 150px; z-index: 10; display: flex; width: 640px; padding: 24px 0; background: var(--surface); color: var(--ink); box-shadow: 0 8px 30px rgba(14, 39, 73, 0.28); }
.period__quick { width: 236px; padding: 0 24px; border-right: 1px solid var(--grey-shade); }
.period__custom { flex: 1; padding: 0 24px; }
.period__title { font-size: 16px; }
.period__choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.period__choices .button_to { display: block; }
.period__form { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.period__form label { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.period__form input { padding: 7px 10px; border: 1px solid #cfd6e6; font: inherit; color: var(--ink); }
.period__hint { font-size: 13px; color: var(--muted); }

/* Review: the period's purchases in the middle, the chosen purchase on the right. */
.review { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(420px, 46%) minmax(0, 1fr); }
.review__list { overflow-y: auto; background: var(--grey); border-right: 1px solid var(--line); padding-bottom: 40px; }
.review__detail { display: block; overflow-y: auto; background: var(--surface); }
.review__detail[busy] { opacity: 0.6; transition: opacity 0.15s 0.1s; }
.review__empty { padding: 40px; color: var(--muted); }

.list__title { padding: 12px 24px; text-align: center; background: #eceff4; border-bottom: 1px solid var(--grey-shade); }
.list__status { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; padding: 16px 24px; background: #f7f8fb; border-bottom: 1px solid var(--grey-shade); }
.list__status em { color: #4c5563; }
.list__done { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 24px 32px 36px; text-align: center; background: #e6eaf2; border-bottom: 1px solid var(--line); }
.list__done img { width: 260px; height: auto; }
.list__done h2 { color: #3d4552; line-height: 1.35; }
.list__group-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 6px 14px; padding: 18px 24px; border-bottom: 1px solid var(--grey-shade); background: #eceff4; font-weight: 700; cursor: pointer; list-style: none; }
.list__group-summary::-webkit-details-marker { display: none; }
.list__group--none .list__group-summary, .list__group--ignored .list__group-summary { background: #f7f8fb; font-weight: 400; font-style: italic; color: #4c5563; }
.list__show { color: var(--blue); font-style: normal; }
.list__group[open] .list__show { display: none; }
.list__row { display: flex; align-items: center; gap: 16px; padding: 14px 20px 14px 24px; border-bottom: 1px solid var(--grey-shade); color: var(--ink); text-decoration: none; }
.list__row:hover { background: #f9fafc; color: var(--ink); }
.list__row.is-current { background: var(--surface); box-shadow: inset 4px 0 0 var(--blue); }
.list__row[hidden] { display: none; }
.list__group--done .list__row { color: var(--muted); }
.list__date { width: 110px; flex-shrink: 0; white-space: nowrap; }
.list__text { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list__row.is-current .list__text { white-space: normal; }
.list__amount { flex-shrink: 0; white-space: nowrap; }

.badge { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex-shrink: 0; border-radius: 14px; font-size: 14px; font-weight: 700; }
.badge--ready, .badge--done { background: var(--green-badge); color: #ffffff; }
.badge--strong { background: var(--blue-soft); color: var(--blue); border: 1px solid #bcd0ec; }
.badge--unsure { background: #fff4e0; color: #8a5a00; border: 1px solid #f0d49c; }
.badge--none, .badge--ignored, .badge--unsearched { background: var(--grey-shade); color: var(--muted); }

/* The chosen purchase. */
.purchase { padding: 28px 36px 40px; }
.purchase__header { padding-bottom: 18px; margin-bottom: 20px; border-bottom: 1px solid var(--grey-shade); }
.purchase__title { margin: 0 0 8px; font-size: 18px; line-height: 1.35; }
.purchase__facts { display: flex; gap: 36px; margin: 0; font-size: 17px; }
.purchase__lead { margin: 0 0 14px; }
.purchase__receipts { display: flex; flex-direction: column; gap: 14px; }
.purchase__others, .purchase__ignored { display: flex; flex-direction: column; gap: 14px; }
.purchase__others > summary, .purchase__ignored > summary { list-style: none; }
.purchase__others[open] > summary { margin-bottom: 14px; }
.purchase__ignored ul { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; font-size: 15px; }
.purchase__ignored li { display: flex; justify-content: space-between; gap: 12px; }
.purchase__help { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-top: 36px; }
.purchase__question { margin: 12px 0 0; font-size: 16px; font-weight: 400; }
.purchase__search { width: 100%; max-width: 440px; }
.search-field { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid #cfd6e6; background: var(--surface); color: var(--blue); }
.search-field input { flex: 1; border: none; outline: none; font: inherit; color: var(--ink); }
.purchase__nav { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin-top: 36px; }
.purchase__keys { margin-top: 20px; font-size: 13px; }

/* A receipt card: the email, what it matched, and a thumbnail. */
.receipt { display: grid; grid-template-columns: minmax(0, 1fr) 120px; gap: 8px 18px; padding: 18px 18px 18px 22px; background: #f7f8fb; border-left: 5px solid #cfd6e6; }
.receipt--attached { background: var(--green-soft); border-left-color: var(--green); }
.receipt__main { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.receipt__subject { margin: 0; font-size: 17px; line-height: 1.35; overflow-wrap: anywhere; }
.receipt__meta { margin: 0; font-size: 14px; color: #4c5563; overflow-wrap: anywhere; }
.receipt__matches { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; margin: 0; font-size: 15px; }
.receipt__matches em { color: var(--muted); }
.match { display: inline-flex; align-items: center; gap: 5px; }
.match--found { color: var(--green-text); }
.match--missing { color: var(--red); }
.receipt__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin-top: 6px; font-size: 15px; }
.receipt__thumbnail { position: relative; width: 120px; height: 156px; overflow: hidden; background: var(--surface); border: 1px solid #cfd6e6; box-shadow: 0 2px 6px rgba(14, 39, 73, 0.12); }
.receipt__thumbnail iframe { width: 600px; height: 780px; border: 0; transform: scale(0.2); transform-origin: 0 0; pointer-events: none; }
.receipt__pdf { position: absolute; left: 6px; bottom: 6px; padding: 1px 5px; background: var(--red); color: #ffffff; font-size: 10px; font-weight: 900; }
.receipt__email { grid-column: 1 / -1; }

.email { border: 1px solid var(--line); background: var(--surface); }
.email__header { padding: 12px 16px; border-bottom: 1px solid var(--grey-shade); font-size: 14px; }
.email__subject { font-size: 16px; margin: 0 0 4px; }
.email__attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.email__body { display: block; width: 100%; height: 600px; border: 0; }
.email__pdf { display: block; width: 100%; height: 760px; border: 0; border-top: 1px solid var(--grey-shade); }
.file-link { padding: 3px 10px; border: 1px solid #cfd6e6; background: var(--grey); font-size: 13px; text-decoration: none; }

/* Settings pages and signing in. */
.signed-out { max-width: 420px; margin: 0 auto; padding: 48px 24px; }
.signed-out__logo { display: block; width: 220px; margin: 0 auto 32px; padding: 16px; background: var(--navy); }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.actions, .company-list { display: flex; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.empty-state { max-width: 560px; margin: 40px auto; padding: 32px; text-align: center; background: var(--surface); }
.empty-state__illustration { width: 280px; height: auto; }
.steps { padding-left: 20px; }
.steps li { margin-bottom: 6px; }

.tabs { display: flex; gap: 4px; margin: 8px 0 20px; border-bottom: 1px solid var(--line); }
.tab { padding: 8px 12px; color: var(--muted); text-decoration: none; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab--active { color: var(--ink); border-bottom-color: var(--blue); font-weight: 700; }

.month { margin-bottom: 28px; }
.month__title { text-transform: capitalize; }
.purchases { width: 100%; border-collapse: collapse; background: var(--surface); }
.purchases td { padding: 10px 14px; border-bottom: 1px solid var(--grey-shade); vertical-align: top; }
.purchases__date { width: 80px; color: var(--muted); font-size: 14px; }
.purchases__supplier .muted { display: block; font-size: 14px; }
.purchases__amount, .purchases__original { text-align: right; white-space: nowrap; font-size: 14px; }
.purchases__original { color: var(--muted); }
.purchases__status { width: 150px; text-align: right; }

.chip { display: inline-block; padding: 2px 9px; border-radius: 999px; background: var(--grey-shade); font-size: 12px; }
.chip--needed { background: #fff4e0; color: #8a5a00; font-weight: 700; }

form input[type="email"], form input[type="password"], form input[type="text"] {
  width: 100%;
  max-width: 360px;
  padding: 9px 12px;
  margin-bottom: 10px;
  border: 1px solid #cfd6e6;
  font: inherit;
}

/* Settings: one page, a section each for the company, email, Folio and Fiken. */
.settings { max-width: 760px; }
.settings__header { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 8px; }
.settings__nav { display: flex; gap: 18px; }
.settings__section { padding: 28px 0; border-top: 1px solid var(--line); scroll-margin-top: 16px; }
.settings__section h2 { font-size: 22px; }
.settings__form { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; margin: 16px 0; }
.settings__form label { display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 420px; }
.settings__form input[type="text"], .settings__form select { width: 100%; padding: 9px 12px; margin: 0; border: 1px solid #cfd6e6; background: var(--surface); font: inherit; }
.settings__list { list-style: none; margin: 16px 0; padding: 0; background: var(--surface); }
.settings__list li { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--grey-shade); }
.settings__item-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.settings__replace { margin-top: 20px; }
.settings__replace > summary { list-style: none; }
.chip--ok { background: var(--green-soft); color: var(--green-text); font-weight: 700; }

/* The steps to make a Folio API key, with small copies of what to look for in Folio. */
.guide { list-style: none; counter-reset: step; margin: 20px 0 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.guide__step { position: relative; padding: 18px 20px 18px 64px; background: var(--surface); counter-increment: step; }
.guide__step::before { content: counter(step); position: absolute; left: 18px; top: 16px; width: 30px; height: 30px; border-radius: 15px; background: var(--blue); color: #ffffff; font-weight: 900; display: flex; align-items: center; justify-content: center; }
.guide__step h3 { margin: 4px 0 10px; font-size: 17px; }
.guide__step p { margin: 8px 0 0; }
.guide__form { display: flex; flex-wrap: wrap; gap: 10px; }
.guide__form input[type="password"] { flex: 1; min-width: 240px; padding: 10px 12px; margin: 0; border: 1px solid #cfd6e6; font: inherit; }
.folio-button { display: inline-block; padding: 10px 18px; border-radius: 8px; background: #5a3fdc; box-shadow: 0 3px 0 #3b2a91; color: #ffffff; font-size: 15px; }
.folio-choices { display: flex; flex-direction: column; gap: 8px; }
.folio-choice { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.folio-choice::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 1px solid #9a95ad; box-sizing: border-box; }
.folio-choice.is-chosen { font-weight: 700; }
.folio-choice.is-chosen::before { border: 5px solid #5a3fdc; }
.folio-choice.is-never { color: var(--muted); text-decoration: line-through; }
.folio-field { display: inline-block; min-width: 260px; padding: 9px 14px; border: 2px solid #5a3fdc; border-radius: 8px; font-size: 15px; }
.purchase__upload { display: flex; align-items: center; flex-wrap: wrap; gap: 14px; margin: 4px 0 8px; }
.badge--uploading { background: var(--blue-soft); color: var(--blue); }
.badge--failed { background: var(--red); color: #ffffff; }
.list__group--failed .list__group-summary { background: var(--red-soft); color: var(--red); }
