:root {
  --ink: #16201d;
  --ink-soft: #52605b;
  --paper: #ffffff;
  --canvas: #f4f6f2;
  --line: #d9dfd9;
  --line-strong: #bdc8c0;
  --brand: #136b50;
  --brand-dark: #0b4c38;
  --brand-soft: #e1f2e9;
  --danger: #a52b32;
  --danger-soft: #fae9e9;
  --warning: #8a5a08;
  --warning-soft: #fff4d8;
  --shadow: 0 18px 55px rgb(21 40 32 / 10%);
  color: var(--ink);
  background: var(--canvas);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-synthesis: none;
  line-height: 1.5;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgb(19 107 80 / 5%), transparent 34rem),
    var(--canvas);
}

button,
input,
textarea {
  font: inherit;
}

button,
summary {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

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

h1,
h2 {
  line-height: 1.16;
  letter-spacing: -0.025em;
}

h1 {
  margin-bottom: 0.65rem;
  font-size: clamp(1.9rem, 4vw, 2.65rem);
}

h2 {
  margin-bottom: 0;
  font-size: 1.25rem;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.65rem 0.9rem;
  transform: translateY(-180%);
  border-radius: 0.35rem;
  color: #fff;
  background: var(--brand-dark);
  font-weight: 700;
}

.skip-link:focus {
  transform: translateY(0);
}

:focus-visible {
  outline: 3px solid #0b7d5a;
  outline-offset: 3px;
}

.eyebrow {
  margin-bottom: 0.45rem;
  color: var(--brand);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.brand-symbol {
  display: inline-grid;
  width: 3rem;
  height: 3rem;
  flex: 0 0 auto;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 25%);
  border-radius: 0.7rem 0.2rem 0.7rem 0.2rem;
  color: #fff;
  background: var(--brand);
  box-shadow: inset 0 0 0 0.3rem rgb(255 255 255 / 8%);
  font-size: 1.25rem;
  font-weight: 900;
}

.brand-symbol-small {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 0.55rem 0.15rem 0.55rem 0.15rem;
  font-size: 1rem;
}

.button {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 0.5rem;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-weight: 750;
  line-height: 1.1;
}

.button-primary {
  color: #fff;
  background: var(--brand);
  box-shadow: 0 7px 18px rgb(19 107 80 / 18%);
}

.button-primary:hover {
  background: var(--brand-dark);
}

.button-quiet {
  border-color: rgb(255 255 255 / 35%);
  color: #fff;
  background: transparent;
}

.button-quiet:hover {
  background: rgb(255 255 255 / 10%);
}

.button-danger {
  min-height: 2.35rem;
  color: #fff;
  background: var(--danger);
}

.button-wide {
  width: 100%;
}

.form-stack {
  display: grid;
  gap: 1rem;
}

.form-field {
  display: grid;
  min-width: 0;
  gap: 0.4rem;
}

.form-field-grow {
  flex: 1 1 20rem;
}

.form-field label,
fieldset legend {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 750;
}

.form-field input,
.form-field textarea {
  width: 100%;
  min-height: 2.8rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.45rem;
  padding: 0.63rem 0.75rem;
  color: var(--ink);
  background: #fff;
}

.form-field textarea {
  min-height: 7rem;
  resize: vertical;
  line-height: 1.6;
}

.form-field input::placeholder,
.form-field textarea::placeholder {
  color: #7b8782;
}

.form-field input:hover,
.form-field textarea:hover {
  border-color: #8c9b93;
}

.form-field input:focus,
.form-field textarea:focus {
  border-color: var(--brand);
}

.form-field small,
.service-item small {
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.form-row > .form-field:first-child {
  flex: 0 1 9rem;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 2rem 1rem;
  background:
    radial-gradient(circle at 15% 15%, rgb(77 173 135 / 19%), transparent 28rem),
    linear-gradient(155deg, #0d2d24 0, #123f31 44%, #f4f6f2 44.1%);
}

.auth-shell {
  width: min(100%, 28rem);
}

.auth-card {
  border: 1px solid rgb(255 255 255 / 65%);
  border-radius: 0.9rem;
  padding: clamp(1.5rem, 5vw, 2.25rem);
  background: rgb(255 255 255 / 97%);
  box-shadow: var(--shadow);
}

.auth-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.auth-header h1 {
  margin: 0;
  font-size: 1.8rem;
}

.auth-header .eyebrow {
  margin-bottom: 0.2rem;
}

.auth-intro {
  margin-bottom: 1.4rem;
  color: var(--ink-soft);
}

.alert {
  margin-bottom: 1.2rem;
  border-left: 4px solid currentcolor;
  padding: 0.75rem 0.9rem;
}

.alert p {
  margin: 0.2rem 0 0;
}

.alert-error {
  color: #7c1f27;
  background: var(--danger-soft);
}

.security-note {
  margin: 1.3rem 0 0;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
  color: var(--ink-soft);
  font-size: 0.8rem;
}

.auth-footer {
  padding: 1rem;
  color: rgb(255 255 255 / 80%);
  text-align: center;
  font-size: 0.76rem;
}

.topbar {
  position: relative;
  z-index: 10;
  border-bottom: 1px solid rgb(255 255 255 / 13%);
  color: #fff;
  background: #10382d;
  box-shadow: 0 8px 28px rgb(11 42 32 / 12%);
}

.topbar-inner {
  display: flex;
  width: min(100% - 2rem, 76rem);
  min-height: 4.25rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 0.95rem;
}

.brand small {
  color: rgb(255 255 255 / 66%);
  font-size: 0.72rem;
}

.admin-shell {
  width: min(100% - 2rem, 76rem);
  margin: 0 auto;
  padding: 2.5rem 0 4rem;
}

.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.5rem;
}

.page-heading h1 {
  margin-bottom: 0.45rem;
}

.page-heading > div > p:last-child {
  max-width: 42rem;
  margin-bottom: 0;
  color: var(--ink-soft);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  margin-bottom: 1.25rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: var(--paper);
}

.metric {
  display: grid;
  gap: 0.15rem;
  padding: 1.15rem 1.25rem;
}

.metric + .metric {
  border-left: 1px solid var(--line);
}

.metric strong {
  font-size: 1.8rem;
  line-height: 1.2;
}

.metric-label {
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
}

.metric small {
  color: var(--ink-soft);
  font-size: 0.72rem;
}

.license-code-inline {
  display: inline-block;
  border: 1px solid #b9d7c9;
  border-radius: 0.3rem;
  padding: 0.3rem 0.45rem;
  color: #073f2c;
  background: var(--brand-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
  font-weight: 750;
  white-space: nowrap;
  user-select: all;
}

.secret-error {
  color: var(--danger);
  font-size: 0.76rem;
  font-weight: 800;
  white-space: nowrap;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(20rem, 0.85fr);
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  padding: 1.3rem;
  background: var(--paper);
  box-shadow: 0 6px 24px rgb(21 40 32 / 4%);
}

.panel-wide {
  margin-bottom: 1.25rem;
}

.panel-heading {
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--line);
  padding-bottom: 1rem;
}

.panel-heading-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
}

.panel-heading > p,
.panel-heading-row > p {
  margin: 0.4rem 0 0;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.service-list {
  display: grid;
  gap: 0.25rem;
}

.service-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
}

.service-item + .service-item {
  border-top: 1px solid var(--line);
}

.service-item strong,
.service-item small {
  display: block;
}

.status-dot {
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  background: var(--line-strong);
  box-shadow: 0 0 0 0.25rem #edf0ed;
}

.status-dot.status-active {
  background: var(--brand);
  box-shadow: 0 0 0 0.25rem var(--brand-soft);
}

.status-badge {
  display: inline-flex;
  min-height: 1.65rem;
  align-items: center;
  border-radius: 999px;
  padding: 0.2rem 0.55rem;
  white-space: nowrap;
  font-size: 0.72rem;
  font-weight: 800;
}

.status-active {
  color: #09513a;
  background: var(--brand-soft);
}

.status-missing,
.status-expired {
  color: var(--warning);
  background: var(--warning-soft);
}

.status-revoked {
  color: #7c1f27;
  background: var(--danger-soft);
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

table {
  width: 100%;
  min-width: 76rem;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 0.8rem 0.65rem;
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--ink-soft);
  background: #f8faf7;
  font-size: 0.72rem;
  letter-spacing: 0.025em;
}

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

tbody tr:hover {
  background: #fafcf9;
}

time,
.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.76rem;
}

