:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --accent: #176b87;
  --accent-strong: #0f5168;
  --bg: #f4f6f8;
  --border: #d9dee5;
  --border-strong: #c7ced8;
  --code-bg: #eef2f6;
  --danger: #a61b1b;
  --danger-bg: #fff1f1;
  --danger-border: #f2b8b8;
  --hover-bg: #f6f9fb;
  --menu-active-bg: #eaf2f5;
  --muted: #5b6471;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --pre-bg: #f2f5f8;
  --text: #20242a;
  --text-strong: #111827;
  background: var(--bg);
  color: var(--text);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --accent: #49a6c2;
  --accent-strong: #84d4ea;
  --bg: #101418;
  --border: #2b3540;
  --border-strong: #3c4856;
  --code-bg: #202a34;
  --danger: #ff9b9b;
  --danger-bg: #351b1d;
  --danger-border: #723136;
  --hover-bg: #182129;
  --menu-active-bg: #17313c;
  --muted: #a8b3bf;
  --panel: #151b22;
  --panel-soft: #111820;
  --pre-bg: #111820;
  --text: #e5edf5;
  --text-strong: #f8fafc;
}

body {
  background: var(--bg);
  color: var(--text);
  margin: 0;
}

.topbar {
  align-items: center;
  background: #050505;
  border-bottom: 1px solid #1f2933;
  display: flex;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  align-items: center;
  color: #ffffff;
  display: flex;
  gap: 14px;
  font-weight: 700;
  text-decoration: none;
}

.brand img {
  display: block;
  height: 20px;
  width: 114px;
}

.brand span {
  border-left: 1px solid #3d4652;
  color: #cbd5df;
  font-size: 14px;
  padding-left: 14px;
}

.topnav {
  align-items: center;
  display: flex;
  gap: 16px;
}

.user-name {
  color: #d8dee7;
  font-size: 14px;
}

.ghost-button {
  background: transparent;
  border-color: #3d4652;
  color: #f8fafc;
  min-height: 34px;
}

.theme-toggle {
  align-items: center;
  background: transparent;
  border-color: #3d4652;
  color: #f8fafc;
  display: inline-flex;
  height: 36px;
  justify-content: center;
  min-height: 36px;
  padding: 0;
  width: 36px;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
}

.theme-icon {
  fill: none;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 18px;
}

.theme-icon-sun {
  display: none;
}

html[data-theme="dark"] .theme-icon-moon {
  display: none;
}

html[data-theme="dark"] .theme-icon-sun {
  display: block;
}

.app-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  min-height: calc(100vh - 59px);
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
}

.menu-item {
  border-radius: 6px;
  color: var(--text);
  display: block;
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 4px;
  padding: 10px 12px;
  text-decoration: none;
}

.menu-item:hover,
.menu-item.active {
  background: var(--menu-active-bg);
  color: var(--accent-strong);
}

main {
  padding: 28px;
  min-width: 0;
}

.page-header {
  align-items: center;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.page-header h1 {
  font-size: 24px;
  margin-bottom: 4px;
}

.page-header p {
  color: var(--muted);
  margin: 0;
}

.header-actions,
.section-title-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.header-actions {
  justify-content: flex-end;
}

.section-title-row {
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title-row h2 {
  margin: 0;
}

.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(280px, 1fr) minmax(360px, 1.3fr);
}

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

.stats-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 20px;
}

.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
}

.stat-card span {
  color: var(--muted);
  display: block;
  font-size: 13px;
  font-weight: 650;
  margin-bottom: 10px;
}

.stat-card strong {
  color: var(--text-strong);
  display: block;
  font-size: 30px;
  line-height: 1;
}

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

.wide-panel {
  grid-column: 1 / -1;
  max-width: 760px;
}

.narrow {
  max-width: 640px;
}

h1 {
  font-size: 20px;
  line-height: 1.25;
  margin: 0 0 16px;
}

h2 {
  font-size: 16px;
  line-height: 1.25;
  margin: 0 0 12px;
}

.stack {
  display: grid;
  gap: 12px;
}

.product-picker {
  margin-bottom: 12px;
}

label {
  display: grid;
  font-size: 14px;
  gap: 6px;
}

