:root {
  --bg: #ffffff;
  --surface: #f5f7f9;
  --text: #1d2226;
  --muted: #5b6670;
  --border: #dde3e8;
  --accent: #066d89;
  --accent-text: #ffffff;
  --good: #1a7f37;
  --good-bg: #e6f4ea;
  --caution: #9a6700;
  --caution-bg: #fff4d6;
  --bad: #c62828;
  --bad-bg: #fdecea;
  --neutral-bg: #eef1f4;
  --retry: #b45309;
  --retry-bg: #fff1e6;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1d2226;
    --surface: #262c31;
    --text: #e8ecef;
    --muted: #9aa5ae;
    --border: #3a4248;
    --accent: #3fb6d4;
    --accent-text: #0b1a20;
    --good: #6fd38b;
    --good-bg: #173322;
    --caution: #f0c25b;
    --caution-bg: #3a2f12;
    --bad: #ff8a80;
    --bad-bg: #3d1d1b;
    --neutral-bg: #2f363b;
    --retry: #f6ad6b;
    --retry-bg: #3b2a1a;
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 "Segoe UI", -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

.bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.bar-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-title.bar-user {
  color: var(--muted);
  font-weight: 400;
}

main {
  padding: 4px 16px 24px;
}

h1 {
  margin: 0 0 8px;
  font-size: 18px;
}

h2 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

.section {
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}

.section:last-child {
  border-bottom: 0;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  display: flex;
  gap: 8px;
}

.row > * {
  flex: 1;
  min-width: 0;
}

.row > button {
  flex: 0 0 auto;
}

.welcome {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 24px 0;
}

.welcome h1 {
  margin: 0;
}

.center {
  padding: 32px 16px;
  text-align: center;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.error {
  margin: 0;
  color: var(--bad);
}

p {
  margin: 0;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  min-height: 32px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

input:focus-visible,
select:focus-visible,
button:focus-visible,
a:focus-visible,
[role="button"]:focus-visible,
[role="option"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button {
  min-height: 32px;
  padding: 5px 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

button.link {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 400;
}

a {
  color: var(--accent);
}

.list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.person {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.person-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.person-text > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-name {
  font-weight: 600;
}

.badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--neutral-bg);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge[data-tone="good"] {
  background: var(--good-bg);
  color: var(--good);
}

.badge[data-tone="caution"] {
  background: var(--caution-bg);
  color: var(--caution);
}

.badge[data-tone="bad"] {
  background: var(--bad-bg);
  color: var(--bad);
}

.badge[data-tone="retry"] {
  background: var(--retry-bg);
  color: var(--retry);
  cursor: pointer;
}

.verdict {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--muted);
  border-radius: 6px;
  background: var(--surface);
}

.verdict[data-tone="good"] {
  border-left-color: var(--good);
}

.verdict[data-tone="caution"] {
  border-left-color: var(--caution);
}

.verdict[data-tone="bad"] {
  border-left-color: var(--bad);
}

.verdict-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.verdict-name {
  font-weight: 600;
}

.sources {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  margin: 0;
  font-size: 12px;
}

.sources dt {
  color: var(--muted);
}

.sources dd {
  margin: 0;
}

.sources dd[data-ok="false"] {
  color: var(--bad);
}

.options {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.options li {
  padding: 6px 8px;
  cursor: pointer;
}

.options li:hover,
.options li:focus {
  background: var(--surface);
}

.rates {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.rates th,
.rates td {
  padding: 4px 6px;
  text-align: right;
  border-bottom: 1px solid var(--border);
}

.rates th:first-child {
  text-align: left;
  color: var(--muted);
  font-weight: 400;
}

.toast {
  position: fixed;
  right: 12px;
  bottom: 12px;
  left: 12px;
  padding: 10px 12px;
  border-radius: 6px;
  background: var(--text);
  color: var(--bg);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
}

.toast[data-tone="bad"] {
  background: var(--bad);
  color: #ffffff;
}

@media (prefers-reduced-motion: no-preference) {
  .toast {
    animation: toast-in 160ms ease-out;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Review sheet: covers the pane while an import is reviewed. */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 8px 10px 16px;
  border-bottom: 1px solid var(--border);
}

.sheet-head h1 {
  margin: 0;
  font-size: 16px;
}

.sheet-body {
  flex: 1;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
  gap: 12px;
}

.sheet-body h2 {
  margin: 4px 0 0;
}

.sheet-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

button.icon {
  min-width: 32px;
  padding: 0;
  border: 0;
  background: none;
  font-size: 20px;
  font-weight: 400;
  line-height: 1;
}

.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0;
  font-size: 13px;
}

.facts dt {
  color: var(--muted);
}

.facts dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.preview {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.doc > * {
  margin-top: 0;
  margin-bottom: 0;
}

.doc > * + * {
  margin-top: 8px;
}

.preview h3,
.preview h4,
.preview h5,
.preview h6 {
  margin-bottom: 0;
  font-size: 14px;
}

.preview h3 {
  font-size: 15px;
}

.preview hr {
  border: 0;
  border-top: 1px solid var(--border);
}

.preview ul,
.preview ol {
  margin-bottom: 0;
  padding-left: 20px;
}

.preview blockquote {
  margin-right: 0;
  margin-left: 0;
  padding-left: 10px;
  border-left: 3px solid var(--border);
  color: var(--muted);
}

.preview pre {
  margin-bottom: 0;
  overflow-x: auto;
  white-space: pre-wrap;
}

.preview code {
  font: 12px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.preview table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: 12px;
}

.preview th,
.preview td {
  padding: 3px 6px;
  border: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.preview img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

.preview.file {
  display: flex;
  align-items: center;
  gap: 12px;
}

.file-type {
  flex: 0 0 auto;
  padding: 10px 6px;
  border-radius: 4px;
  background: var(--neutral-bg);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.nowrap {
  white-space: nowrap;
}
