:root {
  --bg: #101318;
  --panel: #171b22;
  --line: #262c36;
  --text: #e6e9ef;
  --muted: #8b95a5;
  --accent: #4c8dff;
  --ok: #3ecf8e;
  --warn: #f5a524;
  --bad: #ff5d5d;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 -apple-system, "SF Pro Text", "Segoe UI", sans-serif;
}
.shell { width: 100%; max-width: 1280px; margin: 0 auto; padding-left: 20px; padding-right: 20px; }

header { background: var(--panel); border-bottom: 1px solid var(--line); padding: 12px 0; }
.header-inner { display: flex; align-items: center; gap: 16px; }
.brand { font-weight: 600; letter-spacing: .3px; }
.status { color: var(--muted); flex: 1; }

.viewtabs { background: var(--panel); border-bottom: 1px solid var(--line); }
.tabs-inner { display: flex; gap: 8px; padding-top: 10px; }
.viewtabs button {
  background: transparent; border: 1px solid transparent; border-bottom: none;
  border-radius: 8px 8px 0 0; padding: 8px 14px; color: var(--muted);
}
.viewtabs button.active { background: var(--bg); border-color: var(--line); color: var(--text); }
.viewtabs .count {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px;
  border-radius: 999px; background: #232936; color: var(--muted); font-size: 11px;
}

main { display: grid; gap: 16px; padding-top: 16px; padding-bottom: 16px; align-items: start; }
#view-module { grid-template-columns: 300px minmax(320px, 1fr) 380px; }
#view-library { grid-template-columns: minmax(0, 1fr) 380px; }

.col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.card h2 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; color: var(--muted); letter-spacing: .6px; }
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 6px 10px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; word-break: normal; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

button {
  font: inherit; color: var(--text); background: #232936;
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; cursor: pointer;
}
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #08101f; font-weight: 600; }
button.danger { background: #3a1f22; border-color: #5c2a2f; color: #ffb3b3; width: 100%; padding: 12px; font-weight: 600; }
button.danger:not(:disabled):hover { background: #4a2429; }
button.ghost { background: transparent; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button.active { border-color: var(--accent); color: #cfe0ff; }
.tab-body { min-height: 190px; }

label { display: block; margin-bottom: 6px; color: var(--muted); }
input, select {
  width: 100%; font: inherit; color: var(--text); background: #0d1015;
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
}
.help { margin-top: 10px; color: var(--muted); font-size: 12px; }
.kv-line { margin-bottom: 6px; color: var(--muted); }

table.diff { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 10px; }
table.diff th, table.diff td { text-align: left; padding: 4px 6px; border-bottom: 1px solid var(--line); }
table.diff td, table.diff th { white-space: nowrap; }
table.diff tbody tr:hover td, table.diff tbody tr:hover th { background: #1d2330; }
table.diff tbody tr.selected td { background: #223052; }
table.diff code { font-family: ui-monospace, monospace; }
#p-diff td.before { color: var(--bad); font-family: ui-monospace, monospace; }
#p-diff td.after { color: var(--ok); font-family: ui-monospace, monospace; }
#p-diff td:first-child { font-family: ui-monospace, monospace; }

.lib-scroll { overflow-x: auto; }
#lib-table tbody tr { cursor: pointer; }
#lib-search { margin-bottom: 10px; }
.cap { font-weight: 600; }
.cap.yes { color: var(--ok); }
.cap.no { color: #4a5160; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge.ok { background: #12352a; color: var(--ok); }
.badge.warn { background: #3a2c12; color: var(--warn); }
.badge.bad { background: #3a1a1d; color: var(--bad); }

footer {
  border-top: 1px solid var(--line); padding: 10px 0; margin-top: 4px;
  color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; min-height: 36px;
}

.driver {
  color: var(--muted); font-size: 13px; text-decoration: none;
  border-bottom: 1px dashed var(--line); padding-bottom: 1px;
}
.driver:hover { color: var(--accent); border-bottom-color: var(--accent); }


.info-table { margin-top: 12px; }
.info-table th { text-align: left; white-space: nowrap; color: var(--muted); font-weight: 400; width: 130px; }
.info-table td { white-space: normal; }
.hexdump {
  background: #0d1015; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; margin: 8px 0; font-size: 11px; line-height: 1.55;
  font-family: ui-monospace, monospace; color: #b9c2d0; overflow-x: auto;
}
.file-link {
  display: inline-block; margin-top: 6px; padding: 7px 12px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--text); text-decoration: none;
}
.file-link:hover { border-color: var(--accent); color: #cfe0ff; }


table.info-table { table-layout: fixed; width: 100%; margin-top: 12px; }
table.info-table th { width: 104px; text-align: left; color: var(--muted); font-weight: 400; }
table.info-table th, table.info-table td { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
table.info-table td { vertical-align: top; }


#lib-stats { margin-bottom: 8px; font-size: 12px; }


.mono { font-family: ui-monospace, monospace; }
.dump-files { font-size: 12px; }
.dump-files td { font-family: ui-monospace, monospace; }
.dump-files a { color: var(--accent); text-decoration: none; }
.dump-files a:hover { text-decoration: underline; }


#lib-table { font-size: 12px; }
#lib-table th, #lib-table td { padding: 4px 5px; }
#lib-table th.cap-col, #lib-table td.cap-col { text-align: center; width: 54px; }
#lib-table tbody tr td:nth-child(6) { white-space: normal; max-width: 96px; }
#lib-table .badge { font-size: 11px; padding: 2px 6px; }

#lib-files td { white-space: normal; overflow-wrap: anywhere; font-size: 11px; padding: 3px 0; border-bottom: 1px solid var(--line); }
#lib-table td:nth-child(1), #lib-table th:nth-child(1) { max-width: 132px; overflow: hidden; text-overflow: ellipsis; }
.fields-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 8px; }
.fields-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.fields-grid label.wide { grid-column: 1 / -1; }
.fields-grid input, .fields-grid select { width: 100%; }
.fields-grid input { font-family: ui-monospace, monospace; text-transform: uppercase; }
.fields-grid input#vendor-search { text-transform: none; font-family: inherit; }
