/* ACH Studio — styles */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --surface-3: #f1f4fa;
  --ink: #172033;
  --ink-2: #445066;
  --ink-3: #78849a;
  --ink-4: #98a2b6;
  --line: #e3e8f1;
  --line-2: #d5dce8;
  --accent: #3b5bdb;
  --accent-dark: #2f49b2;
  --accent-soft: #eef1fd;
  --accent-line: #d9e0fb;
  --green: #0f7a58;
  --green-soft: #e7f6f0;
  --red: #c22b42;
  --red-soft: #fdeef1;
  --amber: #9a6503;
  --amber-soft: #fff4dc;
  --violet: #6341b8;
  --violet-soft: #f2edfc;
  --violet-line: #e2d8f8;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", "Roboto Mono", Consolas, monospace;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 8px 24px rgba(23, 32, 51, 0.08);
  --radius: 12px;
}

*,
*::before,
*::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html,
body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea { font: inherit; }

button { color: inherit; }

code {
  font-family: var(--mono);
  font-size: 0.92em;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 4px;
}

::selection { background: #cdd8ff; }

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ------------------------------------------------------------------ *
 * Top bar
 * ------------------------------------------------------------------ */

.topbar {
  position: relative;
  z-index: 30;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  padding: 10px 18px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  min-width: 184px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  color: #fff;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  background: linear-gradient(135deg, #3b5bdb 0%, #6d83f2 100%);
  box-shadow: 0 4px 12px rgba(59, 91, 219, 0.28);
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name { font-size: 14.5px; font-weight: 700; letter-spacing: -0.01em; }
.brand-sub { font-size: 10.5px; color: var(--ink-3); letter-spacing: 0.02em; }

.file-meta {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.file-name {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}

.dirty-dot {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.15);
}

.top-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ------------------------------------------------------------------ *
 * Buttons and menus
 * ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 12px;
  border: 1px solid var(--line-2);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease, box-shadow 0.14s ease;
}

.btn:hover { background: #f7f9ff; border-color: #c9d3ea; }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.2); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; background: var(--surface); }
.btn:disabled:hover { border-color: var(--line-2); }

.btn-accent {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(59, 91, 219, 0.28);
}
.btn-accent:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

.btn-danger {
  color: #fff;
  background: var(--red);
  border-color: var(--red);
}
.btn-danger:hover { background: #a92237; border-color: #a92237; }

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-3);
}
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; color: var(--ink); }

.btn-sm { padding: 6px 10px; font-size: 11.5px; border-radius: 7px; }
.btn-xs { padding: 4px 8px; font-size: 10.5px; border-radius: 6px; }
.btn-lg { padding: 11px 18px; font-size: 13.5px; border-radius: 9px; }
.btn-icon { width: 38px; padding: 8px 0; font-size: 15px; }
.btn .btn-icon { font-size: 13px; line-height: 1; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-3);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }

.linklike {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
}
.linklike:hover { text-decoration: underline; }

.menu-wrap { position: relative; }

.menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 80;
  width: 318px;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(23, 32, 51, 0.18);
  animation: menu-in 0.14s ease-out;
}

.menu-head {
  padding: 6px 10px 7px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.menu-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.menu-check:hover { background: var(--surface-2); }
.menu-check input { margin: 2px 0 0; accent-color: var(--accent); flex: 0 0 auto; }
.menu-check strong { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); }
.menu-check small { display: block; margin-top: 2px; font-size: 11px; line-height: 1.35; color: var(--ink-3); }

.menu-sep { height: 1px; margin: 6px 4px; background: var(--line); }

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ink-2);
}
.menu-row select {
  border: 1px solid var(--line-2);
  border-radius: 6px;
  padding: 5px 7px;
  background: var(--surface);
  font-size: 12px;
  color: var(--ink);
}

