:root {
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;
  --colour-page: #f8fafc;
  --colour-surface: #ffffff;
  --colour-primary: #2563eb;
  --colour-primary-hover: #1d4ed8;
  --colour-information-surface: #dbeafe;
  --colour-information-text: #1e40af;
  --colour-attention-surface: #fef3c7;
  --colour-attention-text: #92400e;
  --colour-danger: #b91c1c;
  --colour-danger-hover: #991b1b;
  --colour-strong: #0f172a;
  --colour-muted: #475569;
  --colour-border: #cbd5e1;
  --colour-ready-surface: #ecfdf5;
  --colour-ready-text: #166534;
  --colour-unavailable-surface: #fef2f2;
  --colour-unavailable-text: #991b1b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--colour-page);
  color: var(--colour-strong);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
}

.page-shell {
  width: min(100%, 784px);
  margin-inline: auto;
  padding: var(--space-2xl) var(--space-md);
}

.dashboard-shell {
  width: min(100%, 1240px);
  margin-inline: auto;
  padding: var(--space-2xl) 20px var(--space-3xl);
}

.dashboard-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.dashboard-header p:last-child,
.add-panel p,
footer {
  margin-bottom: 0;
  color: var(--colour-muted);
}

.button {
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--colour-primary);
  border-radius: 8px;
  background: var(--colour-primary);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.button:hover { background: var(--colour-primary-hover); }
.button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 2px solid var(--colour-primary);
  outline-offset: 2px;
}

.button:disabled {
  border-color: #94a3b8;
  background: #e2e8f0;
  color: #475569;
  cursor: wait;
}

.button--quiet {
  border-color: var(--colour-border);
  background: var(--colour-surface);
  color: var(--colour-strong);
}

.button--quiet:hover { background: #f1f5f9; }

.button--quiet:visited { color: var(--colour-strong); }

.button--danger {
  border-color: var(--colour-danger);
  background: var(--colour-danger);
}

.button--danger:hover { background: var(--colour-danger-hover); }

.button--danger-quiet {
  border-color: transparent;
  background: transparent;
  color: var(--colour-danger);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.button--danger-quiet:hover {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--colour-danger-hover);
}

.add-panel,
.filter-panel,
.watch-card,
.empty-panel {
  border: 1px solid var(--colour-border);
  border-radius: 12px;
  background: var(--colour-surface);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.06);
}

.add-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.85fr) minmax(320px, 1.15fr);
  gap: var(--space-xl);
  padding: var(--space-lg);
  margin-bottom: var(--space-2xl);
}

.filter-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.6fr) minmax(0, 1.4fr);
  gap: var(--space-xl);
  padding: var(--space-lg);
}

.filter-panel p { margin-bottom: 0; color: var(--colour-muted); }
.filter-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1.4fr) repeat(2, minmax(150px, 1fr)) auto;
  gap: var(--space-md);
}
.filter-controls label { font-size: 14px; font-weight: 600; }
.filter-controls input,
.filter-controls select { margin-top: var(--space-sm); }
.filter-status { grid-column: 1 / -1; min-height: 24px; font-size: 14px; }
.view-control { min-width: max-content; }
.view-control > span { display: block; font-size: 14px; font-weight: 600; }
.view-control > div { display: flex; margin-top: var(--space-sm); }
.view-option {
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #94a3b8;
  background: var(--colour-surface);
  color: var(--colour-strong);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.view-option:first-child { border-radius: 8px 0 0 8px; }
.view-option:last-child { margin-left: -1px; border-radius: 0 8px 8px 0; }
.view-option[aria-pressed="true"] { z-index: 1; border-color: var(--colour-primary); background: var(--colour-information-surface); color: var(--colour-primary-hover); }

.add-form label {
  display: block;
  margin-bottom: var(--space-sm);
  font-size: 14px;
  font-weight: 600;
}

.add-form > div {
  display: flex;
  gap: var(--space-sm);
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid #94a3b8;
  border-radius: 8px;
  background: #fff;
  color: var(--colour-strong);
  font: inherit;
}

.watch-section { margin-top: var(--space-2xl); }
.section-heading {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}
.section-heading h2 { margin-bottom: 0; }
.section-heading > span,
.badge,
.count-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--colour-information-surface);
  color: var(--colour-information-text);
  font-size: 13px;
  font-weight: 600;
}

.badge--attention {
  background: var(--colour-attention-surface);
  color: var(--colour-attention-text);
}

.badge--info {
  background: var(--colour-information-surface);
  color: var(--colour-information-text);
}

