/* ------------------------------- admin ------------------------------- */
body.admin {
  background: #f4ead9;
  background-image: radial-gradient(rgba(27, 23, 20, 0.07) 1px, transparent 1px);
  background-size: 22px 22px;
}

/* login */
.admin-login {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  min-height: 100vh;
}

.login-art {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  padding: clamp(32px, 6vw, 80px);
  background:
    radial-gradient(circle at 25% 15%, rgba(126, 209, 188, 0.24), transparent 45%),
    radial-gradient(circle at 80% 90%, rgba(226, 96, 61, 0.28), transparent 50%),
    var(--ink);
  color: var(--paper);
  overflow: hidden;
}

.login-art h1 {
  font-size: clamp(44px, 6.5vw, 82px);
  line-height: 0.98;
  color: #fff;
  letter-spacing: -0.05em;
}

.login-art p {
  max-width: 360px;
  color: rgba(255, 249, 239, 0.66);
  font-size: 14px;
}

.login-art img {
  position: absolute;
  right: -40px;
  bottom: -40px;
  width: clamp(220px, 28vw, 380px);
  opacity: 0.12;
  filter: grayscale(1) brightness(3);
  transform: rotate(-7deg);
  pointer-events: none;
}

.login-tape {
  position: absolute;
  top: 34px;
  right: 40px;
  padding: 5px 14px;
  background: var(--sun);
  color: var(--ink);
  border: 1.5px solid rgba(27, 23, 20, 0.5);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.14em;
  transform: rotate(4deg);
}

.login-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 5vw, 72px);
  background: var(--paper);
}

.login-brand {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 34px;
}

.login-brand img {
  width: 230px;
  height: auto;
}

.login-brand small {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ink-faint);
}

.login-panel h2 {
  font-size: clamp(26px, 3vw, 34px);
}

.login-hint {
  margin: 10px 0 24px;
  font-size: 12.5px;
  color: var(--ink-faint);
  line-height: 1.7;
}

.login-hint code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--paper-deep);
  border: 1px solid rgba(27, 23, 20, 0.12);
  font-size: 0.92em;
}

.login-form {
  display: grid;
  gap: 14px;
  max-width: 380px;
}

.login-form .btn {
  margin-top: 6px;
}

.login-back {
  margin-top: 22px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-faint);
}

.login-back:hover {
  color: var(--coral-deep);
}

/* shell */
.admin-shell {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  min-height: 100vh;
}

.admin-rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 26px;
  padding: 20px 16px;
  background: var(--ink);
  color: var(--paper);
  border-right: 2px solid var(--line);
  z-index: 20;
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px;
}

.admin-logo {
  display: flex;
  width: 40px;
  height: 40px;
  border: 2px solid var(--paper);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  flex-shrink: 0;
}

.admin-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.admin-brand span:last-child {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.admin-brand strong {
  font-family: var(--font-display);
  font-size: 17px;
}

.admin-brand small {
  font-size: 8.5px;
  letter-spacing: 0.16em;
  color: rgba(255, 249, 239, 0.48);
}

.admin-nav {
  display: grid;
  gap: 5px;
}

.admin-nav button {
  padding: 10px 13px;
  border: 1.5px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: rgba(255, 249, 239, 0.64);
  font-size: 13px;
  font-weight: 700;
  text-align: left;
}

.admin-nav button:hover {
  background: rgba(255, 249, 239, 0.07);
  color: var(--paper);
}

.admin-nav button.is-active {
  background: var(--paper);
  border-color: var(--line);
  color: var(--ink);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.3);
}

.admin-rail-foot {
  margin-top: auto;
  display: grid;
  gap: 8px;
  padding-top: 16px;
  border-top: 1.5px solid rgba(255, 249, 239, 0.14);
  font-size: 11.5px;
}

.admin-rail-foot a,
.admin-rail-foot button {
  padding: 6px 4px;
  border: 0;
  background: none;
  color: rgba(255, 249, 239, 0.58);
  text-align: left;
  font-size: 11.5px;
  font-weight: 700;
}

.admin-rail-foot a:hover,
.admin-rail-foot button:hover {
  color: var(--sun);
}

.admin-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px clamp(18px, 3vw, 36px);
  border-bottom: 2px solid var(--line);
  background: rgba(255, 249, 239, 0.86);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 12;
}

.admin-crumb {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--coral-deep);
  text-transform: uppercase;
}

.admin-top h1 {
  margin-top: 3px;
  font-size: clamp(21px, 2.6vw, 28px);
}

.admin-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.model-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}

.model-chip i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #39a878;
}

.model-chip.off i {
  background: var(--coral);
}

.admin-user {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--sun);
  font-size: 11px;
  font-weight: 900;
}

.admin-view {
  width: 100%;
  max-width: 1180px;
  padding: clamp(18px, 3vw, 34px);
  padding-bottom: 70px;
}

