:root {
  --text: #172033;
  --muted: #6a7485;
  --line: #e2e8f0;
  --blue: #1677ff;
  --blue-deep: #0f5fd6;
  --red: #ef4444;
  --green: #19b47b;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: #f4f7fb;
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

[hidden] {
  display: none !important;
}

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

.error {
  margin: 8px 0 0;
  color: var(--red);
  font-size: 13px;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login-card {
  width: min(100%, 340px);
  display: grid;
  gap: 8px;
  padding: 24px;
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 12px 30px rgba(35, 73, 125, 0.14);
}

.login-card h1 {
  margin: 0;
  font-size: 22px;
}

.login-card p {
  margin: 0;
  font-size: 13px;
}

.app {
  width: min(100% - 28px, 1080px);
  margin: 0 auto;
  padding: 18px 0 40px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.topbar strong {
  font-size: 20px;
  font-weight: 900;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 999px;
  background: #e7eef8;
}

.tab {
  flex: 1;
  min-height: 36px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.tab.is-active {
  background: #fff;
  color: var(--blue-deep);
  box-shadow: 0 4px 10px rgba(35, 73, 125, 0.12);
}

.panel {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2,
.panel h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
}

.panel h3 {
  margin-top: 8px;
}

.filter-row {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 8px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: inherit;
  font: inherit;
  outline: none;
}

textarea {
  min-height: 72px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(22, 119, 255, 0.58);
  box-shadow: 0 0 0 4px rgba(22, 119, 255, 0.1);
}

.btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: var(--radius);
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--blue-deep));
}

.btn-ghost {
  color: #42526a;
  background: #e9eff7;
}

.btn-danger {
  color: #fff;
  background: var(--red);
}

.btn-sm {
  min-height: 30px;
  padding: 0 10px;
  font-size: 13px;
}

.rows {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.row-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.row-title {
  font-weight: 800;
  overflow-wrap: anywhere;
}

.row-meta {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.empty {
  padding: 26px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.stat-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.stat-card b {
  display: block;
  font-size: 24px;
  font-weight: 900;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
}

.editor {
  width: min(100% - 24px, 560px);
  border: 0;
  border-radius: var(--radius);
  padding: 0;
  box-shadow: 0 24px 60px rgba(16, 32, 60, 0.28);
}

.editor::backdrop {
  background: rgba(16, 32, 60, 0.42);
}

.editor form {
  display: grid;
  gap: 12px;
  padding: 20px;
}

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

.fields {
  display: grid;
  gap: 10px;
  max-height: 62vh;
  overflow: auto;
}

.settings-fields {
  max-height: none;
}

.logo-setting {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}

.logo-preview {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  overflow: hidden;
}

.logo-preview img {
  max-width: 100%;
  max-height: 100%;
}

.logo-actions {
  min-width: 0;
  flex: 1;
}

.logo-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.logo-upload-row input[type="file"] {
  width: auto;
  min-height: 0;
  flex: 1;
  padding: 6px 8px;
}

.logo-tip {
  margin: 8px 0 0;
  font-size: 12px;
}

.field {
  display: grid;
  gap: 4px;
}

.field label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

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

.field-inline input[type="checkbox"] {
  width: auto;
  min-height: 0;
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 60;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(18, 25, 38, 0.94);
  color: #fff;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 640px) {
  .filter-row {
    grid-template-columns: minmax(0, 1fr);
  }
}
