:root {
  --bg: #f0f3f7;
  --card: #fff;
  --text: #152033;
  --muted: #667085;
  --border: #e4e7ec;
  --primary: #2563eb;
  --danger: #c0392b;
  --ok: #027a48;
  --warn-bg: #fff7ed;
  --warn-border: #fdba74;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.08);
  font-family: "PingFang SC", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.25rem 1.5rem 0.75rem;
  max-width: 1280px;
  margin: 0 auto;
}
.top h1 { margin: 0; font-size: 1.4rem; letter-spacing: -0.02em; }
.sub { margin: .3rem 0 0; color: var(--muted); font-size: .88rem; }
.top-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.page { padding: 0 1.5rem 2rem; max-width: 1280px; margin: 0 auto; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem 1.15rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 .55rem; font-size: 1.05rem; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: .4rem; }
.section-head h2 { margin: 0; }
.hint { margin: 0 0 .75rem; color: var(--muted); font-size: .88rem; }
.summary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.25rem;
  align-items: flex-end;
}
.summary-row .label { font-size: .75rem; color: var(--muted); margin-bottom: .2rem; }
.summary-row .value { font-size: .92rem; font-weight: 600; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; font-weight: 500; word-break: break-all; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .15rem .55rem;
  border-radius: 999px;
  font-size: .78rem;
  font-weight: 600;
  background: #eef2ff;
  color: #3730a3;
}
.chip.ok { background: #ecfdf3; color: #027a48; }
.chip.warn { background: #fff7ed; color: #9a3412; }
.chip.err { background: #fef3f2; color: #b42318; }
.adv { margin-top: 1rem; padding-top: .75rem; border-top: 1px dashed var(--border); }
.hidden { display: none !important; }
fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfc;
  margin: 0 0 .85rem;
  padding: .85rem 1rem 1rem;
}
legend { font-weight: 700; padding: 0 .35rem; font-size: .9rem; }
.grid2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .7rem 1rem;
}
label { display: flex; flex-direction: column; gap: .3rem; font-size: .85rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .45rem; color: var(--text); margin-top: 1.2rem; }
label.check.tight { margin-top: 0; white-space: nowrap; }
label.inline { flex-direction: row; align-items: center; gap: .4rem; color: var(--muted); font-size: .85rem; }
input, select, textarea, button { font: inherit; }
input[type="text"], input[type="number"], input[type="search"], select, textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .7rem;
  background: #fff;
  color: var(--text);
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 8px;
  padding: .55rem .9rem;
  cursor: pointer;
  font-weight: 600;
}
button:hover { background: #f9fafb; }
button.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
button.primary:hover { filter: brightness(1.05); }
button.danger { background: var(--danger); color: #fff; border-color: var(--danger); }
button.ghost { background: transparent; }
.row-actions { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.msg { color: var(--ok); font-size: .9rem; }
.msg.err { color: var(--danger); }
.muted { color: var(--muted); font-size: .88rem; }
.folder-row {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
  align-items: center;
}
.folder-row input[type="text"] { flex: 1 1 280px; min-width: 200px; }
.toolbar { display: flex; flex-wrap: wrap; gap: .55rem; align-items: center; margin-bottom: .7rem; }
.spacer { flex: 1 1 auto; }
.table-wrap {
  overflow: auto;
  max-height: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: .55rem .65rem; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
th { background: #f8fafc; position: sticky; top: 0; z-index: 1; }
tr:hover td { background: #f8fafc; }
.badge {
  display: inline-block;
  padding: .1rem .45rem;
  border-radius: 999px;
  font-size: .75rem;
  background: #eef2ff;
  color: #3730a3;
}
.badge.no { background: #fef3f2; color: #b42318; }
.badge.yes { background: #ecfdf3; color: #027a48; }
.tags { color: var(--muted); font-size: .8rem; margin-top: .15rem; }
.empty {
  text-align: center;
  padding: 2.2rem 1rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #fafbfc;
  margin-bottom: .75rem;
}
.empty-title { font-weight: 700; margin-bottom: .35rem; }
.progress {
  height: 10px;
  background: #eef2f6;
  border-radius: 999px;
  overflow: hidden;
  margin: .5rem 0;
}
#progressFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #60a5fa, #2563eb);
  transition: width .2s ease;
}
.summary {
  background: #0b1220;
  color: #e2e8f0;
  padding: .85rem 1rem;
  border-radius: 8px;
  overflow: auto;
  min-height: 3.5rem;
  font-size: .82rem;
}
.foot {
  padding: 1rem 1.5rem 2rem;
  color: var(--muted);
  font-size: .82rem;
  max-width: 1280px;
  margin: 0 auto;
}
#reportLinks a { margin-right: 1rem; }
.toast {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  max-width: 360px;
  padding: .75rem 1rem;
  border-radius: 10px;
  background: #111827;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
  font-size: .9rem;
}
.toast.err { background: #991b1b; }
.toast.ok { background: #065f46; }

.field-help { display:block; font-size:12px; color:#6b7280; margin-top:4px; font-weight:400; }
.hint { color:#4b5563; margin:0 0 12px; line-height:1.5; }

/* editable inventory cells */
td.local-file { max-width: 14rem; }
td.local-file .fname { font-weight: 600; word-break: break-all; }
td.local-file .fpath { color: var(--muted); font-size: .72rem; word-break: break-all; margin-top: .15rem; }
.cell-input {
  width: 100%;
  min-width: 6rem;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: .35rem .45rem;
  background: #f8fafc;
  color: var(--text);
  font: inherit;
}
.cell-input:hover { border-color: var(--border); }
.cell-input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}
.cell-input.dirty { background: #fffbeb; border-color: #f59e0b; }
