:root {
  --ink: #1c1914;
  --paper: #efe6d4;
  --paper-2: #e4d8c0;
  --rule: #cbbfa6;
  --sub: #3a6ea5;
  --plant: #c47b17;
  --proj: #2a7f6f;
  --import: #9a3b4a;
  --hq: #1a1a1a;
  --muted: #6b6254;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: #0e1210;
  color: var(--ink);
  font-family: "Source Serif 4", "Noto Serif SC", serif;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 8;
  opacity: 0.07;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='4'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
}

#map, #map-fallback {
  position: fixed;
  inset: 0;
}

#map-fallback {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 8vh 8vw 8vh 380px;
  color: #d9cbb0;
  background:
    radial-gradient(circle at 70% 30%, #1c2a24 0%, transparent 40%),
    linear-gradient(160deg, #121614, #0b0e0c);
}

#map-fallback[hidden] { display: none; }

#map-fallback h1 {
  font-family: "Noto Serif SC", serif;
  font-size: 42px;
  letter-spacing: 0.04em;
  margin: 12px 0 8px;
}

.stamp {
  display: inline-block;
  border: 2px solid #b23a2f;
  color: #b23a2f;
  padding: 4px 10px;
  letter-spacing: 0.18em;
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  transform: rotate(-8deg);
  width: max-content;
}

.ledger {
  position: fixed;
  z-index: 9;
  top: 18px;
  left: 18px;
  bottom: 18px;
  width: 340px;
  background: var(--paper);
  border: 1px solid #b9ad93;
  box-shadow: 8px 10px 0 rgba(0,0,0,.35);
  padding: 22px 20px 18px;
  overflow: auto;
  animation: slide-in 0.6s ease both;
}

@keyframes slide-in {
  from { transform: translateX(-16px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

.ledger-head h1 {
  font-family: "Noto Serif SC", serif;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.kicker {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--muted);
  text-transform: uppercase;
}

.lede {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
  border-bottom: 1px dashed var(--rule);
  padding-bottom: 14px;
}

.search-wrap { margin: 16px 0 18px; position: relative; }
.search-wrap label {
  display: block;
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--muted);
  margin-bottom: 6px;
}

#q {
  width: 100%;
  border: none;
  border-bottom: 2px solid var(--ink);
  background: transparent;
  font: 16px "Noto Serif SC", serif;
  padding: 6px 0;
  color: var(--ink);
  outline: none;
}

.suggest {
  list-style: none;
  position: absolute;
  left: 0; right: 0;
  background: #f7f0e2;
  border: 1px solid var(--rule);
  z-index: 3;
  max-height: 240px;
  overflow: auto;
}

.suggest li {
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}

.suggest li:hover, .suggest li.active { background: #e7d9b8; }
.mono { font-family: "IBM Plex Mono", monospace; font-size: 12px; }

.company-name { font-size: 20px; font-weight: 700; margin-top: 4px; }
.company-meta { display: flex; gap: 10px; color: var(--muted); margin: 4px 0 10px; }
.progress { font-size: 13px; color: #8a4b12; min-height: 1.4em; }

.layers { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip {
  font-size: 12px;
  border: 1px solid var(--rule);
  padding: 4px 8px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #f4ecda;
}
.chip-sub { box-shadow: inset 3px 0 0 var(--sub); }
.chip-plant { box-shadow: inset 3px 0 0 var(--plant); }
.chip-proj { box-shadow: inset 3px 0 0 var(--proj); }
.chip-import { box-shadow: inset 3px 0 0 #9a3b4a; }
.chip.is-off { opacity: 0.45; }
.chip input { accent-color: var(--ink); }
.chip.disabled { pointer-events: none; opacity: 0.35; }

.counts { font-size: 11px; color: var(--muted); margin-bottom: 16px; }

h2 {
  font-size: 12px;
  letter-spacing: 0.18em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.unlist {
  list-style: none;
  font-size: 13px;
  color: #5c5346;
  max-height: 28vh;
  overflow: auto;
}

.unlist li {
  padding: 4px 0;
  border-bottom: 1px dotted var(--rule);
}

.import-panel { margin: 0 0 18px; }
.hint { font-size: 12px; color: var(--muted); line-height: 1.45; margin: 0 0 8px; }
textarea#import-text {
  width: 100%;
  resize: vertical;
  min-height: 90px;
  border: 1px solid var(--rule);
  background: #f7f0e2;
  font: 13px "Noto Serif SC", serif;
  padding: 8px;
  color: var(--ink);
}
.import-actions { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
#import-btn, .file-btn {
  font: 13px "Noto Serif SC", serif;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 5px 10px;
  cursor: pointer;
}
.file-btn { background: transparent; color: var(--ink); position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.info-list { font-size: 13px; max-height: 240px; overflow: auto; }
.info-list div { padding: 3px 0; border-bottom: 1px dotted #ddd; }