.menu-action {
  display: block;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  text-align: left;
  font-size: 12.5px;
  color: var(--ink-2);
  cursor: pointer;
}
.menu-action:hover { background: var(--surface-2); color: var(--ink); }

/* ------------------------------------------------------------------ *
 * Banner
 * ------------------------------------------------------------------ */

.banner {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}

.banner-error { background: #fdf1f3; border-bottom-color: #f4cdd4; color: #7c1c2a; }
.banner-warn { background: #fff8e9; border-bottom-color: #f0ddb4; color: #7a5408; }

.banner-body { display: flex; align-items: center; gap: 10px; min-width: 0; }
.banner-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.55); }
.banner-text { min-width: 0; }
.banner-text strong { display: block; font-size: 12.5px; }
.banner-text span { display: block; margin-top: 1px; opacity: 0.86; font-size: 11.5px; }
.banner-actions { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.banner-actions .btn { background: rgba(255, 255, 255, 0.7); border-color: rgba(23, 32, 51, 0.12); color: inherit; }
.banner-actions .btn:hover { background: #fff; }
.banner-actions .btn-accent { color: #fff; background: var(--accent); border-color: var(--accent); }

/* ------------------------------------------------------------------ *
 * Empty state
 * ------------------------------------------------------------------ */

.empty {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 24px 0;
  background:
    radial-gradient(900px 420px at 50% -160px, #e6ebff 0%, rgba(230, 235, 255, 0) 70%),
    var(--bg);
}

.empty-inner { width: 100%; max-width: 730px; text-align: center; }

.empty-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  border: 1px solid var(--accent-line);
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 23px;
  font-weight: 700;
  box-shadow: 0 10px 24px rgba(59, 91, 219, 0.12);
}

.eyebrow {
  margin: 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
}

.empty h1 {
  margin: 8px 0 14px;
  font-size: clamp(28px, 4.4vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.025em;
  font-weight: 750;
}

.empty-lead {
  max-width: 580px;
  margin: 0 auto;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--ink-3);
}

.empty-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 26px;
  flex-wrap: wrap;
}

.drop-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
  font-size: 11.5px;
  color: var(--ink-4);
}

.drop-key {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border: 1px dashed var(--line-2);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.65);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-3);
}

.restore-host { margin-top: 24px; }

.restore-card {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 620px;
  margin: 0 auto;
  padding: 12px 14px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
}

.restore-icon {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 18px;
}

.restore-body { display: flex; flex-direction: column; min-width: 0; }
.restore-body strong { font-size: 12.5px; }
.restore-body span { margin-top: 2px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.restore-actions { display: flex; gap: 6px; margin-left: auto; flex: 0 0 auto; }

.feature-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 1100px;
  margin: 52px auto 0;
  padding-bottom: 48px;
}

