:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #4b4b4b;
  --border: #cfcfcf;
  --surface: #f5f5f5;
  --link: #1a4fa0;
  --error-bg: #fdeeee;
  --error-fg: #7a1414;
  --focus: #1a4fa0;

  /* Categorical colours for the four flag types, decorative only (a dot and a
     left border). Identity always comes from the text label and icon too, never
     from colour alone. Chosen for separation under common colour-vision
     deficiencies; see the Door 2 task notes for the source palette. */
  --flag-recurring: #2a78d6;
  --flag-price-increase: #eb6834;
  --flag-duplicate: #1baf7a;
  --flag-unusual: #4a3aa7;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171a;
    --fg: #f0f0f0;
    --muted: #c2c2c2;
    --border: #3a3f44;
    --surface: #1e2227;
    --link: #8ab4f8;
    --error-bg: #3a1a1a;
    --error-fg: #f3b4b4;
    --focus: #8ab4f8;

    --flag-recurring: #3987e5;
    --flag-price-increase: #d95926;
    --flag-duplicate: #199e70;
    --flag-unusual: #9085e9;
  }
}

* {
  box-sizing: border-box;
}

html {
  font-size: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
}

.skip-link:focus {
  left: 8px;
  top: 8px;
  background: var(--surface);
  padding: 0.5em 1em;
  border-radius: 4px;
  z-index: 10;
}

header,
main,
footer {
  max-width: 40rem;
  margin: 0 auto;
  padding: 1rem;
}

h1 {
  font-size: 1.6rem;
  margin-bottom: 0.2rem;
}

.tagline {
  color: var(--muted);
  margin-top: 0;
}

h2 {
  font-size: 1.25rem;
}

section {
  margin-bottom: 2rem;
}

.hint {
  color: var(--muted);
  font-size: 0.95rem;
}

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

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

#drop-zone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 2rem 1rem;
  text-align: center;
  cursor: pointer;
}

#drop-zone.dragover {
  border-color: var(--focus);
  background: var(--surface);
}

.field {
  margin-bottom: 0.9rem;
}

.field label {
  display: inline-block;
  margin-bottom: 0.25rem;
}

input[type="checkbox"],
input[type="radio"] {
  margin-right: 0.4em;
}

select,
input[type="file"] {
  display: block;
  width: 100%;
  max-width: 28rem;
  padding: 0.4em;
  font-size: 1rem;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.9rem;
}

legend {
  font-weight: 600;
}

button {
  font-size: 1rem;
  padding: 0.6em 1.2em;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
}

button:hover {
  border-color: var(--focus);
}

.actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

table#preview-table {
  border-collapse: collapse;
  width: 100%;
  overflow-x: auto;
  display: block;
  margin-bottom: 1rem;
}

table#preview-table th,
table#preview-table td {
  border: 1px solid var(--border);
  padding: 0.35em 0.5em;
  font-size: 0.9rem;
  white-space: nowrap;
}

.error {
  background: var(--error-bg);
  color: var(--error-fg);
  border: 1px solid var(--error-fg);
  border-radius: 6px;
  padding: 0.6em 0.8em;
}

.results-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.flag-card {
  border: 1px solid var(--border);
  border-left: 6px solid var(--fg);
  border-radius: 6px;
  padding: 0.8em 1em;
  margin-bottom: 0.8em;
  background: var(--surface);
}

.flag-card[data-flag-type="recurring"] {
  border-left-color: var(--flag-recurring);
}

.flag-card[data-flag-type="price_increase"] {
  border-left-color: var(--flag-price-increase);
}

.flag-card[data-flag-type="duplicate"] {
  border-left-color: var(--flag-duplicate);
}

.flag-card[data-flag-type="unusual"] {
  border-left-color: var(--flag-unusual);
}

.flag-type-label {
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.flag-type-dot {
  width: 0.7em;
  height: 0.7em;
  border-radius: 50%;
  display: inline-block;
  background: currentColor;
}

.flag-card[data-flag-type="recurring"] .flag-type-label {
  color: var(--flag-recurring);
}

.flag-card[data-flag-type="price_increase"] .flag-type-label {
  color: var(--flag-price-increase);
}

.flag-card[data-flag-type="duplicate"] .flag-type-label {
  color: var(--flag-duplicate);
}

.flag-card[data-flag-type="unusual"] .flag-type-label {
  color: var(--flag-unusual);
}

.flag-reason {
  color: var(--fg);
  margin: 0.4em 0;
}

.flag-yearly-cost dt {
  font-weight: 600;
  float: left;
  margin-right: 0.4em;
}

.flag-feedback {
  border: none;
  padding: 0;
  margin: 0.6em 0 0;
}

.flag-feedback legend {
  font-weight: 400;
  font-size: 0.9rem;
  color: var(--muted);
}

.flag-feedback .field {
  display: inline-block;
  margin-right: 1rem;
  margin-bottom: 0.3rem;
}

@media (max-width: 30rem) {
  header,
  main,
  footer {
    padding: 0.75rem;
  }

  select,
  input[type="file"] {
    max-width: 100%;
  }

  .flag-feedback .field {
    display: block;
  }
}