input,
select,
textarea,
fieldset,
button,
.button {
  background: var(--panel);
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  box-sizing: border-box;
  color: var(--text);
  font: inherit;
  min-height: 38px;
  padding: 8px 10px;
}

button,
.button {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  cursor: pointer;
  display: inline-block;
  font-weight: 650;
  text-align: center;
  text-decoration: none;
}

fieldset {
  padding: 12px;
}

legend {
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  padding: 0 4px;
}

.secondary-button {
  background: var(--panel);
  border-color: var(--border-strong);
  color: var(--text);
}

.danger-button {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.field-group {
  display: grid;
  gap: 10px;
}

.flag-list {
  display: grid;
  gap: 10px;
}

.flag-row {
  align-items: end;
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) 132px 86px;
}

.compact-label {
  gap: 4px;
  line-height: 1.2;
}

.compact-label input {
  width: 100%;
}

.flag-row [data-remove-flag] {
  min-height: 38px;
  padding-left: 8px;
  padding-right: 8px;
  width: 86px;
}

.inline-form {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr) auto;
}

.filter-form {
  align-items: end;
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin-top: 14px;
  padding: 14px;
}

.checkbox-label {
  align-items: center;
  display: flex;
  gap: 8px;
  min-height: 38px;
}

.checkbox-label input {
  min-height: auto;
  width: auto;
}

.filter-actions {
  display: flex;
  gap: 8px;
}

.filter-actions .button,
.filter-actions button {
  min-height: 38px;
  white-space: nowrap;
}

table {
  border-collapse: collapse;
  margin-top: 16px;
  width: 100%;
}

.detail-list {
  display: grid;
  gap: 10px;
  margin: 0 0 16px;
}

