:root {
  --bg: #F4F5F2; --panel: #FAFBF8; --surface: #FFFFFF; --ink: #15171C; --ink-2: #3B4049; --muted: #5A606B;
  --line: #E2E4DF; --line-2: #ECEEE9; --input: #D5DAD2;
  --green: #17694F; --green-d: #0F4C39; --green-s: #E3F1EB; --green-s2: #F2F8F5;
  --amber: #8A4A05; --amber-s: #FBEEDD; --blue: #1F4A8F; --blue-s: #E6EEFA;
  --red: #8F1F18; --red-s: #FBE7E5; --rust: #B4532A; --purple: #5B3593; --purple-s: #EEE8F7;
  --display: 'Bricolage Grotesque', system-ui, sans-serif; --body: 'IBM Plex Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--body); font-size: 14px; line-height: 1.45; }
a { color: var(--green); } a:hover { color: var(--green-d); }
h1, h2, h3 { font-family: var(--display); margin: 0; }
h1 { font-size: 30px; } h2 { font-size: 18px; } h3 { font-size: 16px; }
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side { flex: 1 1 220px; max-width: 260px; padding: 24px 16px; display: flex; flex-direction: column; gap: 4px;
        border-right: 1px solid var(--line); background: var(--panel); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 12px 20px; font-family: var(--display); font-weight: 700; font-size: 20px; color: var(--ink); text-decoration: none; }
.nav { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; color: var(--ink-2); text-decoration: none; font-weight: 500; min-height: 40px; }
.nav:hover { background: var(--line-2); color: var(--ink); }
.nav.on { background: var(--green-s); color: var(--green-d); }
.nav .chip { margin-left: auto; }
.budget { margin-top: auto; padding: 14px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.main { flex: 999 1 560px; min-width: 0; padding: 28px 36px 64px; display: flex; flex-direction: column; gap: 22px; max-width: 1280px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 20px; }
.row { display: flex; flex-wrap: wrap; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.between { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi .v { font-family: var(--mono); font-weight: 500; font-size: 32px; }
.lbl, .muted { color: var(--muted); font-size: 13px; }
.num { font-family: var(--mono); font-weight: 500; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; background: var(--line-2); color: var(--ink-2); }
.chip.green { background: var(--green-s); color: var(--green-d); } .chip.amber { background: var(--amber-s); color: var(--amber); }
.chip.blue { background: var(--blue-s); color: var(--blue); } .chip.red { background: var(--red-s); color: var(--red); }
.chip.purple { background: var(--purple-s); color: var(--purple); } .chip.solid { background: var(--green); color: #fff; }
.btn { font: inherit; font-weight: 600; font-size: 14px; border-radius: 10px; padding: 10px 16px; min-height: 42px; border: 1px solid var(--input); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { border-color: var(--muted); color: var(--ink); }
.btn.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn.primary { background: var(--green); color: #fff; border-color: var(--green); }
.btn.primary:hover { background: var(--green-d); color: #fff; }
.btn.small { padding: 6px 10px; min-height: 32px; font-size: 13px; }
form.inline { display: inline; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=url], input:not([type]), textarea, select {
  font-family: inherit; font-weight: 400; font-size: 14px; color: var(--ink); border: 1px solid var(--input); border-radius: 10px; padding: 10px 12px; background: var(--surface); min-height: 42px; width: 100%; }
textarea { resize: vertical; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.choice:has(input:checked) { border: 1.5px solid var(--green); background: var(--green-s2); }
.choice input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--green); }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar { display: grid; grid-template-columns: 150px 1fr 56px; gap: 12px; align-items: center; }
.track { height: 12px; border-radius: 6px; background: var(--line-2); overflow: hidden; }
.fill { height: 100%; border-radius: 6px; background: var(--green); }
.fill.rust { background: var(--rust); }
.alert { display: flex; gap: 12px; padding: 12px; border-radius: 10px; background: var(--bg); text-decoration: none; color: var(--ink); }
.alert.green { background: var(--green-s); } .alert.amber { background: var(--amber-s); } .alert.purple { background: var(--purple-s); }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 600; padding: 12px 10px; white-space: nowrap; }
td { padding: 12px 10px; border-top: 1px solid var(--line-2); vertical-align: top; }
td a { font-weight: 600; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; }
.filters a { font-size: 13px; font-weight: 600; border: 1px solid var(--input); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 7px 14px; text-decoration: none; }
.filters a.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.cv { font-size: 14px; line-height: 1.6; }
.cv h4 { margin: 14px 0 4px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.cv ul { margin: 4px 0; padding-left: 18px; }
ins { background: #DDF0E6; color: var(--green-d); text-decoration: none; border-radius: 3px; padding: 0 2px; }
del { background: var(--red-s); color: var(--red); border-radius: 3px; padding: 0 2px; }
.letter { white-space: pre-wrap; font-size: 14px; line-height: 1.6; }
.actionbar { position: sticky; bottom: 16px; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; align-items: center; padding: 12px 16px; border-radius: 14px; background: var(--ink); color: #fff; }
.actionbar .btn { background: transparent; color: #fff; border-color: #5A606B; }
.actionbar .btn.go { background: #3DBE8B; color: #0B2A1F; border-color: #3DBE8B; }
.queue a { display: flex; flex-direction: column; gap: 4px; padding: 12px; border-radius: 10px; color: var(--ink); text-decoration: none; border: 1px solid transparent; }
.queue a:hover { background: var(--line-2); }
.queue a.on { background: var(--surface); border-color: var(--green); }
.notice { padding: 12px 16px; border-radius: 10px; background: var(--blue-s); color: var(--blue); font-size: 13px; }
.notice.warn { background: var(--amber-s); color: var(--amber); }
.dark-card { background: var(--ink); color: #fff; border-color: var(--ink); }
.dark-card strong { color: #8FD9B6; }
details summary { cursor: pointer; font-weight: 600; }
.tabs { display: flex; gap: 22px; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 2px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--ink); }
@media (max-width: 720px) { .main { padding: 20px 16px 48px; } .side { max-width: none; flex-basis: 100%; } .bar { grid-template-columns: 110px 1fr 44px; } }
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth .card { width: 100%; max-width: 420px; padding: 32px; display: flex; flex-direction: column; gap: 16px; }
.auth .brand { padding: 0; }
.error { padding: 10px 14px; border-radius: 10px; background: var(--red-s); color: var(--red); font-size: 13px; }
.success { padding: 10px 14px; border-radius: 10px; background: var(--green-s); color: var(--green-d); font-size: 13px; }
.danger { border-color: #EBC2BE; }
.btn.danger-btn { color: var(--red); border-color: #EBC2BE; }
.btn.danger-btn:hover { background: var(--red-s); color: var(--red); }
code.temp { font-family: var(--mono); font-size: 15px; background: var(--surface); padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); user-select: all; }

/* ---------- Form controls & buttons (one consistent system) ---------- */
:root { --focus: 0 0 0 3px rgba(23, 105, 79, .25); }

/* Buttons: states */
.btn { transition: background-color .12s, border-color .12s, color .12s, box-shadow .12s; white-space: nowrap; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:focus-visible, button:focus-visible, summary:focus-visible, a:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 10px; }
.btn.dark:hover { background: #2A2E36; color: #fff; }
.btn:disabled, .btn[aria-disabled=true] { opacity: .5; cursor: not-allowed; transform: none; }
.actionbar .btn:hover:not(:disabled) { border-color: #9AA0A8; }
.actionbar .btn.go:hover:not(:disabled) { background: #5BD3A2; border-color: #5BD3A2; }
.actionbar .btn:focus-visible { box-shadow: 0 0 0 3px rgba(61, 190, 139, .45); }

/* Text inputs, selects, textareas: states */
input[type=text], input[type=password], input[type=email], input[type=number], input[type=url], input[type=search],
input:not([type]), textarea, select { transition: border-color .12s, box-shadow .12s; }
input[type=search] { font-family: inherit; font-weight: 400; font-size: 14px; color: var(--ink); border: 1px solid var(--input); border-radius: 10px; padding: 10px 12px; background: var(--surface); min-height: 42px; width: 100%; }
input:hover:not(:disabled):not([type=checkbox]):not([type=radio]):not([type=file]), textarea:hover:not(:disabled), select:hover:not(:disabled) { border-color: #A9AFA6; }
input:focus:not([type=checkbox]):not([type=radio]):not([type=file]), textarea:focus, select:focus { outline: none; border-color: var(--green); box-shadow: var(--focus); }
input::placeholder, textarea::placeholder { color: #8A9099; }
input:disabled, textarea:disabled, select:disabled { background: var(--bg); color: var(--muted); cursor: not-allowed; }
input:user-invalid:not([type=checkbox]):not([type=radio]), textarea:user-invalid { border-color: #C9554C; }
input:user-invalid:focus, textarea:user-invalid:focus { box-shadow: 0 0 0 3px rgba(201, 85, 76, .2); }
textarea { min-height: 84px; line-height: 1.5; }

/* Select: custom chevron */
select { appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%235A606B' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
select.compact { min-height: 34px; padding: 4px 32px 4px 10px; width: auto; font-size: 13px; background-position: right 10px center; }

/* Checkboxes & radios */
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; margin: 0; accent-color: var(--green); cursor: pointer; flex: none; }
input[type=checkbox]:focus-visible, input[type=radio]:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 4px; }
input[type=radio]:focus-visible { border-radius: 50%; }
.check { display: inline-flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.choice input { margin-top: 2px; }
.choice:hover { border-color: #A9AFA6; }
.choice:focus-within { box-shadow: var(--focus); }

/* File picker: a drop-zone style field with a real button */
input[type=file] { font-family: inherit; font-weight: 400; font-size: 14px; color: var(--muted); width: 100%; cursor: pointer;
  border: 1.5px dashed #A9C9BA; border-radius: 12px; background: var(--green-s2); padding: 12px; min-height: 64px; }
input[type=file]:hover { border-color: var(--green); }
input[type=file]:focus-visible { outline: none; border-color: var(--green); box-shadow: var(--focus); }
input[type=file]::file-selector-button { font: inherit; font-weight: 600; font-size: 14px; color: #fff; background: var(--green);
  border: 0; border-radius: 10px; padding: 10px 16px; margin-right: 14px; cursor: pointer; transition: background-color .12s; }
input[type=file]::file-selector-button:hover { background: var(--green-d); }
.hint { font-size: 12px; font-weight: 400; color: var(--muted); }

/* Chips used as buttons, and <summary> used as a button */
button.chip { font: inherit; font-size: 12px; font-weight: 600; border: 0; cursor: pointer; }
button.chip:hover { filter: brightness(.96); }
summary { list-style: none; }
summary::-webkit-details-marker { display: none; }
details > summary:not(.btn)::before { content: "▸"; display: inline-block; margin-right: 6px; transition: transform .12s; color: var(--muted); }
details[open] > summary:not(.btn)::before { transform: rotate(90deg); }

/* ---------- Connect your email ---------- */
.mailbox-card { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.mailbox-icon { width: 40px; height: 40px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line); display: grid; place-items: center; color: var(--ink-2); flex: none; }
.mail-setup { border-top: 1px solid var(--line-2); padding-top: 14px; }
.setup-summary { font-weight: 600; color: var(--green); }
.google-option { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; justify-content: space-between; padding: 18px; border: 1.5px solid var(--green); border-radius: 12px; background: var(--green-s2); }
.btn.google-btn { background: #fff; border-color: #C6CCC3; color: #1F1F1F; padding: 11px 18px; }
.btn.google-btn:hover { border-color: #8A9099; background: #FAFAFA; }
.or-divider { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.step-title { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-weight: 700; font-size: 16px; color: var(--ink); padding: 0; }
.step-num { width: 26px; height: 26px; border-radius: 13px; background: var(--ink); color: #fff; font-family: var(--body); font-size: 13px; display: inline-grid; place-items: center; flex: none; }
.provider-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.provider-tile { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600; min-height: 46px; }
.provider-tile:hover { border-color: #A9AFA6; }
.provider-tile:has(input:checked) { border: 1.5px solid var(--green); background: var(--green-s2); }
.provider-tile:focus-within { box-shadow: var(--focus); }
.guide { display: none; padding: 14px 16px; border-radius: 10px; background: var(--bg); }
.guide ol { margin: 0 0 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; line-height: 1.5; }
.mail-form:has(input[value=gmail]:checked) .guide-gmail,
.mail-form:has(input[value=icloud]:checked) .guide-icloud,
.mail-form:has(input[value=yahoo]:checked) .guide-yahoo,
.mail-form:has(input[value=proton]:checked) .guide-proton,
.mail-form:has(input[value=outlook]:checked) .guide-outlook,
.mail-form:has(input[value=other]:checked) .guide-other { display: block; }
.mail-form:has(input[value=outlook]:checked) .paste-step { display: none; }
.mail-form:has(input[value=outlook]:checked) .guide-outlook { background: var(--amber-s); color: var(--amber); }
.mail-form:has(input[value=other]:checked) .advanced > summary { color: var(--green); }
.advanced > summary { font-size: 13px; color: var(--muted); }

/* ---------- Empty states ---------- */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 14px; padding: 48px 24px; }
.empty-state h2 { font-size: 24px; }
.empty-state > p { max-width: 520px; margin: 0; line-height: 1.55; }
.empty-icon { width: 72px; height: 72px; border-radius: 36px; background: var(--green-s); color: var(--green); display: grid; place-items: center; }
.empty-links { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; width: 100%; max-width: 760px; text-align: left; margin-top: 6px; }
.empty-links .alert { flex-direction: column; gap: 2px; }

/* ---------- Activity ---------- */
.runs { display: flex; flex-direction: column; gap: 2px; padding: 8px; max-height: 75vh; overflow-y: auto; }
.run-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px; border-radius: 10px; color: var(--ink); text-decoration: none; border: 1px solid transparent; }
.run-item:hover { background: var(--line-2); color: var(--ink); }
.run-item.on { background: var(--green-s2); border-color: var(--green); }
.run-dot { width: 10px; height: 10px; border-radius: 5px; margin-top: 5px; flex: none; background: var(--muted); }
.run-dot.running { background: #2A5DB0; box-shadow: 0 0 0 4px rgba(42, 93, 176, .18); animation: pulse 1.4s ease-in-out infinite; }
.run-dot.done { background: var(--green); } .run-dot.failed { background: #C9554C; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px rgba(42, 93, 176, .06); } }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.run-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.run-stats > div { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--bg); }
.run-stats .num { font-size: 18px; }
.log { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; font-size: 13px; }
.log-row { display: grid; grid-template-columns: 70px 92px 1fr; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--line-2); align-items: baseline; }
.log-row:first-child { border-top: 0; }
.log-row time { font-family: var(--mono); color: var(--muted); font-size: 12px; }
.log-row .stage { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.log-row .msg { overflow-wrap: anywhere; }
.log-row.success .msg { color: var(--green-d); font-weight: 500; }
.log-row.warn { background: #FFFBF4; } .log-row.warn .msg { color: var(--amber); }
.log-row.error { background: var(--red-s); } .log-row.error .msg { color: var(--red); font-weight: 500; }
.log-row.debug { background: var(--bg); } .log-row.debug .msg { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.spinner { width: 10px; height: 10px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.live-card .log { border: 0; }
.live-card .log-row { grid-template-columns: 64px 1fr; padding: 6px 0; }
.live-card .log-row .stage { display: none; }
@media (max-width: 720px) { .log-row { grid-template-columns: 60px 1fr; } .log-row .stage { display: none; } }

/* ---------- Pagination ---------- */
.pager { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; font-size: 13px; }
.pager-pages { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.pager-btn { min-width: 36px; min-height: 36px; padding: 0 10px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--input); border-radius: 8px; background: var(--surface); color: var(--ink-2); text-decoration: none; font-weight: 600; }
.pager-btn:hover { border-color: var(--muted); color: var(--ink); }
.pager-btn.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.pager-btn.disabled { opacity: .4; cursor: default; }
.pager-gap { padding: 0 4px; color: var(--muted); }
.filters a .num { opacity: .75; font-weight: 500; margin-left: 2px; }
.proton-only { display: none; }
.mail-form:has(input[value=proton]:checked) .proton-only { display: inline; }

/* ---------- Profile facts ---------- */
.fact-source { display: flex; flex-direction: column; gap: 8px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); }
.facts { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.fact { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 12px 14px; border-top: 1px solid var(--line-2); }
.fact:first-child { border-top: 0; }
.fact.pending { background: #FFFBF4; }
.fact-text { font-weight: 500; }
.fact-edit summary::before { content: none !important; }
.fact-edit summary { display: inline; cursor: pointer; text-decoration: underline; }

/* ---------- Sidebar: fixed to the screen on desktop, account box always visible ---------- */
@media (min-width: 721px) {
  .side { position: sticky; top: 0; height: 100vh; overflow-y: auto; align-self: flex-start; }
}

.kw-card { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; border-radius: 12px; background: var(--green-s2); border: 1px solid #BFE0D2; font-size: 14px; }
.kw-score { font-size: 18px; }

tr.row-highlight td { background: var(--green-s2); }
tr.row-highlight td:first-child { box-shadow: inset 3px 0 0 var(--green); }