.muted {
  color: var(--ink-soft);
}

.actions-cell {
  position: relative;
  width: 1%;
  white-space: nowrap;
}

.confirm-action {
  position: relative;
}

.confirm-action summary {
  min-width: 3.4rem;
  cursor: pointer;
  color: var(--danger);
  font-weight: 750;
  list-style-position: inside;
}

.confirm-card {
  width: 15rem;
  margin-top: 0.55rem;
  border: 1px solid #e4bfc1;
  border-radius: 0.55rem;
  padding: 0.85rem;
  white-space: normal;
  background: #fff;
  box-shadow: 0 12px 30px rgb(87 24 29 / 16%);
}

.confirm-card p {
  margin-bottom: 0.7rem;
  color: #6f282d;
  font-size: 0.78rem;
}

.empty-state {
  padding: 2.5rem 1rem;
  color: var(--ink-soft);
  text-align: center;
}

.empty-state strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--ink);
}

.empty-state p {
  margin-bottom: 0;
}

.settings-form {
  display: grid;
  gap: 1.25rem;
}

.password-form {
  display: grid;
  gap: 1.25rem;
}

fieldset {
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}

fieldset + fieldset {
  border-top: 1px solid var(--line);
  padding-top: 1.25rem;
}

.fieldset-help {
  max-width: 52rem;
  margin: -0.25rem 0 1rem;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.form-field small code {
  color: var(--brand-dark);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.74rem;
}

.prompt-rules-grid {
  margin-top: 1rem;
}

fieldset legend {
  margin-bottom: 0.8rem;
  padding: 0;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

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

.check-field {
  display: inline-flex;
  min-height: 2.75rem;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.75rem;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 0.82rem;
}

.check-field input {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--brand);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 1.1rem;
}

.form-actions p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.78rem;
}