/* panels & stats */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.stat-card {
  padding: 16px 18px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

.stat-card span {
  display: block;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--ink-faint);
}

.stat-card strong {
  display: block;
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: 30px;
  line-height: 1;
}

.stat-card em {
  display: block;
  margin-top: 5px;
  font-style: normal;
  font-size: 10.5px;
  color: var(--ink-faint);
}

.stat-card.needs-review {
  border-color: #d98a2b;
  background: #fff6e0;
  box-shadow: 4px 4px 0 #d98a2b;
}

.stat-card.needs-review strong {
  color: #a35a00;
}

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

.admin-points > div {
  padding: 14px;
  border: 1.5px dashed rgba(27, 23, 20, 0.2);
  border-radius: 12px;
  background: var(--paper);
}

.admin-points strong {
  display: block;
  font-size: 12px;
  margin-bottom: 6px;
}

.admin-points span {
  display: block;
  font-size: 11px;
  line-height: 1.6;
  color: var(--ink-soft);
}

.status-pill {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--paper-deep);
  font-size: 10.5px;
  font-weight: 800;
  color: var(--ink-soft);
  white-space: nowrap;
}

.status-pill.done { background: #e2f6ee; color: #155f45; }
.status-pill.running { background: #fff2c6; color: #7a5a00; }
.status-pill.pending { background: #fff2c6; color: #7a5a00; }
.status-pill.failed { background: #ffe3d8; color: #8b2f14; }

.table-select {
  min-width: 116px;
  padding: 6px 8px;
  border: 1.5px solid rgba(27, 23, 20, 0.24);
  border-radius: 8px;
  background: var(--white);
  font-size: 11px;
}

.reject-reason {
  color: #8b2f14;
}

.group-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
}

.group-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 3px 3px 0 rgba(27, 23, 20, 0.75);
}

.group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.group-head strong {
  display: block;
  font-size: 14px;
}

.group-head small {
  display: block;
  margin-top: 3px;
  font-size: 10.5px;
  color: var(--ink-faint);
}

.group-models {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--white);
  border: 1.5px solid rgba(27, 23, 20, 0.12);
}

.group-models > div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 0;
  border-bottom: 1px dashed rgba(27, 23, 20, 0.1);
}

.group-models > div:last-child {
  border-bottom: 0;
}

.group-models dt {
  font-size: 10.5px;
  color: var(--ink-faint);
}

.group-models dd {
  margin: 0;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10.5px;
}

.group-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 10.5px;
  color: var(--ink-faint);
}

.admin-card {
  padding: 22px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.admin-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.admin-card-head h2 {
  font-size: 17px;
}

.admin-card-head p {
  font-size: 11.5px;
  color: var(--ink-faint);
}

.admin-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.admin-note {
  padding: 12px 14px;
  border: 1.5px dashed rgba(27, 23, 20, 0.24);
  border-radius: 10px;
  background: var(--paper);
  font-size: 11.5px;
  color: var(--ink-soft);
  line-height: 1.7;
}

.admin-note strong {
  color: var(--coral-deep);
}

.service-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed rgba(27, 23, 20, 0.14);
}

.service-row:last-child {
  border-bottom: 0;
}

.service-row strong {
  font-size: 13.5px;
}

.service-row small {
  display: block;
  font-size: 10.5px;
  color: var(--ink-faint);
}

.service-row .status-pill {
  margin-left: auto;
}

/* settings */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.key-field {
  position: relative;
}

.key-field .field-hint {
  margin-top: 4px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 2px dashed rgba(27, 23, 20, 0.14);
}

.test-result {
  margin-top: 12px;
  font-size: 12px;
  font-weight: 700;
  min-height: 18px;
}

.test-result.ok { color: #15705c; }
.test-result.err { color: var(--coral-deep); }

.test-result .test-meta {
  margin-top: 4px;
  font-weight: 500;
  opacity: 0.75;
  word-break: break-all;
}

.test-result .test-diagnostic {
  margin: 8px 0 0;
  padding: 10px 12px;
  max-height: 280px;
  overflow: auto;
  border-radius: 8px;
  background: rgba(27, 23, 20, 0.06);
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* skills */
.skill-list {
  display: grid;
  gap: 14px;
}

.skill-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}

.skill-card h3 {
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.skill-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  font-size: 10.5px;
  color: var(--ink-faint);
}

.skill-meta span {
  padding: 2px 8px;
  border: 1px solid rgba(27, 23, 20, 0.16);
  border-radius: 999px;
  background: var(--white);
}

.skill-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 10px;
}

.skill-buttons {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.skill-buttons .btn {
  padding: 6px 12px;
  font-size: 11.5px;
  box-shadow: 0 2px 0 var(--line);
}

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-soft);
  cursor: pointer;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
}

.toggle-track {
  width: 40px;
  height: 22px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #d9cdbd;
  transition: background 0.18s ease;
  position: relative;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--white);
  border: 1.5px solid var(--line);
  transition: transform 0.18s ease;
}

