* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: #222;
  background: #f5f6f8;
  font-family: Arial, "Microsoft YaHei", sans-serif;
  font-size: 14px;
}

a {
  color: #0b66d8;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
}

.sidebar {
  background: #111827;
  color: #fff;
  padding: 22px 18px;
}

.brand {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 24px;
}

.brand span {
  color: #aeb8c8;
  font-size: 13px;
  font-weight: 400;
}

.sidebar nav {
  display: grid;
  gap: 6px;
}

.sidebar nav a,
.logout button {
  display: block;
  width: 100%;
  color: #e5e7eb;
  background: transparent;
  border: 0;
  border-radius: 6px;
  padding: 10px 12px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}

.sidebar nav a:hover,
.logout button:hover {
  background: #1f2937;
  text-decoration: none;
}

.logout {
  margin-top: 28px;
}

.content {
  min-width: 0;
  padding: 24px;
}

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.page-head h1 {
  margin: 0;
  font-size: 24px;
}

.page-head span,
.hint {
  color: #667085;
}

.panel {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  overflow-x: auto;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(3, 220px) 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.metric,
.quick {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 18px;
}

.metric span {
  display: block;
  color: #667085;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 42px;
}

.quick {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.panel.narrow {
  max-width: 820px;
}

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

.panel h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.panel-title-row,
.site-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.site-title h2 {
  margin-bottom: 2px;
}

.panel-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.ssl-provision {
  gap: 12px;
}

.ssl-progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 4px;
  background: #e4e7ec;
}

.ssl-progress-value {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #1570ef;
  transition: width 180ms ease;
}

.ssl-retry-form {
  margin: 0;
}

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

th,
td {
  padding: 11px 10px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: top;
  text-align: left;
}

th {
  color: #475467;
  background: #f9fafb;
  font-weight: 600;
}

.mono {
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  word-break: break-all;
}

.tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2ff;
  color: #3538cd;
  white-space: nowrap;
}

.tag.ok {
  background: #ecfdf3;
  color: #027a48;
}

.tag.off {
  background: #fef3f2;
  color: #b42318;
}

.tag.warn {
  background: #fffaeb;
  color: #b54708;
}

.notice {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  margin: 10px 0 16px;
  padding: 12px 14px;
}

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

.notice p {
  margin: 0;
  color: #475467;
  line-height: 1.6;
}

.notice.warn {
  background: #fffaeb;
  border-color: #fedf89;
}

.actions {
  min-width: 190px;
}

.actions form,
td form {
  display: inline-block;
  margin: 3px 4px 3px 0;
}

.inline-form {
  margin: 10px 0 0;
}

button,
.button {
  display: inline-block;
  border: 0;
  border-radius: 6px;
  background: #0b66d8;
  color: #fff;
  padding: 8px 13px;
  font: inherit;
  cursor: pointer;
}

button:hover,
.button:hover {
  background: #0957ba;
  text-decoration: none;
}

button.small,
.button.small {
  padding: 5px 9px;
  font-size: 13px;
}

button.secondary,
.button.secondary {
  background: #344054;
}

button.secondary:hover,
.button.secondary:hover {
  background: #1d2939;
}

button.danger,
.button.danger {
  background: #b42318;
}

button.danger:hover,
.button.danger:hover {
  background: #912018;
}

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

.form-group {
  margin-top: 8px;
}

.form-group h3 {
  margin: 0 0 4px;
  font-size: 16px;
}

.form-group .hint {
  margin: 0;
}

.form label {
  font-weight: 600;
}

.form .checkbox-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.form .checkbox-line input {
  width: auto;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #d0d5dd;
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
}

textarea.code {
  font-family: Consolas, "Liberation Mono", monospace;
}

.code-block {
  margin: 0;
  padding: 12px;
  overflow: auto;
  border-radius: 6px;
  background: #0f172a;
  color: #e5e7eb;
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
}

.filter-bar,
.inline-search {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filter-bar input,
.inline-search input {
  width: min(260px, 100%);
}

.filter-bar select {
  width: min(220px, 100%);
}

.rule-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.check input {
  width: auto;
}

.thumb-preview {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
}

.thumb-preview img {
  width: 96px;
  height: 96px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid #d0d5dd;
  background: #fff;
}

.flash {
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 14px;
  background: #eff8ff;
  color: #175cd3;
}

.flash.success {
  background: #ecfdf3;
  color: #027a48;
}

.flash.error {
  background: #fef3f2;
  color: #b42318;
}

.flash.warn {
  background: #fffaeb;
  color: #b54708;
}

.settings {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 10px 16px;
}

.settings dt {
  color: #667085;
  font-weight: 600;
}

.settings dd {
  margin: 0;
  font-family: Consolas, "Liberation Mono", monospace;
  overflow-wrap: anywhere;
}

.checkbox-list {
  display: grid;
  gap: 8px;
  max-height: 300px;
  overflow: auto;
  padding: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f9fafb;
}

.site-permission-search {
  margin-bottom: 2px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

.check-row input {
  width: auto;
}

.muted {
  color: #667085;
}

.log-details {
  max-width: 420px;
  max-height: 220px;
  margin: 8px 0 0;
  padding: 10px;
  overflow: auto;
  border-radius: 6px;
  background: #f9fafb;
  color: #344054;
  font-family: Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.compact-form {
  margin-top: 18px;
}

.inline-fields {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) minmax(180px, 1fr) 120px auto;
  gap: 10px;
  align-items: end;
}

.inline-fields.user-inline-fields {
  grid-template-columns: minmax(140px, 1fr) minmax(170px, 1fr) 110px 190px auto;
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.login-card {
  width: min(420px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

.login-card h1 {
  margin: 0;
  text-align: center;
}

.login-card p {
  margin: 6px 0 22px;
  text-align: center;
  color: #667085;
}

.login-card form {
  display: grid;
  gap: 10px;
}

.login-card button {
  margin-top: 8px;
  width: 100%;
}

@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
  }

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

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

  .inline-fields {
    grid-template-columns: 1fr;
  }
}