.site-footer {
  width: min(100% - 2rem, 76rem);
  margin: -2.5rem auto 0;
  padding-bottom: 2rem;
  color: var(--ink-soft);
  text-align: center;
  font-size: 0.72rem;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (max-width: 880px) {
  .metrics,
  .content-grid,
  .settings-grid,
  .settings-grid-two {
    grid-template-columns: 1fr;
  }

  .metric + .metric {
    border-top: 1px solid var(--line);
    border-left: 0;
  }
}

@media (max-width: 600px) {
  .auth-page {
    align-items: start;
    padding-top: 8vh;
    background: linear-gradient(165deg, #10382d 0, #10382d 18rem, var(--canvas) 18.1rem);
  }

  .auth-footer {
    color: var(--ink-soft);
  }

  .topbar-inner,
  .admin-shell,
  .site-footer {
    width: min(100% - 1.25rem, 76rem);
  }

  .topbar-inner {
    min-height: 3.9rem;
  }

  .brand strong {
    max-width: 9.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .admin-shell {
    padding-top: 1.5rem;
  }

  .panel,
  .metric {
    padding: 1rem;
  }

  .panel-heading-row,
  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions .button,
  .form-row > .form-field:first-child {
    width: 100%;
  }

  .service-item {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .service-item .status-badge {
    grid-column: 2;
    justify-self: start;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
  }
}