.watch-card { padding: var(--space-md); margin-bottom: var(--space-md); }
.watch-meta { margin-block: var(--space-md); padding: 12px; }
.watch-card th,
.watch-card td { padding-block: var(--space-sm); }
.history-section,
.watch-footer { margin-top: var(--space-md); padding-top: var(--space-md); }
.watch-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--space-lg);
}
.watch-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-sm); }
.watch-identity { min-width: 0; }
.watch-packages {
  margin: 3px 0 4px;
  color: var(--colour-muted);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.watch-packages span { font-weight: 600; }
h3 { margin: 0; font-size: 20px; }
h4 { margin: var(--space-lg) 0 var(--space-sm); font-size: 16px; }
.watch-header a,
.watch-card a { color: var(--colour-primary-hover); text-underline-offset: 2px; }
.watch-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: var(--space-sm); }
.watch-actions form { margin: 0; }
.list-last-success,
.list-disclosure,
.list-secondary-actions,
.list-source-link { display: none; }
.dashboard-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: var(--space-sm); }
.dashboard-actions form { margin: 0; }
.button { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.cve-id {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-variant-numeric: tabular-nums;
}

.watch-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-md);
  margin: var(--space-md) 0;
  padding: 12px;
  border-radius: 8px;
  background: #f8fafc;
}
.watch-meta dt { color: var(--colour-muted); font-size: 13px; font-weight: 600; }
.watch-meta dd { margin: 2px 0 0; overflow-wrap: anywhere; font-weight: 600; }
.watch-meta time { color: var(--colour-muted); font-weight: 400; }
.muted, .empty-state, .event-time { color: var(--colour-muted); }

.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 10px; border-bottom: 1px solid #e2e8f0; text-align: left; vertical-align: top; }
thead th { color: var(--colour-muted); font-size: 13px; font-weight: 600; }
tbody th { font-weight: 600; }