.feature {
  padding: 18px;
  text-align: left;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.feature-num {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.06em;
}
.feature strong { display: block; margin: 7px 0 5px; font-size: 13px; }
.feature p { margin: 0; font-size: 12px; line-height: 1.55; color: var(--ink-3); }

/* ------------------------------------------------------------------ *
 * Workspace and sidebar
 * ------------------------------------------------------------------ */

.workspace {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
}

.sidebar {
  min-height: 0;
  background: #f8faff;
  border-right: 1px solid var(--line);
}

.sidebar-scroll {
  height: 100%;
  overflow-y: auto;
  padding: 16px 14px 34px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.summary-card {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.validation-pill {
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 9.5px;
  letter-spacing: 0.03em;
  text-transform: none;
  white-space: nowrap;
}
.validation-pill.ok { color: var(--green); background: var(--green-soft); }
.validation-pill.warn { color: var(--amber); background: var(--amber-soft); }
.validation-pill.bad { color: var(--red); background: var(--red-soft); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 7px 9px;
  background: var(--surface-2);
  border: 1px solid #eef2f8;
  border-radius: 8px;
}
.stat-wide { grid-column: span 2; }
.stat-label { font-size: 9.5px; font-weight: 600; letter-spacing: 0.055em; text-transform: uppercase; color: var(--ink-4); }
.stat-value { font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-value.mono { font-family: var(--mono); font-size: 12px; font-weight: 600; letter-spacing: 0.02em; }
.stat-value.pos { color: var(--green); }
.stat-value.neg { color: var(--red); }

.summary-foot {
  margin-top: 10px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
  font-size: 10.5px;
  line-height: 1.4;
  color: var(--ink-4);
}

.outline-block { padding: 0 2px; }

.outline-title {
  padding: 0 6px;
  margin-bottom: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-4);
}

.outline { display: flex; flex-direction: column; gap: 1px; }

.outline-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 8px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  text-align: left;
  cursor: pointer;
}
.outline-item:hover { background: #edf2fe; color: var(--accent); }
.outline-text { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.outline-count {
  margin-left: auto;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink-3);
}

.outline-dot,
.map-legend i {
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

.outline-dot.type-1, .map-legend i.type-1 { background: #3b5bdb; }
.outline-dot.type-5, .map-legend i.type-5 { background: #0e7490; }
.outline-dot.type-6, .map-legend i.type-6 { background: #0f7a58; }
.outline-dot.type-7, .map-legend i.type-7 { background: #b7791f; }
.outline-dot.type-9, .map-legend i.type-9 { background: #475569; }
.outline-dot.type-pad { background: #c3ccdd; }

.sidebar-tip {
  padding: 11px 12px;
  background: var(--surface);
  border: 1px dashed var(--line-2);
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-3);
}
.sidebar-tip strong { display: block; margin-bottom: 3px; color: var(--ink-2); }
.sidebar-tip p { margin: 0; }

.auto-badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 5px;
  border: 1px solid var(--violet-line);
  border-radius: 4px;
  background: var(--violet-soft);
  color: var(--violet);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1.5;
}

/* ------------------------------------------------------------------ *
 * Main column
 * ------------------------------------------------------------------ */

.main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg);
  scroll-behavior: smooth;
}

.main-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 18px 22px 46px;
}

.map-panel {
  margin-bottom: 14px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.map-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.map-head h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.map-sub { display: block; margin-top: 2px; font-size: 10.5px; color: var(--ink-4); }

.map-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 10px;
  color: var(--ink-4);
}
.map-legend span { display: inline-flex; align-items: center; gap: 4px; }

.map-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
}

.map-chip {
  width: 23px;
  height: 23px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  color: #fff;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.map-chip:hover { transform: translateY(-1px); box-shadow: 0 3px 8px rgba(23, 32, 51, 0.2); }
.map-chip.type-1 { background: #3b5bdb; }
.map-chip.type-5 { background: #0e7490; }
.map-chip.type-6 { background: #0f7a58; }
.map-chip.type-7 { background: #b7791f; }
.map-chip.type-8 { background: #7c3aed; }
.map-chip.type-9 { background: #475569; }
.map-chip.type-pad { background: #f1f4f9; border-color: #d9e0eb; color: #64748b; }

.map-more { align-self: center; padding: 0 3px; font-size: 10.5px; color: var(--ink-4); }

/* ------------------------------------------------------------------ *
 * Panels / diagnostics
 * ------------------------------------------------------------------ */

.panel {
  margin-bottom: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.panel-head h2 { margin: 0; font-size: 12.5px; font-weight: 700; letter-spacing: 0.01em; }
.panel-sub { display: block; margin-top: 2px; font-size: 10.5px; color: var(--ink-4); }

.diag-counts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.count-badge {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  white-space: nowrap;
}
.count-badge.bad { color: var(--red); background: var(--red-soft); }
.count-badge.warn { color: var(--amber); background: var(--amber-soft); }
.count-badge.ok { color: var(--green); background: var(--green-soft); }

.diag-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
}

.diag-ok {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 14px;
  font-weight: 700;
}
.diag-empty strong { display: block; font-size: 12.5px; color: var(--ink); }
.diag-empty span:not(.diag-ok) { display: block; margin-top: 2px; font-size: 11.5px; color: var(--ink-3); }

.diag-list {
  max-height: 318px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  list-style: none;
}

.diag-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px 9px;
  border-radius: 8px;
}
.diag-item + .diag-item { margin-top: 2px; }
.diag-item.error { background: #fdf4f5; }
.diag-item.warning { background: #fffbf2; }

.diag-mark {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  margin-top: 1px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}
.diag-item.error .diag-mark { background: #f7d6dc; color: var(--red); }
.diag-item.warning .diag-mark { background: #f6e4bc; color: var(--amber); }

.diag-copy { flex: 1 1 auto; min-width: 0; }
.diag-copy p { margin: 0; font-size: 12px; line-height: 1.4; color: var(--ink-2); }
.diag-path { display: block; margin-top: 2px; font-size: 10px; color: var(--ink-4); }

.diag-go {
  flex: 0 0 auto;
  padding: 3px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink-3);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
}
.diag-go:hover { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------------------ *
 * Sections
 * ------------------------------------------------------------------ */

.file-block,
.batch-block { margin-bottom: 22px; scroll-margin-top: 18px; }

.section-head { margin: 0 0 10px 2px; }
.section-kicker {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--accent);
}
.section-head h2,
.batch-head h2 {
  margin: 2px 0 3px;
  font-size: 18px;
  line-height: 1.2;
  letter-spacing: -0.015em;
  font-weight: 700;
}
.section-head p {
  max-width: 820px;
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--ink-3);
}

.batch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  padding: 13px 15px;
  background: linear-gradient(180deg, #ffffff 0%, #f9faff 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.batch-ident { display: flex; align-items: center; gap: 12px; min-width: 0; }
.batch-ident > div { min-width: 0; }
.batch-head h2 { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.batch-head p { margin: 0; font-size: 11px; color: var(--ink-3); }
.batch-num {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
}
.batch-tools { display: flex; align-items: center; gap: 7px; flex: 0 0 auto; }

.entries-block {
  margin: 12px 0 12px 18px;
  padding-left: 16px;
  border-left: 2px solid #e4e9f5;
}

.entries-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
}
.entries-head h3 { margin: 0; font-size: 10.5px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-3); }
.count-pill {
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-family: var(--mono);
  font-size: 9.5px;
  color: var(--ink-3);
}
.entries-note { margin-left: 3px; font-size: 10.5px; color: var(--ink-4); }

.entries-empty {
  padding: 18px;
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line-2);
  border-radius: 10px;
}
.entries-empty p { margin: 0 0 10px; font-size: 12px; color: var(--ink-3); }

.add-batch-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 24px 2px;
  font-size: 11px;
  color: var(--ink-4);
}

/* ------------------------------------------------------------------ *
 * Records
 * ------------------------------------------------------------------ */

.record {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  scroll-margin-top: 18px;
}
.record + .record,
.record + .raw-preview { margin-top: 10px; }
.record-embedded { border-color: #e6ebf4; box-shadow: none; }

.record.flash { animation: flash 1.4s ease-out; }

.record-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 13px;
  background: #fcfdff;
  border-bottom: 1px solid #edf1f7;
}
.record-ident { display: flex; align-items: center; gap: 9px; min-width: 0; }
.record-ident h3 { margin: 0; font-size: 12px; font-weight: 700; letter-spacing: 0.005em; }
.record-meta { display: block; margin-top: 1px; font-size: 10px; color: var(--ink-4); font-variant-numeric: tabular-nums; }
.record-tools { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }

.rec-chip {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  color: #fff;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
}
.rec-chip.type-1 { background: #3b5bdb; }
.rec-chip.type-5 { background: #0e7490; }
.rec-chip.type-6 { background: #0f7a58; }
.rec-chip.type-7 { background: #b7791f; }
.rec-chip.type-8 { background: #7c3aed; }
.rec-chip.type-9 { background: #475569; }

.fields-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px 8px;
  padding: 13px;
}

.field {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px 6px 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.field-wide { grid-column: span 2; }
.field:focus-within { background: #f8faff; border-color: #e1e7f9; }

.field-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.field-head label {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  color: #5e6a7f;
}
.field-tags { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.field-pos {
  padding: 1px 4px;
  border-radius: 3px;
  background: #f5f7fb;
  color: #9aa4b8;
  font-family: var(--mono);
  font-size: 8.5px;
  line-height: 1.5;
}

.input-wrap { position: relative; display: flex; align-items: center; }
.field-input {
  width: 100%;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line-2);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  transition: border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.field-input:hover { border-color: #c4cee0; }
.field-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.13);
  background: #fff;
}
.field-input[readonly] { background: #f7f9fd; border-color: #e8edf6; color: #48546a; cursor: default; }
.field-input[readonly]:focus { box-shadow: 0 0 0 3px rgba(59, 91, 219, 0.08); border-color: #b9c5e5; }
.field-fixed .field-input { color: #6c778c; background: #f8fafd; }
.field-derived .field-input[readonly] { background: #f6f3fd; border-color: #e7e0fa; color: #4c3c88; }
.field-money .field-input { text-align: right; font-variant-numeric: tabular-nums; }
.input-wrap.has-prefix .field-input { padding-left: 17px; }
.money-prefix {
  position: absolute;
  left: 7px;
  z-index: 1;
  color: #8993a7;
  font-family: var(--mono);
  font-size: 11px;
  pointer-events: none;
}

.field-foot { display: flex; flex-direction: column; gap: 2px; min-height: 12px; }
.field-note {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 9.5px;
  line-height: 1.3;
  color: #8b95a8;
}
.field-issue { display: none; font-size: 9.5px; line-height: 1.3; color: var(--red); }

.field.has-error { background: #fff7f8; border-color: #f4d4da; }
.field.has-error .field-input { border-color: #e7a4b0; background: #fffafb; }
.field.has-error .field-issue { display: block; }
.field.has-error .field-note { display: none; }

.field.has-warning { background: #fffbf3; border-color: #f5e5c4; }
.field.has-warning .field-input { border-color: #e6cb93; background: #fffdf8; }
.field.has-warning .field-issue { display: block; color: var(--amber); }
.field.has-warning .field-note { display: none; }

.field-input.input-invalid { border-color: var(--red); background: #fff7f8; box-shadow: 0 0 0 3px rgba(194, 43, 66, 0.12); }

/* ------------------------------------------------------------------ *
 * Entries
 * ------------------------------------------------------------------ */

.entry-block {
  margin-top: 10px;
  padding-left: 10px;
  border-left: 3px solid #e7ecf8;
  scroll-margin-top: 18px;
}
.entry-block:first-of-type { margin-top: 0; }

.entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}
.entry-ident { display: flex; align-items: center; gap: 9px; min-width: 0; }
.entry-ident > div { min-width: 0; }
.entry-num {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
}
.entry-head h4 { margin: 0; font-size: 12.5px; font-weight: 700; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.entry-meta { display: block; margin-top: 1px; font-size: 10.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.entry-meta .pos { color: var(--green); font-weight: 600; }
.entry-meta .neg { color: var(--red); font-weight: 600; }
.entry-tools { display: flex; align-items: center; gap: 5px; flex: 0 0 auto; }

.entry-empty-addenda {
  margin-top: 6px;
  padding: 8px 12px;
  background: #fbfcff;
  border: 1px dashed #e4e9f3;
  border-radius: 8px;
  font-size: 10.5px;
  color: var(--ink-4);
}

/* ------------------------------------------------------------------ *
 * Raw previews
 * ------------------------------------------------------------------ */

.raw-preview {
  padding: 10px 14px 12px;
  background: #0f172a;
  border-top: 1px dashed #263349;
}
.raw-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
  color: #93a2b8;
  font-size: 10px;
}
.raw-preview .btn {
  padding: 3px 7px;
  border-color: #334155;
  background: #1b263a;
  color: #cbd5e1;
  font-size: 9.5px;
}
.raw-preview .btn:hover { background: #263449; border-color: #475569; color: #fff; }
.raw-preview pre {
  margin: 0;
  color: #d8e1ef;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ------------------------------------------------------------------ *
 * Padding and footer
 * ------------------------------------------------------------------ */

.padding-block { margin-top: 2px; }

.padding-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #fbfcff;
  border: 1px dashed var(--line-2);
  border-radius: var(--radius);
}
.pad-glyph {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: #eef2f8;
  color: #64748b;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
}
.padding-copy { flex: 1 1 auto; min-width: 0; }
.padding-copy h2 { margin: 2px 0 3px; font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.padding-copy p { max-width: 700px; margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--ink-3); }
.padding-stats { display: flex; gap: 18px; flex: 0 0 auto; }
.padding-stats span { font-size: 10px; color: var(--ink-4); text-align: right; }
.padding-stats strong { display: block; color: var(--ink-2); font-family: var(--mono); font-size: 14px; }

.main-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--ink-4);
}

/* ------------------------------------------------------------------ *
 * Status bar
 * ------------------------------------------------------------------ */

.statusbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  height: 30px;
  padding: 0 14px;
  background: var(--surface);
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--ink-3);
}
#statusLeft, #statusCenter, #statusRight {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
#statusCenter { text-align: center; font-variant-numeric: tabular-nums; }
#statusRight { text-align: right; }

/* ------------------------------------------------------------------ *
 * Drop overlay
 * ------------------------------------------------------------------ */

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(18, 27, 52, 0.55);
  backdrop-filter: blur(3px);
}
.drop-overlay-inner {
  width: min(560px, 88vw);
  padding: 48px 32px;
  text-align: center;
  border: 2px dashed rgba(255, 255, 255, 0.62);
  border-radius: 22px;
  background: rgba(59, 91, 219, 0.34);
  color: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.25);
}
.drop-big { font-size: 26px; font-weight: 750; letter-spacing: -0.02em; }
.drop-overlay-inner p { margin: 6px 0 0; font-size: 13px; opacity: 0.82; }

/* ------------------------------------------------------------------ *
 * Toasts
 * ------------------------------------------------------------------ */

.toasts {
  position: fixed;
  right: 18px;
  bottom: 44px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.toast {
  max-width: 380px;
  padding: 10px 14px;
  border-left: 3px solid #64748b;
  border-radius: 9px;
  background: #111827;
  color: #f8fafc;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
  animation: toast-in 0.18s ease-out;
  pointer-events: auto;
}
.toast-success { border-left-color: #34d399; }
.toast-warn { border-left-color: #fbbf24; }
.toast-error { border-left-color: #f87171; }
.toast-out { animation: toast-out 0.26s ease-in forwards; }

/* ------------------------------------------------------------------ *
 * Modals
 * ------------------------------------------------------------------ */

body.modal-open { overflow: hidden; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 350;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(2px);
  animation: fade-in 0.14s ease-out;
}

.modal {
  display: flex;
  flex-direction: column;
  width: min(600px, 100%);
  max-height: 90vh;
  overflow: hidden;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 28px 90px rgba(15, 23, 42, 0.38);
  animation: modal-in 0.17s ease-out;
}
.modal-wide { width: min(1040px, 100%); }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 17px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }

.modal-body {
  padding: 16px 17px;
  overflow: auto;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-2);
}
.modal-text { margin: 0; }

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 17px;
  background: #fbfcfe;
  border-top: 1px solid var(--line);
}

.raw-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 10.5px;
  color: var(--ink-3);
}
.raw-note { color: var(--ink-4); }

.raw-full {
  max-height: 60vh;
  margin: 0;
  padding: 14px;
  overflow: auto;
  border-radius: 9px;
  background: #0f172a;
  color: #d8e1ef;
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.65;
  white-space: pre;
  tab-size: 4;
}

/* ------------------------------------------------------------------ *
 * Animation and scrollbars
 * ------------------------------------------------------------------ */

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px); }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(59, 91, 219, 0.45); }
  35% { box-shadow: 0 0 0 5px rgba(59, 91, 219, 0.16); }
  100% { box-shadow: 0 0 0 0 rgba(59, 91, 219, 0); }
}

* { scrollbar-width: thin; scrollbar-color: #cbd4e3 transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccd5e4; border: 3px solid transparent; border-radius: 999px; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #aebbd0; border: 3px solid transparent; background-clip: padding-box; }

/* ------------------------------------------------------------------ *
 * Responsive
 * ------------------------------------------------------------------ */

@media (max-width: 1240px) {
  .fields-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 1020px) {
  .workspace { grid-template-columns: 244px minmax(0, 1fr); }
  .brand { min-width: 150px; }
  .brand-sub { display: none; }
  .fields-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-wide { grid-column: span 2; }
  .top-actions .btn:not(.btn-accent):not(.btn-icon) { padding: 8px 9px; }
}

@media (max-width: 860px) {
  .app { height: 100dvh; }
  .topbar { flex-wrap: wrap; min-height: 0; gap: 8px 12px; }
  .file-meta { order: 3; flex-basis: 100%; }
  .top-actions { margin-left: auto; }
  .brand { min-width: 0; }
  .workspace { display: flex; flex-direction: column; overflow: hidden; }
  .sidebar {
    flex: 0 0 auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-scroll {
    flex-direction: row;
    align-items: stretch;
    gap: 8px;
    padding: 8px 12px;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .summary-card { flex: 0 0 auto; padding: 8px 10px; }
  .summary-head { display: none; }
  .stat-grid { display: flex; align-items: stretch; gap: 6px; }
  .stat { flex: 0 0 auto; min-width: 78px; padding: 5px 7px; }
  .stat-wide { grid-column: auto; min-width: 124px; }
  .stat-label { font-size: 8.5px; }
  .stat-value { font-size: 12px; }
  .stat-value.mono { font-size: 10.5px; }
  .summary-foot { display: none; }
  .outline-block, .sidebar-tip { display: none; }
  .main { flex: 1 1 auto; }
  .main-inner { padding: 14px 14px 40px; }
  .feature-row { grid-template-columns: 1fr; }
  .empty { padding-top: 36px; }
  .batch-head { align-items: flex-start; flex-direction: column; }
  .entries-block { margin-left: 8px; padding-left: 10px; }
  .banner { align-items: flex-start; flex-direction: column; }
  .banner-actions { width: 100%; justify-content: flex-end; }
  .map-legend { display: none; }
}

@media (max-width: 620px) {
  .top-actions .btn span:not(.btn-icon) { display: none; }
  .top-actions .btn { padding: 8px 10px; }
  .btn-text { display: none; }
  .fields-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: span 1; }
  .entry-head { align-items: flex-start; flex-direction: column; }
  .padding-card { align-items: flex-start; flex-wrap: wrap; }
  .padding-stats { width: 100%; justify-content: flex-start; }
  .statusbar { grid-template-columns: 1fr auto; }
  #statusCenter { display: none; }
  .record-head { align-items: flex-start; }
  .record-tools .btn:not(:last-child) { display: none; }
  .toasts { left: 12px; right: 12px; bottom: 40px; align-items: stretch; }
  .toast { max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
