:root {
  --ink: #161616;
  --muted: #696969;
  --paper: #f4f2ec;
  --white: #fff;
  --line: #ddd7ce;
  --dark: #1d1f22;
  --orange: #f28a00;
  --blue: #0c6f9d;
  --green: #3f744d;
  --red: #b34135;
  --radius: 8px;
  font-family: Arial, "Microsoft YaHei", "PingFang SC", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  display: block;
  max-width: 100%;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100svh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(120deg, rgba(20, 20, 20, 0.82), rgba(20, 20, 20, 0.56)),
    url("/assets/images/hero-rolling-door.png") center / cover;
}

.login-card {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 28px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.25);
}

.login-card img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius);
}

.login-card h1,
.topbar h1,
.panel h2,
.editor-card h3 {
  margin: 0;
}

.login-card p,
.topbar p {
  margin: 0;
  color: var(--muted);
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 900;
}

input,
select,
textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid #ccc7bd;
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(242, 138, 0, 0.16);
}

button,
.top-actions a,
.preview-actions a,
.upload-btn,
.link-button {
  min-height: 40px;
  padding: 10px 13px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--white);
  font-weight: 900;
}

button.secondary,
.top-actions a,
.preview-actions a,
.upload-btn,
.link-button {
  background: var(--white);
  color: var(--ink);
  border-color: var(--line);
}

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

.admin-app {
  display: grid;
  grid-template-columns: minmax(440px, 0.95fr) minmax(540px, 1.05fr);
  height: 100svh;
  min-height: 720px;
  overflow: hidden;
}

.preview-pane {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  min-width: 0;
  padding: 18px;
  background: var(--dark);
  color: var(--white);
}

.preview-header,
.preview-title,
.preview-actions {
  display: flex;
  align-items: center;
}

.preview-header {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.08rem;
  font-weight: 900;
}

.brand img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: var(--radius);
}

.preview-actions {
  gap: 8px;
}

.preview-title {
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.preview-title h2,
.preview-title p {
  margin: 0;
}

.preview-title p,
.preview-title span {
  color: rgba(255, 255, 255, 0.62);
}

.preview-title h2 {
  margin-top: 3px;
  font-size: 1.25rem;
}

.preview-title span {
  font-size: 0.86rem;
  font-weight: 800;
}

.preview-frame-shell {
  min-height: 0;
  overflow: hidden;
  background: #0f1012;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

.preview-frame-shell iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--white);
}

.control-panel {
  min-width: 0;
  overflow: auto;
  padding: clamp(18px, 3vw, 34px);
}

.control-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 16px;
}

.side-btn {
  justify-content: center;
  width: 100%;
  background: var(--white);
  color: var(--ink);
  border-color: var(--line);
  text-align: center;
}

.side-btn.is-active,
.side-btn:hover {
  background: var(--ink);
  color: var(--white);
  border-color: var(--ink);
}

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

.top-actions {
  display: flex;
  gap: 10px;
}

.notice {
  min-height: 24px;
  margin-bottom: 12px;
  color: var(--green);
  font-weight: 900;
}

.view {
  display: grid;
  gap: 18px;
}

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

.metric,
.panel,
.editor-card {
  background: var(--white);
  border: 1px solid rgba(22, 22, 22, 0.08);
  border-radius: var(--radius);
  box-shadow: 0 10px 24px rgba(20, 20, 20, 0.06);
}

.metric {
  padding: 18px;
}

.metric strong {
  display: block;
  font-size: 2rem;
}

.metric span {
  color: var(--muted);
  font-weight: 900;
}

.panel {
  padding: 18px;
}

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

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

.grid-form .full {
  grid-column: 1 / -1;
}

.editor-layout {
  display: grid;
  grid-template-columns: minmax(260px, 0.38fr) minmax(0, 0.62fr);
  gap: 18px;
}

.record-list {
  display: grid;
  gap: 8px;
  max-height: 680px;
  overflow: auto;
}

.record-btn {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  text-align: left;
}

.record-btn.is-active {
  border-color: var(--orange);
  box-shadow: inset 4px 0 0 var(--orange);
}

.record-btn span {
  color: var(--muted);
  font-size: 0.82rem;
}

.editor-card {
  padding: 18px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  grid-column: 1 / -1;
}

.image-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.upload-btn input {
  display: none;
}

.preview-img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
}

.gallery-editor {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #fbfaf7;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.gallery-editor textarea {
  min-height: 130px;
}

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

.gallery-tools span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.gallery-preview-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.gallery-preview-grid p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.gallery-preview-grid figure {
  overflow: hidden;
  margin: 0;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.gallery-preview-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.gallery-preview-grid figcaption {
  padding: 6px 7px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.table-wrap {
  overflow: auto;
  background: var(--white);
  border: 1px solid rgba(22, 22, 22, 0.08);
  border-radius: var(--radius);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 920px;
}

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

th {
  background: #eee9df;
  font-size: 0.82rem;
  text-transform: uppercase;
}

td {
  color: #303030;
}

.lead-message {
  max-width: 360px;
  white-space: pre-wrap;
}

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

.media-thumb {
  overflow: hidden;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.media-thumb img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
}

.media-thumb span {
  display: block;
  padding: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.status {
  min-height: 1.2em;
  color: var(--red);
  font-weight: 900;
}

@media (max-width: 1060px) {
  .admin-app {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100svh;
    overflow: visible;
  }

  .preview-pane {
    min-height: 58svh;
  }

  .control-panel {
    overflow: visible;
  }

  .control-nav {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .editor-layout,
  .metrics,
  .media-grid,
  .gallery-preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .control-panel,
  .preview-pane {
    padding: 14px;
  }

  .topbar,
  .panel-header,
  .preview-header,
  .preview-title {
    align-items: stretch;
    flex-direction: column;
  }

  .control-nav,
  .grid-form,
  .editor-layout,
  .metrics,
  .media-grid,
  .gallery-preview-grid {
    grid-template-columns: 1fr;
  }
}
