:root {
  --green: #1f513a;
  --green-2: #2d6a4f;
  --gold: #c77a1f;
  --paper: #fbfaf6;
  --line: #e5eadf;
  --text: #1f2a24;
  --muted: #718077;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: #f4f6f1;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}

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

button {
  border: 0;
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(136deg, #143927, #245f45 58%, #c79a3b);
}

.login-panel {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: 16px;
  background: var(--paper);
  box-shadow: 0 22px 70px rgba(12, 28, 19, .24);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

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

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

.hint {
  margin-bottom: 0;
  font-size: 12px;
}

.login form {
  display: grid;
  gap: 12px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  background: #fff;
  outline: none;
}

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

.login button,
.toolbar button,
.editor button:not(.icon-btn),
.topbar button {
  min-height: 40px;
  border-radius: 10px;
  padding: 0 16px;
  color: #fff;
  background: var(--green);
  font-weight: 900;
}

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

.sidebar {
  padding: 22px 16px;
  color: #fff;
  background: #173c2b;
}

.brand {
  margin-bottom: 26px;
}

.brand .eyebrow {
  color: rgba(255,255,255,.72);
}

.brand h1 {
  margin: 0;
}

.nav {
  width: 100%;
  margin-bottom: 8px;
  padding: 12px 14px;
  border-radius: 10px;
  color: rgba(255,255,255,.78);
  background: transparent;
  text-align: left;
  font-weight: 900;
}

.nav.active,
.nav:hover {
  color: #fff;
  background: rgba(255,255,255,.14);
}

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

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

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-chip {
  max-width: 220px;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--green);
  background: #eef4ed;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar h2 {
  margin-bottom: 4px;
}

.ghost {
  background: #eef3ec !important;
  color: var(--green) !important;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.section-title {
  margin: 22px 0 12px;
  font-size: 18px;
}

.workbench-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.workbench-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 70px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  background: #fff;
  text-align: left;
}

.workbench-card strong {
  color: var(--gold);
  font-size: 24px;
}

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

.stat-value {
  margin-top: 8px;
  color: var(--green);
  font-size: 30px;
  font-weight: 900;
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 180px 160px auto;
  gap: 12px;
  margin-bottom: 14px;
}

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

.pager-size,
.import-export {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.pager-size select {
  width: 92px;
}

.import-export input[type="file"] {
  max-width: 220px;
}

.import-export button,
.ghost-action {
  min-height: 36px;
  border-radius: 10px;
  padding: 0 14px;
  color: #fff;
  background: var(--green);
  font-weight: 900;
}

.ghost-action {
  color: var(--green) !important;
  background: #eef3ec !important;
}

.gallery-toolbar {
  grid-template-columns: 1fr 160px auto;
}

.users-toolbar {
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) 120px minmax(120px, 1fr) auto;
}

.logs-toolbar {
  grid-template-columns: 1fr auto;
}

.import-page-toolbar {
  grid-template-columns: 160px minmax(220px, 1fr) auto auto;
}

.notice {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #e1d3a8;
  border-radius: 10px;
  color: #6d4f15;
  background: #fff8e2;
  font-weight: 700;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

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

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

th {
  color: #52645a;
  background: #f8faf5;
  font-weight: 900;
}

tr:hover td {
  background: #fffaf0;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--green);
  background: #eef4ed;
  font-size: 12px;
  font-weight: 900;
}

.row-actions {
  min-width: 190px;
}

.row-actions .tag {
  margin: 0 5px 5px 0;
}

.danger-tag {
  color: #9a3d2a;
  background: #fff0e9;
}

.primary-tag {
  color: #8a5812;
  background: #fff2cf;
}

.inline-input {
  min-width: 120px;
  padding: 7px 9px;
  border-radius: 8px;
}

.editor {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 20;
  width: min(460px, 100vw);
  height: 100vh;
  overflow: auto;
  padding: 22px;
  border-left: 1px solid var(--line);
  background: var(--paper);
  box-shadow: -18px 0 50px rgba(22, 38, 29, .14);
}

.editor-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #405046;
  background: #eef2eb;
  font-size: 24px;
  font-weight: 900;
}

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

.field label {
  display: block;
  margin-bottom: 6px;
  color: #52645a;
  font-size: 12px;
  font-weight: 900;
}

.photo-block {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.photo-list {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.photo-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
}

.photo-item span:first-of-type {
  min-width: 0;
  flex: 1;
}

.photo-item img {
  width: 58px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.gallery-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(31, 42, 36, .05);
}

.gallery-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: #e9efe7;
}

.gallery-body {
  padding: 14px;
}

.gallery-owner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.gallery-owner strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gallery-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.gallery-actions button {
  flex: 1 1 86px;
  min-height: 34px;
  border-radius: 9px;
  color: #fff;
  background: var(--green);
  font-weight: 900;
}

.gallery-actions .danger {
  background: #a54832;
}

.empty-state {
  padding: 36px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: #fff;
  text-align: center;
}

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

.pagination-meta {
  color: var(--muted);
  font-size: 13px;
}

.pagination-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.page-btn {
  min-width: 38px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--green);
  background: #eef3ec;
  font-weight: 900;
}

.page-btn.active {
  color: #fff;
  background: var(--green);
}

.page-btn:disabled {
  cursor: not-allowed;
  opacity: .45;
}

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

  .sidebar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 12px;
  }

  .brand {
    display: none;
  }

  .nav {
    width: auto;
    margin: 0;
    white-space: nowrap;
  }

  .toolbar,
  .gallery-toolbar,
  .users-toolbar,
  .logs-toolbar,
  .import-page-toolbar {
    grid-template-columns: 1fr;
  }

  .list-actions,
  .pagination,
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }
}
