:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --border: #2a2e37;
  --text: #e6e8eb;
  --text-dim: #9aa0ac;
  --accent: #5b8def;
  --danger: #e35d6a;
  --success: #4caf7d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

header {
  padding: 2rem 1.5rem 1rem;
  text-align: center;
}

header h1 {
  margin: 0;
  font-size: 2rem;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-dim);
  margin: 0.25rem 0 0;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
  display: grid;
  gap: 1.5rem;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.hint {
  color: var(--text-dim);
  font-size: 0.85rem;
  margin: 0 0 1rem;
}

.tool-form {
  display: grid;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.tool-form label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.tool-form label.checkbox-label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

input,
select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font-size: 0.95rem;
  font-family: inherit;
}

button {
  background: var(--accent);
  border: none;
  border-radius: 8px;
  color: white;
  padding: 0.6rem 1rem;
  font-size: 0.95rem;
  cursor: pointer;
  justify-self: start;
}

button:hover {
  opacity: 0.9;
}

.result {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.85rem;
  font-size: 0.9rem;
  min-height: 1.2em;
}

.result.error {
  color: var(--danger);
  border-color: var(--danger);
}

/* --- Search/browse (shared by per diem and exchange rates) --- */

.pd-search {
  width: 100%;
  margin-bottom: 0.75rem;
}

.pd-list {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1rem;
  display: grid;
}

.pd-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  justify-self: stretch;
  border-radius: 0;
  background: var(--bg);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.pd-row:last-child {
  border-bottom: none;
}

.pd-row:hover {
  background: #20242d;
}

.pd-row.selected {
  background: var(--accent);
  color: white;
}

.pd-rate {
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}

.pd-row.selected .pd-rate {
  color: rgba(255, 255, 255, 0.85);
}

.pd-list .hint {
  padding: 0.75rem 0.85rem;
  margin: 0;
}

.pd-calc {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.pd-selected {
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
}

/* --- Day counter --- */

.counter {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}

.counter-btn {
  width: 2.4rem;
  height: 2.4rem;
  padding: 0;
  font-size: 1.2rem;
  line-height: 1;
  justify-self: unset;
  flex: none;
}

.counter input[type="number"] {
  width: 4.5rem;
  text-align: center;
  font-size: 1.1rem;
  -moz-appearance: textfield;
}

.counter input[type="number"]::-webkit-inner-spin-button,
.counter input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.counter-label {
  color: var(--text-dim);
  font-size: 0.9rem;
}

.pd-options {
  margin-top: 0.75rem;
}

.pd-options summary {
  cursor: pointer;
  color: var(--accent);
  font-size: 0.85rem;
  user-select: none;
}

.pd-options-body {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.date-range {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.date-range label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* --- Exchange rate converter --- */

.fx-calc {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.fx-amount-row {
  display: flex;
  align-items: flex-end;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.fx-amount-row label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-dim);
}

.fx-amount-row input {
  width: 8rem;
  font-size: 1rem;
}

.fx-amount-row input:disabled {
  opacity: 0.5;
}

.fx-equals {
  color: var(--text-dim);
  padding-bottom: 0.6rem;
}

.source-note {
  color: var(--text-dim);
  font-size: 0.78rem;
  margin: 1rem 0 0;
  line-height: 1.4;
}

.source-note a {
  color: var(--accent);
}

footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 1rem 1.5rem 2rem;
}