.status--pending { background: var(--colour-attention-surface); color: var(--colour-attention-text); }
.status--neutral { background: #f1f5f9; color: #334155; }
.notice,
.error-state {
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--colour-information-surface);
  color: var(--colour-information-text);
}
.notice--error,
.error-state { background: #fef2f2; color: #991b1b; }

.history-section { margin-top: var(--space-lg); border-top: 1px solid #e2e8f0; padding-top: var(--space-lg); }
.history-heading { display: flex; align-items: start; justify-content: space-between; gap: var(--space-lg); }
.history-heading h4 { margin: 0 0 var(--space-xs); }
.history-heading p { margin: 0; color: var(--colour-muted); font-size: 14px; }
.history { margin-top: var(--space-md); }
.history summary { width: fit-content; color: var(--colour-primary-hover); font-weight: 600; cursor: pointer; }
.event-list { margin: var(--space-md) 0 0; padding-left: 22px; }
.event-list li { margin-bottom: 12px; }
.event-transition { color: var(--colour-muted); }
.event-time { font-size: 13px; }
.empty-panel { display: flex; flex-direction: column; gap: 4px; padding: var(--space-xl); color: var(--colour-muted); }
.empty-panel strong { color: var(--colour-strong); }
footer { margin-top: var(--space-2xl); padding-top: var(--space-lg); border-top: 1px solid var(--colour-border); }
.watch-footer {
  display: flex;
  justify-content: start;
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid #e2e8f0;
}
.watch-footer form { margin: 0; }
.filter-empty { margin-top: var(--space-md); }

.list-view .watch-section { margin-top: var(--space-xl); }
.list-view .watch-card {
  padding: 0;
  margin-bottom: 0;
  border-radius: 0;
  border-width: 0 0 1px;
  box-shadow: none;
}
.list-view .watch-card:first-of-type { border-top-width: 1px; }
.list-view .watch-header {
  display: grid;
  grid-template-columns: minmax(250px, 1.5fr) minmax(150px, 0.8fr) auto auto;
  align-items: center;
  gap: var(--space-md);
  min-height: 68px;
  padding: 10px var(--space-md);
}
.list-view .watch-identity > a { display: none; }
.list-view .watch-title-row { flex-wrap: nowrap; }
.list-view .watch-title-row .badge { flex: 0 0 auto; }
.list-view .list-last-success { display: flex; flex-direction: column; gap: 2px; color: var(--colour-muted); font-size: 13px; }
.list-view .list-last-success > span { font-weight: 600; }
.list-view .list-last-success time { color: var(--colour-strong); font-size: 14px; }
.list-view .watch-actions form:not(.list-primary-action) { display: none; }
.list-view .list-disclosure { display: inline-flex; gap: var(--space-sm); min-width: 100px; }
.list-view .disclosure-icon { font-size: 18px; transition: transform 120ms ease; }
.list-view .list-disclosure[aria-expanded="true"] .disclosure-icon { transform: rotate(180deg); }
.list-view .watch-details { display: none; padding: 0 var(--space-md) var(--space-md); }
.list-view .watch-card.is-expanded .watch-details { display: block; }
.list-view .list-source-link { display: block; margin: 0 0 var(--space-md); }
.list-view .list-secondary-actions { display: flex; margin-top: var(--space-md); }
.list-view .list-secondary-actions form { margin: 0; }

.confirmation-dialog {
  width: min(calc(100% - 32px), 520px);
  padding: 0;
  border: 1px solid var(--colour-border);
  border-radius: 12px;
  background: var(--colour-surface);
  color: var(--colour-strong);
  box-shadow: 0 24px 48px rgb(15 23 42 / 0.22);
}
.confirmation-dialog::backdrop { background: rgb(15 23 42 / 0.55); }
.confirmation-dialog form { padding: var(--space-xl); }
.confirmation-dialog h2 { margin-bottom: var(--space-sm); }
.confirmation-dialog p { color: var(--colour-muted); }
.dialog-actions { display: flex; justify-content: end; gap: var(--space-sm); margin-top: var(--space-lg); }

.product-header {
  margin-bottom: var(--space-xl);
}

.context-label {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin: 0 0 var(--space-sm);
  color: var(--colour-muted);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.context-label span {
  width: var(--space-sm);
  height: var(--space-sm);
  border-radius: 50%;
  background: var(--colour-primary);
}

h1,
h2,
p,
dl,
dd {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 32px;
  font-weight: 600;
  line-height: 1.2;
}

h2 {
  margin-bottom: var(--space-sm);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
}

.readiness-card,
.operational-notes {
  max-width: 720px;
}

.readiness-card {
  padding: var(--space-lg);
  border: 1px solid var(--colour-border);
  border-radius: 12px;
  background: var(--colour-surface);
  box-shadow: 0 1px 2px rgb(15 23 42 / 0.08);
}

.card-summary,
.operational-notes,
.readiness-row dd span:last-child {
  color: var(--colour-muted);
}

.card-summary {
  margin-bottom: var(--space-lg);
}

.readiness-list {
  margin-bottom: var(--space-md);
  border-block: 1px solid var(--colour-border);
}

.readiness-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-block: var(--space-md);
}

.readiness-row + .readiness-row {
  border-top: 1px solid var(--colour-border);
}

.readiness-row dt {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.readiness-row dd {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: 0;
}

.status {
  align-self: flex-start;
  padding: var(--space-xs) var(--space-sm);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
}

.status--ready {
  background: var(--colour-ready-surface);
  color: var(--colour-ready-text);
}

.status--unavailable {
  background: var(--colour-unavailable-surface);
  color: var(--colour-unavailable-text);
}

.error-state {
  color: var(--colour-muted);
}

.refresh-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--colour-primary-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.refresh-link:focus-visible {
  border-radius: 2px;
  outline: 2px solid var(--colour-primary);
  outline-offset: 2px;
}

.operational-notes {
  margin-top: var(--space-lg);
}

.operational-notes p {
  margin-bottom: var(--space-sm);
}

.operational-notes strong {
  color: var(--colour-strong);
  font-weight: 600;
}

@media (min-width: 480px) {
  .readiness-row {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) minmax(0, 2fr);
    align-items: start;
    gap: var(--space-lg);
  }
}

@media (min-width: 768px) {
  .page-shell {
    padding: var(--space-3xl) var(--space-xl);
  }
}

@media (max-width: 760px) {
  .dashboard-shell { padding: 28px 16px 48px; }
  .dashboard-header, .watch-header { align-items: stretch; flex-direction: column; }
  .watch-actions { justify-content: start; }
  .dashboard-actions { justify-content: start; }
  .add-panel, .filter-panel { grid-template-columns: 1fr; }
  .filter-controls { grid-template-columns: 1fr 1fr; }
  .filter-controls label:first-child { grid-column: 1 / -1; }
  .view-control { grid-column: 1 / -1; }
  .watch-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list-view .watch-header { grid-template-columns: minmax(0, 1fr) auto auto; }
  .list-view .list-last-success { display: none; }
}

@media (max-width: 480px) {
  .add-form > div { flex-direction: column; }
  .filter-controls { grid-template-columns: 1fr; }
  .filter-controls label:first-child { grid-column: auto; }
  .view-control { grid-column: auto; }
  .watch-meta { grid-template-columns: 1fr; }
  .watch-actions .button { width: 100%; }
  .watch-actions form { flex: 1 1 100%; }
  .dashboard-actions { align-items: stretch; flex-direction: column; }
  .dashboard-actions .button { width: 100%; }
  .history-heading { align-items: stretch; flex-direction: column; }
  .history-heading .button { width: 100%; }
  .dialog-actions { align-items: stretch; flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
  .list-view .watch-header { grid-template-columns: minmax(0, 1fr) auto; gap: var(--space-sm); }
  .list-view .watch-title-row { align-items: start; flex-direction: column; }
  .list-view .watch-actions { grid-column: 1; grid-row: 2; }
  .list-view .list-disclosure { grid-column: 2; grid-row: 1 / span 2; min-width: 44px; padding-inline: 10px; }
  .list-view .list-disclosure > span:first-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
