:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --sidebar: #18212b;
  --sidebar-muted: #a7b3c2;
  --text: #17202a;
  --muted: #697586;
  --line: #d9e0e8;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --accent-soft: #dff5f1;
  --warm: #b7791f;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(23, 32, 42, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

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

button:disabled {
  cursor: default;
  opacity: 0.48;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.1;
}

h2 {
  font-size: 21px;
  line-height: 1.2;
}

h3 {
  font-size: 16px;
}

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

.eyebrow {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.11), transparent 36%),
    linear-gradient(315deg, rgba(183, 121, 31, 0.12), transparent 32%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.admin-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 26px 18px;
  background: var(--sidebar);
  color: #fff;
}

.sidebar .eyebrow {
  color: #60d6ca;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-list button {
  width: 100%;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: transparent;
  color: var(--sidebar-muted);
  cursor: pointer;
  font-weight: 800;
  text-align: left;
}

.nav-list button:hover,
.nav-list button.is-active {
  background: rgba(255, 255, 255, 0.10);
  color: #fff;
}

.account-box {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.account-box span {
  color: var(--sidebar-muted);
  font-size: 13px;
}

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

.panel {
  min-height: calc(100vh - 48px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.panel-heading {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.workspace {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.control-panel,
.preview-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.control-panel {
  padding: 20px;
}

.preview-panel {
  min-height: 650px;
  padding: 18px;
}

.preview-topbar,
.image-actions,
.reference-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-topbar,
.image-actions {
  justify-content: space-between;
}

.row-actions {
  flex-wrap: wrap;
}

.status-chip {
  flex: 0 0 auto;
  min-width: 76px;
  border: 1px solid var(--accent-soft);
  border-radius: 999px;
  padding: 7px 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.field {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.login-card .field {
  margin-top: 0;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

textarea,
select,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  min-height: 210px;
  padding: 13px;
  line-height: 1.55;
  resize: vertical;
}

select,
input {
  height: 42px;
  padding: 0 12px;
}

textarea:focus,
select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.13);
}

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

.field.compact {
  margin-top: 14px;
}

.settings-grid .field:last-child {
  grid-column: 1 / -1;
}

.generate-button,
.ghost-button,
.download-link,
.copy-link,
.upload-button,
.text-button,
.small-button {
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.generate-button {
  min-height: 44px;
  border: 0;
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 26px rgba(15, 118, 110, 0.22);
}

.control-panel > .generate-button,
.login-card > .generate-button {
  width: 100%;
  min-height: 50px;
  margin-top: 20px;
}

.generate-button:hover {
  background: var(--accent-strong);
}

.generate-button.is-cancel {
  background: #334155;
  box-shadow: 0 12px 26px rgba(51, 65, 85, 0.18);
}

.button-icon {
  font-size: 18px;
  line-height: 1;
}

.ghost-button {
  min-height: 36px;
  border: 1px solid var(--line);
  padding: 0 13px;
  background: #fff;
  color: var(--muted);
}

.sidebar .ghost-button {
  border-color: rgba(255, 255, 255, 0.20);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.upload-button,
.text-button,
.small-button,
.download-link,
.copy-link {
  min-height: 34px;
  border: 1px solid var(--line);
  padding: 0 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: var(--text);
  font-size: 13px;
}

.upload-button,
.download-link {
  border-color: var(--accent-soft);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.text-button,
.copy-link {
  color: var(--muted);
}

.small-button {
  min-height: 32px;
  white-space: nowrap;
}

.message {
  min-height: 22px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.message.error,
.error-cell {
  color: var(--danger);
}

.file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

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

.reference-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.reference-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.reference-item button {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 24px;
  height: 24px;
  border: 0;
  border-radius: 999px;
  background: rgba(23, 32, 42, 0.78);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.empty-state {
  min-height: 560px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  color: var(--muted);
  text-align: center;
}

.empty-mark {
  width: 124px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 1px dashed #aab5ae;
  border-radius: 8px;
  background: #fff;
  color: #98a39c;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.image-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.image-link {
  width: 100%;
  border: 0;
  padding: 0;
  display: block;
  background: #edf1ee;
  cursor: zoom-in;
}

.image-card img {
  width: 100%;
  aspect-ratio: 1;
  display: block;
  object-fit: contain;
}

.image-actions {
  padding: 11px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.image-type {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}

.inline-form .generate-button {
  min-height: 42px;
}

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

.settings-form .field {
  margin-top: 0;
}

.settings-form .wide-field,
.settings-form .config-paths,
.settings-form .generate-button,
.settings-form .message {
  grid-column: 1 / -1;
}

.config-paths {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.config-paths strong {
  color: var(--text);
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
  padding: 18px 22px 24px;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  color: var(--muted);
  font-weight: 900;
  white-space: nowrap;
}

td {
  color: var(--text);
}

code {
  padding: 3px 6px;
  border-radius: 6px;
  background: var(--surface-soft);
  font-family: Consolas, "Courier New", monospace;
}

.mini-input {
  width: 110px;
  height: 34px;
}

.password-reset-input {
  width: 130px;
}

.prompt-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-images {
  display: flex;
  align-items: center;
  gap: 6px;
}

.log-image-button {
  width: 42px;
  height: 42px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  background: #fff;
  cursor: zoom-in;
}

.log-image-button img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.log-image-more {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.audit-table {
  min-width: 1280px;
}

.audit-summary {
  max-width: 320px;
  white-space: normal;
  line-height: 1.45;
}

.muted-id {
  margin-left: 4px;
  color: var(--muted);
  font-size: 12px;
}

.audit-details summary {
  cursor: pointer;
  color: var(--accent-strong);
  font-weight: 800;
}

.audit-details pre {
  max-width: 420px;
  max-height: 240px;
  overflow: auto;
  margin: 8px 0 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101820;
  color: #e8f2f0;
  font-size: 12px;
  line-height: 1.5;
}

.card-output {
  white-space: pre-wrap;
  margin: 18px 22px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--warm);
  font-family: Consolas, "Courier New", monospace;
  font-size: 13px;
}

.card-output:empty {
  display: none;
}

.secret-output {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin: 18px 22px 0;
  padding: 14px;
  border: 1px solid var(--accent-soft);
  border-radius: 8px;
  background: #effbf8;
}

.secret-output strong {
  grid-column: 1 / -1;
  color: var(--accent-strong);
  font-size: 13px;
}

.secret-output code {
  overflow: auto;
  white-space: nowrap;
}

.docs-body {
  display: grid;
  gap: 18px;
  padding: 22px;
}

.docs-section {
  display: grid;
  gap: 10px;
}

.docs-section p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.docs-section pre {
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101820;
  color: #e8f2f0;
  font-size: 13px;
  line-height: 1.55;
}

.docs-section pre code {
  padding: 0;
  background: transparent;
  color: inherit;
}

.docs-table-wrap {
  padding: 0;
}

.docs-table-wrap table {
  min-width: 760px;
}

.balance-card {
  width: min(360px, calc(100% - 44px));
  margin: 22px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.balance-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.balance-card strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
  line-height: 1;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
  padding: 18px;
  background: rgba(15, 23, 42, 0.84);
}

.preview-modal-bar {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.preview-modal-bar a,
.preview-modal-bar button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 0 14px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
}

.preview-modal img {
  max-width: min(100%, 1400px);
  max-height: 100%;
  width: auto;
  height: auto;
  place-self: center;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
}

@media (max-width: 980px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
  }

  .nav-list {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  }

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

@media (max-width: 620px) {
  h1 {
    font-size: 28px;
  }

  .main-panel {
    padding: 12px;
  }

  .panel {
    min-height: calc(100vh - 24px);
  }

  .panel-heading,
  .inline-form,
  .table-wrap,
  .workspace {
    padding-left: 14px;
    padding-right: 14px;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .settings-grid,
  .settings-form,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    min-height: 430px;
  }

  .empty-state {
    min-height: 300px;
  }
}
