
:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --line: #dde3ea;
  --text: #142033;
  --muted: #607085;
  --primary: #d63f33;
  --primary-dark: #b93228;
  --green: #157347;
  --yellow: #9a6700;
  --danger: #b42318;
  --user-scale: 1;
  font-family: Inter, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
a { color: inherit; }
.topbar {
  display: flex; justify-content: space-between; gap: 24px; align-items: flex-start;
  padding: 28px 32px 18px; background: linear-gradient(135deg, #0f172a, #1f2937); color: #fff;
}
.topbar h1 { margin: 4px 0 8px; font-size: 34px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 12px; opacity: 0.8; }
.subtitle { max-width: 860px; margin: 0; color: #dbe2ea; }
.top-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.top-actions form { margin: 0; }
.user-badge {
  display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; border-radius: 14px;
  background: rgba(255, 255, 255, 0.12); border: 1px solid rgba(255, 255, 255, 0.18);
}
.user-badge span { color: #dbe2ea; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }

.section-nav {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px; padding: 18px 32px 8px;
}
.section-link {
  text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px 16px; display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}
.section-link span { color: var(--muted); font-size: 14px; }
.section-link strong { font-size: 18px; }
.section-link.active { background: #111827; color: #fff; border-color: #111827; }
.section-link.active span { color: #d1d5db; }
.section-link.ghost { opacity: 0.85; }

.flash-stack { padding: 0 32px; display: grid; gap: 8px; }
.flash { padding: 12px 14px; border-radius: 12px; background: #fff; border: 1px solid var(--line); }
.flash.success { border-color: #9fd0b4; background: #eef9f1; }
.flash.error { border-color: #f0b2ac; background: #fff4f3; }
.flash.info { border-color: #c9d7ea; background: #f4f8fd; }

.tabbar { padding: 0 32px; display: flex; gap: 12px; flex-wrap: wrap; }
.tab-button { text-decoration: none; display: inline-flex; padding: 12px 16px; border-radius: 999px; background: #fff; border: 1px solid var(--line); }
.tab-button.active { background: #111827; color: #fff; }

.panel {
  margin: 16px 32px; background: var(--card); border: 1px solid var(--line); border-radius: 22px;
  padding: 22px; box-shadow: 0 10px 22px rgba(15, 23, 42, 0.05);
}
.panel.inner { margin: 0; }
.auth-panel { max-width: 720px; margin: 56px auto; }
.grid.two { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.stats-grid {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px;
}
.stat-card {
  background: #f8fafc; border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px;
  display: flex; flex-direction: column; gap: 8px;
}
.stat-card span { color: var(--muted); font-size: 14px; }
.stat-card strong { font-size: 22px; }
.filters {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
}
.filters.compact { grid-template-columns: 1fr; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.wide { grid-column: span 2; }
label { font-size: 14px; color: var(--muted); }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; background: #fff; color: var(--text);
  font: inherit;
}
.checkbox { display: flex; align-items: center; gap: 8px; color: var(--text); }
.checkbox input { width: auto; }
.actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.button {
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
  padding: 11px 16px; border-radius: 12px; background: var(--primary); color: #fff; border: 1px solid var(--primary);
  cursor: pointer; font: inherit;
}
.button:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.button.secondary { background: #fff; color: var(--text); border-color: var(--line); }
.button.danger { background: #fff2f1; color: var(--danger); border-color: #f2b8b5; }
.button.small { padding: 8px 12px; font-size: 14px; }

.results { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 18px; }
.compact-results { grid-template-columns: 1fr; }
.item-card {
  border: 1px solid var(--line); border-radius: 18px; padding: 18px; background: #fff;
  display: flex; flex-direction: column; gap: 12px;
}
.item-card.match { box-shadow: inset 0 0 0 1px rgba(21, 115, 71, 0.18); }
.item-card.miss { box-shadow: inset 0 0 0 1px rgba(154, 103, 0, 0.16); }
.item-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.item-head h3 { margin: 2px 0 0; font-size: 22px; }
.price-block strong { font-size: 24px; white-space: nowrap; }
.meta-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.meta-grid span { color: var(--muted); font-size: 13px; display: block; margin-bottom: 2px; }
.meta-grid strong { font-size: 15px; }
.notes, .muted { color: var(--muted); }
.review-box {
  background: #fff9e8; color: #7a5b00; border: 1px solid #f4dda5; padding: 10px 12px; border-radius: 12px;
}
.raw-details summary { cursor: pointer; color: var(--muted); }
.raw-details pre {
  white-space: pre-wrap; word-break: break-word; background: #0f172a; color: #e2e8f0;
  padding: 12px; border-radius: 12px; font-size: 13px;
}
.footer-line { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
.badge { display: inline-flex; padding: 7px 10px; border-radius: 999px; font-size: 13px; }
.badge.ok { background: #eef9f1; color: var(--green); }
.badge.warn { background: #fff8e6; color: var(--yellow); }
.badge.neutral { background: #eef2f7; color: #334155; }
.card-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.card-actions form { margin: 0; }
.group-summary { display: flex; gap: 8px; flex-wrap: wrap; }
.matrix-details { border: 1px solid var(--line); border-radius: 14px; background: #f8fafc; }
.matrix-details summary { cursor: pointer; padding: 12px 14px; color: var(--text); font-weight: 600; }
.matrix-table-wrap { padding: 0 14px 14px; overflow-x: auto; }
.matrix-table { width: 100%; border-collapse: collapse; min-width: 760px; }
.matrix-table th, .matrix-table td { text-align: left; vertical-align: top; padding: 10px 8px; border-top: 1px solid var(--line); font-size: 14px; }
.matrix-table th { color: var(--muted); font-weight: 600; background: #f8fafc; position: sticky; top: 0; }
.matrix-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.matrix-actions form { margin: 0; }
.rx-geometry-block { display: grid; gap: 12px; padding: 12px 14px 16px; border-top: 1px solid var(--line); }
.purpose-guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.purpose-guide { border: 1px solid var(--line); border-radius: 16px; background: #f8fafc; overflow: hidden; }
.purpose-guide.active { box-shadow: inset 0 0 0 1px rgba(17, 24, 39, 0.18); }
.purpose-guide summary { cursor: pointer; padding: 14px 16px; font-weight: 700; }
.purpose-guide p { margin: 0; padding: 0 16px 10px; }

.map-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.map-card { border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: #fff; }
.map-frame { overflow: auto; border: 1px dashed var(--line); border-radius: 14px; padding: 10px; background: #fafafa; }
.map-frame img { display: block; max-width: none; height: auto; }
.import-log-list { display: grid; gap: 10px; }
.log-entry { border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fff; }
.log-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

.simple-list { margin: 0; padding-left: 18px; }
.state-list { display: grid; gap: 10px; }
.state-list > div { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; background: #f8fafc; border-radius: 12px; border: 1px solid var(--line); }
.calibration-box { margin: 10px 0 14px; }
.scale-labels { display: flex; justify-content: space-between; color: var(--muted); margin-bottom: 8px; }
.test-scale { width: 100mm; height: 12px; background: repeating-linear-gradient(90deg, #111827 0, #111827 2px, transparent 2px, transparent 10px); border-radius: 999px; }
.preview-ruler { margin-top: 16px; padding: 14px; background: #f8fafc; border: 1px solid var(--line); border-radius: 16px; }
.preview-title { color: var(--muted); margin-bottom: 8px; }
.preview-line { height: 10px; width: 100mm; background: linear-gradient(90deg, #d63f33, #111827); border-radius: 999px; }

@media (max-width: 1100px) {
  .section-nav, .stats-grid, .filters, .results, .map-grid, .grid.two {
    grid-template-columns: 1fr;
  }
  .field.wide { grid-column: span 1; }
  .topbar { flex-direction: column; }
}
