:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --border: #d8d8d3;
  --text: #1c1c1a;
  --muted: #6a6a65;
  --accent: #8b3a2f;
  --accent-fg: #ffffff;
  --error: #b00020;
  --warn: #8a6d00;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 760px;
  margin: 2rem auto;
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

h1 { margin-top: 0; font-size: 1.4rem; }
h2 { font-size: 1.05rem; margin-bottom: 0.5rem; }

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

label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; }

.combo { position: relative; }

input[type="text"] {
  width: 100%;
  padding: 0.55rem 0.75rem;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white;
  color: var(--text);
}
input[type="text"]:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

.suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
  background: white;
  border: 1px solid var(--border);
  border-radius: 4px;
  max-height: 240px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}
.suggestions li {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.95rem;
}
.suggestions li:hover, .suggestions li.active {
  background: var(--bg);
}
.suggestions .province {
  color: var(--muted);
  font-size: 0.85rem;
  margin-left: 0.4rem;
}

.trip { margin-top: 1.5rem; }
.trip-list {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg);
  min-height: 2.5rem;
}
.trip-list .empty {
  color: var(--muted);
  font-style: italic;
  padding: 0.6rem 0.75rem;
  text-align: center;
}
.trip-list li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.trip-list li:last-child { border-bottom: none; }
.trip-list .index {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  width: 1.5rem;
}
.trip-list .name { flex: 1; }
.trip-list .controls { display: flex; gap: 0.25rem; }

button {
  font: inherit;
  padding: 0.45rem 0.9rem;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary,
#calculate {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
button.icon {
  padding: 0.2rem 0.5rem;
  font-size: 0.85rem;
}
button.link {
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  padding: 0.45rem 0.5rem;
}

.actions { display: flex; gap: 0.5rem; align-items: center; }

.results { margin-top: 2rem; }
.results table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.results th, .results td {
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.results th.num, .results td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.results tfoot th { font-weight: 700; border-bottom: none; padding-top: 0.6rem; }
.results tr.error-leg td { color: var(--error); }
.results tr.error-leg td.num { font-style: italic; }

.error { color: var(--error); margin-top: 1rem; }
.warn { color: var(--warn); margin-top: 0.75rem; font-size: 0.9rem; }