.toggle input:checked + .toggle-track {
  background: var(--mint);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(18px);
}

/* table */
.table-wrap {
  overflow-x: auto;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--white);
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 640px;
}

.admin-table th,
.admin-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(27, 23, 20, 0.1);
  vertical-align: middle;
}

.admin-table th {
  background: var(--paper-deep);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  font-weight: 900;
  white-space: nowrap;
}

.admin-table tr:last-child td {
  border-bottom: 0;
}

.admin-table tbody tr:hover td {
  background: rgba(255, 249, 239, 0.6);
}

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

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

.table-actions .btn {
  padding: 4px 9px;
  font-size: 10.5px;
  box-shadow: 0 2px 0 var(--line);
}

.mono {
  font-family: "Cascadia Code", Consolas, monospace;
  font-size: 11px;
}

/* modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 17, 14, 0.56);
  backdrop-filter: blur(3px);
}

.modal-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(980px, 100%);
  max-height: 90vh;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 10px 12px 0 rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.modal-panel.modal-wide {
  height: 88vh;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 2px solid var(--line);
  background: var(--white);
}

.modal-head h2 {
  font-size: 18px;
}

.modal-head p {
  margin-top: 3px;
  font-size: 11px;
  color: var(--ink-faint);
}

.modal-close {
  width: 32px;
  height: 32px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  font-size: 13px;
  font-weight: 900;
  flex-shrink: 0;
}

.modal-close:hover {
  background: var(--coral-soft);
}

.modal-body {
  padding: 16px 20px;
  overflow: auto;
}

.modal-body.doc {
  background: var(--white);
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 20px;
  border-top: 2px solid var(--line);
  background: var(--white);
}

.modal-foot .btn {
  padding: 8px 16px;
  font-size: 12.5px;
}

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

.editor-tools .file-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 2px 0 var(--line);
}

.editor-tools input[type="file"] {
  display: none;
}

.editor-tools .hint {
  font-size: 11px;
  color: var(--ink-faint);
}

.skill-editor {
  width: 100%;
  min-height: 58vh;
  height: 100%;
  padding: 14px;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: #fffdf7;
  font-family: "Cascadia Code", Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
  line-height: 1.65;
  resize: vertical;
  outline: none;
}

.skill-editor:focus {
  border-color: var(--coral);
  box-shadow: 0 0 0 4px rgba(226, 96, 61, 0.14);
}

.upload-note {
  font-size: 10.5px;
  color: var(--ink-faint);
}

.shot-title {
  margin: 20px 0 10px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
}

.shot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.shot-card {
  margin: 0;
  padding: 6px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 2px 0 var(--line);
}

.shot-card img {
  display: block;
  width: 100%;
  border-radius: 8px;
}

/* responsive */
@media (max-width: 1000px) {
  .admin-login {
    grid-template-columns: 1fr;
  }

  .login-art {
    min-height: 240px;
    padding: 34px 26px;
  }

  .login-art h1 {
    font-size: 44px;
  }

  .login-art p {
    display: none;
  }

  .login-art img {
    width: 200px;
    right: -30px;
    bottom: -60px;
  }

  .login-panel {
    padding: 30px 24px 46px;
    justify-content: flex-start;
  }

  .login-brand img {
    width: 190px;
  }

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

  .admin-rail {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    overflow-x: auto;
  }

  .admin-brand span:last-child {
    display: none;
  }

  .admin-nav {
    display: flex;
    gap: 5px;
  }

  .admin-nav button {
    white-space: nowrap;
    padding: 7px 12px;
    font-size: 12px;
  }

  .admin-rail-foot {
    margin: 0 0 0 auto;
    padding: 0;
    border: 0;
    display: flex;
    gap: 10px;
    align-items: center;
  }

  .admin-rail-foot a {
    display: none;
  }

  .admin-top {
    position: static;
    padding: 16px;
  }

  .admin-view {
    padding: 16px;
  }

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

  .admin-split,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

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

  .stat-card strong {
    font-size: 24px;
  }

  .admin-top-right .model-chip {
    display: none;
  }

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

  .skill-side {
    flex-direction: row;
    align-items: center;
  }

  .modal {
    padding: 8px;
  }

  .modal-panel {
    max-height: 94vh;
  }

  .modal-panel.modal-wide {
    height: 94vh;
  }

  .skill-editor {
    min-height: 50vh;
  }
}

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

.admin-table td strong,
.admin-table td .mono {
  white-space: nowrap;
}

.admin-table .table-actions {
  flex-wrap: nowrap;
}

.admin-table .table-actions .btn {
  white-space: nowrap;
  padding: 5px 10px;
  font-size: 10.5px;
}

.admin-table th:nth-child(3),
.admin-table td:nth-child(3) {
  min-width: 130px;
}

.admin-table th:nth-child(6),
.admin-table td:nth-child(6) {
  min-width: 108px;
}
