:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --surface: #ffffff;
  --surface-soft: #f2f7fb;
  --line: #dbe4ec;
  --line-strong: #c9d6e2;
  --text: #20323c;
  --muted: #637381;
  --accent: #0a6e9d;
  --accent-dark: #075276;
  --gold: #edbf85;
  --danger: #b42318;
  --success-bg: #e8f5ee;
  --success-text: #175c36;
  --control-height: 44px;
  --control-radius: 8px;
  --focus-ring: 0 0 0 3px rgba(10, 110, 157, 0.16);
  --shadow: 0 18px 45px rgba(15, 43, 61, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 24px;
  min-height: 56px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}

.brand {
  align-items: center;
  color: var(--text);
  display: inline-flex;
  gap: 10px;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  height: 32px;
  width: 32px;
  object-fit: contain;
}

.brand span {
  display: grid;
  line-height: 1.05;
}

.brand strong {
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.topbar nav {
  align-items: center;
  display: flex;
  gap: 16px;
  margin-left: auto;
}

.topbar nav a {
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

.topbar form {
  margin: 0;
}

.page {
  margin: 0 auto;
  max-width: 1320px;
  padding: 30px 24px 52px;
}

.page-header,
.panel-heading {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.page-header {
  margin-bottom: 20px;
}

h1,
h2,
h3 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  color: #102a3a;
  font-size: 30px;
  line-height: 1.15;
}

h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.18em;
  margin: 0 0 7px;
  text-transform: uppercase;
}

.button,
button {
  align-items: center;
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 600;
  justify-content: center;
  min-height: 36px;
  padding: 7px 12px;
}

.button:hover,
button:hover {
  background: var(--accent-dark);
  text-decoration: none;
}

.button-secondary {
  background: #ffffff;
  border-color: var(--line-strong);
  color: #244253;
}

.button-secondary:hover {
  background: #f4f8fb;
  color: #102a3a;
}

.button-small {
  font-size: 12px;
  min-height: 30px;
  padding: 5px 9px;
}

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

.link-button {
  background: transparent;
  border: 0;
  color: var(--accent);
  min-height: auto;
  padding: 0;
  font-size: 13px;
}

.link-button:hover {
  background: transparent;
  text-decoration: underline;
}

.dashboard-hero,
.activity-panel,
.summary-panel,
.form-shell {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dashboard-hero {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 18px;
  min-height: 132px;
  overflow: hidden;
  padding: 24px;
  position: relative;
}

.dashboard-hero::before {
  background: var(--gold);
  content: "";
  height: 100%;
  left: 0;
  position: absolute;
  top: 0;
  width: 5px;
}

.hero-meta {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  margin: 8px 0 0;
}

.hero-actions,
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

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

.metric-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 6px;
  min-height: 96px;
  padding: 16px;
}

.metric-card:hover {
  border-color: var(--line-strong);
  text-decoration: none;
}

.metric-card span {
  color: var(--text);
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

.metric-card strong {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.metric-primary {
  border-left: 4px solid var(--accent);
}

.metric-success {
  border-left: 4px solid #26946a;
}

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

.activity-panel,
.summary-panel,
.form-shell {
  margin-bottom: 18px;
  overflow: hidden;
  padding: 18px;
}

.filter-bar {
  align-items: end;
  display: grid;
  gap: 12px;
  grid-template-columns: minmax(220px, 1fr) 180px 180px auto auto;
}

.filter-bar label {
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
  margin: 0;
}

table {
  border-collapse: collapse;
  width: 100%;
}

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

th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.table-title {
  color: var(--text);
  display: block;
  font-weight: 800;
}

.table-muted {
  color: var(--muted);
  display: block;
  font-size: 12px;
  margin-top: 2px;
}

.table-actions form {
  margin: 0;
}

.checksum-cell {
  align-items: flex-start;
  display: flex;
  gap: 8px;
  max-width: 420px;
}

.checksum-cell .hash {
  flex: 1;
  min-width: 0;
}

.status {
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 800;
  line-height: 1;
  padding: 6px 9px;
  text-transform: uppercase;
}

.status-draft {
  background: #edf2f7;
  color: #4a5568;
}

.status-published,
.status-active {
  background: var(--success-bg);
  color: var(--success-text);
}

.status-retired,
.status-revoked,
.status-expired,
.status-exhausted {
  background: #fef2f2;
  color: var(--danger);
}

.detail-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 18px;
}

.detail-grid > div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 5px;
  min-height: 72px;
  padding: 13px;
}

.detail-grid strong {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.detail-grid span {
  color: var(--text);
  overflow-wrap: anywhere;
}

.form {
  display: grid;
  gap: 14px;
}

.form label,
.form fieldset {
  border: 0;
  color: var(--muted);
  display: grid;
  font-size: 13px;
  font-weight: 700;
  gap: 6px;
  margin: 0;
  padding: 0;
}

input,
select,
textarea {
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: var(--control-radius);
  box-shadow: inset 0 1px 0 rgba(15, 43, 61, 0.03);
  color: var(--text);
  font: inherit;
  outline: 0;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
  width: 100%;
}

input:not([type="checkbox"]):not([type="file"]),
select {
  height: var(--control-height);
  min-height: var(--control-height);
  padding: 0 14px;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%23637381' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-position: right 14px center;
  background-repeat: no-repeat;
  background-size: 18px 18px;
  padding-right: 44px;
}

input[type="file"] {
  height: var(--control-height);
  min-height: var(--control-height);
  padding: 5px;
}

input[type="file"]::file-selector-button {
  background: var(--surface-soft);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  color: #244253;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  height: 32px;
  margin-right: 12px;
  padding: 0 12px;
}

input[type="file"]::file-selector-button:hover {
  background: #e8f1f7;
}

.form.is-uploading {
  opacity: 0.94;
}

.form.is-uploading input,
.form.is-uploading select,
.form.is-uploading textarea,
.form.is-uploading button {
  cursor: progress;
}

.upload-progress {
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.upload-progress[hidden] {
  display: none;
}

.upload-progress-row {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.upload-progress-row strong {
  color: var(--text);
  font-size: 13px;
}

.upload-progress-row span,
.upload-progress p {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.upload-progress p {
  margin: 0;
}

.upload-progress-track {
  background: #d8e6ef;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}

.upload-progress-track span {
  background: linear-gradient(90deg, var(--accent), #20a6c8);
  border-radius: inherit;
  display: block;
  height: 100%;
  transition: width 140ms ease;
  width: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--focus-ring), inset 0 1px 0 rgba(15, 43, 61, 0.03);
}

textarea {
  min-height: 104px;
  padding: 12px 14px;
  resize: vertical;
}

legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.checkbox-row label {
  align-items: center;
  display: flex;
  gap: 6px;
}

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

.alert {
  background: #fff5f5;
  border: 1px solid #fed7d7;
  border-radius: 8px;
  color: var(--danger);
  font-weight: 700;
  margin: 0 0 18px;
  padding: 12px 14px;
}

.upload-alert {
  margin-bottom: 0;
}

.success {
  margin-bottom: 18px;
}

.created-key-card {
  background: var(--success-bg);
  border: 1px solid #b7dfca;
  border-radius: 8px;
  color: var(--success-text);
  display: grid;
  gap: 10px;
  padding: 16px;
}

.created-key-row {
  align-items: center;
  display: flex;
  gap: 10px;
}

.created-key,
.hash {
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 6px;
  display: inline-block;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 6px 8px;
}

.hash {
  font-size: 12px;
}

.notice-text,
.empty-state {
  color: var(--muted);
  font-size: 13px;
}

.preline {
  white-space: pre-line;
}

.login-page {
  align-items: center;
  display: flex;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  margin: 0 auto;
  max-width: 420px;
  padding: 28px;
  width: 100%;
}

.login-mark {
  height: 42px;
  margin-bottom: 16px;
  width: 42px;
  object-fit: contain;
}

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

  .dashboard-hero,
  .page-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 14px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 18px;
  }

  .topbar nav {
    flex-wrap: wrap;
    margin-left: 0;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }
}
