:root {
  --bg: #f5f7f8;
  --panel: #ffffff;
  --ink: #16212a;
  --muted: #65717d;
  --line: #d9e0e5;
  --accent: #136f63;
  --accent-dark: #0e5149;
  --warn: #a76011;
  --danger: #b42318;
  --ok: #207a46;
  --info: #315a9d;
  --shadow: 0 14px 36px rgba(22, 33, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Noto Sans TC", Arial, sans-serif;
  line-height: 1.5;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 34px clamp(18px, 4vw, 56px) 24px;
  background: #1b2a32;
  color: #fff;
  border-bottom: 5px solid var(--accent);
}

.eyebrow {
  margin: 0 0 8px;
  color: #b8d6d1;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.1;
}

h2 {
  margin-bottom: 14px;
  font-size: 20px;
}

.subtitle {
  max-width: 720px;
  margin-bottom: 0;
  color: #d7e4e7;
}

.meta-panel {
  align-self: end;
  min-width: 230px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
}

.header-actions {
  display: grid;
  gap: 12px;
  justify-items: end;
  align-self: end;
}

.meta-panel span,
.meta-panel small {
  display: block;
  color: #c9d7dc;
}

.meta-panel strong {
  display: block;
  margin: 3px 0 6px;
  font-size: 19px;
  white-space: nowrap;
}

.auto-sync {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 230px;
  color: #fff;
}

.auto-sync strong,
.auto-sync small {
  display: block;
}

.auto-sync small {
  margin-top: 2px;
  color: #c9d7dc;
}

.sync-indicator {
  width: 11px;
  height: 11px;
  flex: 0 0 11px;
  border-radius: 50%;
  background: #91a0a8;
  box-shadow: 0 0 0 4px rgba(145, 160, 168, 0.18);
}

.sync-indicator.ok {
  background: #55c987;
  box-shadow: 0 0 0 4px rgba(85, 201, 135, 0.18);
}

.sync-indicator.warning {
  background: #f4c542;
  box-shadow: 0 0 0 4px rgba(244, 197, 66, 0.18);
}

.sync-indicator.error {
  background: #f97066;
  box-shadow: 0 0 0 4px rgba(249, 112, 102, 0.18);
}

main {
  width: min(1400px, calc(100% - 32px));
  margin: 24px auto 46px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.summary-grid article,
.controls,
.table-wrap,
.subfilters {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.summary-grid article {
  padding: 18px;
}

.summary-grid span {
  display: block;
  color: var(--accent-dark);
  font-size: 32px;
  font-weight: 800;
}

.summary-grid p {
  margin-bottom: 0;
  color: var(--muted);
}

.controls {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
  padding: 16px;
  margin-bottom: 18px;
}

.filterbox > span,
.searchbox span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.filterbox {
  min-width: 0;
}

.search-actions {
  display: grid;
  grid-template-columns: minmax(280px, 430px) auto;
  gap: 10px;
  align-items: end;
  margin-left: auto;
}

.search-actions[hidden] {
  display: none;
}

input,
textarea,
button {
  font: inherit;
}

input[type="search"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
}

input[type="search"] {
  height: 42px;
  padding: 0 12px;
}

.segmented {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 4px;
  padding: 4px;
  background: #edf2f4;
  border-radius: 8px;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.segmented button {
  padding: 0 12px;
  background: transparent;
  color: var(--muted);
}

.segmented button.active,
.utility-button {
  background: var(--accent);
  color: #fff;
}

.utility-button {
  padding: 0 16px;
}

.subfilters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 16px;
  margin: -6px 0 18px;
}

.subfilters[hidden] {
  display: none;
}

.subfilters button {
  min-height: 34px;
  padding: 0 12px;
  background: #eef3f5;
  color: #465560;
}

.subfilters button.active {
  background: var(--accent-dark);
  color: #fff;
}

.brand-subfilters {
  margin-top: -10px;
  border-left: 4px solid var(--accent-dark);
}

.industry-subfilters {
  margin-top: -10px;
  border-left: 4px solid #315a9d;
}

.subfilter-label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.law-sort {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-left: auto;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.law-sort > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.brand-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.iso-guidance {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  margin: -6px 0 18px;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  background: #f1f6f5;
}

.iso-guidance[hidden] {
  display: none;
}

.iso-guidance p {
  max-width: 980px;
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.supply-guidance {
  border-left-color: var(--danger);
  background: #fff4f2;
}

.custom-analysis-filter {
  border: 1px solid #9fbab5;
}

.company-analyzer {
  margin: -6px 0 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-top: 4px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.company-analyzer[hidden],
.company-analyzer-result[hidden] {
  display: none;
}

.company-analyzer-header {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(360px, 1.2fr);
  gap: 28px;
  align-items: end;
  padding: 22px 24px;
}

.section-kicker,
.company-result-heading > span,
.company-laws-header span {
  display: block;
  margin-bottom: 4px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.company-analyzer-header h2,
.company-result-heading h3,
.company-laws-header h3 {
  margin: 0;
}

.company-query-form label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.company-query-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.company-query-row input {
  min-width: 0;
}

.company-query-row button {
  min-width: 108px;
}

.company-query-row button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.company-analyzer-status {
  min-height: 0;
  margin: 0;
  padding: 0 24px;
  color: var(--muted);
  font-size: 13px;
}

.company-analyzer-status:not(:empty) {
  min-height: 40px;
  padding-bottom: 16px;
}

.company-analyzer-status.error {
  color: var(--danger);
}

.company-analyzer-result {
  border-top: 1px solid var(--line);
}

.company-profile-band,
.company-laws-band {
  padding: 22px 24px;
}

.company-laws-band {
  border-top: 1px solid var(--line);
  background: #fbfcfc;
}

.company-result-heading {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.company-result-heading > span {
  padding-top: 3px;
}

.company-result-heading h3 {
  font-size: 22px;
}

.company-result-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.company-profile-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.company-profile-meta div {
  min-width: 0;
  padding: 12px 14px 12px 0;
}

.company-profile-meta div + div {
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

.company-profile-meta dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.company-profile-meta dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-weight: 700;
}

.company-classifications {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.company-classification {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid #bfcdd2;
  border-radius: 999px;
  background: #f4f7f8;
  color: #3d5059;
  font-size: 12px;
  font-weight: 800;
}

.company-classification.verified {
  border-color: #91c2a8;
  background: #edf8f1;
  color: #17613c;
}

.company-classification.inferred {
  border-color: #b8c8e2;
  background: #f0f4fa;
  color: #31547f;
}

.company-classification.review {
  border-color: #dfbe91;
  background: #fff6e9;
  color: #8a5311;
}

.company-classification-basis,
.company-warnings {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.company-warnings:empty {
  display: none;
}

.company-warnings {
  color: var(--warn);
}

.company-data-source {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
}

.company-laws-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: end;
  margin-bottom: 14px;
}

.company-laws-header > strong {
  color: var(--accent-dark);
  font-size: 14px;
}

.company-law-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.company-law-item {
  min-width: 0;
  padding: 15px 18px 15px 0;
  border-bottom: 1px solid var(--line);
}

.company-law-item:nth-child(even) {
  padding-right: 0;
  padding-left: 18px;
  border-left: 1px solid var(--line);
}

.company-law-heading {
  display: flex;
  gap: 9px;
  align-items: flex-start;
}

.company-law-heading a {
  min-width: 0;
  overflow-wrap: anywhere;
}

.company-law-level {
  display: inline-flex;
  min-height: 24px;
  flex: 0 0 auto;
  align-items: center;
  padding: 2px 7px;
  border-radius: 4px;
  background: #e7eff2;
  color: #3d5059;
  font-size: 10px;
  font-weight: 800;
}

.company-law-level.verified {
  background: #e7f4ec;
  color: var(--ok);
}

.company-law-level.inferred {
  background: #e8eef8;
  color: var(--info);
}

.company-law-level.review {
  background: #fff1df;
  color: var(--warn);
}

.company-law-item p {
  margin: 5px 0 7px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.company-law-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.company-law-tags span {
  color: #48606a;
  font-size: 10px;
  font-weight: 800;
}

.company-analyzer-note {
  margin: 0;
  padding: 14px 24px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #f5f8f8;
  font-size: 12px;
  line-height: 1.6;
}

.typing::after {
  content: "";
  display: inline-block;
  height: 1em;
  margin-left: 2px;
  border-right: 2px solid var(--accent);
  vertical-align: -0.1em;
  animation: typing-cursor 0.75s step-end infinite;
}

@keyframes typing-cursor {
  50% {
    border-color: transparent;
  }
}

.source-links {
  display: grid;
  gap: 6px;
}

.source-check {
  display: block;
  max-width: 180px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}

.source-check.ok {
  color: var(--ok);
}

.source-check.changed {
  color: var(--warn);
}

.source-check.error {
  color: var(--danger);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1280px;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #eef3f5;
  color: #42505a;
  font-size: 13px;
  white-space: nowrap;
}

td strong {
  display: block;
  margin-bottom: 4px;
}

.tag,
.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.tag {
  background: #e7eff2;
  color: #33444d;
}

.status.ok {
  background: #e7f4ec;
  color: var(--ok);
}

.status.watch {
  background: #fff1df;
  color: var(--warn);
}

.status.expired {
  background: #fde8e6;
  color: var(--danger);
}

.status.critical {
  background: #b42318;
  color: #fff;
}

.status.info {
  background: #e8eef8;
  color: var(--info);
}

.date-main {
  font-weight: 800;
}

.iso-ref {
  display: inline-block;
  max-width: 180px;
  color: #274b54;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
}

.date-sub,
.note {
  color: var(--muted);
  font-size: 13px;
}

.version-line {
  display: block;
  margin: 3px 0;
  color: #294d56;
  font-size: 13px;
  font-weight: 800;
}

.lifecycle-title {
  display: block;
}

.version-role {
  display: inline-block;
  margin: 5px 0 4px;
  padding: 2px 6px;
  border: 1px solid #bdcbd0;
  border-radius: 4px;
  color: #41545c;
  background: #f4f7f8;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.4;
}

.version-role.current {
  border-color: #a7cfbd;
  color: #14623e;
  background: #eef8f2;
}

.version-role + .note {
  display: block;
}

.intel-group {
  display: inline-block;
  margin-top: 6px;
  padding: 2px 6px;
  border: 1px solid #bfccd1;
  border-radius: 4px;
  color: #42545d;
  font-size: 11px;
  font-weight: 800;
}

.threat-tag {
  background: #fbe9e7;
  color: #8f241b;
}

.cve-id {
  color: var(--danger);
  white-space: nowrap;
}

.threat-row {
  background: #fffdfd;
}

.intel-guidance {
  border-left-color: #9c2f27;
  background: #fff7f6;
}

.model-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
  max-width: 360px;
}

.model-label {
  width: 100%;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.model-chip {
  padding: 3px 6px;
  border: 1px solid #cbd6da;
  border-radius: 4px;
  background: #f6f9fa;
  color: #384952;
  font-size: 11px;
  line-height: 1.35;
}

.history-cell {
  width: 310px;
  min-width: 310px;
}

.history-list {
  display: grid;
  gap: 12px;
}

.history-entry + .history-entry {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.history-heading {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
}

.history-heading strong {
  margin: 0;
  font-size: 13px;
}

.history-state {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.history-state.expired,
.history-state.vulnerable,
.history-state.risk {
  background: #fde8e6;
  color: var(--danger);
}

.history-state.watch,
.history-state.limited {
  background: #fff1df;
  color: var(--warn);
}

.history-date {
  display: block;
  margin-top: 3px;
  color: var(--danger);
  font-size: 12px;
  font-weight: 800;
}

.history-entry p {
  margin: 3px 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.history-entry a {
  font-size: 12px;
}

.history-empty {
  color: var(--muted);
}

.law-summary-row > td {
  padding-bottom: 9px;
  border-bottom: 0;
}

.law-details-table-row > td {
  padding: 0 16px 14px;
}

.law-details {
  border-top: 1px solid var(--line);
}

.law-details summary {
  padding: 10px 0 5px;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.law-details summary span {
  display: inline-flex;
  min-width: 22px;
  min-height: 22px;
  align-items: center;
  justify-content: center;
  margin-left: 5px;
  border-radius: 50%;
  background: #e5efed;
  font-size: 11px;
}

.law-detail-body {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(0, 2.3fr);
  gap: 14px 28px;
  padding: 8px 0 4px;
}

.law-applicability {
  align-self: start;
}

.applicability-row {
  margin-bottom: 12px;
}

.applicability-row > strong {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 11px;
}

.law-group-list,
.law-industry-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.law-group-list span,
.law-industry-list span {
  padding: 2px 6px;
  border: 1px solid #c3d3d0;
  border-radius: 4px;
  background: #f1f6f5;
  color: #31524e;
  font-size: 11px;
  font-weight: 800;
}

.law-industry-list span {
  border-color: #c7d1e2;
  background: #f1f4fa;
  color: #385178;
}

.law-topic-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px 24px;
  align-content: start;
}

.law-topic {
  padding-left: 10px;
  border-left: 3px solid #90aaa5;
}

.law-topic > div {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: baseline;
}

.law-topic strong {
  display: inline;
  margin: 0;
  font-size: 12px;
}

.law-topic span {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 800;
}

.law-topic p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.law-detail-body small {
  display: block;
  grid-column: 1 / -1;
  margin-top: 2px;
  color: var(--muted);
  line-height: 1.5;
}

.empty-state {
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

a {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

@media (max-width: 900px) {
  .topbar,
  .controls {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .meta-panel {
    align-self: stretch;
  }

  .header-actions {
    justify-items: stretch;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .controls {
    display: grid;
  }

  .search-actions {
    width: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
    margin-left: 0;
  }

  .segmented {
    grid-auto-flow: row;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .law-sort {
    width: 100%;
    margin-left: 0;
    padding-top: 10px;
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .iso-guidance {
    grid-template-columns: 1fr;
  }

  .company-analyzer-header {
    grid-template-columns: 1fr;
  }

  .company-profile-meta {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .company-profile-meta div:nth-child(3) {
    border-left: 0;
  }

  .company-profile-meta div:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .company-law-list {
    grid-template-columns: 1fr;
  }

  .company-law-item:nth-child(even) {
    padding-left: 0;
    border-left: 0;
  }

  .applicability-row {
    margin-bottom: 10px;
  }

  .law-detail-body {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .law-topic-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 540px) {
  main {
    width: min(100% - 20px, 1400px);
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .law-topic-list {
    grid-template-columns: 1fr;
  }

  .company-analyzer-header,
  .company-profile-band,
  .company-laws-band {
    padding-right: 16px;
    padding-left: 16px;
  }

  .company-query-row,
  .company-result-heading {
    grid-template-columns: 1fr;
  }

  .company-profile-meta {
    grid-template-columns: 1fr;
  }

  .company-profile-meta div + div,
  .company-profile-meta div:nth-child(3) {
    padding-left: 0;
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .company-analyzer-note {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .typing::after {
    animation: none;
  }
}
