:root {
  --ink: #222;
  --muted: #666;
  --line: #e3e3e3;
  --bg: #f4f4f5;
  --accent: #c9913d;
  --accent-dark: #8a5f1e;
  --valid: #14803c;
  --expired: #a15c00;
  --void: #b42318;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

a { color: var(--accent-dark); }

.site-header {
  background: #111;
  color: #fff;
  padding: 10px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 24px;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; font-weight: 600; }
.brand img { display: block; height: 28px; width: auto; }
.site-header nav { display: flex; flex-wrap: wrap; gap: 4px 16px; }
.site-header nav a { color: var(--accent); text-decoration: none; font-size: 14px; }
.site-header nav a:hover { text-decoration: underline; }
.site-header nav .nav-button { color: var(--accent); text-decoration: none; font-size: 14px; }
.site-header nav .nav-button:hover { text-decoration: underline; }

main { max-width: 1160px; margin: 0 auto; padding: 20px; }
h1 { font-size: 24px; margin: 4px 0 16px; }
h2 { font-size: 18px; margin: 0 0 8px; }

.card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 18px; margin-bottom: 16px; }
.table-card { padding: 0; overflow-x: auto; }

.notice { background: #fff8ec; border: 1px solid #efd9b0; border-radius: 6px; padding: 10px 14px; }
.error { color: var(--void); font-size: 13px; margin: 3px 0 0; }
.error-box { background: #fef3f2; border: 1px solid #fecdca; border-radius: 6px; padding: 10px 14px; color: var(--void); margin-bottom: 16px; }

label { display: block; font-size: 13px; color: #555; }
input, select, textarea {
  width: 100%;
  padding: 8px 10px;
  margin-top: 3px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font: inherit;
  color: var(--ink);
  background: #fff;
}
textarea { min-height: 200px; }
input[type="checkbox"] { width: auto; margin: 0 6px 0 0; }
.check { display: flex; align-items: center; font-size: 14px; color: var(--ink); }

.button, button {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 4px;
  padding: 9px 16px;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.button-plain {
  background: #fff;
  color: var(--ink);
  border: 1px solid #bbb;
  font-weight: 400;
}
.button-danger { background: #fff; color: var(--void); border: 1px solid var(--void); font-weight: 400; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent-dark); text-decoration: underline; font-weight: 400; font-size: inherit; }

.search-form { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; align-items: end; }

table { width: 100%; border-collapse: collapse; }
th, td { border-bottom: 1px solid var(--line); padding: 9px 12px; text-align: left; vertical-align: top; }
th { background: #f8f8f8; font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; }
td.actions form { display: inline; }

.status { font-weight: 600; }
.status-valid { color: var(--valid); }
.status-expired { color: var(--expired); }
.status-void { color: var(--void); }
.deleted { opacity: .6; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input[type="search"] { flex: 1; min-width: 220px; margin: 0; width: auto; }
.pager { display: flex; gap: 14px; justify-content: center; margin: 14px 0; }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 16px; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--accent-dark); border-bottom: 1px solid var(--line); padding-bottom: 4px; margin: 20px 0 12px; }
.section-title:first-child { margin-top: 0; }
.buttons { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; align-items: center; }
.meta { font-size: 13px; color: var(--muted); }
.details { display: grid; grid-template-columns: 170px 1fr; gap: 4px 12px; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }
.narrow { max-width: 420px; }
.login { max-width: 380px; margin: 40px auto; }
.login label, .stacked label { margin-bottom: 12px; }
.changes { font-size: 13px; overflow-wrap: anywhere; }

.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 10px 20px 28px; }

/* Certificate */
.cert-actions { max-width: 794px; margin: 0 auto 14px; display: flex; gap: 10px; }
.cert-page { background: #fff; border: 1px solid var(--line); max-width: 794px; margin: 0 auto 20px; padding: 44px 50px; }
.cert-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.cert-head img { height: 44px; width: auto; display: block; }
.cert-title { text-align: center; font-size: 20px; margin: 24px 0 8px; }
.cert-section { font-size: 13px; font-weight: 700; text-transform: uppercase; border-bottom: 3px solid var(--accent); padding-bottom: 3px; margin: 18px 0 8px; }
.cert-page table th { background: none; padding: 3px 8px 3px 0; color: var(--muted); }
.cert-page table td { border: 0; padding: 3px 8px 3px 0; }
.cert-page .details { grid-template-columns: 160px 1fr; }
.cert-void { color: var(--void); border: 3px solid var(--void); font-size: 22px; font-weight: 800; text-align: center; padding: 6px; margin-top: 14px; letter-spacing: .2em; }
.cert-terms { white-space: pre-line; font-size: 13px; }
.cert-terms-title { font-weight: 700; margin: 14px 0 4px; font-size: 13px; }

@media (max-width: 720px) {
  main { padding: 14px; }
  .search-form { grid-template-columns: 1fr; }
  .details { grid-template-columns: 1fr; }
  .details dt { margin-top: 6px; }
  table.stack thead { display: none; }
  table.stack tr { display: block; border-bottom: 2px solid var(--line); padding: 8px 0; }
  table.stack tr:last-child { border-bottom: 0; }
  table.stack td { display: flex; gap: 12px; justify-content: space-between; border: 0; padding: 4px 14px; text-align: right; }
  table.stack td::before { content: attr(data-label); color: var(--muted); text-align: left; flex: none; }
  td.actions { white-space: normal; }
  .cert-page { padding: 22px; }
  .cert-page .details { grid-template-columns: 1fr; }
}

@media print {
  @page { size: A4; margin: 14mm; }
  body { background: #fff; font-size: 13px; }
  .site-header, .site-footer, .cert-actions, .notice { display: none; }
  main { max-width: none; padding: 0; }
  .cert-page { border: 0; padding: 0; margin: 0; max-width: none; }
  .cert-page + .cert-page { break-before: page; }
  .cert-section { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input { margin: 0; min-width: 140px; }
.site-header nav form { display: inline; }

.search-hint { grid-column: 1 / -1; margin: 0; }

.search-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }

.site-header nav { align-items: center; }
.site-header nav form { display: flex; }
.site-header nav .nav-button { line-height: inherit; }
.site-header nav a[aria-current="page"] { color: #fff; font-weight: 700; }
