:root {
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #647084;
  --line: #d9dee6;
  --brand: #1f513f;
  --brand-ink: #ffffff;
  --accent: #2b6cb0;
  --danger: #b42318;
  --ok: #1f7a4d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.45;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--brand);
  color: var(--brand-ink);
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.6rem 1.25rem;
  flex-wrap: wrap;
}
.topbar a { color: var(--brand-ink); }
.topbar .brand { font-weight: 700; letter-spacing: 0.02em; }
.topbar nav { display: flex; gap: 1rem; }
.topbar .spacer { flex: 1; }
.topbar form { margin: 0; display: flex; gap: 0.4rem; align-items: center; }
.topbar select { padding: 0.25rem 0.4rem; border-radius: 4px; border: 1px solid var(--line); }
.topbar .user { opacity: 0.9; font-size: 0.9rem; }
.topbar button.link {
  background: none; border: 1px solid rgba(255,255,255,0.5); color: var(--brand-ink);
  padding: 0.25rem 0.6rem; border-radius: 4px; cursor: pointer; font: inherit;
}

main { max-width: 64rem; margin: 1.5rem auto; padding: 0 1.25rem; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }

.badge {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px;
  font-size: 0.75rem; background: #eef1f5; color: var(--muted); border: 1px solid var(--line);
}
.badge.ok { background: #e7f4ec; color: var(--ok); border-color: #bfe3cd; }

.login-wrap { max-width: 22rem; margin: 4rem auto; }
.field { margin-bottom: 0.9rem; }
.field label { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.25rem; }
.field input {
  width: 100%; padding: 0.55rem 0.6rem; border: 1px solid var(--line);
  border-radius: 6px; font: inherit;
}
button.primary {
  background: var(--brand); color: var(--brand-ink); border: none;
  padding: 0.6rem 1rem; border-radius: 6px; cursor: pointer; font: inherit; font-weight: 600;
}
button.primary:hover { filter: brightness(1.08); }

.alert { padding: 0.6rem 0.8rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.9rem; }
.alert.error { background: #fdeceb; color: var(--danger); border: 1px solid #f5c6c2; }
.alert.ok { background: #e7f4ec; color: var(--ok); border: 1px solid #bfe3cd; }
.import-form .field input[type="file"] { width: 100%; padding: 0.4rem; border: 1px dashed var(--line); border-radius: 6px; background: #fafbfc; }
.product-detail { display: flex; gap: 1.25rem; align-items: flex-start; flex-wrap: wrap; }
.product-image { max-width: 280px; max-height: 280px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.product-desc { flex: 1; min-width: 16rem; margin: 0; white-space: pre-wrap; }

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

.panel-head { display: flex; justify-content: space-between; align-items: baseline; }
.thread { margin: 0.25rem 0 1rem; }
.comment { padding: 0.6rem 0; border-bottom: 1px solid var(--line); }
.comment-meta { display: flex; gap: 0.6rem; align-items: baseline; font-size: 0.85rem; margin-bottom: 0.2rem; }
.comment-body { white-space: pre-wrap; }
.comment-form textarea {
  width: 100%; padding: 0.55rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; resize: vertical;
}
.comment-actions { display: flex; gap: 0.6rem; align-items: center; margin-top: 0.5rem; }
.comment-actions select { padding: 0.4rem; border: 1px solid var(--line); border-radius: 6px; font: inherit; }

.report-actions { display: flex; gap: 0.6rem; align-items: center; }
.report-links { font-size: 0.9rem; margin-top: 0.5rem; }
a.button {
  display: inline-block; background: var(--brand); color: var(--brand-ink); padding: 0.35rem 0.75rem;
  border-radius: 6px; font-weight: 600;
}
a.button:hover { text-decoration: none; filter: brightness(1.08); }
tfoot th { border-top: 2px solid var(--line); font-variant-numeric: tabular-nums; }

@media print {
  .topbar, .noprint, form, .report-links { display: none !important; }
  body { background: #fff; }
  main { margin: 0; max-width: none; }
  .panel { border: none; padding: 0; margin: 0 0 1rem; }
  a { color: inherit; text-decoration: none; }
}

.topbar input[type="search"] {
  padding: 0.3rem 0.6rem; border-radius: 4px; border: 1px solid var(--line); min-width: 14rem; font: inherit;
}
.searchform { display: flex; gap: 0.5rem; margin: 0.75rem 0 0; }
.searchform input[type="search"], .searchform input[type="text"] {
  flex: 1; padding: 0.5rem 0.6rem; border: 1px solid var(--line); border-radius: 6px; font: inherit;
}
ul.results { list-style: none; padding: 0; margin: 0.5rem 0 0; }
ul.results li { padding: 0.4rem 0; border-bottom: 1px solid var(--line); display: flex; gap: 0.5rem; align-items: baseline; flex-wrap: wrap; }
h3 { font-size: 0.95rem; margin: 1rem 0 0.25rem; color: var(--muted); }

.projmeta { display: grid; grid-template-columns: max-content 1fr; gap: 0.15rem 0.75rem; margin: 0.6rem 0 0; }
.projmeta dt { color: var(--muted); font-size: 0.85rem; }
.projmeta dd { margin: 0; font-size: 0.9rem; }
.projnotes { margin: 0.6rem 0 0; padding: 0.5rem 0.7rem; background: #fbf7e9; border: 1px solid #ecdfae; border-radius: 6px; font-size: 0.9rem; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 1.25rem; }
.card .metric { font-size: 1.9rem; font-weight: 700; margin: 0.25rem 0; }
.card .line { display: flex; justify-content: space-between; margin: 0.2rem 0; font-size: 0.95rem; }

table.kv th { text-transform: none; color: var(--muted); width: 12rem; font-weight: 600; vertical-align: top; }
table.kv td { font-variant-numeric: tabular-nums; }
td, .metric { font-variant-numeric: tabular-nums; }