.detail-list div {
  display: grid;
  gap: 4px;
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.info-list {
  display: grid;
  gap: 10px;
}

.info-list div {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 4px;
  padding: 12px;
}

.info-list strong {
  color: var(--text-strong);
  font-size: 14px;
}

.info-list span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.machine-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.machine-card {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
}

.machine-card h3 {
  font-size: 15px;
  margin: 0;
}

.audit-count {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 8px 12px;
}

.audit-filter-form {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.audit-list {
  display: grid;
  gap: 10px;
}

.audit-item {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 10px;
  padding: 14px;
}

.audit-item-main {
  align-items: start;
  display: grid;
  gap: 12px;
  grid-template-columns: 190px minmax(0, 1fr);
}

.audit-title {
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.audit-meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 8px 14px;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.audit-meta a {
  color: var(--accent-strong);
  font-weight: 700;
  text-decoration: none;
}

.audit-badge {
  border-radius: 999px;
  border: 1px solid var(--border);
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  padding: 6px 10px;
  text-align: center;
}

.audit-badge-customer {
  background: #eaf2f5;
  color: #0f5168;
}

.audit-badge-machine {
  background: #eef7ee;
  color: #245b2d;
}

.audit-badge-download {
  background: #eef2ff;
  color: #34408a;
}

.audit-badge-license {
  background: #f6effb;
  color: #653083;
}

.audit-badge-report {
  background: #fff7e8;
  color: #7a4a00;
}

.audit-badge-warning {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}

.audit-badge-system {
  background: var(--code-bg);
  color: var(--muted);
}

html[data-theme="dark"] .audit-badge-customer,
html[data-theme="dark"] .audit-badge-machine,
html[data-theme="dark"] .audit-badge-download,
html[data-theme="dark"] .audit-badge-license,
html[data-theme="dark"] .audit-badge-report {
  background: var(--code-bg);
  color: var(--text);
}

.audit-detail-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.audit-detail-chips span {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  padding: 5px 8px;
}

th,
td {
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 650;
}

td a,
.section-title-row a,
.link-button {
  color: var(--accent-strong);
  font-weight: 650;
  text-decoration: none;
}

td a:hover,
.section-title-row a:hover,
.link-button:hover {
  text-decoration: underline;
}

.link-button {
  background: transparent;
  border: 0;
  cursor: pointer;
  min-height: auto;
  padding: 0;
  text-align: left;
}

.clickable-row {
  cursor: pointer;
}

.clickable-row:hover {
  background: var(--hover-bg);
}

iframe {
  background: var(--panel-soft);
  border: 1px solid var(--border);
  border-radius: 6px;
  height: 260px;
  width: 100%;
}

.preview-stack {
  display: grid;
  gap: 20px;
}

.preview-frame {
  height: 230px;
}

.pdf-preview {
  height: 360px;
}

.embedded {
  background: var(--panel);
  padding: 12px;
}

.pagination {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 12px;
}

.pagination span {
  color: var(--muted);
  font-size: 14px;
}

.version-meta {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.version-preview-layout {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wide-preview-panel {
  grid-column: 1 / -1;
}

.version-checksum-frame {
  height: 220px;
}

.version-changelog-frame {
  height: 520px;
}

.version-pdf-frame {
  height: min(980px, calc(100vh - 180px));
  min-height: 680px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.checksum-body {
  background: var(--pre-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  line-height: 1.5;
  padding: 12px;
}

.markdown-body {
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  border-bottom: 1px solid var(--border);
  margin: 18px 0 10px;
  padding-bottom: 6px;
}

.markdown-body h1 {
  font-size: 22px;
}

.markdown-body h2 {
  font-size: 18px;
}

.markdown-body h3 {
  font-size: 16px;
}

.markdown-body p,
.markdown-body ul,
.markdown-body ol,
.markdown-body table,
.markdown-body pre {
  margin: 0 0 12px;
}

.markdown-body code {
  background: var(--code-bg);
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.92em;
  padding: 2px 4px;
}

.markdown-body pre {
  background: var(--pre-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
  padding: 12px;
}

.markdown-body pre code {
  background: transparent;
  padding: 0;
}

.markdown-body blockquote {
  border-left: 4px solid var(--border-strong);
  color: var(--muted);
  margin: 0 0 12px;
  padding: 0 0 0 12px;
}

.markdown-body table {
  display: block;
  overflow-x: auto;
}

.error {
  color: var(--danger);
  font-weight: 650;
}

.notice {
  border-radius: 8px;
  margin-bottom: 20px;
  padding: 12px 14px;
}

.notice.error {
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
}

.action-panel {
  align-content: start;
  display: grid;
  gap: 12px;
}

.note {
  color: var(--muted);
}

.preserve-lines {
  line-height: 1.5;
  margin: 0;
  white-space: pre-wrap;
}

.download-shell {
  display: grid;
  min-height: 80vh;
  place-items: center;
}

.login-shell {
  align-items: center;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--panel-soft) 60%, transparent), transparent 45%),
    var(--bg);
  display: grid;
  min-height: calc(100vh - 59px);
  padding: 24px;
  place-items: center;
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 18px 55px rgba(15, 23, 42, 0.12);
  display: grid;
  gap: 20px;
  padding: 28px;
  width: min(440px, 100%);
}

html[data-theme="dark"] .login-panel {
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.35);
}

.login-card-header {
  align-items: center;
  display: flex;
  gap: 14px;
}

.login-mark {
  align-items: center;
  background: var(--menu-active-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--accent-strong);
  display: inline-flex;
  flex: 0 0 auto;
  height: 48px;
  justify-content: center;
  width: 48px;
}

.login-mark svg {
  fill: none;
  height: 24px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  width: 24px;
}

.login-kicker {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 4px;
  text-transform: uppercase;
}

.login-panel h1 {
  color: var(--text-strong);
  font-size: 24px;
  margin: 0;
}

.login-copy {
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.login-form {
  display: grid;
}

.login-submit {
  min-height: 44px;
}

.file-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.file-row {
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  display: flex;
  justify-content: space-between;
  padding: 12px;
  text-decoration: none;
}

.file-row:hover {
  background: var(--hover-bg);
  border-color: var(--border-strong);
}

.file-row span {
  display: grid;
  gap: 3px;
}

.file-row small {
  color: var(--muted);
}

.file-row em {
  color: var(--accent);
  font-style: normal;
  font-weight: 700;
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-bottom: 1px solid var(--border);
    border-right: 0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 10px 12px;
  }

  .menu-item {
    margin-bottom: 0;
    white-space: nowrap;
  }

  .grid,
  .dashboard-grid,
  .version-preview-layout,
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .wide-preview-panel {
    grid-column: auto;
  }

  main {
    padding: 16px;
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form {
    grid-template-columns: 1fr;
  }

  .flag-row {
    grid-template-columns: 1fr;
  }

  .audit-item-main {
    grid-template-columns: 1fr;
  }
}
